#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int snprintf(char *, int, char *, ...);
int genInstrStr(unsigned int iword, char retStr[]) {
  int catValue = (iword & 0xE0000000) >> 28;
  int opcode = 0;
  int bufoffset = 0;
  int rs, rd, rt, imm_val = 0;
  switch (catValue) {
  case 0x0:
    opcode = (iword & 0x1C000000) >> 26;
    switch (opcode) {
    case 0x0:
      imm_val = (iword & 0x03FFFFFF) << 2;
      snprintf(retStr, 32, "J #%d", imm_val);
      break;
    case 0x2:
      rs = (iword & 0x03E00000) >> 21;
      rt = (iword & 0x001F0000) >> 16;
      imm_val = (iword & 0x0000FFFF) << 2;
      snprintf(retStr, 32, "BEQ R%d, R%d, #%d", rs, rt, imm_val);
      break;
    case 0x4:
      rs = (iword & 0x03E00000) >> 21;
      imm_val = (iword & 0x0000FFFF) << 2;
      snprintf(retStr, 32, "BGTZ R%d, #%d", rs, imm_val);
      break;
    case 0x5:
      snprintf(retStr, 32, "BREAK");
      return 1;
      break;
    case 0x6:
      rs = (iword & 0x03E00000) >> 21;
      rt = (iword & 0x001F0000) >> 16;
      imm_val = (iword & 0x0000FFFF);
      snprintf(retStr, 32, "SW R%d, %d(R%d)", rt, imm_val, rs);
      break;
    case 0x7:
      rs = (iword & 0x03E00000) >> 21;
      rt = (iword & 0x001F0000) >> 16;
      imm_val = (iword & 0x0000FFFF);
      snprintf(retStr, 32, "LW R%d, %d(R%d)", rt, imm_val, rs);
      break;
    default:
      printf(
          "Unimplemented opcode in category 1 used. This opcode is reserved.");
      break;
    }
    break;
  case 0xc:
    opcode = (iword & 0x00070000) >> 16;
    switch (opcode) {
    case 0x0:
      bufoffset = snprintf(retStr, 32, "ADD ");
      break;
    case 0x1:
      bufoffset = snprintf(retStr, 32, "SUB ");
      break;
    case 0x2:
      bufoffset = snprintf(retStr, 32, "MUL ");
      break;
    case 0x3:
      bufoffset = snprintf(retStr, 32, "AND ");
      break;
    case 0x4:
      bufoffset = snprintf(retStr, 32, "OR ");
      break;
    case 0x5:
      bufoffset = snprintf(retStr, 32, "XOR ");
      break;
    case 0x6:
      bufoffset = snprintf(retStr, 32, "NOR ");
      break;
    default:
      printf(
          "Unimplemented opcode in category 2 used. This opcode is reserved.");
      break;
    }
    rs = (iword & 0x1F000000) >> 24;
    rt = (iword & 0x00F80000) >> 19;
    rd = (iword & 0x0000F800) >> 11;
    snprintf(retStr + bufoffset, 32 - bufoffset, "R%d, R%d, R%d", rd, rs, rt);
    break;
  case 0xe:
    opcode = (iword & 0x00070000) >> 16;
    switch (opcode) {
    case 0x0:
      bufoffset = snprintf(retStr, 32, "ADDI ");
      break;
    case 0x1:
      bufoffset = snprintf(retStr, 32, "ANDI ");
      break;
    case 0x2:
      bufoffset = snprintf(retStr, 32, "ORI ");
      break;
    case 0x3:
      bufoffset = snprintf(retStr, 32, "XORI ");
      break;
    default:
      printf(
          "Unimplemented opcode in category 3 used. This opcode is reserved.");
      break;
    }
    rs = (iword & 0x1F000000) >> 24;
    rt = (iword & 0x00F80000) >> 19;
    imm_val = (iword & 0x0000FFFF);
    snprintf(retStr + bufoffset, 32 - bufoffset, "R%d, R%d, #%d", rt, rs,
             imm_val);
    break;
  default:
    printf("Unimplemented opcode category used. This opcode is reserved.");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<genInstrStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x1c,%eax
and    $0xfffffffe,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
test   %eax,%eax
je     1185 <genInstrStr+0x65>
jmp    1163 <genInstrStr+0x43>
mov    -0x30(%rbp),%eax
sub    $0xc,%eax
je     1343 <genInstrStr+0x223>
jmp    1174 <genInstrStr+0x54>
mov    -0x30(%rbp),%eax
sub    $0xe,%eax
je     14b2 <genInstrStr+0x392>
jmp    15c1 <genInstrStr+0x4a1>
mov    -0x8(%rbp),%eax
shr    $0x1a,%eax
and    $0x7,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %rax,-0x38(%rbp)
sub    $0x7,%rax
ja     1332 <genInstrStr+0x212>
mov    -0x38(%rbp),%rax
lea    0xe7f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%eax
and    $0x3ffffff,%eax
shl    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
mov    $0x20,%esi
lea    0xe75(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    133e <genInstrStr+0x21e>
mov    -0x8(%rbp),%eax
and    $0x3e00000,%eax
shr    $0x15,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1f0000,%eax
shr    $0x10,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffff,%eax
shl    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    $0x20,%esi
lea    0xe2a(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    133e <genInstrStr+0x21e>
mov    -0x8(%rbp),%eax
and    $0x3e00000,%eax
shr    $0x15,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffff,%eax
shl    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    $0x20,%esi
lea    0xdfd(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    133e <genInstrStr+0x21e>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
lea    0xdef(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15d4 <genInstrStr+0x4b4>
mov    -0x8(%rbp),%eax
and    $0x3e00000,%eax
shr    $0x15,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1f0000,%eax
shr    $0x10,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    $0x20,%esi
lea    0xda0(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    133e <genInstrStr+0x21e>
mov    -0x8(%rbp),%eax
and    $0x3e00000,%eax
shr    $0x15,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1f0000,%eax
shr    $0x10,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    $0x20,%esi
lea    0xd62(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    133e <genInstrStr+0x21e>
lea    0xd5f(%rip),%rdi
call   1030 <printf@plt>
jmp    15cd <genInstrStr+0x4ad>
movzwl -0x6(%rbp),%eax
and    $0x7,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0x6,%rax
ja     144b <genInstrStr+0x32b>
mov    -0x40(%rbp),%rax
lea    0xca7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
lea    0xd58(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1457 <genInstrStr+0x337>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
lea    0xd3e(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1457 <genInstrStr+0x337>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
lea    0xd24(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1457 <genInstrStr+0x337>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
lea    0xd0a(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1457 <genInstrStr+0x337>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
lea    0xcf6(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1457 <genInstrStr+0x337>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
lea    0xcd1(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1457 <genInstrStr+0x337>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
lea    0xcb7(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1457 <genInstrStr+0x337>
lea    0xca6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
and    $0x1f000000,%eax
shr    $0x18,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf80000,%eax
shr    $0x13,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf800,%eax
shr    $0xb,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    $0x20,%esi
sub    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x28(%rbp),%r9d
lea    0xc94(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    15cd <genInstrStr+0x4ad>
movzwl -0x6(%rbp),%eax
and    $0x7,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %rax,-0x48(%rbp)
sub    $0x3,%rax
ja     155d <genInstrStr+0x43d>
mov    -0x48(%rbp),%rax
lea    0xb28(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
lea    0xc57(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1569 <genInstrStr+0x449>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
lea    0xc3e(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1569 <genInstrStr+0x449>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
lea    0xc26(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1569 <genInstrStr+0x449>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
lea    0xc06(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
jmp    1569 <genInstrStr+0x449>
lea    0xbf6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
and    $0x1f000000,%eax
shr    $0x18,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf80000,%eax
shr    $0x13,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    $0x20,%esi
sub    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
lea    0xaa1(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    15cd <genInstrStr+0x4ad>
lea    0xbd4(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genInstrStr>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    %edi,%eax
shr    $0x1c,%eax
and    $0xfffffffe,%eax
cmp    $0xe,%eax
je     118c <genInstrStr+0x6c>
cmp    $0xc,%eax
je     11b2 <genInstrStr+0x92>
test   %eax,%eax
jne    11df <genInstrStr+0xbf>
mov    %ebp,%eax
shr    $0x1a,%eax
and    $0x7,%eax
cmp    $0x7,%eax
ja     125e <genInstrStr+0x13e>
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
shl    $0x2,%ebp
and    $0xffffffc,%ebp
lea    0xed8(%rip),%rdx
xor    %ebx,%ebx
mov    %r14,%rdi
mov    $0x20,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <snprintf@plt>
jmp    13bb <genInstrStr+0x29b>
mov    %ebp,%eax
shr    $0x10,%eax
and    $0x7,%eax
cmp    $0x3,%eax
ja     11f2 <genInstrStr+0xd2>
lea    0xe60(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf98(%rip),%rdx
jmp    121b <genInstrStr+0xfb>
mov    %ebp,%eax
shr    $0x10,%eax
and    $0x7,%eax
cmp    $0x6,%eax
ja     132b <genInstrStr+0x20b>
lea    0xe46(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf00(%rip),%rdx
jmp    136f <genInstrStr+0x24f>
lea    0xfb6(%rip),%rdi
call   1030 <printf@plt>
xor    %ebx,%ebx
jmp    13bb <genInstrStr+0x29b>
lea    0xf61(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
jmp    122a <genInstrStr+0x10a>
lea    0xf45(%rip),%rdx
jmp    121b <genInstrStr+0xfb>
lea    0xf43(%rip),%rdx
jmp    121b <genInstrStr+0xfb>
lea    0xf39(%rip),%rdx
mov    %r14,%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %ebp,%r8d
shr    $0x18,%r8d
and    $0x1f,%r8d
mov    %ebp,%ecx
shr    $0x13,%ecx
and    $0x1f,%ecx
movzwl %bp,%r9d
cltq
add    %rax,%r14
mov    $0x20,%esi
sub    %eax,%esi
lea    0xe02(%rip),%rdx
xor    %ebx,%ebx
mov    %r14,%rdi
jmp    13b4 <genInstrStr+0x294>
lea    0xe33(%rip),%rdi
jmp    11e6 <genInstrStr+0xc6>
mov    %ebp,%ecx
shr    $0x15,%ecx
and    $0x1f,%ecx
mov    %ebp,%r8d
shr    $0x10,%r8d
and    $0x1f,%r8d
movzwl %bp,%r9d
shl    $0x2,%r9d
lea    0xdc6(%rip),%rdx
jmp    131c <genInstrStr+0x1fc>
mov    %ebp,%ecx
shr    $0x15,%ecx
and    $0x1f,%ecx
movzwl %bp,%r8d
shl    $0x2,%r8d
lea    0xdbc(%rip),%rdx
xor    %ebx,%ebx
mov    %r14,%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
jmp    13bb <genInstrStr+0x29b>
lea    0xdad(%rip),%rdx
mov    %r14,%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    $0x1,%ebx
jmp    13bb <genInstrStr+0x29b>
mov    %ebp,%r9d
shr    $0x15,%r9d
and    $0x1f,%r9d
mov    %ebp,%ecx
shr    $0x10,%ecx
and    $0x1f,%ecx
movzwl %bp,%r8d
lea    0xd7c(%rip),%rdx
jmp    131c <genInstrStr+0x1fc>
mov    %ebp,%r9d
shr    $0x15,%r9d
and    $0x1f,%r9d
mov    %ebp,%ecx
shr    $0x10,%ecx
and    $0x1f,%ecx
movzwl %bp,%r8d
lea    0xd6c(%rip),%rdx
xor    %ebx,%ebx
mov    %r14,%rdi
mov    $0x20,%esi
jmp    13b4 <genInstrStr+0x294>
lea    0xdc6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
jmp    137e <genInstrStr+0x25e>
lea    0xd9d(%rip),%rdx
jmp    136f <genInstrStr+0x24f>
lea    0xd99(%rip),%rdx
jmp    136f <genInstrStr+0x24f>
lea    0xd95(%rip),%rdx
jmp    136f <genInstrStr+0x24f>
lea    0xd97(%rip),%rdx
jmp    136f <genInstrStr+0x24f>
lea    0xd88(%rip),%rdx
jmp    136f <genInstrStr+0x24f>
lea    0xd84(%rip),%rdx
mov    %r14,%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %ebp,%r8d
shr    $0x18,%r8d
and    $0x1f,%r8d
mov    %ebp,%r9d
shr    $0x13,%r9d
and    $0x1f,%r9d
shr    $0xb,%ebp
and    $0x1f,%ebp
cltq
add    %rax,%r14
mov    $0x20,%esi
sub    %eax,%esi
lea    0xd8d(%rip),%rdx
xor    %ebx,%ebx
mov    %r14,%rdi
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"J #%d\00"
@.str.1 = [18 x i8] c"BEQ R%d, R%d, #%d\00"
@.str.2 = [14 x i8] c"BGTZ R%d, #%d\00"
@.str.3 = [6 x i8] c"BREAK\00"
@.str.4 = [16 x i8] c"SW R%d, %d(R%d)\00"
@.str.5 = [16 x i8] c"LW R%d, %d(R%d)\00"
@.str.6 = [66 x i8] c"Unimplemented opcode in category 1 used. This opcode is reserved.\00"
@.str.7 = [5 x i8] c"ADD \00"
@.str.8 = [5 x i8] c"SUB \00"
@.str.9 = [5 x i8] c"MUL \00"
@.str.10 = [5 x i8] c"AND \00"
@.str.11 = [4 x i8] c"OR \00"
@.str.12 = [5 x i8] c"XOR \00"
@.str.13 = [5 x i8] c"NOR \00"
@.str.14 = [66 x i8] c"Unimplemented opcode in category 2 used. This opcode is reserved.\00"
@.str.15 = [14 x i8] c"R%d, R%d, R%d\00"
@.str.16 = [6 x i8] c"ADDI \00"
@.str.17 = [6 x i8] c"ANDI \00"
@.str.18 = [5 x i8] c"ORI \00"
@.str.19 = [6 x i8] c"XORI \00"
@.str.20 = [66 x i8] c"Unimplemented opcode in category 3 used. This opcode is reserved.\00"
@.str.21 = [14 x i8] c"R%d, R%d, #%d\00"
@.str.22 = [61 x i8] c"Unimplemented opcode category used. This opcode is reserved.\00"
define i32 @genInstrStr(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%13 = load i32, i32* %4
%14 = and i32 %13, -536870912
%15 = lshr i32 %14, 28
store i32 %15, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %12
%16 = load i32, i32* %6
switch i32 %16, label %175 [
i32 0, label %17
i32 12, label %89
i32 14, label %137
]
17: ; preds = %2
%18 = load i32, i32* %4
%19 = and i32 %18, 469762048
%20 = lshr i32 %19, 26
store i32 %20, i32* %7
%21 = load i32, i32* %7
switch i32 %21, label %86 [
i32 0, label %22
i32 2, label %29
i32 4, label %44
i32 5, label %55
i32 6, label %58
i32 7, label %72
]
22: ; preds = %17
%23 = load i32, i32* %4
%24 = and i32 %23, 67108863
%25 = shl i32 %24, 2
store i32 %25, i32* %12
%26 = load i8*, i8** %5
%27 = load i32, i32* %12
%28 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %26, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %88
29: ; preds = %17
%30 = load i32, i32* %4
%31 = and i32 %30, 65011712
%32 = lshr i32 %31, 21
store i32 %32, i32* %9
%33 = load i32, i32* %4
%34 = and i32 %33, 2031616
%35 = lshr i32 %34, 16
store i32 %35, i32* %11
%36 = load i32, i32* %4
%37 = and i32 %36, 65535
%38 = shl i32 %37, 2
store i32 %38, i32* %12
%39 = load i8*, i8** %5
%40 = load i32, i32* %9
%41 = load i32, i32* %11
%42 = load i32, i32* %12
%43 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %39, i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %41, i32 %42)
br label %88
44: ; preds = %17
%45 = load i32, i32* %4
%46 = and i32 %45, 65011712
%47 = lshr i32 %46, 21
store i32 %47, i32* %9
%48 = load i32, i32* %4
%49 = and i32 %48, 65535
%50 = shl i32 %49, 2
store i32 %50, i32* %12
%51 = load i8*, i8** %5
%52 = load i32, i32* %9
%53 = load i32, i32* %12
%54 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %51, i32 32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %52, i32 %53)
br label %88
55: ; preds = %17
%56 = load i8*, i8** %5
%57 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %56, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %178
58: ; preds = %17
%59 = load i32, i32* %4
%60 = and i32 %59, 65011712
%61 = lshr i32 %60, 21
store i32 %61, i32* %9
%62 = load i32, i32* %4
%63 = and i32 %62, 2031616
%64 = lshr i32 %63, 16
store i32 %64, i32* %11
%65 = load i32, i32* %4
%66 = and i32 %65, 65535
store i32 %66, i32* %12
%67 = load i8*, i8** %5
%68 = load i32, i32* %11
%69 = load i32, i32* %12
%70 = load i32, i32* %9
%71 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %67, i32 32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %68, i32 %69, i32 %70)
br label %88
72: ; preds = %17
%73 = load i32, i32* %4
%74 = and i32 %73, 65011712
%75 = lshr i32 %74, 21
store i32 %75, i32* %9
%76 = load i32, i32* %4
%77 = and i32 %76, 2031616
%78 = lshr i32 %77, 16
store i32 %78, i32* %11
%79 = load i32, i32* %4
%80 = and i32 %79, 65535
store i32 %80, i32* %12
%81 = load i8*, i8** %5
%82 = load i32, i32* %11
%83 = load i32, i32* %12
%84 = load i32, i32* %9
%85 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %81, i32 32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %82, i32 %83, i32 %84)
br label %88
86: ; preds = %17
%87 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.6, i64 0, i64 0))
br label %88
88: ; preds = %86, %72, %58, %44, %29, %22
br label %177
89: ; preds = %2
%90 = load i32, i32* %4
%91 = and i32 %90, 458752
%92 = lshr i32 %91, 16
store i32 %92, i32* %7
%93 = load i32, i32* %7
switch i32 %93, label %115 [
i32 0, label %94
i32 1, label %97
i32 2, label %100
i32 3, label %103
i32 4, label %106
i32 5, label %109
i32 6, label %112
]
94: ; preds = %89
%95 = load i8*, i8** %5
%96 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %95, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
store i32 %96, i32* %8
br label %117
97: ; preds = %89
%98 = load i8*, i8** %5
%99 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %98, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
store i32 %99, i32* %8
br label %117
100: ; preds = %89
%101 = load i8*, i8** %5
%102 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %101, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
store i32 %102, i32* %8
br label %117
103: ; preds = %89
%104 = load i8*, i8** %5
%105 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %104, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
store i32 %105, i32* %8
br label %117
106: ; preds = %89
%107 = load i8*, i8** %5
%108 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %107, i32 32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
store i32 %108, i32* %8
br label %117
109: ; preds = %89
%110 = load i8*, i8** %5
%111 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %110, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
store i32 %111, i32* %8
br label %117
112: ; preds = %89
%113 = load i8*, i8** %5
%114 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %113, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
store i32 %114, i32* %8
br label %117
115: ; preds = %89
%116 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.14, i64 0, i64 0))
br label %117
117: ; preds = %115, %112, %109, %106, %103, %100, %97, %94
%118 = load i32, i32* %4
%119 = and i32 %118, 520093696
%120 = lshr i32 %119, 24
store i32 %120, i32* %9
%121 = load i32, i32* %4
%122 = and i32 %121, 16252928
%123 = lshr i32 %122, 19
store i32 %123, i32* %11
%124 = load i32, i32* %4
%125 = and i32 %124, 63488
%126 = lshr i32 %125, 11
store i32 %126, i32* %10
%127 = load i8*, i8** %5
%128 = load i32, i32* %8
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i8, i8* %127, i64 %129
%131 = load i32, i32* %8
%132 = sub nsw i32 32, %131
%133 = load i32, i32* %10
%134 = load i32, i32* %9
%135 = load i32, i32* %11
%136 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %130, i32 %132, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0), i32 %133, i32 %134, i32 %135)
br label %177
137: ; preds = %2
%138 = load i32, i32* %4
%139 = and i32 %138, 458752
%140 = lshr i32 %139, 16
store i32 %140, i32* %7
%141 = load i32, i32* %7
switch i32 %141, label %154 [
i32 0, label %142
i32 1, label %145
i32 2, label %148
i32 3, label %151
]
142: ; preds = %137
%143 = load i8*, i8** %5
%144 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %143, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0))
store i32 %144, i32* %8
br label %156
145: ; preds = %137
%146 = load i8*, i8** %5
%147 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %146, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
store i32 %147, i32* %8
br label %156
148: ; preds = %137
%149 = load i8*, i8** %5
%150 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %149, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0))
store i32 %150, i32* %8
br label %156
151: ; preds = %137
%152 = load i8*, i8** %5
%153 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %152, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
store i32 %153, i32* %8
br label %156
154: ; preds = %137
%155 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.20, i64 0, i64 0))
br label %156
156: ; preds = %154, %151, %148, %145, %142
%157 = load i32, i32* %4
%158 = and i32 %157, 520093696
%159 = lshr i32 %158, 24
store i32 %159, i32* %9
%160 = load i32, i32* %4
%161 = and i32 %160, 16252928
%162 = lshr i32 %161, 19
store i32 %162, i32* %11
%163 = load i32, i32* %4
%164 = and i32 %163, 65535
store i32 %164, i32* %12
%165 = load i8*, i8** %5
%166 = load i32, i32* %8
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds i8, i8* %165, i64 %167
%169 = load i32, i32* %8
%170 = sub nsw i32 32, %169
%171 = load i32, i32* %11
%172 = load i32, i32* %9
%173 = load i32, i32* %12
%174 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %168, i32 %170, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), i32 %171, i32 %172, i32 %173)
br label %177
175: ; preds = %2
%176 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.22, i64 0, i64 0))
br label %177
177: ; preds = %175, %156, %117, %88
store i32 0, i32* %3
br label %178
178: ; preds = %177, %55
%179 = load i32, i32* %3
ret i32 %179
}

LLVM IR (-O2):
@.str = [6 x i8] c"J #%d\00"
@.str.1 = [18 x i8] c"BEQ R%d, R%d, #%d\00"
@.str.2 = [14 x i8] c"BGTZ R%d, #%d\00"
@.str.3 = [6 x i8] c"BREAK\00"
@.str.4 = [16 x i8] c"SW R%d, %d(R%d)\00"
@.str.5 = [16 x i8] c"LW R%d, %d(R%d)\00"
@.str.6 = [66 x i8] c"Unimplemented opcode in category 1 used. This opcode is reserved.\00"
@.str.7 = [5 x i8] c"ADD \00"
@.str.8 = [5 x i8] c"SUB \00"
@.str.9 = [5 x i8] c"MUL \00"
@.str.10 = [5 x i8] c"AND \00"
@.str.11 = [4 x i8] c"OR \00"
@.str.12 = [5 x i8] c"XOR \00"
@.str.13 = [5 x i8] c"NOR \00"
@.str.14 = [66 x i8] c"Unimplemented opcode in category 2 used. This opcode is reserved.\00"
@.str.15 = [14 x i8] c"R%d, R%d, R%d\00"
@.str.16 = [6 x i8] c"ADDI \00"
@.str.17 = [6 x i8] c"ANDI \00"
@.str.18 = [5 x i8] c"ORI \00"
@.str.19 = [6 x i8] c"XORI \00"
@.str.20 = [66 x i8] c"Unimplemented opcode in category 3 used. This opcode is reserved.\00"
@.str.21 = [14 x i8] c"R%d, R%d, #%d\00"
@.str.22 = [61 x i8] c"Unimplemented opcode category used. This opcode is reserved.\00"
define i32 @genInstrStr(i32 %0, i8* %1) {
%3 = lshr i32 %0, 28
%4 = and i32 %3, 14
switch i32 %4, label %99 [
i32 0, label %5
i32 12, label %44
i32 14, label %75
]
5: ; preds = %2
%6 = lshr i32 %0, 26
%7 = and i32 %6, 7
switch i32 %7, label %42 [
i32 0, label %8
i32 2, label %12
i32 4, label %20
i32 5, label %26
i32 6, label %28
i32 7, label %35
]
8: ; preds = %5
%9 = shl i32 %0, 2
%10 = and i32 %9, 268435452
%11 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %101
12: ; preds = %5
%13 = lshr i32 %0, 21
%14 = and i32 %13, 31
%15 = lshr i32 %0, 16
%16 = and i32 %15, 31
%17 = shl i32 %0, 2
%18 = and i32 %17, 262140
%19 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %16, i32 %18)
br label %101
20: ; preds = %5
%21 = lshr i32 %0, 21
%22 = and i32 %21, 31
%23 = shl i32 %0, 2
%24 = and i32 %23, 262140
%25 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %24)
br label %101
26: ; preds = %5
%27 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %101
28: ; preds = %5
%29 = lshr i32 %0, 21
%30 = and i32 %29, 31
%31 = lshr i32 %0, 16
%32 = and i32 %31, 31
%33 = and i32 %0, 65535
%34 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %32, i32 %33, i32 %30)
br label %101
35: ; preds = %5
%36 = lshr i32 %0, 21
%37 = and i32 %36, 31
%38 = lshr i32 %0, 16
%39 = and i32 %38, 31
%40 = and i32 %0, 65535
%41 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %39, i32 %40, i32 %37)
br label %101
42: ; preds = %5
%43 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.6, i64 0, i64 0))
br label %101
44: ; preds = %2
%45 = lshr i32 %0, 16
%46 = and i32 %45, 7
switch i32 %46, label %61 [
i32 0, label %47
i32 1, label %49
i32 2, label %51
i32 3, label %53
i32 4, label %55
i32 5, label %57
i32 6, label %59
]
47: ; preds = %44
%48 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %63
49: ; preds = %44
%50 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %63
51: ; preds = %44
%52 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %63
53: ; preds = %44
%54 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %63
55: ; preds = %44
%56 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
br label %63
57: ; preds = %44
%58 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
br label %63
59: ; preds = %44
%60 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
br label %63
61: ; preds = %44
%62 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.14, i64 0, i64 0))
br label %63
63: ; preds = %61, %59, %57, %55, %53, %51, %49, %47
%64 = phi i32 [ 0, %61 ], [ %60, %59 ], [ %58, %57 ], [ %56, %55 ], [ %54, %53 ], [ %52, %51 ], [ %50, %49 ], [ %48, %47 ]
%65 = lshr i32 %0, 24
%66 = and i32 %65, 31
%67 = lshr i32 %0, 19
%68 = and i32 %67, 31
%69 = lshr i32 %0, 11
%70 = and i32 %69, 31
%71 = sext i32 %64 to i64
%72 = getelementptr inbounds i8, i8* %1, i64 %71
%73 = sub nsw i32 32, %64
%74 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %72, i32 %73, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0), i32 %70, i32 %66, i32 %68)
br label %101
75: ; preds = %2
%76 = lshr i32 %0, 16
%77 = and i32 %76, 7
switch i32 %77, label %86 [
i32 0, label %78
i32 1, label %80
i32 2, label %82
i32 3, label %84
]
78: ; preds = %75
%79 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i64 0, i64 0))
br label %88
80: ; preds = %75
%81 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
br label %88
82: ; preds = %75
%83 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0))
br label %88
84: ; preds = %75
%85 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %1, i32 32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
br label %88
86: ; preds = %75
%87 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.20, i64 0, i64 0))
br label %88
88: ; preds = %86, %84, %82, %80, %78
%89 = phi i32 [ 0, %86 ], [ %85, %84 ], [ %83, %82 ], [ %81, %80 ], [ %79, %78 ]
%90 = lshr i32 %0, 24
%91 = and i32 %90, 31
%92 = lshr i32 %0, 19
%93 = and i32 %92, 31
%94 = and i32 %0, 65535
%95 = sext i32 %89 to i64
%96 = getelementptr inbounds i8, i8* %1, i64 %95
%97 = sub nsw i32 32, %89
%98 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %96, i32 %97, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), i32 %93, i32 %91, i32 %94)
br label %101
99: ; preds = %2
%100 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.22, i64 0, i64 0))
br label %101
101: ; preds = %63, %88, %99, %42, %35, %28, %20, %12, %8, %26
%102 = phi i32 [ 1, %26 ], [ 0, %8 ], [ 0, %12 ], [ 0, %20 ], [ 0, %28 ], [ 0, %35 ], [ 0, %42 ], [ 0, %99 ], [ 0, %88 ], [ 0, %63 ]
ret i32 %102
}