#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ base_modrm_mem;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, short);
int /*<<< orphan*/ stderr;
volatile char *build_mov_register_to_memory(short mov_size, short addr_size,
                                            int src, int mem_reg,
                                            short disp_size, long displacement,
                                            volatile char *tgt_addr) {
  char base_modrm_mem;
  if (disp_size == 0) {
    base_modrm_mem = 0x00;
  } else if (disp_size == 8) {
    base_modrm_mem = 0x40;
  } else if (disp_size == 32) {
    base_modrm_mem = 0x80;
  } else {
    fprintf(stderr,
            "ERROR: Incorrect  Displacement size (%d) passed for register to "
            "memory move\n",
            disp_size);
    return (NULL);
  }
  if (addr_size != 32 && addr_size != 64) {
    fprintf(stderr,
            "ERROR: Incorrect  address size (%d) passed for register to memory "
            "move\n",
            addr_size);
    return (NULL);
  }
  switch (mov_size) {
  case 1:
    if (addr_size == 32) {
      (*tgt_addr++) = 0x67;
    }
    (*(short *)tgt_addr) =
        ((base_modrm_mem) + (src << 0x3) + mem_reg) << 8 | 0x88;
    tgt_addr += 0x2;
    if (disp_size == 8) {
      (*(char *)tgt_addr) = displacement;
      tgt_addr += 0x1;
    }
    if (disp_size == 32) {
      (*(int *)tgt_addr) = displacement;
      tgt_addr += 0x4;
    }
    break;
  case 2:
    if (addr_size == 32) {
      (*tgt_addr++) = 0x67;
    }
    (*tgt_addr++) = 0x66;
    (*(short *)tgt_addr) =
        ((base_modrm_mem) + (src << 0x3) + mem_reg) << 8 | (0x89);
    tgt_addr += 0x2;
    if (disp_size == 8) {
      (*(char *)tgt_addr) = displacement;
      tgt_addr += 0x1;
    }
    if (disp_size == 32) {
      (*(int *)tgt_addr) = displacement;
      tgt_addr += 0x4;
    }
    break;
  case 4:
    if (addr_size == 32) {
      (*tgt_addr++) = 0x67;
    }
    (*(short *)tgt_addr) =
        ((base_modrm_mem) + (src << 0x3) + mem_reg) << 8 | 0x89;
    tgt_addr += 0x2;
    if (disp_size == 8) {
      (*(char *)tgt_addr) = displacement;
      tgt_addr += 0x1;
    }
    if (disp_size == 32) {
      (*(int *)tgt_addr) = displacement;
      tgt_addr += 0x4;
    }
    break;
  case 8:
    if (addr_size == 64) {
      (*tgt_addr++) = 0x40 | 0x8;
      (*(short *)tgt_addr) =
          ((base_modrm_mem) + (src << 0x3) + mem_reg) << 8 | (0x89);
      tgt_addr += 0x2;
    }
    if (disp_size == 8) {
      (*(char *)tgt_addr) = displacement;
      tgt_addr += 0x1;
    }
    if (disp_size == 32) {
      (*(int *)tgt_addr) = displacement;
      tgt_addr += 0x4;
    }
    break;
  default:
    fprintf(stderr,
            "ERROR: Incorrect size (%d) passed for register to memory move\n",
            mov_size);
    return (NULL);
  }
  return (tgt_addr);
}


x86 assembly (clang, -O0):
<build_mov_register_to_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8w,%ax
mov    0x10(%rbp),%r8
mov    %di,-0xa(%rbp)
mov    %si,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %ax,-0x16(%rbp)
mov    %r9,-0x20(%rbp)
movswl -0x16(%rbp),%eax
cmp    $0x0,%eax
jne    114c <build_mov_register_to_memory+0x3c>
movb   $0x0,-0x21(%rbp)
jmp    11a8 <build_mov_register_to_memory+0x98>
movswl -0x16(%rbp),%eax
cmp    $0x8,%eax
jne    1162 <build_mov_register_to_memory+0x52>
movb   $0x40,-0x21(%rbp)
jmp    11a3 <build_mov_register_to_memory+0x93>
movswl -0x16(%rbp),%eax
cmp    $0x20,%eax
jne    1178 <build_mov_register_to_memory+0x68>
movb   $0x80,-0x21(%rbp)
jmp    119e <build_mov_register_to_memory+0x8e>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
movswl -0x16(%rbp),%edx
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    14be <build_mov_register_to_memory+0x3ae>
jmp    11a3 <build_mov_register_to_memory+0x93>
jmp    11a8 <build_mov_register_to_memory+0x98>
movswl -0xc(%rbp),%eax
cmp    $0x20,%eax
je     11e8 <build_mov_register_to_memory+0xd8>
movswl -0xc(%rbp),%eax
cmp    $0x40,%eax
je     11e8 <build_mov_register_to_memory+0xd8>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
movswl -0xc(%rbp),%edx
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    14be <build_mov_register_to_memory+0x3ae>
movswl -0xa(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x7,%eax
ja     1490 <build_mov_register_to_memory+0x380>
mov    -0x30(%rbp),%rax
lea    0xdf7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movswl -0xc(%rbp),%eax
cmp    $0x20,%eax
jne    1231 <build_mov_register_to_memory+0x121>
mov    0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,0x10(%rbp)
movb   $0x67,(%rax)
movsbl -0x21(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x3,%ecx
add    %ecx,%eax
add    -0x14(%rbp),%eax
shl    $0x8,%eax
or     $0x88,%eax
mov    %ax,%cx
mov    0x10(%rbp),%rax
mov    %cx,(%rax)
mov    0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,0x10(%rbp)
movswl -0x16(%rbp),%eax
cmp    $0x8,%eax
jne    1283 <build_mov_register_to_memory+0x173>
mov    -0x20(%rbp),%rax
mov    %al,%cl
mov    0x10(%rbp),%rax
mov    %cl,(%rax)
mov    0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,0x10(%rbp)
movswl -0x16(%rbp),%eax
cmp    $0x20,%eax
jne    12a8 <build_mov_register_to_memory+0x198>
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,0x10(%rbp)
jmp    14b6 <build_mov_register_to_memory+0x3a6>
movswl -0xc(%rbp),%eax
cmp    $0x20,%eax
jne    12cc <build_mov_register_to_memory+0x1bc>
mov    0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,0x10(%rbp)
movb   $0x67,(%rax)
mov    0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,0x10(%rbp)
movb   $0x66,(%rax)
movsbl -0x21(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x3,%ecx
add    %ecx,%eax
add    -0x14(%rbp),%eax
shl    $0x8,%eax
or     $0x89,%eax
mov    %ax,%cx
mov    0x10(%rbp),%rax
mov    %cx,(%rax)
mov    0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,0x10(%rbp)
movswl -0x16(%rbp),%eax
cmp    $0x8,%eax
jne    1330 <build_mov_register_to_memory+0x220>
mov    -0x20(%rbp),%rax
mov    %al,%cl
mov    0x10(%rbp),%rax
mov    %cl,(%rax)
mov    0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,0x10(%rbp)
movswl -0x16(%rbp),%eax
cmp    $0x20,%eax
jne    1355 <build_mov_register_to_memory+0x245>
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,0x10(%rbp)
jmp    14b6 <build_mov_register_to_memory+0x3a6>
movswl -0xc(%rbp),%eax
cmp    $0x20,%eax
jne    1379 <build_mov_register_to_memory+0x269>
mov    0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,0x10(%rbp)
movb   $0x67,(%rax)
movsbl -0x21(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x3,%ecx
add    %ecx,%eax
add    -0x14(%rbp),%eax
shl    $0x8,%eax
or     $0x89,%eax
mov    %ax,%cx
mov    0x10(%rbp),%rax
mov    %cx,(%rax)
mov    0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,0x10(%rbp)
movswl -0x16(%rbp),%eax
cmp    $0x8,%eax
jne    13cb <build_mov_register_to_memory+0x2bb>
mov    -0x20(%rbp),%rax
mov    %al,%cl
mov    0x10(%rbp),%rax
mov    %cl,(%rax)
mov    0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,0x10(%rbp)
movswl -0x16(%rbp),%eax
cmp    $0x20,%eax
jne    13f0 <build_mov_register_to_memory+0x2e0>
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,0x10(%rbp)
jmp    14b6 <build_mov_register_to_memory+0x3a6>
movswl -0xc(%rbp),%eax
cmp    $0x40,%eax
jne    1441 <build_mov_register_to_memory+0x331>
mov    0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,0x10(%rbp)
movb   $0x48,(%rax)
movsbl -0x21(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x3,%ecx
add    %ecx,%eax
add    -0x14(%rbp),%eax
shl    $0x8,%eax
or     $0x89,%eax
mov    %ax,%cx
mov    0x10(%rbp),%rax
mov    %cx,(%rax)
mov    0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,0x10(%rbp)
movswl -0x16(%rbp),%eax
cmp    $0x8,%eax
jne    1466 <build_mov_register_to_memory+0x356>
mov    -0x20(%rbp),%rax
mov    %al,%cl
mov    0x10(%rbp),%rax
mov    %cl,(%rax)
mov    0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,0x10(%rbp)
movswl -0x16(%rbp),%eax
cmp    $0x20,%eax
jne    148b <build_mov_register_to_memory+0x37b>
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,0x10(%rbp)
jmp    14b6 <build_mov_register_to_memory+0x3a6>
mov    0x2b49(%rip),%rax
mov    (%rax),%edi
lea    0xc15(%rip),%rsi
movswl -0xa(%rbp),%edx
call   1030 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    14be <build_mov_register_to_memory+0x3ae>
mov    0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_mov_register_to_memory>:
push   %rbx
test   %r8w,%r8w
je     1145 <build_mov_register_to_memory+0x35>
cmp    $0x20,%r8w
je     1137 <build_mov_register_to_memory+0x27>
cmp    $0x8,%r8w
jne    11b9 <build_mov_register_to_memory+0xa9>
mov    $0x40,%r11d
cmp    $0x20,%si
jne    114e <build_mov_register_to_memory+0x3e>
jmp    1154 <build_mov_register_to_memory+0x44>
mov    $0xffffff80,%r11d
cmp    $0x20,%si
jne    114e <build_mov_register_to_memory+0x3e>
jmp    1154 <build_mov_register_to_memory+0x44>
xor    %r11d,%r11d
cmp    $0x20,%si
je     1154 <build_mov_register_to_memory+0x44>
cmp    $0x40,%si
jne    11d2 <build_mov_register_to_memory+0xc2>
movswl %di,%r10d
lea    -0x1(%r10),%edi
cmp    $0x7,%edi
ja     129f <build_mov_register_to_memory+0x18f>
mov    0x10(%rsp),%rax
lea    0xe8f(%rip),%rbx
movslq (%rbx,%rdi,4),%rdi
add    %rbx,%rdi
jmp    *%rdi
cmp    $0x20,%si
jne    1187 <build_mov_register_to_memory+0x77>
movb   $0x67,(%rax)
add    $0x1,%rax
add    %ecx,%r11d
lea    (%r11,%rdx,8),%ecx
shl    $0x8,%ecx
or     $0x88,%ecx
mov    %cx,(%rax)
cmp    $0x20,%r8w
je     12bb <build_mov_register_to_memory+0x1ab>
cmp    $0x8,%r8w
jne    125b <build_mov_register_to_memory+0x14b>
mov    %r9b,0x2(%rax)
jmp    1299 <build_mov_register_to_memory+0x189>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
movswl %r8w,%edx
lea    0xe53(%rip),%rsi
jmp    12b2 <build_mov_register_to_memory+0x1a2>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
movswl %si,%edx
lea    0xe88(%rip),%rsi
jmp    12b2 <build_mov_register_to_memory+0x1a2>
cmp    $0x20,%si
jne    11f7 <build_mov_register_to_memory+0xe7>
movb   $0x67,(%rax)
add    $0x1,%rax
movb   $0x66,(%rax)
add    %ecx,%r11d
lea    (%r11,%rdx,8),%ecx
shl    $0x8,%ecx
or     $0x89,%ecx
mov    %cx,0x1(%rax)
cmp    $0x20,%r8w
je     12c5 <build_mov_register_to_memory+0x1b5>
cmp    $0x8,%r8w
jne    1299 <build_mov_register_to_memory+0x189>
mov    %r9b,0x3(%rax)
jmp    12d2 <build_mov_register_to_memory+0x1c2>
cmp    $0x20,%si
jne    1236 <build_mov_register_to_memory+0x126>
movb   $0x67,(%rax)
add    $0x1,%rax
add    %ecx,%r11d
lea    (%r11,%rdx,8),%ecx
shl    $0x8,%ecx
or     $0x89,%ecx
mov    %cx,(%rax)
cmp    $0x20,%r8w
je     12bb <build_mov_register_to_memory+0x1ab>
cmp    $0x8,%r8w
je     11b0 <build_mov_register_to_memory+0xa0>
add    $0x2,%rax
pop    %rbx
ret
cmp    $0x40,%si
jne    1282 <build_mov_register_to_memory+0x172>
movb   $0x48,(%rax)
add    %ecx,%r11d
lea    (%r11,%rdx,8),%ecx
shl    $0x8,%ecx
or     $0x89,%ecx
mov    %cx,0x1(%rax)
add    $0x3,%rax
cmp    $0x20,%r8w
je     12cf <build_mov_register_to_memory+0x1bf>
cmp    $0x8,%r8w
jne    12b9 <build_mov_register_to_memory+0x1a9>
mov    %r9b,(%rax)
add    $0x1,%rax
pop    %rbx
ret
add    $0x3,%rax
pop    %rbx
ret
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
mov    %r10d,%edx
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    %r9d,0x2(%rax)
add    $0x6,%rax
pop    %rbx
ret
mov    %r9d,0x3(%rax)
add    $0x7,%rax
pop    %rbx
ret
mov    %r9d,(%rax)
add    $0x4,%rax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [77 x i8] c"ERROR: Incorrect Displacement size (%d) passed for register to memory move\0A\00"
@.str.1 = [72 x i8] c"ERROR: Incorrect address size (%d) passed for register to memory move\0A\00"
@.str.2 = [63 x i8] c"ERROR: Incorrect size (%d) passed for register to memory move\0A\00"
define i8* @build_mov_register_to_memory(i16 signext %0, i16 signext %1, i32 %2, i32 %3, i16 signext %4, i64 %5, i8* %6) {
%8 = alloca i8*
%9 = alloca i16
%10 = alloca i16
%11 = alloca i32
%12 = alloca i32
%13 = alloca i16
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i8
store i16 %0, i16* %9
store i16 %1, i16* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i16 %4, i16* %13
store i64 %5, i64* %14
store i8* %6, i8** %15
%17 = load i16, i16* %13
%18 = sext i16 %17 to i32
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %7
store i8 0, i8* %16
br label %37
21: ; preds = %7
%22 = load i16, i16* %13
%23 = sext i16 %22 to i32
%24 = icmp eq i32 %23, 8
br i1 %24, label %25, label %26
25: ; preds = %21
store i8 64, i8* %16
br label %36
26: ; preds = %21
%27 = load i16, i16* %13
%28 = sext i16 %27 to i32
%29 = icmp eq i32 %28, 32
br i1 %29, label %30, label %31
30: ; preds = %26
store i8 -128, i8* %16
br label %35
31: ; preds = %26
%32 = load i32, i32* @stderr
%33 = load i16, i16* %13
%34 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), i16 signext %33)
store i8* null, i8** %8
br label %232
35: ; preds = %30
br label %36
36: ; preds = %35, %25
br label %37
37: ; preds = %36, %20
%38 = load i16, i16* %10
%39 = sext i16 %38 to i32
%40 = icmp ne i32 %39, 32
br i1 %40, label %41, label %49
41: ; preds = %37
%42 = load i16, i16* %10
%43 = sext i16 %42 to i32
%44 = icmp ne i32 %43, 64
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = load i32, i32* @stderr
%47 = load i16, i16* %10
%48 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0), i16 signext %47)
store i8* null, i8** %8
br label %232
49: ; preds = %41, %37
%50 = load i16, i16* %9
%51 = sext i16 %50 to i32
switch i32 %51, label %226 [
i32 1, label %52
i32 2, label %95
i32 4, label %140
i32 8, label %183
]
52: ; preds = %49
%53 = load i16, i16* %10
%54 = sext i16 %53 to i32
%55 = icmp eq i32 %54, 32
br i1 %55, label %56, label %59
56: ; preds = %52
%57 = load i8*, i8** %15
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %15
store volatile i8 103, i8* %57
br label %59
59: ; preds = %56, %52
%60 = load i8, i8* %16
%61 = sext i8 %60 to i32
%62 = load i32, i32* %11
%63 = shl i32 %62, 3
%64 = add nsw i32 %61, %63
%65 = load i32, i32* %12
%66 = add nsw i32 %64, %65
%67 = shl i32 %66, 8
%68 = or i32 %67, 136
%69 = trunc i32 %68 to i16
%70 = load i8*, i8** %15
%71 = bitcast i8* %70 to i16*
store i16 %69, i16* %71
%72 = load i8*, i8** %15
%73 = getelementptr inbounds i8, i8* %72, i64 2
store i8* %73, i8** %15
%74 = load i16, i16* %13
%75 = sext i16 %74 to i32
%76 = icmp eq i32 %75, 8
br i1 %76, label %77, label %83
77: ; preds = %59
%78 = load i64, i64* %14
%79 = trunc i64 %78 to i8
%80 = load i8*, i8** %15
store i8 %79, i8* %80
%81 = load i8*, i8** %15
%82 = getelementptr inbounds i8, i8* %81, i64 1
store i8* %82, i8** %15
br label %83
83: ; preds = %77, %59
%84 = load i16, i16* %13
%85 = sext i16 %84 to i32
%86 = icmp eq i32 %85, 32
br i1 %86, label %87, label %94
87: ; preds = %83
%88 = load i64, i64* %14
%89 = trunc i64 %88 to i32
%90 = load i8*, i8** %15
%91 = bitcast i8* %90 to i32*
store i32 %89, i32* %91
%92 = load i8*, i8** %15
%93 = getelementptr inbounds i8, i8* %92, i64 4
store i8* %93, i8** %15
br label %94
94: ; preds = %87, %83
br label %230
95: ; preds = %49
%96 = load i16, i16* %10
%97 = sext i16 %96 to i32
%98 = icmp eq i32 %97, 32
br i1 %98, label %99, label %102
99: ; preds = %95
%100 = load i8*, i8** %15
%101 = getelementptr inbounds i8, i8* %100, i32 1
store i8* %101, i8** %15
store volatile i8 103, i8* %100
br label %102
102: ; preds = %99, %95
%103 = load i8*, i8** %15
%104 = getelementptr inbounds i8, i8* %103, i32 1
store i8* %104, i8** %15
store volatile i8 102, i8* %103
%105 = load i8, i8* %16
%106 = sext i8 %105 to i32
%107 = load i32, i32* %11
%108 = shl i32 %107, 3
%109 = add nsw i32 %106, %108
%110 = load i32, i32* %12
%111 = add nsw i32 %109, %110
%112 = shl i32 %111, 8
%113 = or i32 %112, 137
%114 = trunc i32 %113 to i16
%115 = load i8*, i8** %15
%116 = bitcast i8* %115 to i16*
store i16 %114, i16* %116
%117 = load i8*, i8** %15
%118 = getelementptr inbounds i8, i8* %117, i64 2
store i8* %118, i8** %15
%119 = load i16, i16* %13
%120 = sext i16 %119 to i32
%121 = icmp eq i32 %120, 8
br i1 %121, label %122, label %128
122: ; preds = %102
%123 = load i64, i64* %14
%124 = trunc i64 %123 to i8
%125 = load i8*, i8** %15
store i8 %124, i8* %125
%126 = load i8*, i8** %15
%127 = getelementptr inbounds i8, i8* %126, i64 1
store i8* %127, i8** %15
br label %128
128: ; preds = %122, %102
%129 = load i16, i16* %13
%130 = sext i16 %129 to i32
%131 = icmp eq i32 %130, 32
br i1 %131, label %132, label %139
132: ; preds = %128
%133 = load i64, i64* %14
%134 = trunc i64 %133 to i32
%135 = load i8*, i8** %15
%136 = bitcast i8* %135 to i32*
store i32 %134, i32* %136
%137 = load i8*, i8** %15
%138 = getelementptr inbounds i8, i8* %137, i64 4
store i8* %138, i8** %15
br label %139
139: ; preds = %132, %128
br label %230
140: ; preds = %49
%141 = load i16, i16* %10
%142 = sext i16 %141 to i32
%143 = icmp eq i32 %142, 32
br i1 %143, label %144, label %147
144: ; preds = %140
%145 = load i8*, i8** %15
%146 = getelementptr inbounds i8, i8* %145, i32 1
store i8* %146, i8** %15
store volatile i8 103, i8* %145
br label %147
147: ; preds = %144, %140
%148 = load i8, i8* %16
%149 = sext i8 %148 to i32
%150 = load i32, i32* %11
%151 = shl i32 %150, 3
%152 = add nsw i32 %149, %151
%153 = load i32, i32* %12
%154 = add nsw i32 %152, %153
%155 = shl i32 %154, 8
%156 = or i32 %155, 137
%157 = trunc i32 %156 to i16
%158 = load i8*, i8** %15
%159 = bitcast i8* %158 to i16*
store i16 %157, i16* %159
%160 = load i8*, i8** %15
%161 = getelementptr inbounds i8, i8* %160, i64 2
store i8* %161, i8** %15
%162 = load i16, i16* %13
%163 = sext i16 %162 to i32
%164 = icmp eq i32 %163, 8
br i1 %164, label %165, label %171
165: ; preds = %147
%166 = load i64, i64* %14
%167 = trunc i64 %166 to i8
%168 = load i8*, i8** %15
store i8 %167, i8* %168
%169 = load i8*, i8** %15
%170 = getelementptr inbounds i8, i8* %169, i64 1
store i8* %170, i8** %15
br label %171
171: ; preds = %165, %147
%172 = load i16, i16* %13
%173 = sext i16 %172 to i32
%174 = icmp eq i32 %173, 32
br i1 %174, label %175, label %182
175: ; preds = %171
%176 = load i64, i64* %14
%177 = trunc i64 %176 to i32
%178 = load i8*, i8** %15
%179 = bitcast i8* %178 to i32*
store i32 %177, i32* %179
%180 = load i8*, i8** %15
%181 = getelementptr inbounds i8, i8* %180, i64 4
store i8* %181, i8** %15
br label %182
182: ; preds = %175, %171
br label %230
183: ; preds = %49
%184 = load i16, i16* %10
%185 = sext i16 %184 to i32
%186 = icmp eq i32 %185, 64
br i1 %186, label %187, label %204
187: ; preds = %183
%188 = load i8*, i8** %15
%189 = getelementptr inbounds i8, i8* %188, i32 1
store i8* %189, i8** %15
store volatile i8 72, i8* %188
%190 = load i8, i8* %16
%191 = sext i8 %190 to i32
%192 = load i32, i32* %11
%193 = shl i32 %192, 3
%194 = add nsw i32 %191, %193
%195 = load i32, i32* %12
%196 = add nsw i32 %194, %195
%197 = shl i32 %196, 8
%198 = or i32 %197, 137
%199 = trunc i32 %198 to i16
%200 = load i8*, i8** %15
%201 = bitcast i8* %200 to i16*
store i16 %199, i16* %201
%202 = load i8*, i8** %15
%203 = getelementptr inbounds i8, i8* %202, i64 2
store i8* %203, i8** %15
br label %204
204: ; preds = %187, %183
%205 = load i16, i16* %13
%206 = sext i16 %205 to i32
%207 = icmp eq i32 %206, 8
br i1 %207, label %208, label %214
208: ; preds = %204
%209 = load i64, i64* %14
%210 = trunc i64 %209 to i8
%211 = load i8*, i8** %15
store i8 %210, i8* %211
%212 = load i8*, i8** %15
%213 = getelementptr inbounds i8, i8* %212, i64 1
store i8* %213, i8** %15
br label %214
214: ; preds = %208, %204
%215 = load i16, i16* %13
%216 = sext i16 %215 to i32
%217 = icmp eq i32 %216, 32
br i1 %217, label %218, label %225
218: ; preds = %214
%219 = load i64, i64* %14
%220 = trunc i64 %219 to i32
%221 = load i8*, i8** %15
%222 = bitcast i8* %221 to i32*
store i32 %220, i32* %222
%223 = load i8*, i8** %15
%224 = getelementptr inbounds i8, i8* %223, i64 4
store i8* %224, i8** %15
br label %225
225: ; preds = %218, %214
br label %230
226: ; preds = %49
%227 = load i32, i32* @stderr
%228 = load i16, i16* %9
%229 = call i32 @fprintf(i32 %227, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i16 signext %228)
store i8* null, i8** %8
br label %232
230: ; preds = %225, %182, %139, %94
%231 = load i8*, i8** %15
store i8* %231, i8** %8
br label %232
232: ; preds = %230, %226, %45, %31
%233 = load i8*, i8** %8
ret i8* %233
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [77 x i8] c"ERROR: Incorrect Displacement size (%d) passed for register to memory move\0A\00"
@.str.1 = [72 x i8] c"ERROR: Incorrect address size (%d) passed for register to memory move\0A\00"
@.str.2 = [63 x i8] c"ERROR: Incorrect size (%d) passed for register to memory move\0A\00"
define i8* @build_mov_register_to_memory(i16 signext %0, i16 signext %1, i32 %2, i32 %3, i16 signext %4, i64 %5, i8* %6) {
switch i16 %4, label %10 [
i16 0, label %13
i16 8, label %8
i16 32, label %9
]
8: ; preds = %7
br label %13
9: ; preds = %7
br label %13
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), i16 signext %4)
br label %108
13: ; preds = %7, %8, %9
%14 = phi i32 [ 64, %8 ], [ -128, %9 ], [ 0, %7 ]
switch i16 %1, label %15 [
i16 64, label %18
i16 32, label %18
]
15: ; preds = %13
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0), i16 signext %1)
br label %108
18: ; preds = %13, %13
%19 = sext i16 %0 to i32
switch i32 %19, label %105 [
i32 1, label %20
i32 2, label %41
i32 4, label %63
i32 8, label %84
]
20: ; preds = %18
%21 = icmp eq i16 %1, 32
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = getelementptr inbounds i8, i8* %6, i64 1
store volatile i8 103, i8* %6
br label %24
24: ; preds = %22, %20
%25 = phi i8* [ %23, %22 ], [ %6, %20 ]
%26 = shl i32 %2, 3
%27 = add i32 %14, %3
%28 = add i32 %27, %26
%29 = trunc i32 %28 to i16
%30 = shl i16 %29, 8
%31 = or i16 %30, 136
%32 = bitcast i8* %25 to i16*
store i16 %31, i16* %32
%33 = getelementptr inbounds i8, i8* %25, i64 2
switch i16 %4, label %108 [
i16 8, label %34
i16 32, label %37
]
34: ; preds = %24
%35 = trunc i64 %5 to i8
store i8 %35, i8* %33
%36 = getelementptr inbounds i8, i8* %25, i64 3
br label %108
37: ; preds = %24
%38 = trunc i64 %5 to i32
%39 = bitcast i8* %33 to i32*
store i32 %38, i32* %39
%40 = getelementptr inbounds i8, i8* %25, i64 6
br label %108
41: ; preds = %18
%42 = icmp eq i16 %1, 32
br i1 %42, label %43, label %45
43: ; preds = %41
%44 = getelementptr inbounds i8, i8* %6, i64 1
store volatile i8 103, i8* %6
br label %45
45: ; preds = %43, %41
%46 = phi i8* [ %44, %43 ], [ %6, %41 ]
%47 = getelementptr inbounds i8, i8* %46, i64 1
store volatile i8 102, i8* %46
%48 = shl i32 %2, 3
%49 = add i32 %14, %3
%50 = add i32 %49, %48
%51 = trunc i32 %50 to i16
%52 = shl i16 %51, 8
%53 = or i16 %52, 137
%54 = bitcast i8* %47 to i16*
store i16 %53, i16* %54
%55 = getelementptr inbounds i8, i8* %46, i64 3
switch i16 %4, label %108 [
i16 8, label %56
i16 32, label %59
]
56: ; preds = %45
%57 = trunc i64 %5 to i8
store i8 %57, i8* %55
%58 = getelementptr inbounds i8, i8* %46, i64 4
br label %108
59: ; preds = %45
%60 = trunc i64 %5 to i32
%61 = bitcast i8* %55 to i32*
store i32 %60, i32* %61
%62 = getelementptr inbounds i8, i8* %46, i64 7
br label %108
63: ; preds = %18
%64 = icmp eq i16 %1, 32
br i1 %64, label %65, label %67
65: ; preds = %63
%66 = getelementptr inbounds i8, i8* %6, i64 1
store volatile i8 103, i8* %6
br label %67
67: ; preds = %65, %63
%68 = phi i8* [ %66, %65 ], [ %6, %63 ]
%69 = shl i32 %2, 3
%70 = add i32 %14, %3
%71 = add i32 %70, %69
%72 = trunc i32 %71 to i16
%73 = shl i16 %72, 8
%74 = or i16 %73, 137
%75 = bitcast i8* %68 to i16*
store i16 %74, i16* %75
%76 = getelementptr inbounds i8, i8* %68, i64 2
switch i16 %4, label %108 [
i16 8, label %77
i16 32, label %80
]
77: ; preds = %67
%78 = trunc i64 %5 to i8
store i8 %78, i8* %76
%79 = getelementptr inbounds i8, i8* %68, i64 3
br label %108
80: ; preds = %67
%81 = trunc i64 %5 to i32
%82 = bitcast i8* %76 to i32*
store i32 %81, i32* %82
%83 = getelementptr inbounds i8, i8* %68, i64 6
br label %108
84: ; preds = %18
%85 = icmp eq i16 %1, 64
br i1 %85, label %86, label %96
86: ; preds = %84
%87 = getelementptr inbounds i8, i8* %6, i64 1
store volatile i8 72, i8* %6
%88 = shl i32 %2, 3
%89 = add i32 %14, %3
%90 = add i32 %89, %88
%91 = trunc i32 %90 to i16
%92 = shl i16 %91, 8
%93 = or i16 %92, 137
%94 = bitcast i8* %87 to i16*
store i16 %93, i16* %94
%95 = getelementptr inbounds i8, i8* %6, i64 3
br label %96
96: ; preds = %86, %84
%97 = phi i8* [ %95, %86 ], [ %6, %84 ]
switch i16 %4, label %108 [
i16 8, label %98
i16 32, label %101
]
98: ; preds = %96
%99 = trunc i64 %5 to i8
store i8 %99, i8* %97
%100 = getelementptr inbounds i8, i8* %97, i64 1
br label %108
101: ; preds = %96
%102 = trunc i64 %5 to i32
%103 = bitcast i8* %97 to i32*
store i32 %102, i32* %103
%104 = getelementptr inbounds i8, i8* %97, i64 4
br label %108
105: ; preds = %18
%106 = load i32, i32* @stderr
%107 = tail call i32 @fprintf(i32 %106, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i16 signext %0)
br label %108
108: ; preds = %96, %67, %45, %24, %98, %77, %56, %34, %37, %59, %80, %101, %105, %15, %10
%109 = phi i8* [ null, %15 ], [ null, %105 ], [ null, %10 ], [ %104, %101 ], [ %83, %80 ], [ %62, %59 ], [ %40, %37 ], [ %36, %34 ], [ %58, %56 ], [ %79, %77 ], [ %100, %98 ], [ %33, %24 ], [ %55, %45 ], [ %76, %67 ], [ %97, %96 ]
ret i8* %109
}