diff --git a/src/plugins/builtin/builtin_builder.ml b/src/plugins/builtin/builtin_builder.ml
index 12299a7886d7ea054856da8d0b1030bcbf2bc3fb..c3c201351ed540c80cf523d8109f0a308bb215e9 100644
--- a/src/plugins/builtin/builtin_builder.ml
+++ b/src/plugins/builtin/builtin_builder.ml
@@ -28,8 +28,8 @@ module type Generator_sig = sig
   type override_key = Hashtbl.key
 
   val function_name: string
-  val well_typed_call: exp list -> bool
-  val key_from_call: exp list -> override_key
+  val well_typed_call: lval option -> exp list -> bool
+  val key_from_call: lval option -> exp list -> override_key
   val retype_args: override_key -> exp list -> exp list
   val generate_prototype: override_key -> (string * typ)
   val generate_spec: override_key -> fundec -> location -> funspec
@@ -41,8 +41,8 @@ module type Builtin = sig
   type override_key
 
   val function_name: string
-  val well_typed_call: exp list -> bool
-  val key_from_call: exp list -> override_key
+  val well_typed_call: lval option -> exp list -> bool
+  val key_from_call: lval option -> exp list -> override_key
   val retype_args: override_key -> exp list -> exp list
   val get_override: override_key -> fundec
   val get_kfs: unit -> kernel_function list
diff --git a/src/plugins/builtin/builtin_builder.mli b/src/plugins/builtin/builtin_builder.mli
index f45a623f37010f689ff20d2b54a371b2ebb7733a..7e16ff3d2f6b75cf8829217fca8dcc05e2048ad9 100644
--- a/src/plugins/builtin/builtin_builder.mli
+++ b/src/plugins/builtin/builtin_builder.mli
@@ -27,8 +27,8 @@ module type Generator_sig = sig
   type override_key = Hashtbl.key
 
   val function_name: string
-  val well_typed_call: exp list -> bool
-  val key_from_call: exp list -> override_key
+  val well_typed_call: lval option -> exp list -> bool
+  val key_from_call: lval option -> exp list -> override_key
   val retype_args: override_key -> exp list -> exp list
   val generate_prototype: override_key -> (string * typ)
   val generate_spec: override_key -> fundec -> location -> funspec
@@ -40,8 +40,8 @@ module type Builtin = sig
   type override_key
 
   val function_name: string
-  val well_typed_call: exp list -> bool
-  val key_from_call: exp list -> override_key
+  val well_typed_call: lval option -> exp list -> bool
+  val key_from_call: lval option -> exp list -> override_key
   val retype_args: override_key -> exp list -> exp list
   val get_override: override_key -> fundec
   val get_kfs: unit -> kernel_function list
diff --git a/src/plugins/builtin/memcmp.ml b/src/plugins/builtin/memcmp.ml
index 96dcef8d6ae1c3acb80f8ec596395e07e5c07cbd..b6052d003d2061161a1324d0503015aa50dda9d8 100644
--- a/src/plugins/builtin/memcmp.ml
+++ b/src/plugins/builtin/memcmp.ml
@@ -96,13 +96,13 @@ let type_from_arg x =
   let xt = Cil.type_remove_qualifier_attributes_deep xt in
   Cil.typeOf_pointed xt
 
-let well_typed_call = function
+let well_typed_call _ret = function
   | [ s1 ; s2 ; len ] ->
     (Cil.isIntegralType (Cil.typeOf len)) &&
     (Cil_datatype.Typ.equal (type_from_arg s1) (type_from_arg s2))
   | _ -> false
 
-let key_from_call = function
+let key_from_call _ret = function
   | [ s1 ; _ ; _ ] -> type_from_arg s1
   | _ -> failwith "Call to Memmove.key_from_call on an ill-typed builtin call"
 
diff --git a/src/plugins/builtin/memcpy.ml b/src/plugins/builtin/memcpy.ml
index 84cbca6cd6125f5edf41299f5161a925c1b1c675..c69f8761334799d4a196f90e43a5f9ed1bd039fe 100644
--- a/src/plugins/builtin/memcpy.ml
+++ b/src/plugins/builtin/memcpy.ml
@@ -102,13 +102,13 @@ let type_from_arg x =
   let xt = Cil.type_remove_qualifier_attributes_deep xt in
   Cil.typeOf_pointed xt
 
-let well_typed_call = function
+let well_typed_call _ret = function
   | [ dest ; src ; len ] ->
     (Cil.isIntegralType (Cil.typeOf len)) &&
     (Cil_datatype.Typ.equal (type_from_arg dest) (type_from_arg src))
   | _ -> false
 
-let key_from_call = function
+let key_from_call _ret = function
   | [ dest ; _ ; _ ] -> type_from_arg dest
   | _ -> failwith "Call to Memcpy.key_from_call on an ill-typed builtin call"
 
diff --git a/src/plugins/builtin/memmove.ml b/src/plugins/builtin/memmove.ml
index 67e7ec479623a0f5a4f12b099ad51d2591c12fe7..e0445c020be4d4e6e4165fc6613fe98ac19be164 100644
--- a/src/plugins/builtin/memmove.ml
+++ b/src/plugins/builtin/memmove.ml
@@ -96,13 +96,13 @@ let type_from_arg x =
   let xt = Cil.type_remove_qualifier_attributes_deep xt in
   Cil.typeOf_pointed xt
 
-let well_typed_call = function
+let well_typed_call _ret = function
   | [ dest ; src ; len ] ->
     (Cil.isIntegralType (Cil.typeOf len)) &&
     (Cil_datatype.Typ.equal (type_from_arg dest) (type_from_arg src))
   | _ -> false
 
-let key_from_call = function
+let key_from_call _ret = function
   | [ dest ; _ ; _ ] -> type_from_arg dest
   | _ -> failwith "Call to Memmove.key_from_call on an ill-typed builtin call"
 
diff --git a/src/plugins/builtin/memset.ml b/src/plugins/builtin/memset.ml
index ef758fbcf6ec1dec136b8836cb73ca8c4b58671d..9be7f29ca81c29cecc8e6ac66aee806a2ba7912b 100644
--- a/src/plugins/builtin/memset.ml
+++ b/src/plugins/builtin/memset.ml
@@ -187,7 +187,7 @@ let is_union_type = function
   | TComp({ cstruct = false }, _, _) -> true
   | _ -> false
 
-let well_typed_call = function
+let well_typed_call _ret = function
   | [ ptr ; _ ; _ ] when any_char_composed_type (type_from_arg ptr) -> true
   | [ ptr ; _ ; _ ] when is_union_type (type_from_arg ptr) -> false
   | [ _ ; value ; _ ] ->
@@ -197,7 +197,7 @@ let well_typed_call = function
     end
   | _ -> false
 
-let key_from_call = function
+let key_from_call _ret = function
   | [ ptr ; _ ; _ ] when any_char_composed_type (type_from_arg ptr) ->
     (type_from_arg ptr), None
   | [ ptr ; value ; _ ] when not (is_union_type (type_from_arg ptr)) ->
diff --git a/src/plugins/builtin/transform.ml b/src/plugins/builtin/transform.ml
index a8265b21159680c716a2f8ae738951f11121ec91..c501c73ee299fc4b2ac0e8e1f8cd54e14c2a7520 100644
--- a/src/plugins/builtin/transform.ml
+++ b/src/plugins/builtin/transform.ml
@@ -91,11 +91,11 @@ class transformer = object(self)
     if not (B.Enabled.get ()) then raise Not_found ;
     builtin
 
-  method private replace_call (fct, args) =
+  method private replace_call (lval, fct, args) =
     try
       let module B = (val (self#find_enabled_builtin fct): Builtin) in
-      if B.well_typed_call args then
-        let key = B.key_from_call args in
+      if B.well_typed_call lval args then
+        let key = B.key_from_call lval args in
         let fundec = B.get_override key in
         let new_args = B.retype_args key args in
         Queue.add fundec used_builtin_last_kf ;
@@ -111,10 +111,10 @@ class transformer = object(self)
     | Call(_) | Local_init(_, ConsInit(_, _, Plain_func), _) ->
       let change = function
         | [ Call(r, ({ enode = Lval((Var f), NoOffset) } as e), args, loc) ] ->
-          let f, args = self#replace_call (f, args) in
+          let f, args = self#replace_call (r, f, args) in
           [ Call(r, { e with enode = Lval((Var f), NoOffset) }, args, loc) ]
         | [ Local_init(r, ConsInit(f, args, Plain_func), loc) ] ->
-          let f, args = self#replace_call (f, args) in
+          let f, args = self#replace_call (Some (Cil.var r), f, args) in
           [ Local_init(r, ConsInit(f, args, Plain_func), loc) ]
         | _ -> assert false
       in