diff mbox series

[13/20] disas/nanomips: Add free() calls

Message ID 20220815072629.12865-14-milica.lazarevic@syrmia.com (mailing list archive)
State New, archived
Headers show
Series Convert nanoMIPS disassembler from C++ to C | expand

Commit Message

Milica Lazarevic Aug. 15, 2022, 7:26 a.m. UTC
The free() function is called for every string allocated using the
strdup() function to prevent memory leaking.

The implementation of the several functions working with dynamically
allocated strings is slightly changed so we can free those strings.

Almost every disassembly_function returns the result of the img_format()
function, which returns a dynamically allocated string. To be able to
free that string for every disassembly_function, a strdup() call is
added for returning value of some disassembly functions like TLBGINV,
TLBGINVF, TLBGP, etc.

Signed-off-by: Milica Lazarevic <milica.lazarevic@syrmia.com>
---
 disas/nanomips.cpp | 1117 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 841 insertions(+), 276 deletions(-)

Comments

Milica Lazarevic Aug. 26, 2022, 7:59 a.m. UTC | #1
Any comments on this patch?
Thomas Huth Aug. 27, 2022, 7:45 a.m. UTC | #2
On 15/08/2022 09.26, Milica Lazarevic wrote:
> The free() function is called for every string allocated using the
> strdup() function to prevent memory leaking.
> 
> The implementation of the several functions working with dynamically
> allocated strings is slightly changed so we can free those strings.
> 
> Almost every disassembly_function returns the result of the img_format()
> function, which returns a dynamically allocated string. To be able to
> free that string for every disassembly_function, a strdup() call is
> added for returning value of some disassembly functions like TLBGINV,
> TLBGINVF, TLBGP, etc.
> 
> Signed-off-by: Milica Lazarevic <milica.lazarevic@syrmia.com>
> ---
>   disas/nanomips.cpp | 1117 +++++++++++++++++++++++++++++++++-----------
>   1 file changed, 841 insertions(+), 276 deletions(-)
> 
> diff --git a/disas/nanomips.cpp b/disas/nanomips.cpp
> index 561e4ff095..551bcb3164 100644
> --- a/disas/nanomips.cpp
> +++ b/disas/nanomips.cpp
> @@ -526,7 +526,9 @@ static const char *save_restore_list(uint64 rt, uint64 count, uint64 gp)
>       for (uint64 counter = 0; counter != count; counter++) {
>           bool use_gp = gp && (counter == count - 1);
>           uint64 this_rt = use_gp ? 28 : ((rt & 0x10) | (rt + counter)) & 0x1f;
> -        strcat(str, img_format(",%s", GPR(this_rt)));
> +        const char *dis_str = img_format(",%s", GPR(this_rt));
> +        strcat(str, dis_str);
> +        free((char *)dis_str);

When using glib, you could get rid of the free() here by declaring dis_str 
with g_autofree.

>       }
>   
>       return strdup(str);
> @@ -663,7 +665,9 @@ static int Disassemble(const uint16 *data, char *dis,
>                                   return -6;
>                               }
>                               type = table[i].type;
> -                            strcpy(dis, dis_fn(op_code));
> +                            const char *dis_str = dis_fn(op_code);
> +                            strcpy(dis, dis_str);
> +                            free((char *)dis_str);

dito

>                               return table[i].instructions_size;
>                           } else {
>                               strcpy(dis, "reserved instruction");
> @@ -1737,7 +1741,10 @@ static const char *ACLR(uint64 instruction)
>       const char *s = IMMEDIATE(copy(s_value));
>       const char *rs = GPR(copy(rs_value));
>   
> -    return img_format("ACLR %s, %s(%s)", bit, s, rs);
> +    const char *ret = img_format("ACLR %s, %s(%s)", bit, s, rs);
> +    free((char *)bit);
> +    free((char *)s);
> +    return ret;
>   }
>   
>   
> @@ -1833,7 +1840,9 @@ static const char *ADDIU_32_(uint64 instruction)
>       const char *rs = GPR(copy(rs_value));
>       const char *u = IMMEDIATE(copy(u_value));
>   
> -    return img_format("ADDIU %s, %s, %s", rt, rs, u);
> +    const char *ret = img_format("ADDIU %s, %s, %s", rt, rs, u);
> +    free((char *)u);

I really dislike the need of having these "(char *)" casts in the calls to 
free() everywhere.
IMHO, if a function allocated memory and the caller is required to free it, 
the memory belongs to the caller after the function has finished, so it 
would be better to return "char *" instead of "const char *" in these cases. 
"const char *" should be used in the cases where the return value points to 
static strings that the caller must not free.
(Apart from that, please consider to use g_autofree for the variables 
declaration everywhere you added a free() here ... that would make this 
patch way easier).

  Thomas
diff mbox series

Patch

diff --git a/disas/nanomips.cpp b/disas/nanomips.cpp
index 561e4ff095..551bcb3164 100644
--- a/disas/nanomips.cpp
+++ b/disas/nanomips.cpp
@@ -526,7 +526,9 @@  static const char *save_restore_list(uint64 rt, uint64 count, uint64 gp)
     for (uint64 counter = 0; counter != count; counter++) {
         bool use_gp = gp && (counter == count - 1);
         uint64 this_rt = use_gp ? 28 : ((rt & 0x10) | (rt + counter)) & 0x1f;
-        strcat(str, img_format(",%s", GPR(this_rt)));
+        const char *dis_str = img_format(",%s", GPR(this_rt));
+        strcat(str, dis_str);
+        free((char *)dis_str);
     }
 
     return strdup(str);
@@ -663,7 +665,9 @@  static int Disassemble(const uint16 *data, char *dis,
                                 return -6;
                             }
                             type = table[i].type;
-                            strcpy(dis, dis_fn(op_code));
+                            const char *dis_str = dis_fn(op_code);
+                            strcpy(dis, dis_str);
+                            free((char *)dis_str);
                             return table[i].instructions_size;
                         } else {
                             strcpy(dis, "reserved instruction");
@@ -1737,7 +1741,10 @@  static const char *ACLR(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("ACLR %s, %s(%s)", bit, s, rs);
+    const char *ret = img_format("ACLR %s, %s(%s)", bit, s, rs);
+    free((char *)bit);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -1833,7 +1840,9 @@  static const char *ADDIU_32_(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("ADDIU %s, %s, %s", rt, rs, u);
+    const char *ret = img_format("ADDIU %s, %s, %s", rt, rs, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -1853,8 +1862,9 @@  static const char *ADDIU_48_(uint64 instruction)
 
     const char *rt = GPR(copy(rt_value));
     const char *s = IMMEDIATE(copy(s_value));
-
-    return img_format("ADDIU %s, %s", rt, s);
+    const char *ret = img_format("ADDIU %s, %s", rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -1874,8 +1884,9 @@  static const char *ADDIU_GP48_(uint64 instruction)
 
     const char *rt = GPR(copy(rt_value));
     const char *s = IMMEDIATE(copy(s_value));
-
-    return img_format("ADDIU %s, $%d, %s", rt, 28, s);
+    const char *ret = img_format("ADDIU %s, $%d, %s", rt, 28, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -1896,7 +1907,9 @@  static const char *ADDIU_GP_B_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("ADDIU %s, $%d, %s", rt, 28, u);
+    const char *ret = img_format("ADDIU %s, $%d, %s", rt, 28, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -1917,7 +1930,9 @@  static const char *ADDIU_GP_W_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("ADDIU %s, $%d, %s", rt, 28, u);
+    const char *ret = img_format("ADDIU %s, $%d, %s", rt, 28, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -1940,7 +1955,9 @@  static const char *ADDIU_NEG_(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *u = IMMEDIATE(neg_copy(u_value));
 
-    return img_format("ADDIU %s, %s, %s", rt, rs, u);
+    const char *ret = img_format("ADDIU %s, %s, %s", rt, rs, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -1961,7 +1978,9 @@  static const char *ADDIU_R1_SP_(uint64 instruction)
     const char *rt3 = GPR(decode_gpr_gpr3(rt3_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("ADDIU %s, $%d, %s", rt3, 29, u);
+    const char *ret = img_format("ADDIU %s, $%d, %s", rt3, 29, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -1984,7 +2003,9 @@  static const char *ADDIU_R2_(uint64 instruction)
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("ADDIU %s, %s, %s", rt3, rs3, u);
+    const char *ret = img_format("ADDIU %s, %s, %s", rt3, rs3, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -2004,7 +2025,9 @@  static const char *ADDIU_RS5_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = IMMEDIATE(copy(s_value));
 
-    return img_format("ADDIU %s, %s", rt, s);
+    const char *ret = img_format("ADDIU %s, %s", rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2026,7 +2049,9 @@  static const char *ADDIUPC_32_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("ADDIUPC %s, %s", rt, s);
+    const char *ret = img_format("ADDIUPC %s, %s", rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2048,7 +2073,9 @@  static const char *ADDIUPC_48_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 6);
 
-    return img_format("ADDIUPC %s, %s", rt, s);
+    const char *ret = img_format("ADDIUPC %s, %s", rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2506,7 +2533,9 @@  static const char *ALUIPC(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("ALUIPC %s, %%pcrel_hi(%s)", rt, s);
+    const char *ret = img_format("ALUIPC %s, %%pcrel_hi(%s)", rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2574,7 +2603,9 @@  static const char *ANDI_16_(uint64 instruction)
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
     const char *eu = IMMEDIATE(encode_eu_from_u_andi16(eu_value));
 
-    return img_format("ANDI %s, %s, %s", rt3, rs3, eu);
+    const char *ret = img_format("ANDI %s, %s, %s", rt3, rs3, eu);
+    free((char *)eu);
+    return ret;
 }
 
 
@@ -2598,7 +2629,9 @@  static const char *ANDI_32_(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("ANDI %s, %s, %s", rt, rs, u);
+    const char *ret = img_format("ANDI %s, %s, %s", rt, rs, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -2622,7 +2655,9 @@  static const char *APPEND(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("APPEND %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("APPEND %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -2646,7 +2681,10 @@  static const char *ASET(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("ASET %s, %s(%s)", bit, s, rs);
+    const char *ret = img_format("ASET %s, %s(%s)", bit, s, rs);
+    free((char *)bit);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2666,7 +2704,9 @@  static const char *BALC_16_(uint64 instruction)
 
     const char *s = ADDRESS(encode_s_from_address(s_value), 2);
 
-    return img_format("BALC %s", s);
+    const char *ret = img_format("BALC %s", s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2686,7 +2726,9 @@  static const char *BALC_32_(uint64 instruction)
 
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BALC %s", s);
+    const char *ret = img_format("BALC %s", s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2732,7 +2774,10 @@  static const char *BBEQZC(uint64 instruction)
     const char *bit = IMMEDIATE(copy(bit_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BBEQZC %s, %s, %s", rt, bit, s);
+    const char *ret = img_format("BBEQZC %s, %s, %s", rt, bit, s);
+    free((char *)bit);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2756,7 +2801,10 @@  static const char *BBNEZC(uint64 instruction)
     const char *bit = IMMEDIATE(copy(bit_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BBNEZC %s, %s, %s", rt, bit, s);
+    const char *ret = img_format("BBNEZC %s, %s, %s", rt, bit, s);
+    free((char *)bit);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2776,7 +2824,9 @@  static const char *BC_16_(uint64 instruction)
 
     const char *s = ADDRESS(encode_s_from_address(s_value), 2);
 
-    return img_format("BC %s", s);
+    const char *ret = img_format("BC %s", s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2796,7 +2846,9 @@  static const char *BC_32_(uint64 instruction)
 
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BC %s", s);
+    const char *ret = img_format("BC %s", s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2818,7 +2870,9 @@  static const char *BC1EQZC(uint64 instruction)
     const char *ft = FPR(copy(ft_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BC1EQZC %s, %s", ft, s);
+    const char *ret = img_format("BC1EQZC %s, %s", ft, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2840,7 +2894,9 @@  static const char *BC1NEZC(uint64 instruction)
     const char *ft = FPR(copy(ft_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BC1NEZC %s, %s", ft, s);
+    const char *ret = img_format("BC1NEZC %s, %s", ft, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2862,7 +2918,9 @@  static const char *BC2EQZC(uint64 instruction)
     const char *ct = CPR(copy(ct_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BC2EQZC %s, %s", ct, s);
+    const char *ret = img_format("BC2EQZC %s, %s", ct, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2884,7 +2942,9 @@  static const char *BC2NEZC(uint64 instruction)
     const char *ct = CPR(copy(ct_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BC2NEZC %s, %s", ct, s);
+    const char *ret = img_format("BC2NEZC %s, %s", ct, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2908,7 +2968,9 @@  static const char *BEQC_16_(uint64 instruction)
     const char *rt3 = GPR(decode_gpr_gpr3(rt3_value));
     const char *u = ADDRESS(encode_u_from_address(u_value), 2);
 
-    return img_format("BEQC %s, %s, %s", rs3, rt3, u);
+    const char *ret = img_format("BEQC %s, %s, %s", rs3, rt3, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -2932,7 +2994,9 @@  static const char *BEQC_32_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BEQC %s, %s, %s", rs, rt, s);
+    const char *ret = img_format("BEQC %s, %s, %s", rs, rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2956,7 +3020,10 @@  static const char *BEQIC(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BEQIC %s, %s, %s", rt, u, s);
+    const char *ret = img_format("BEQIC %s, %s, %s", rt, u, s);
+    free((char *)u);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -2978,7 +3045,9 @@  static const char *BEQZC_16_(uint64 instruction)
     const char *rt3 = GPR(decode_gpr_gpr3(rt3_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 2);
 
-    return img_format("BEQZC %s, %s", rt3, s);
+    const char *ret = img_format("BEQZC %s, %s", rt3, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3002,7 +3071,9 @@  static const char *BGEC(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BGEC %s, %s, %s", rs, rt, s);
+    const char *ret = img_format("BGEC %s, %s, %s", rs, rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3026,7 +3097,10 @@  static const char *BGEIC(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BGEIC %s, %s, %s", rt, u, s);
+    const char *ret = img_format("BGEIC %s, %s, %s", rt, u, s);
+    free((char *)u);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3050,7 +3124,10 @@  static const char *BGEIUC(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BGEIUC %s, %s, %s", rt, u, s);
+    const char *ret = img_format("BGEIUC %s, %s, %s", rt, u, s);
+    free((char *)u);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3074,7 +3151,9 @@  static const char *BGEUC(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BGEUC %s, %s, %s", rs, rt, s);
+    const char *ret = img_format("BGEUC %s, %s, %s", rs, rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3098,7 +3177,9 @@  static const char *BLTC(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BLTC %s, %s, %s", rs, rt, s);
+    const char *ret = img_format("BLTC %s, %s, %s", rs, rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3122,7 +3203,10 @@  static const char *BLTIC(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BLTIC %s, %s, %s", rt, u, s);
+    const char *ret = img_format("BLTIC %s, %s, %s", rt, u, s);
+    free((char *)u);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3146,7 +3230,10 @@  static const char *BLTIUC(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BLTIUC %s, %s, %s", rt, u, s);
+    const char *ret = img_format("BLTIUC %s, %s, %s", rt, u, s);
+    free((char *)u);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3170,7 +3257,9 @@  static const char *BLTUC(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BLTUC %s, %s, %s", rs, rt, s);
+    const char *ret = img_format("BLTUC %s, %s, %s", rs, rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3194,7 +3283,9 @@  static const char *BNEC_16_(uint64 instruction)
     const char *rt3 = GPR(decode_gpr_gpr3(rt3_value));
     const char *u = ADDRESS(encode_u_from_address(u_value), 2);
 
-    return img_format("BNEC %s, %s, %s", rs3, rt3, u);
+    const char *ret = img_format("BNEC %s, %s, %s", rs3, rt3, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -3218,7 +3309,9 @@  static const char *BNEC_32_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BNEC %s, %s, %s", rs, rt, s);
+    const char *ret = img_format("BNEC %s, %s, %s", rs, rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3242,7 +3335,10 @@  static const char *BNEIC(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BNEIC %s, %s, %s", rt, u, s);
+    const char *ret = img_format("BNEIC %s, %s, %s", rt, u, s);
+    free((char *)u);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3264,7 +3360,9 @@  static const char *BNEZC_16_(uint64 instruction)
     const char *rt3 = GPR(decode_gpr_gpr3(rt3_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 2);
 
-    return img_format("BNEZC %s, %s", rt3, s);
+    const char *ret = img_format("BNEZC %s, %s", rt3, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3284,7 +3382,9 @@  static const char *BPOSGE32C(uint64 instruction)
 
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("BPOSGE32C %s", s);
+    const char *ret = img_format("BPOSGE32C %s", s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3304,7 +3404,9 @@  static const char *BREAK_16_(uint64 instruction)
 
     const char *code = IMMEDIATE(copy(code_value));
 
-    return img_format("BREAK %s", code);
+    const char *ret = img_format("BREAK %s", code);
+    free((char *)code);
+    return ret;
 }
 
 
@@ -3324,7 +3426,9 @@  static const char *BREAK_32_(uint64 instruction)
 
     const char *code = IMMEDIATE(copy(code_value));
 
-    return img_format("BREAK %s", code);
+    const char *ret = img_format("BREAK %s", code);
+    free((char *)code);
+    return ret;
 }
 
 
@@ -3368,7 +3472,10 @@  static const char *CACHE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("CACHE %s, %s(%s)", op, s, rs);
+    const char *ret = img_format("CACHE %s, %s(%s)", op, s, rs);
+    free((char *)op);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -3392,7 +3499,10 @@  static const char *CACHEE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("CACHEE %s, %s(%s)", op, s, rs);
+    const char *ret = img_format("CACHEE %s, %s(%s)", op, s, rs);
+    free((char *)op);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -4967,7 +5077,9 @@  static const char *COP2_1(uint64 instruction)
 
     const char *cofun = IMMEDIATE(copy(cofun_value));
 
-    return img_format("COP2_1 %s", cofun);
+    const char *ret = img_format("COP2_1 %s", cofun);
+    free((char *)cofun);
+    return ret;
 }
 
 
@@ -5297,7 +5409,9 @@  static const char *DADDIU_48_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = IMMEDIATE(copy(s_value));
 
-    return img_format("DADDIU %s, %s", rt, s);
+    const char *ret = img_format("DADDIU %s, %s", rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -5321,7 +5435,9 @@  static const char *DADDIU_NEG_(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *u = IMMEDIATE(neg_copy(u_value));
 
-    return img_format("DADDIU %s, %s, %s", rt, rs, u);
+    const char *ret = img_format("DADDIU %s, %s, %s", rt, rs, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -5345,7 +5461,9 @@  static const char *DADDIU_U12_(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("DADDIU %s, %s, %s", rt, rs, u);
+    const char *ret = img_format("DADDIU %s, %s, %s", rt, rs, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -5503,7 +5621,7 @@  static const char *DERET(uint64 instruction)
 {
     (void)instruction;
 
-    return "DERET ";
+    return strdup("DERET ");
 }
 
 
@@ -5529,7 +5647,10 @@  static const char *DEXTM(uint64 instruction)
     const char *lsb = IMMEDIATE(copy(lsb_value));
     const char *msbd = IMMEDIATE(encode_msbd_from_size(msbd_value));
 
-    return img_format("DEXTM %s, %s, %s, %s", rt, rs, lsb, msbd);
+    const char *ret = img_format("DEXTM %s, %s, %s, %s", rt, rs, lsb, msbd);
+    free((char *)lsb);
+    free((char *)msbd);
+    return ret;
 }
 
 
@@ -5555,7 +5676,10 @@  static const char *DEXT(uint64 instruction)
     const char *lsb = IMMEDIATE(copy(lsb_value));
     const char *msbd = IMMEDIATE(encode_msbd_from_size(msbd_value));
 
-    return img_format("DEXT %s, %s, %s, %s", rt, rs, lsb, msbd);
+    const char *ret = img_format("DEXT %s, %s, %s, %s", rt, rs, lsb, msbd);
+    free((char *)lsb);
+    free((char *)msbd);
+    return ret;
 }
 
 
@@ -5581,7 +5705,10 @@  static const char *DEXTU(uint64 instruction)
     const char *lsb = IMMEDIATE(copy(lsb_value));
     const char *msbd = IMMEDIATE(encode_msbd_from_size(msbd_value));
 
-    return img_format("DEXTU %s, %s, %s, %s", rt, rs, lsb, msbd);
+    const char *ret = img_format("DEXTU %s, %s, %s, %s", rt, rs, lsb, msbd);
+    free((char *)lsb);
+    free((char *)msbd);
+    return ret;
 }
 
 
@@ -5608,8 +5735,11 @@  static const char *DINSM(uint64 instruction)
     const char *size = IMMEDIATE(encode_lsb_from_pos_and_size(msbd_value));
     /* !!!!!!!!!! - no conversion function */
 
-    return img_format("DINSM %s, %s, %s, %s", rt, rs, pos, size);
+    const char *ret = img_format("DINSM %s, %s, %s, %s", rt, rs, pos, size);
     /* hand edited */
+    free((char *)pos);
+    free((char *)size);
+    return ret;
 }
 
 
@@ -5636,8 +5766,11 @@  static const char *DINS(uint64 instruction)
     const char *size = IMMEDIATE(encode_lsb_from_pos_and_size(msbd_value));
     /* !!!!!!!!!! - no conversion function */
 
-    return img_format("DINS %s, %s, %s, %s", rt, rs, pos, size);
+    const char *ret = img_format("DINS %s, %s, %s, %s", rt, rs, pos, size);
     /* hand edited */
+    free((char *)pos);
+    free((char *)size);
+    return ret;
 }
 
 
@@ -5664,8 +5797,11 @@  static const char *DINSU(uint64 instruction)
     const char *size = IMMEDIATE(encode_lsb_from_pos_and_size(msbd_value));
     /* !!!!!!!!!! - no conversion function */
 
-    return img_format("DINSU %s, %s, %s, %s", rt, rs, pos, size);
+    const char *ret = img_format("DINSU %s, %s, %s, %s", rt, rs, pos, size);
     /* hand edited */
+    free((char *)pos);
+    free((char *)size);
+    return ret;
 }
 
 
@@ -5807,7 +5943,9 @@  static const char *DLSA(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u2 = IMMEDIATE(copy(u2_value));
 
-    return img_format("DLSA %s, %s, %s, %s", rd, rs, rt, u2);
+    const char *ret = img_format("DLSA %s, %s, %s, %s", rd, rs, rt, u2);
+    free((char *)u2);
+    return ret;
 }
 
 
@@ -5829,7 +5967,9 @@  static const char *DLUI_48_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("DLUI %s, %s", rt, u);
+    const char *ret = img_format("DLUI %s, %s", rt, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -5853,7 +5993,9 @@  static const char *DMFC0(uint64 instruction)
     const char *c0s = CPR(copy(c0s_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("DMFC0 %s, %s, %s", rt, c0s, sel);
+    const char *ret = img_format("DMFC0 %s, %s, %s", rt, c0s, sel);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -5921,7 +6063,9 @@  static const char *DMFGC0(uint64 instruction)
     const char *c0s = CPR(copy(c0s_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("DMFGC0 %s, %s, %s", rt, c0s, sel);
+    const char *ret = img_format("DMFGC0 %s, %s, %s", rt, c0s, sel);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -5993,7 +6137,9 @@  static const char *DMTC0(uint64 instruction)
     const char *c0s = CPR(copy(c0s_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("DMTC0 %s, %s, %s", rt, c0s, sel);
+    const char *ret = img_format("DMTC0 %s, %s, %s", rt, c0s, sel);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -6061,7 +6207,9 @@  static const char *DMTGC0(uint64 instruction)
     const char *c0s = CPR(copy(c0s_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("DMTGC0 %s, %s, %s", rt, c0s, sel);
+    const char *ret = img_format("DMTGC0 %s, %s, %s", rt, c0s, sel);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -6586,7 +6734,9 @@  static const char *DROTR(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("DROTR %s, %s, %s", rt, rs, shift);
+    const char *ret = img_format("DROTR %s, %s, %s", rt, rs, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -6610,7 +6760,9 @@  static const char *DROTR32(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("DROTR32 %s, %s, %s", rt, rs, shift);
+    const char *ret = img_format("DROTR32 %s, %s, %s", rt, rs, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -6660,7 +6812,10 @@  static const char *DROTX(uint64 instruction)
     const char *shift = IMMEDIATE(copy(shift_value));
     const char *shiftx = IMMEDIATE(copy(shiftx_value));
 
-    return img_format("DROTX %s, %s, %s, %s", rt, rs, shift, shiftx);
+    const char *ret = img_format("DROTX %s, %s, %s, %s", rt, rs, shift, shiftx);
+    free((char *)shift);
+    free((char *)shiftx);
+    return ret;
 }
 
 
@@ -6684,7 +6839,9 @@  static const char *DSLL(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("DSLL %s, %s, %s", rt, rs, shift);
+    const char *ret = img_format("DSLL %s, %s, %s", rt, rs, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -6708,7 +6865,9 @@  static const char *DSLL32(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("DSLL32 %s, %s, %s", rt, rs, shift);
+    const char *ret = img_format("DSLL32 %s, %s, %s", rt, rs, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -6756,7 +6915,9 @@  static const char *DSRA(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("DSRA %s, %s, %s", rt, rs, shift);
+    const char *ret = img_format("DSRA %s, %s, %s", rt, rs, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -6780,7 +6941,9 @@  static const char *DSRA32(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("DSRA32 %s, %s, %s", rt, rs, shift);
+    const char *ret = img_format("DSRA32 %s, %s, %s", rt, rs, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -6828,7 +6991,9 @@  static const char *DSRL(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("DSRL %s, %s, %s", rt, rs, shift);
+    const char *ret = img_format("DSRL %s, %s, %s", rt, rs, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -6852,7 +7017,9 @@  static const char *DSRL32(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("DSRL32 %s, %s, %s", rt, rs, shift);
+    const char *ret = img_format("DSRL32 %s, %s, %s", rt, rs, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -6982,7 +7149,7 @@  static const char *EHB(uint64 instruction)
 {
     (void)instruction;
 
-    return "EHB ";
+    return strdup("EHB ");
 }
 
 
@@ -7040,7 +7207,7 @@  static const char *ERET(uint64 instruction)
 {
     (void)instruction;
 
-    return "ERET ";
+    return strdup("ERET ");
 }
 
 
@@ -7058,7 +7225,7 @@  static const char *ERETNC(uint64 instruction)
 {
     (void)instruction;
 
-    return "ERETNC ";
+    return strdup("ERETNC ");
 }
 
 
@@ -7124,7 +7291,10 @@  static const char *EXT(uint64 instruction)
     const char *lsb = IMMEDIATE(copy(lsb_value));
     const char *msbd = IMMEDIATE(encode_msbd_from_size(msbd_value));
 
-    return img_format("EXT %s, %s, %s, %s", rt, rs, lsb, msbd);
+    const char *ret = img_format("EXT %s, %s, %s, %s", rt, rs, lsb, msbd);
+    free((char *)lsb);
+    free((char *)msbd);
+    return ret;
 }
 
 
@@ -7150,7 +7320,9 @@  static const char *EXTD(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("EXTD %s, %s, %s, %s", rd, rs, rt, shift);
+    const char *ret = img_format("EXTD %s, %s, %s, %s", rd, rs, rt, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -7176,7 +7348,9 @@  static const char *EXTD32(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("EXTD32 %s, %s, %s, %s", rd, rs, rt, shift);
+    const char *ret = img_format("EXTD32 %s, %s, %s, %s", rd, rs, rt, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -7200,7 +7374,9 @@  static const char *EXTPDP(uint64 instruction)
     const char *ac = AC(copy(ac_value));
     const char *size = IMMEDIATE(copy(size_value));
 
-    return img_format("EXTPDP %s, %s, %s", rt, ac, size);
+    const char *ret = img_format("EXTPDP %s, %s, %s", rt, ac, size);
+    free((char *)size);
+    return ret;
 }
 
 
@@ -7248,7 +7424,9 @@  static const char *EXTP(uint64 instruction)
     const char *ac = AC(copy(ac_value));
     const char *size = IMMEDIATE(copy(size_value));
 
-    return img_format("EXTP %s, %s, %s", rt, ac, size);
+    const char *ret = img_format("EXTP %s, %s, %s", rt, ac, size);
+    free((char *)size);
+    return ret;
 }
 
 
@@ -7297,7 +7475,9 @@  static const char *EXTR_RS_W(uint64 instruction)
     const char *ac = AC(copy(ac_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("EXTR_RS.W %s, %s, %s", rt, ac, shift);
+    const char *ret = img_format("EXTR_RS.W %s, %s, %s", rt, ac, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -7322,7 +7502,9 @@  static const char *EXTR_R_W(uint64 instruction)
     const char *ac = AC(copy(ac_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("EXTR_R.W %s, %s, %s", rt, ac, shift);
+    const char *ret = img_format("EXTR_R.W %s, %s, %s", rt, ac, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -7347,7 +7529,9 @@  static const char *EXTR_S_H(uint64 instruction)
     const char *ac = AC(copy(ac_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("EXTR_S.H %s, %s, %s", rt, ac, shift);
+    const char *ret = img_format("EXTR_S.H %s, %s, %s", rt, ac, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -7372,7 +7556,9 @@  static const char *EXTR_W(uint64 instruction)
     const char *ac = AC(copy(ac_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("EXTR.W %s, %s, %s", rt, ac, shift);
+    const char *ret = img_format("EXTR.W %s, %s, %s", rt, ac, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -7499,7 +7685,9 @@  static const char *EXTW(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("EXTW %s, %s, %s, %s", rd, rs, rt, shift);
+    const char *ret = img_format("EXTW %s, %s, %s, %s", rd, rs, rt, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -7631,7 +7819,9 @@  static const char *HYPCALL(uint64 instruction)
 
     const char *code = IMMEDIATE(copy(code_value));
 
-    return img_format("HYPCALL %s", code);
+    const char *ret = img_format("HYPCALL %s", code);
+    free((char *)code);
+    return ret;
 }
 
 
@@ -7651,7 +7841,9 @@  static const char *HYPCALL_16_(uint64 instruction)
 
     const char *code = IMMEDIATE(copy(code_value));
 
-    return img_format("HYPCALL %s", code);
+    const char *ret = img_format("HYPCALL %s", code);
+    free((char *)code);
+    return ret;
 }
 
 
@@ -7678,8 +7870,11 @@  static const char *INS(uint64 instruction)
     const char *size = IMMEDIATE(encode_lsb_from_pos_and_size(msbd_value));
     /* !!!!!!!!!! - no conversion function */
 
-    return img_format("INS %s, %s, %s, %s", rt, rs, pos, size);
+    const char *ret = img_format("INS %s, %s, %s, %s", rt, rs, pos, size);
     /* hand edited */
+    free((char *)pos);
+    free((char *)size);
+    return ret;
 }
 
 
@@ -7718,7 +7913,7 @@  static const char *IRET(uint64 instruction)
 {
     (void)instruction;
 
-    return "IRET ";
+    return strdup("IRET ");
 }
 
 
@@ -7826,7 +8021,9 @@  static const char *LB_16_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
 
-    return img_format("LB %s, %s(%s)", rt3, u, rs3);
+    const char *ret = img_format("LB %s, %s(%s)", rt3, u, rs3);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -7848,7 +8045,9 @@  static const char *LB_GP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("LB %s, %s($%d)", rt, u, 28);
+    const char *ret = img_format("LB %s, %s($%d)", rt, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -7872,7 +8071,9 @@  static const char *LB_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LB %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LB %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -7896,7 +8097,9 @@  static const char *LB_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LB %s, %s(%s)", rt, u, rs);
+    const char *ret = img_format("LB %s, %s(%s)", rt, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -7920,7 +8123,9 @@  static const char *LBE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LBE %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LBE %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -7944,7 +8149,9 @@  static const char *LBU_16_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
 
-    return img_format("LBU %s, %s(%s)", rt3, u, rs3);
+    const char *ret = img_format("LBU %s, %s(%s)", rt3, u, rs3);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -7966,7 +8173,9 @@  static const char *LBU_GP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("LBU %s, %s($%d)", rt, u, 28);
+    const char *ret = img_format("LBU %s, %s($%d)", rt, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -7990,7 +8199,9 @@  static const char *LBU_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LBU %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LBU %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8014,7 +8225,9 @@  static const char *LBU_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LBU %s, %s(%s)", rt, u, rs);
+    const char *ret = img_format("LBU %s, %s(%s)", rt, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -8038,7 +8251,9 @@  static const char *LBUE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LBUE %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LBUE %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8108,7 +8323,9 @@  static const char *LD_GP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("LD %s, %s($%d)", rt, u, 28);
+    const char *ret = img_format("LD %s, %s($%d)", rt, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -8132,7 +8349,9 @@  static const char *LD_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LD %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LD %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8156,7 +8375,9 @@  static const char *LD_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LD %s, %s(%s)", rt, u, rs);
+    const char *ret = img_format("LD %s, %s(%s)", rt, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -8178,7 +8399,9 @@  static const char *LDC1_GP_(uint64 instruction)
     const char *ft = FPR(copy(ft_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("LDC1 %s, %s($%d)", ft, u, 28);
+    const char *ret = img_format("LDC1 %s, %s($%d)", ft, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -8202,7 +8425,9 @@  static const char *LDC1_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LDC1 %s, %s(%s)", ft, s, rs);
+    const char *ret = img_format("LDC1 %s, %s(%s)", ft, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8226,7 +8451,9 @@  static const char *LDC1_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LDC1 %s, %s(%s)", ft, u, rs);
+    const char *ret = img_format("LDC1 %s, %s(%s)", ft, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -8298,7 +8525,9 @@  static const char *LDC2(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LDC2 %s, %s(%s)", ct, s, rs);
+    const char *ret = img_format("LDC2 %s, %s(%s)", ct, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8324,7 +8553,10 @@  static const char *LDM(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *count3 = IMMEDIATE(encode_count3_from_count(count3_value));
 
-    return img_format("LDM %s, %s(%s), %s", rt, s, rs, count3);
+    const char *ret = img_format("LDM %s, %s(%s), %s", rt, s, rs, count3);
+    free((char *)s);
+    free((char *)count3);
+    return ret;
 }
 
 
@@ -8346,7 +8578,9 @@  static const char *LDPC_48_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 6);
 
-    return img_format("LDPC %s, %s", rt, s);
+    const char *ret = img_format("LDPC %s, %s", rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8418,7 +8652,9 @@  static const char *LH_16_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
 
-    return img_format("LH %s, %s(%s)", rt3, u, rs3);
+    const char *ret = img_format("LH %s, %s(%s)", rt3, u, rs3);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -8440,7 +8676,9 @@  static const char *LH_GP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("LH %s, %s($%d)", rt, u, 28);
+    const char *ret = img_format("LH %s, %s($%d)", rt, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -8464,7 +8702,9 @@  static const char *LH_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LH %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LH %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8488,7 +8728,9 @@  static const char *LH_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LH %s, %s(%s)", rt, u, rs);
+    const char *ret = img_format("LH %s, %s(%s)", rt, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -8512,7 +8754,9 @@  static const char *LHE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LHE %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LHE %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8536,7 +8780,9 @@  static const char *LHU_16_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
 
-    return img_format("LHU %s, %s(%s)", rt3, u, rs3);
+    const char *ret = img_format("LHU %s, %s(%s)", rt3, u, rs3);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -8558,7 +8804,9 @@  static const char *LHU_GP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("LHU %s, %s($%d)", rt, u, 28);
+    const char *ret = img_format("LHU %s, %s($%d)", rt, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -8582,7 +8830,9 @@  static const char *LHU_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LHU %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LHU %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8606,7 +8856,9 @@  static const char *LHU_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LHU %s, %s(%s)", rt, u, rs);
+    const char *ret = img_format("LHU %s, %s(%s)", rt, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -8630,7 +8882,9 @@  static const char *LHUE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LHUE %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LHUE %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8748,7 +9002,9 @@  static const char *LI_16_(uint64 instruction)
     const char *rt3 = GPR(decode_gpr_gpr3(rt3_value));
     const char *eu = IMMEDIATE(encode_eu_from_s_li16(eu_value));
 
-    return img_format("LI %s, %s", rt3, eu);
+    const char *ret = img_format("LI %s, %s", rt3, eu);
+    free((char *)eu);
+    return ret;
 }
 
 
@@ -8770,7 +9026,9 @@  static const char *LI_48_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = IMMEDIATE(copy(s_value));
 
-    return img_format("LI %s, %s", rt, s);
+    const char *ret = img_format("LI %s, %s", rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8794,7 +9052,9 @@  static const char *LL(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LL %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LL %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8818,7 +9078,9 @@  static const char *LLD(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LLD %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LLD %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8866,7 +9128,9 @@  static const char *LLE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LLE %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LLE %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8940,7 +9204,9 @@  static const char *LSA(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u2 = IMMEDIATE(copy(u2_value));
 
-    return img_format("LSA %s, %s, %s, %s", rd, rs, rt, u2);
+    const char *ret = img_format("LSA %s, %s, %s, %s", rd, rs, rt, u2);
+    free((char *)u2);
+    return ret;
 }
 
 
@@ -8962,7 +9228,9 @@  static const char *LUI(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = IMMEDIATE(copy(s_value));
 
-    return img_format("LUI %s, %%hi(%s)", rt, s);
+    const char *ret = img_format("LUI %s, %%hi(%s)", rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -8986,7 +9254,9 @@  static const char *LW_16_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
 
-    return img_format("LW %s, %s(%s)", rt3, u, rs3);
+    const char *ret = img_format("LW %s, %s(%s)", rt3, u, rs3);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -9010,7 +9280,9 @@  static const char *LW_4X4_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs4 = GPR(decode_gpr_gpr4(rs4_value));
 
-    return img_format("LW %s, %s(%s)", rt4, u, rs4);
+    const char *ret = img_format("LW %s, %s(%s)", rt4, u, rs4);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -9032,7 +9304,9 @@  static const char *LW_GP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("LW %s, %s($%d)", rt, u, 28);
+    const char *ret = img_format("LW %s, %s($%d)", rt, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -9054,7 +9328,9 @@  static const char *LW_GP16_(uint64 instruction)
     const char *rt3 = GPR(decode_gpr_gpr3(rt3_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("LW %s, %s($%d)", rt3, u, 28);
+    const char *ret = img_format("LW %s, %s($%d)", rt3, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -9078,7 +9354,9 @@  static const char *LW_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LW %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LW %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -9100,7 +9378,9 @@  static const char *LW_SP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("LW %s, %s($%d)", rt, u, 29);
+    const char *ret = img_format("LW %s, %s($%d)", rt, u, 29);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -9124,7 +9404,9 @@  static const char *LW_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LW %s, %s(%s)", rt, u, rs);
+    const char *ret = img_format("LW %s, %s(%s)", rt, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -9146,7 +9428,9 @@  static const char *LWC1_GP_(uint64 instruction)
     const char *ft = FPR(copy(ft_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("LWC1 %s, %s($%d)", ft, u, 28);
+    const char *ret = img_format("LWC1 %s, %s($%d)", ft, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -9170,7 +9454,9 @@  static const char *LWC1_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LWC1 %s, %s(%s)", ft, s, rs);
+    const char *ret = img_format("LWC1 %s, %s(%s)", ft, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -9194,7 +9480,9 @@  static const char *LWC1_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LWC1 %s, %s(%s)", ft, u, rs);
+    const char *ret = img_format("LWC1 %s, %s(%s)", ft, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -9266,7 +9554,9 @@  static const char *LWC2(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LWC2 %s, %s(%s)", ct, s, rs);
+    const char *ret = img_format("LWC2 %s, %s(%s)", ct, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -9290,7 +9580,9 @@  static const char *LWE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LWE %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LWE %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -9316,7 +9608,10 @@  static const char *LWM(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *count3 = IMMEDIATE(encode_count3_from_count(count3_value));
 
-    return img_format("LWM %s, %s(%s), %s", rt, s, rs, count3);
+    const char *ret = img_format("LWM %s, %s(%s), %s", rt, s, rs, count3);
+    free((char *)s);
+    free((char *)count3);
+    return ret;
 }
 
 
@@ -9338,7 +9633,9 @@  static const char *LWPC_48_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 6);
 
-    return img_format("LWPC %s, %s", rt, s);
+    const char *ret = img_format("LWPC %s, %s", rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -9360,7 +9657,9 @@  static const char *LWU_GP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("LWU %s, %s($%d)", rt, u, 28);
+    const char *ret = img_format("LWU %s, %s($%d)", rt, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -9384,7 +9683,9 @@  static const char *LWU_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LWU %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("LWU %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -9408,7 +9709,9 @@  static const char *LWU_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("LWU %s, %s(%s)", rt, u, rs);
+    const char *ret = img_format("LWU %s, %s(%s)", rt, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -9504,7 +9807,9 @@  static const char *LWXS_16_(uint64 instruction)
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
     const char *rt3 = IMMEDIATE(decode_gpr_gpr3(rt3_value));
 
-    return img_format("LWXS %s, %s(%s)", rd3, rs3, rt3);
+    const char *ret = img_format("LWXS %s, %s(%s)", rd3, rs3, rt3);
+    free((char *)rt3);
+    return ret;
 }
 
 
@@ -9846,7 +10151,10 @@  static const char *MFC0(uint64 instruction)
     const char *c0s = CPR(copy(c0s_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("MFC0 %s, %s, %s", rt, c0s, sel);
+    const char *ret = img_format("MFC0 %s, %s, %s", rt, c0s, sel);
+    free((char *)c0s);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -9914,7 +10222,10 @@  static const char *MFGC0(uint64 instruction)
     const char *c0s = CPR(copy(c0s_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("MFGC0 %s, %s, %s", rt, c0s, sel);
+    const char *ret = img_format("MFGC0 %s, %s, %s", rt, c0s, sel);
+    free((char *)c0s);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -9938,7 +10249,10 @@  static const char *MFHC0(uint64 instruction)
     const char *c0s = CPR(copy(c0s_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("MFHC0 %s, %s, %s", rt, c0s, sel);
+    const char *ret = img_format("MFHC0 %s, %s, %s", rt, c0s, sel);
+    free((char *)c0s);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -10006,7 +10320,10 @@  static const char *MFHGC0(uint64 instruction)
     const char *c0s = CPR(copy(c0s_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("MFHGC0 %s, %s, %s", rt, c0s, sel);
+    const char *ret = img_format("MFHGC0 %s, %s, %s", rt, c0s, sel);
+    free((char *)c0s);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -10053,7 +10370,11 @@  static const char *MFHTR(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("MFHTR %s, %s, %s, %s", rt, c0s, u, sel);
+    const char *ret = img_format("MFHTR %s, %s, %s, %s", rt, c0s, u, sel);
+    free((char *)c0s);
+    free((char *)u);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -10100,7 +10421,11 @@  static const char *MFTR(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("MFTR %s, %s, %s, %s", rt, c0s, u, sel);
+    const char *ret = img_format("MFTR %s, %s, %s, %s", rt, c0s, u, sel);
+    free((char *)c0s);
+    free((char *)u);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -10336,7 +10661,9 @@  static const char *MOVE_BALC(uint64 instruction)
     const char *rtz4 = GPR(decode_gpr_gpr4_zero(rtz4_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 4);
 
-    return img_format("MOVE.BALC %s, %s, %s", rd1, rtz4, s);
+    const char *ret = img_format("MOVE.BALC %s, %s, %s", rd1, rtz4, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -10580,7 +10907,10 @@  static const char *MTC0(uint64 instruction)
     const char *c0s = CPR(copy(c0s_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("MTC0 %s, %s, %s", rt, c0s, sel);
+    const char *ret = img_format("MTC0 %s, %s, %s", rt, c0s, sel);
+    free((char *)c0s);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -10648,7 +10978,10 @@  static const char *MTGC0(uint64 instruction)
     const char *c0s = CPR(copy(c0s_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("MTGC0 %s, %s, %s", rt, c0s, sel);
+    const char *ret = img_format("MTGC0 %s, %s, %s", rt, c0s, sel);
+    free((char *)c0s);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -10672,7 +11005,10 @@  static const char *MTHC0(uint64 instruction)
     const char *c0s = CPR(copy(c0s_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("MTHC0 %s, %s, %s", rt, c0s, sel);
+    const char *ret = img_format("MTHC0 %s, %s, %s", rt, c0s, sel);
+    free((char *)c0s);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -10740,7 +11076,10 @@  static const char *MTHGC0(uint64 instruction)
     const char *c0s = CPR(copy(c0s_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("MTHGC0 %s, %s, %s", rt, c0s, sel);
+    const char *ret = img_format("MTHGC0 %s, %s, %s", rt, c0s, sel);
+    free((char *)c0s);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -10808,7 +11147,11 @@  static const char *MTHTR(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("MTHTR %s, %s, %s, %s", rt, c0s, u, sel);
+    const char *ret = img_format("MTHTR %s, %s, %s, %s", rt, c0s, u, sel);
+    free((char *)c0s);
+    free((char *)u);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -10855,7 +11198,11 @@  static const char *MTTR(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("MTTR %s, %s, %s, %s", rt, c0s, u, sel);
+    const char *ret = img_format("MTTR %s, %s, %s, %s", rt, c0s, u, sel);
+    free((char *)c0s);
+    free((char *)u);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -11431,7 +11778,7 @@  static const char *NOP_16_(uint64 instruction)
 {
     (void)instruction;
 
-    return "NOP ";
+    return strdup("NOP ");
 }
 
 
@@ -11449,7 +11796,7 @@  static const char *NOP_32_(uint64 instruction)
 {
     (void)instruction;
 
-    return "NOP ";
+    return strdup("NOP ");
 }
 
 
@@ -11565,7 +11912,9 @@  static const char *ORI(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("ORI %s, %s, %s", rt, rs, u);
+    const char *ret = img_format("ORI %s, %s, %s", rt, rs, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -11608,7 +11957,7 @@  static const char *PAUSE(uint64 instruction)
 {
     (void)instruction;
 
-    return "PAUSE ";
+    return strdup("PAUSE ");
 }
 
 
@@ -11940,7 +12289,9 @@  static const char *PRECR_SRA_PH_W(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("PRECR_SRA.PH.W %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("PRECR_SRA.PH.W %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -11965,7 +12316,9 @@  static const char *PRECR_SRA_R_PH_W(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("PRECR_SRA_R.PH.W %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("PRECR_SRA_R.PH.W %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -12089,7 +12442,10 @@  static const char *PREF_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("PREF %s, %s(%s)", hint, s, rs);
+    const char *ret = img_format("PREF %s, %s(%s)", hint, s, rs);
+    free((char *)hint);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -12113,7 +12469,10 @@  static const char *PREF_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("PREF %s, %s(%s)", hint, u, rs);
+    const char *ret = img_format("PREF %s, %s(%s)", hint, u, rs);
+    free((char *)hint);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -12137,7 +12496,10 @@  static const char *PREFE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("PREFE %s, %s(%s)", hint, s, rs);
+    const char *ret = img_format("PREFE %s, %s(%s)", hint, s, rs);
+    free((char *)hint);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -12161,7 +12523,9 @@  static const char *PREPEND(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("PREPEND %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("PREPEND %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -12203,7 +12567,9 @@  static const char *RDDSP(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *mask = IMMEDIATE(copy(mask_value));
 
-    return img_format("RDDSP %s, %s", rt, mask);
+    const char *ret = img_format("RDDSP %s, %s", rt, mask);
+    free((char *)mask);
+    return ret;
 }
 
 
@@ -12227,7 +12593,10 @@  static const char *RDHWR(uint64 instruction)
     const char *hs = CPR(copy(hs_value));
     const char *sel = IMMEDIATE(copy(sel_value));
 
-    return img_format("RDHWR %s, %s, %s", rt, hs, sel);
+    const char *ret = img_format("RDHWR %s, %s, %s", rt, hs, sel);
+    free((char *)hs);
+    free((char *)sel);
+    return ret;
 }
 
 
@@ -12316,6 +12685,7 @@  static const char *REPL_PH(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
 
     return img_format("REPL.PH %s, %s", rt, s);
+
 }
 
 
@@ -12337,7 +12707,9 @@  static const char *REPL_QB(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("REPL.QB %s, %s", rt, u);
+    const char *ret = img_format("REPL.QB %s, %s", rt, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -12402,8 +12774,13 @@  static const char *RESTORE_32_(uint64 instruction)
     uint64 gp_value = extract_gp_2(instruction);
 
     const char *u = IMMEDIATE(copy(u_value));
-    return img_format("RESTORE %s%s", u,
-               save_restore_list(rt_value, count_value, gp_value));
+    const char *save_restore_str = save_restore_list(
+        rt_value, count_value, gp_value);
+
+    const char *ret = img_format("RESTORE %s%s", u, save_restore_str);
+    free((char *)save_restore_str);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -12424,8 +12801,13 @@  static const char *RESTORE_JRC_16_(uint64 instruction)
     uint64 count_value = extract_count_3_2_1_0(instruction);
 
     const char *u = IMMEDIATE(copy(u_value));
-    return img_format("RESTORE.JRC %s%s", u,
-        save_restore_list(encode_rt1_from_rt(rt1_value), count_value, 0));
+    const char *save_restore_str = save_restore_list(
+        encode_rt1_from_rt(rt1_value), count_value, 0);
+
+    const char *ret = img_format("RESTORE.JRC %s%s", u, save_restore_str);
+    free((char *)u);
+    free((char *)save_restore_str);
+    return ret;
 }
 
 
@@ -12447,8 +12829,13 @@  static const char *RESTORE_JRC_32_(uint64 instruction)
     uint64 gp_value = extract_gp_2(instruction);
 
     const char *u = IMMEDIATE(copy(u_value));
-    return img_format("RESTORE.JRC %s%s", u,
-               save_restore_list(rt_value, count_value, gp_value));
+    const char *save_restore_str = save_restore_list(
+        rt_value, count_value, gp_value);
+
+    const char *ret = img_format("RESTORE.JRC %s%s", u, save_restore_str);
+    free((char *)u);
+    free((char *)save_restore_str);
+    return ret;
 }
 
 
@@ -12470,7 +12857,10 @@  static const char *RESTOREF(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *count = IMMEDIATE(copy(count_value));
 
-    return img_format("RESTOREF %s, %s", u, count);
+    const char *ret = img_format("RESTOREF %s, %s", u, count);
+    free((char *)u);
+    free((char *)count);
+    return ret;
 }
 
 
@@ -12538,7 +12928,9 @@  static const char *ROTR(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("ROTR %s, %s, %s", rt, rs, shift);
+    const char *ret = img_format("ROTR %s, %s, %s", rt, rs, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -12590,8 +12982,12 @@  static const char *ROTX(uint64 instruction)
     const char *shiftx = IMMEDIATE(copy(shiftx_value));
     const char *stripe = IMMEDIATE(copy(stripe_value));
 
-    return img_format("ROTX %s, %s, %s, %s, %s",
+    const char *ret = img_format("ROTX %s, %s, %s, %s, %s",
                        rt, rs, shift, shiftx, stripe);
+    free((char *)shift);
+    free((char *)shiftx);
+    free((char *)stripe);
+    return ret;
 }
 
 
@@ -12744,8 +13140,13 @@  static const char *SAVE_16_(uint64 instruction)
     uint64 count_value = extract_count_3_2_1_0(instruction);
 
     const char *u = IMMEDIATE(copy(u_value));
-    return img_format("SAVE %s%s", u,
-        save_restore_list(encode_rt1_from_rt(rt1_value), count_value, 0));
+    const char *save_restore_str = save_restore_list(
+        encode_rt1_from_rt(rt1_value), count_value, 0);
+
+    const char *ret = img_format("SAVE %s%s", u, save_restore_str);
+    free((char *)u);
+    free((char *)save_restore_str);
+    return ret;
 }
 
 
@@ -12767,8 +13168,13 @@  static const char *SAVE_32_(uint64 instruction)
     uint64 gp_value = extract_gp_2(instruction);
 
     const char *u = IMMEDIATE(copy(u_value));
-    return img_format("SAVE %s%s", u,
-               save_restore_list(rt_value, count_value, gp_value));
+    const char *save_restore_str = save_restore_list(
+        rt_value, count_value, gp_value);
+
+    const char *ret = img_format("SAVE %s%s", u, save_restore_str);
+    free((char *)u);
+    free((char *)save_restore_str);
+    return ret;
 }
 
 
@@ -12790,7 +13196,10 @@  static const char *SAVEF(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *count = IMMEDIATE(copy(count_value));
 
-    return img_format("SAVEF %s, %s", u, count);
+    const char *ret = img_format("SAVEF %s, %s", u, count);
+    free((char *)u);
+    free((char *)count);
+    return ret;
 }
 
 
@@ -12814,7 +13223,9 @@  static const char *SB_16_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
 
-    return img_format("SB %s, %s(%s)", rtz3, u, rs3);
+    const char *ret = img_format("SB %s, %s(%s)", rtz3, u, rs3);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -12836,7 +13247,9 @@  static const char *SB_GP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("SB %s, %s($%d)", rt, u, 28);
+    const char *ret = img_format("SB %s, %s($%d)", rt, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -12860,7 +13273,9 @@  static const char *SB_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SB %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("SB %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -12884,7 +13299,9 @@  static const char *SB_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SB %s, %s(%s)", rt, u, rs);
+    const char *ret = img_format("SB %s, %s(%s)", rt, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -12908,7 +13325,9 @@  static const char *SBE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SBE %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("SBE %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -12956,7 +13375,9 @@  static const char *SC(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SC %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("SC %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -12980,7 +13401,9 @@  static const char *SCD(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SCD %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("SCD %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -13028,7 +13451,9 @@  static const char *SCE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SCE %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("SCE %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -13098,7 +13523,9 @@  static const char *SD_GP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("SD %s, %s($%d)", rt, u, 28);
+    const char *ret = img_format("SD %s, %s($%d)", rt, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -13122,7 +13549,9 @@  static const char *SD_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SD %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("SD %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -13146,7 +13575,9 @@  static const char *SD_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SD %s, %s(%s)", rt, u, rs);
+    const char *ret = img_format("SD %s, %s(%s)", rt, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -13166,7 +13597,9 @@  static const char *SDBBP_16_(uint64 instruction)
 
     const char *code = IMMEDIATE(copy(code_value));
 
-    return img_format("SDBBP %s", code);
+    const char *ret = img_format("SDBBP %s", code);
+    free((char *)code);
+    return ret;
 }
 
 
@@ -13186,7 +13619,9 @@  static const char *SDBBP_32_(uint64 instruction)
 
     const char *code = IMMEDIATE(copy(code_value));
 
-    return img_format("SDBBP %s", code);
+    const char *ret = img_format("SDBBP %s", code);
+    free((char *)code);
+    return ret;
 }
 
 
@@ -13208,7 +13643,9 @@  static const char *SDC1_GP_(uint64 instruction)
     const char *ft = FPR(copy(ft_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("SDC1 %s, %s($%d)", ft, u, 28);
+    const char *ret = img_format("SDC1 %s, %s($%d)", ft, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -13232,7 +13669,9 @@  static const char *SDC1_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SDC1 %s, %s(%s)", ft, s, rs);
+    const char *ret = img_format("SDC1 %s, %s(%s)", ft, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -13256,7 +13695,9 @@  static const char *SDC1_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SDC1 %s, %s(%s)", ft, u, rs);
+    const char *ret = img_format("SDC1 %s, %s(%s)", ft, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -13328,7 +13769,9 @@  static const char *SDC2(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SDC2 %s, %s(%s)", cs, s, rs);
+    const char *ret = img_format("SDC2 %s, %s(%s)", cs, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -13354,7 +13797,10 @@  static const char *SDM(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *count3 = IMMEDIATE(encode_count3_from_count(count3_value));
 
-    return img_format("SDM %s, %s(%s), %s", rt, s, rs, count3);
+    const char *ret = img_format("SDM %s, %s(%s), %s", rt, s, rs, count3);
+    free((char *)s);
+    free((char *)count3);
+    return ret;
 }
 
 
@@ -13376,7 +13822,9 @@  static const char *SDPC_48_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 6);
 
-    return img_format("SDPC %s, %s", rt, s);
+    const char *ret = img_format("SDPC %s, %s", rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -13636,7 +14084,9 @@  static const char *SEQI(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("SEQI %s, %s, %s", rt, rs, u);
+    const char *ret = img_format("SEQI %s, %s, %s", rt, rs, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -13660,7 +14110,9 @@  static const char *SH_16_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
 
-    return img_format("SH %s, %s(%s)", rtz3, u, rs3);
+    const char *ret = img_format("SH %s, %s(%s)", rtz3, u, rs3);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -13682,7 +14134,9 @@  static const char *SH_GP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("SH %s, %s($%d)", rt, u, 28);
+    const char *ret = img_format("SH %s, %s($%d)", rt, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -13706,7 +14160,9 @@  static const char *SH_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SH %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("SH %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -13730,7 +14186,9 @@  static const char *SH_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SH %s, %s(%s)", rt, u, rs);
+    const char *ret = img_format("SH %s, %s(%s)", rt, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -13754,7 +14212,9 @@  static const char *SHE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SHE %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("SHE %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -13776,7 +14236,9 @@  static const char *SHILO(uint64 instruction)
     const char *shift = IMMEDIATE(copy(shift_value));
     const char *ac = AC(copy(ac_value));
 
-    return img_format("SHILO %s, %s", ac, shift);
+    const char *ret = img_format("SHILO %s, %s", ac, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -13822,7 +14284,9 @@  static const char *SHLL_PH(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("SHLL.PH %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("SHLL.PH %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -13846,7 +14310,9 @@  static const char *SHLL_QB(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("SHLL.QB %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("SHLL.QB %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -13871,7 +14337,9 @@  static const char *SHLL_S_PH(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("SHLL_S.PH %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("SHLL_S.PH %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -13895,7 +14363,9 @@  static const char *SHLL_S_W(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("SHLL_S.W %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("SHLL_S.W %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -14017,7 +14487,9 @@  static const char *SHRA_PH(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("SHRA.PH %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("SHRA.PH %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -14041,7 +14513,9 @@  static const char *SHRA_QB(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("SHRA.QB %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("SHRA.QB %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -14065,7 +14539,9 @@  static const char *SHRA_R_PH(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("SHRA_R.PH %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("SHRA_R.PH %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -14089,7 +14565,9 @@  static const char *SHRA_R_QB(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("SHRA_R.QB %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("SHRA_R.QB %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -14113,7 +14591,9 @@  static const char *SHRA_R_W(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("SHRA_R.W %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("SHRA_R.W %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -14257,7 +14737,9 @@  static const char *SHRL_PH(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("SHRL.PH %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("SHRL.PH %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -14281,7 +14763,9 @@  static const char *SHRL_QB(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *sa = IMMEDIATE(copy(sa_value));
 
-    return img_format("SHRL.QB %s, %s, %s", rt, rs, sa);
+    const char *ret = img_format("SHRL.QB %s, %s, %s", rt, rs, sa);
+    free((char *)sa);
+    return ret;
 }
 
 
@@ -14398,7 +14882,9 @@  static const char *SIGRIE(uint64 instruction)
 
     const char *code = IMMEDIATE(copy(code_value));
 
-    return img_format("SIGRIE %s", code);
+    const char *ret = img_format("SIGRIE %s", code);
+    free((char *)code);
+    return ret;
 }
 
 
@@ -14422,7 +14908,9 @@  static const char *SLL_16_(uint64 instruction)
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
     const char *shift3 = IMMEDIATE(encode_shift3_from_shift(shift3_value));
 
-    return img_format("SLL %s, %s, %s", rt3, rs3, shift3);
+    const char *ret = img_format("SLL %s, %s, %s", rt3, rs3, shift3);
+    free((char *)shift3);
+    return ret;
 }
 
 
@@ -14446,7 +14934,9 @@  static const char *SLL_32_(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("SLL %s, %s, %s", rt, rs, shift);
+    const char *ret = img_format("SLL %s, %s, %s", rt, rs, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -14518,7 +15008,9 @@  static const char *SLTI(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("SLTI %s, %s, %s", rt, rs, u);
+    const char *ret = img_format("SLTI %s, %s, %s", rt, rs, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -14542,7 +15034,9 @@  static const char *SLTIU(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("SLTIU %s, %s, %s", rt, rs, u);
+    const char *ret = img_format("SLTIU %s, %s, %s", rt, rs, u);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -14610,7 +15104,9 @@  static const char *SPECIAL2(uint64 instruction)
 
     const char *op = IMMEDIATE(copy(op_value));
 
-    return img_format("SPECIAL2 %s", op);
+    const char *ret = img_format("SPECIAL2 %s", op);
+    free((char *)op);
+    return ret;
 }
 
 
@@ -14678,7 +15174,9 @@  static const char *SRA(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("SRA %s, %s, %s", rt, rs, shift);
+    const char *ret = img_format("SRA %s, %s, %s", rt, rs, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -14726,7 +15224,9 @@  static const char *SRL_16_(uint64 instruction)
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
     const char *shift3 = IMMEDIATE(encode_shift3_from_shift(shift3_value));
 
-    return img_format("SRL %s, %s, %s", rt3, rs3, shift3);
+    const char *ret = img_format("SRL %s, %s, %s", rt3, rs3, shift3);
+    free((char *)shift3);
+    return ret;
 }
 
 
@@ -14750,7 +15250,9 @@  static const char *SRL_32_(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *shift = IMMEDIATE(copy(shift_value));
 
-    return img_format("SRL %s, %s, %s", rt, rs, shift);
+    const char *ret = img_format("SRL %s, %s, %s", rt, rs, shift);
+    free((char *)shift);
+    return ret;
 }
 
 
@@ -15240,7 +15742,9 @@  static const char *SW_16_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs3 = GPR(decode_gpr_gpr3(rs3_value));
 
-    return img_format("SW %s, %s(%s)", rtz3, u, rs3);
+    const char *ret = img_format("SW %s, %s(%s)", rtz3, u, rs3);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -15264,7 +15768,9 @@  static const char *SW_4X4_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs4 = GPR(decode_gpr_gpr4(rs4_value));
 
-    return img_format("SW %s, %s(%s)", rtz4, u, rs4);
+    const char *ret = img_format("SW %s, %s(%s)", rtz4, u, rs4);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -15286,7 +15792,9 @@  static const char *SW_GP16_(uint64 instruction)
     const char *rtz3 = GPR(decode_gpr_gpr3_src_store(rtz3_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("SW %s, %s($%d)", rtz3, u, 28);
+    const char *ret = img_format("SW %s, %s($%d)", rtz3, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -15308,7 +15816,9 @@  static const char *SW_GP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("SW %s, %s($%d)", rt, u, 28);
+    const char *ret = img_format("SW %s, %s($%d)", rt, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -15332,7 +15842,9 @@  static const char *SW_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SW %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("SW %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -15354,7 +15866,9 @@  static const char *SW_SP_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("SW %s, %s($%d)", rt, u, 29);
+    const char *ret = img_format("SW %s, %s($%d)", rt, u, 29);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -15378,7 +15892,9 @@  static const char *SW_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SW %s, %s(%s)", rt, u, rs);
+    const char *ret = img_format("SW %s, %s(%s)", rt, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -15400,7 +15916,9 @@  static const char *SWC1_GP_(uint64 instruction)
     const char *ft = FPR(copy(ft_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("SWC1 %s, %s($%d)", ft, u, 28);
+    const char *ret = img_format("SWC1 %s, %s($%d)", ft, u, 28);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -15424,7 +15942,9 @@  static const char *SWC1_S9_(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SWC1 %s, %s(%s)", ft, s, rs);
+    const char *ret = img_format("SWC1 %s, %s(%s)", ft, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -15448,7 +15968,9 @@  static const char *SWC1_U12_(uint64 instruction)
     const char *u = IMMEDIATE(copy(u_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SWC1 %s, %s(%s)", ft, u, rs);
+    const char *ret = img_format("SWC1 %s, %s(%s)", ft, u, rs);
+    free((char *)u);
+    return ret;
 }
 
 
@@ -15520,7 +16042,9 @@  static const char *SWC2(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SWC2 %s, %s(%s)", cs, s, rs);
+    const char *ret = img_format("SWC2 %s, %s(%s)", cs, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -15544,7 +16068,9 @@  static const char *SWE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SWE %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("SWE %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -15570,7 +16096,10 @@  static const char *SWM(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *count3 = IMMEDIATE(encode_count3_from_count(count3_value));
 
-    return img_format("SWM %s, %s(%s), %s", rt, s, rs, count3);
+    const char *ret = img_format("SWM %s, %s(%s), %s", rt, s, rs, count3);
+    free((char *)s);
+    free((char *)count3);
+    return ret;
 }
 
 
@@ -15592,7 +16121,9 @@  static const char *SWPC_48_(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *s = ADDRESS(encode_s_from_address(s_value), 6);
 
-    return img_format("SWPC %s, %s", rt, s);
+    const char *ret = img_format("SWPC %s, %s", rt, s);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -15660,7 +16191,9 @@  static const char *SYNC(uint64 instruction)
 
     const char *stype = IMMEDIATE(copy(stype_value));
 
-    return img_format("SYNC %s", stype);
+    const char *ret = img_format("SYNC %s", stype);
+    free((char *)stype);
+    return ret;
 }
 
 
@@ -15682,7 +16215,9 @@  static const char *SYNCI(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SYNCI %s(%s)", s, rs);
+    const char *ret = img_format("SYNCI %s(%s)", s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -15704,7 +16239,9 @@  static const char *SYNCIE(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("SYNCIE %s(%s)", s, rs);
+    const char *ret = img_format("SYNCIE %s(%s)", s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -15724,7 +16261,9 @@  static const char *SYSCALL_16_(uint64 instruction)
 
     const char *code = IMMEDIATE(copy(code_value));
 
-    return img_format("SYSCALL %s", code);
+    const char *ret = img_format("SYSCALL %s", code);
+    free((char *)code);
+    return ret;
 }
 
 
@@ -15742,7 +16281,9 @@  static const char *SYSCALL_32_(uint64 instruction)
 
     const char *code = IMMEDIATE(copy(code_value));
 
-    return img_format("SYSCALL %s", code);
+    const char *ret = img_format("SYSCALL %s", code);
+    free((char *)code);
+    return ret;
 }
 
 
@@ -15782,7 +16323,7 @@  static const char *TLBGINV(uint64 instruction)
 {
     (void)instruction;
 
-    return "TLBGINV ";
+    return strdup("TLBGINV ");
 }
 
 
@@ -15800,7 +16341,7 @@  static const char *TLBGINVF(uint64 instruction)
 {
     (void)instruction;
 
-    return "TLBGINVF ";
+    return strdup("TLBGINVF ");
 }
 
 
@@ -15818,7 +16359,7 @@  static const char *TLBGP(uint64 instruction)
 {
     (void)instruction;
 
-    return "TLBGP ";
+    return strdup("TLBGP ");
 }
 
 
@@ -15836,7 +16377,7 @@  static const char *TLBGR(uint64 instruction)
 {
     (void)instruction;
 
-    return "TLBGR ";
+    return strdup("TLBGR ");
 }
 
 
@@ -15854,7 +16395,7 @@  static const char *TLBGWI(uint64 instruction)
 {
     (void)instruction;
 
-    return "TLBGWI ";
+    return strdup("TLBGWI ");
 }
 
 
@@ -15872,7 +16413,7 @@  static const char *TLBGWR(uint64 instruction)
 {
     (void)instruction;
 
-    return "TLBGWR ";
+    return strdup("TLBGWR ");
 }
 
 
@@ -15890,7 +16431,7 @@  static const char *TLBINV(uint64 instruction)
 {
     (void)instruction;
 
-    return "TLBINV ";
+    return strdup("TLBINV ");
 }
 
 
@@ -15908,7 +16449,7 @@  static const char *TLBINVF(uint64 instruction)
 {
     (void)instruction;
 
-    return "TLBINVF ";
+    return strdup("TLBINVF ");
 }
 
 
@@ -15926,7 +16467,7 @@  static const char *TLBP(uint64 instruction)
 {
     (void)instruction;
 
-    return "TLBP ";
+    return strdup("TLBP ");
 }
 
 
@@ -15944,7 +16485,7 @@  static const char *TLBR(uint64 instruction)
 {
     (void)instruction;
 
-    return "TLBR ";
+    return strdup("TLBR ");
 }
 
 
@@ -15962,7 +16503,7 @@  static const char *TLBWI(uint64 instruction)
 {
     (void)instruction;
 
-    return "TLBWI ";
+    return strdup("TLBWI ");
 }
 
 
@@ -15980,7 +16521,7 @@  static const char *TLBWR(uint64 instruction)
 {
     (void)instruction;
 
-    return "TLBWR ";
+    return strdup("TLBWR ");
 }
 
 
@@ -16116,7 +16657,10 @@  static const char *UALDM(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *count3 = IMMEDIATE(encode_count3_from_count(count3_value));
 
-    return img_format("UALDM %s, %s(%s), %s", rt, s, rs, count3);
+    const char *ret = img_format("UALDM %s, %s(%s), %s", rt, s, rs, count3);
+    free((char *)s);
+    free((char *)count3);
+    return ret;
 }
 
 
@@ -16140,7 +16684,9 @@  static const char *UALH(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("UALH %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("UALH %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -16166,7 +16712,10 @@  static const char *UALWM(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *count3 = IMMEDIATE(encode_count3_from_count(count3_value));
 
-    return img_format("UALWM %s, %s(%s), %s", rt, s, rs, count3);
+    const char *ret = img_format("UALWM %s, %s(%s), %s", rt, s, rs, count3);
+    free((char *)s);
+    free((char *)count3);
+    return ret;
 }
 
 
@@ -16192,7 +16741,10 @@  static const char *UASDM(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *count3 = IMMEDIATE(encode_count3_from_count(count3_value));
 
-    return img_format("UASDM %s, %s(%s), %s", rt, s, rs, count3);
+    const char *ret = img_format("UASDM %s, %s(%s), %s", rt, s, rs, count3);
+    free((char *)s);
+    free((char *)count3);
+    return ret;
 }
 
 
@@ -16216,7 +16768,9 @@  static const char *UASH(uint64 instruction)
     const char *s = IMMEDIATE(copy(s_value));
     const char *rs = GPR(copy(rs_value));
 
-    return img_format("UASH %s, %s(%s)", rt, s, rs);
+    const char *ret = img_format("UASH %s, %s(%s)", rt, s, rs);
+    free((char *)s);
+    return ret;
 }
 
 
@@ -16242,7 +16796,10 @@  static const char *UASWM(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *count3 = IMMEDIATE(encode_count3_from_count(count3_value));
 
-    return img_format("UASWM %s, %s(%s), %s", rt, s, rs, count3);
+    const char *ret = img_format("UASWM %s, %s(%s), %s", rt, s, rs, count3);
+    free((char *)s);
+    free((char *)count3);
+    return ret;
 }
 
 
@@ -16262,7 +16819,9 @@  static const char *UDI(uint64 instruction)
 
     const char *op = IMMEDIATE(copy(op_value));
 
-    return img_format("UDI %s", op);
+    const char *ret = img_format("UDI %s", op);
+    free((char *)op);
+    return ret;
 }
 
 
@@ -16280,7 +16839,9 @@  static const char *WAIT(uint64 instruction)
 
     const char *code = IMMEDIATE(copy(code_value));
 
-    return img_format("WAIT %s", code);
+    const char *ret = img_format("WAIT %s", code);
+    free((char *)code);
+    return ret;
 }
 
 
@@ -16302,7 +16863,9 @@  static const char *WRDSP(uint64 instruction)
     const char *rt = GPR(copy(rt_value));
     const char *mask = IMMEDIATE(copy(mask_value));
 
-    return img_format("WRDSP %s, %s", rt, mask);
+    const char *ret = img_format("WRDSP %s, %s", rt, mask);
+    free((char *)mask);
+    return ret;
 }
 
 
@@ -16394,7 +16957,9 @@  static const char *XORI(uint64 instruction)
     const char *rs = GPR(copy(rs_value));
     const char *u = IMMEDIATE(copy(u_value));
 
-    return img_format("XORI %s, %s, %s", rt, rs, u);
+    const char *ret = img_format("XORI %s, %s, %s", rt, rs, u);
+    free((char *)u);
+    return ret;
 }