#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 */
unsigned int ALU(unsigned int, unsigned int, unsigned int, unsigned int, int *,
                 int *, int *);
unsigned int decode(unsigned int, unsigned int, unsigned int);
unsigned int fetch_instruction(unsigned int);
unsigned int get_bit(unsigned int, int);
int /*<<< orphan*/ increment_PC(unsigned int *);
int /*<<< orphan*/ jump_PC(unsigned int *, unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int, ...);
unsigned int read_ram(unsigned int);
unsigned int start_PC();
int /*<<< orphan*/ write_ram(unsigned int, unsigned int);
void CPU() {
  unsigned int instruction;
  unsigned int PC;
  unsigned int MAR;
  unsigned int DRR;
  unsigned int A;
  unsigned int inst_bits, inst_mode, Binvert, Ainvert, alu_off_flag, opcode;
  unsigned int address, short_address_one, short_address_two, dest_address;
  int carryOut;
  int overflow;
  int zr;
  unsigned int inst_shift = 26, opcode_shift = 0, Binvert_shift = 2,
               Ainvert_shift = 3;
  unsigned int mask_instruction = 0xfc000000;
  unsigned int mask_opcode = 0x00000003;
  unsigned int mask_Binvert = 0x00000004;
  unsigned int mask_Ainvert = 0x00000008;
  int long_addr_shift = 0, sh_addr1_shift = 21, sh_addr2_shift = 16,
      dest_addr_shift = 0;
  unsigned int mask_long_address = 0x03ffffff;
  unsigned int mask_short_address_one = 0x03e00000;
  unsigned int mask_short_address_two = 0x001f0000;
  unsigned int mask_destination_address = 0x0000ffff;
  PC = start_PC();
  int clock_counter = 1;
  while (1) {
    printf("Instruction Cycle: %d\tPC: %d\n", clock_counter, PC);
    MAR = PC;
    increment_PC(&PC);
    instruction = fetch_instruction(MAR);
    inst_bits = decode(instruction, mask_instruction, inst_shift);
    inst_mode = get_bit(inst_bits, 5);
    if (inst_mode == 1) {
      short_address_one =
          decode(instruction, mask_short_address_one, sh_addr1_shift);
      short_address_two =
          decode(instruction, mask_short_address_two, sh_addr2_shift);
      dest_address =
          decode(instruction, mask_destination_address, dest_addr_shift);
      if (inst_bits == 0x21) {
        if (read_ram(short_address_one) > read_ram(short_address_two)) {
          jump_PC(&PC, dest_address);
        }
      }
    } else {
      alu_off_flag = get_bit(inst_bits, 4);
      address = decode(instruction, mask_long_address, long_addr_shift);
      DRR = read_ram(address);
      if (alu_off_flag == 0) {
        opcode = decode(inst_bits, mask_opcode, opcode_shift);
        Binvert = decode(inst_bits, mask_Binvert, Binvert_shift);
        Ainvert = decode(inst_bits, mask_Ainvert, Ainvert_shift);
        A = ALU(A, DRR, opcode, Binvert, &carryOut, &zr, &overflow);
      } else {
        if (inst_bits == 0x11) {
          A = DRR;
        } else if (inst_bits == 0x12) {
          A = address;
        } else if (inst_bits == 0x13) {
          write_ram(A, address);
        } else if (inst_bits == 0x14) {
          A += 1;
        } else if (inst_bits == 0x1c) {
          printf("A_reg: %d\n", A);
        } else if (inst_bits == 0x1d) {
          jump_PC(&PC, address);
        } else if (inst_bits == 0x1f) {
          printf("Program halted execution at PC: %d\n", PC);
          return;
        }
      }
    }
    clock_counter++;
  }
}


x86 assembly (clang, -O0):
<CPU>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x1a,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x2,-0x54(%rbp)
movl   $0x3,-0x58(%rbp)
movl   $0xfc000000,-0x5c(%rbp)
movl   $0x3,-0x60(%rbp)
movl   $0x4,-0x64(%rbp)
movl   $0x8,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
movl   $0x15,-0x70(%rbp)
movl   $0x10,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x3ffffff,-0x7c(%rbp)
movl   $0x3e00000,-0x80(%rbp)
movl   $0x1f0000,-0x84(%rbp)
movl   $0xffff,-0x88(%rbp)
mov    $0x0,%al
call   1040 <start_PC@plt>
mov    %eax,-0x8(%rbp)
movl   $0x1,-0x8c(%rbp)
mov    -0x8c(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <increment_PC@plt>
mov    -0xc(%rbp),%edi
call   1050 <fetch_instruction@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x5c(%rbp),%esi
mov    -0x4c(%rbp),%edx
call   1080 <decode@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x5,%esi
call   10a0 <get_bit@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    1310 <CPU+0x170>
mov    -0x4(%rbp),%edi
mov    -0x80(%rbp),%esi
mov    -0x70(%rbp),%edx
call   1080 <decode@plt>
mov    %eax,-0x34(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x84(%rbp),%esi
mov    -0x74(%rbp),%edx
call   1080 <decode@plt>
mov    %eax,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x88(%rbp),%esi
mov    -0x78(%rbp),%edx
call   1080 <decode@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x21,-0x18(%rbp)
jne    130b <CPU+0x16b>
mov    -0x34(%rbp),%edi
call   1090 <read_ram@plt>
mov    %eax,-0x90(%rbp)
mov    -0x38(%rbp),%edi
call   1090 <read_ram@plt>
mov    %eax,%ecx
mov    -0x90(%rbp),%eax
cmp    %ecx,%eax
jbe    1306 <CPU+0x166>
mov    -0x3c(%rbp),%esi
lea    -0x8(%rbp),%rdi
call   10c0 <jump_PC@plt>
jmp    130b <CPU+0x16b>
jmp    1485 <CPU+0x2e5>
mov    -0x18(%rbp),%edi
mov    $0x4,%esi
call   10a0 <get_bit@plt>
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x7c(%rbp),%esi
mov    -0x6c(%rbp),%edx
call   1080 <decode@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
call   1090 <read_ram@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    13a2 <CPU+0x202>
mov    -0x18(%rbp),%edi
mov    -0x60(%rbp),%esi
mov    -0x50(%rbp),%edx
call   1080 <decode@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x64(%rbp),%esi
mov    -0x54(%rbp),%edx
call   1080 <decode@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x68(%rbp),%esi
mov    -0x58(%rbp),%edx
call   1080 <decode@plt>
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    -0x40(%rbp),%r8
lea    -0x48(%rbp),%r9
lea    -0x44(%rbp),%rax
mov    %rax,(%rsp)
call   1070 <ALU@plt>
mov    %eax,-0x14(%rbp)
jmp    1480 <CPU+0x2e0>
cmpl   $0x11,-0x18(%rbp)
jne    13b7 <CPU+0x217>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    147b <CPU+0x2db>
cmpl   $0x12,-0x18(%rbp)
jne    13cc <CPU+0x22c>
mov    -0x30(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1476 <CPU+0x2d6>
cmpl   $0x13,-0x18(%rbp)
jne    13e6 <CPU+0x246>
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%esi
call   10b0 <write_ram@plt>
jmp    1471 <CPU+0x2d1>
cmpl   $0x14,-0x18(%rbp)
jne    13fe <CPU+0x25e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    146c <CPU+0x2cc>
cmpl   $0x1c,-0x18(%rbp)
jne    141e <CPU+0x27e>
mov    -0x14(%rbp),%esi
lea    0xc0c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1467 <CPU+0x2c7>
cmpl   $0x1d,-0x18(%rbp)
jne    1439 <CPU+0x299>
mov    -0x30(%rbp),%esi
lea    -0x8(%rbp),%rdi
call   10c0 <jump_PC@plt>
jmp    1462 <CPU+0x2c2>
cmpl   $0x1f,-0x18(%rbp)
jne    145d <CPU+0x2bd>
mov    -0x8(%rbp),%esi
lea    0xbdc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
add    $0xa0,%rsp
pop    %rbp
ret
jmp    1462 <CPU+0x2c2>
jmp    1467 <CPU+0x2c7>
jmp    146c <CPU+0x2cc>
jmp    1471 <CPU+0x2d1>
jmp    1476 <CPU+0x2d6>
jmp    147b <CPU+0x2db>
jmp    1480 <CPU+0x2e0>
jmp    1485 <CPU+0x2e5>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    1235 <CPU+0x95>

x86 assembly (clang, -O2):
<CPU>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
call   1040 <start_PC@plt>
mov    %eax,%edx
mov    %eax,0x14(%rsp)
mov    $0x1,%r15d
lea    0xe74(%rip),%r13
jmp    11e5 <CPU+0x45>
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp),%ebp
mov    0x18(%rsp),%r15d
add    $0x1,%r15d
mov    0x14(%rsp),%edx
mov    %ebp,0x10(%rsp)
mov    %r13,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rsp),%ebx
lea    0x14(%rsp),%rdi
call   1030 <increment_PC@plt>
mov    %ebx,%edi
call   1050 <fetch_instruction@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    $0xfc000000,%esi
mov    $0x1a,%edx
call   1080 <decode@plt>
mov    %eax,%r12d
mov    %eax,%edi
mov    $0x5,%esi
call   10a0 <get_bit@plt>
cmp    $0x1,%eax
jne    12b0 <CPU+0x110>
mov    %r15d,0x18(%rsp)
mov    %ebp,%edi
mov    $0x3e00000,%esi
mov    $0x15,%edx
call   1080 <decode@plt>
mov    %eax,%r14d
mov    %ebp,%edi
mov    $0x1f0000,%esi
mov    $0x10,%edx
call   1080 <decode@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0xffff,%esi
xor    %edx,%edx
call   1080 <decode@plt>
cmp    $0x21,%r12d
jne    11d0 <CPU+0x30>
mov    %eax,%r15d
mov    %r14d,%edi
call   1090 <read_ram@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1090 <read_ram@plt>
cmp    %eax,%ebp
mov    0x10(%rsp),%ebp
jbe    11d4 <CPU+0x34>
lea    0x14(%rsp),%rdi
mov    %r15d,%esi
call   10c0 <jump_PC@plt>
jmp    11d4 <CPU+0x34>
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    $0x4,%esi
call   10a0 <get_bit@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0x3ffffff,%esi
xor    %edx,%edx
call   1080 <decode@plt>
mov    %eax,%r14d
mov    %eax,%edi
call   1090 <read_ram@plt>
mov    %eax,%ebp
test   %ebx,%ebx
je     1303 <CPU+0x163>
add    $0xffffffef,%r12d
cmp    $0xe,%r12d
ja     13aa <CPU+0x20a>
lea    0xd0e(%rip),%rcx
movslq (%rcx,%r12,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r14d,%ebp
jmp    11d9 <CPU+0x39>
mov    %r12d,%edi
mov    $0x3,%esi
xor    %edx,%edx
call   1080 <decode@plt>
mov    %eax,%r14d
mov    %r12d,%edi
mov    $0x4,%esi
mov    $0x2,%edx
call   1080 <decode@plt>
mov    %eax,%ebx
mov    %r12d,%edi
mov    $0x8,%esi
mov    $0x3,%edx
call   1080 <decode@plt>
lea    0x20(%rsp),%rax
mov    %rax,(%rsp)
mov    0x10(%rsp),%edi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
lea    0x24(%rsp),%r8
lea    0x1c(%rsp),%r9
call   1070 <ALU@plt>
mov    %eax,%ebp
jmp    11d9 <CPU+0x39>
mov    0x10(%rsp),%ebp
mov    %ebp,%edi
mov    %r14d,%esi
call   10b0 <write_ram@plt>
jmp    11d9 <CPU+0x39>
mov    0x10(%rsp),%ebp
add    $0x1,%ebp
jmp    11d9 <CPU+0x39>
lea    0xccf(%rip),%rdi
mov    0x10(%rsp),%ebp
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11d9 <CPU+0x39>
lea    0x14(%rsp),%rdi
mov    %r14d,%esi
call   10c0 <jump_PC@plt>
mov    0x10(%rsp),%ebp
jmp    11d9 <CPU+0x39>
mov    0x14(%rsp),%esi
lea    0xca7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Instruction Cycle: %d\09PC: %d\0A\00"
@.str.1 = [11 x i8] c"A_reg: %d\0A\00"
@.str.2 = [36 x i8] c"Program halted execution at PC: %d\0A\00"
define void @CPU() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
store i32 26, i32* %19
store i32 0, i32* %20
store i32 2, i32* %21
store i32 3, i32* %22
store i32 -67108864, i32* %23
store i32 3, i32* %24
store i32 4, i32* %25
store i32 8, i32* %26
store i32 0, i32* %27
store i32 21, i32* %28
store i32 16, i32* %29
store i32 0, i32* %30
store i32 67108863, i32* %31
store i32 65011712, i32* %32
store i32 2031616, i32* %33
store i32 65535, i32* %34
%36 = call i32 (...) @start_PC()
store i32 %36, i32* %2
store i32 1, i32* %35
br label %37
37: ; preds = %0, %157
%38 = load i32, i32* %35
%39 = load i32, i32* %2
%40 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %38, i32 %39)
%41 = load i32, i32* %2
store i32 %41, i32* %3
%42 = call i32 @increment_PC(i32* %2)
%43 = load i32, i32* %3
%44 = call i32 @fetch_instruction(i32 %43)
store i32 %44, i32* %1
%45 = load i32, i32* %1
%46 = load i32, i32* %23
%47 = load i32, i32* %19
%48 = call i32 @decode(i32 %45, i32 %46, i32 %47)
store i32 %48, i32* %6
%49 = load i32, i32* %6
%50 = call i32 @get_bit(i32 %49, i32 5)
store i32 %50, i32* %7
%51 = load i32, i32* %7
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %79
53: ; preds = %37
%54 = load i32, i32* %1
%55 = load i32, i32* %32
%56 = load i32, i32* %28
%57 = call i32 @decode(i32 %54, i32 %55, i32 %56)
store i32 %57, i32* %13
%58 = load i32, i32* %1
%59 = load i32, i32* %33
%60 = load i32, i32* %29
%61 = call i32 @decode(i32 %58, i32 %59, i32 %60)
store i32 %61, i32* %14
%62 = load i32, i32* %1
%63 = load i32, i32* %34
%64 = load i32, i32* %30
%65 = call i32 @decode(i32 %62, i32 %63, i32 %64)
store i32 %65, i32* %15
%66 = load i32, i32* %6
%67 = icmp eq i32 %66, 33
br i1 %67, label %68, label %78
68: ; preds = %53
%69 = load i32, i32* %13
%70 = call i32 @read_ram(i32 %69)
%71 = load i32, i32* %14
%72 = call i32 @read_ram(i32 %71)
%73 = icmp ugt i32 %70, %72
br i1 %73, label %74, label %77
74: ; preds = %68
%75 = load i32, i32* %15
%76 = call i32 @jump_PC(i32* %2, i32 %75)
br label %77
77: ; preds = %74, %68
br label %78
78: ; preds = %77, %53
br label %157
79: ; preds = %37
%80 = load i32, i32* %6
%81 = call i32 @get_bit(i32 %80, i32 4)
store i32 %81, i32* %10
%82 = load i32, i32* %1
%83 = load i32, i32* %31
%84 = load i32, i32* %27
%85 = call i32 @decode(i32 %82, i32 %83, i32 %84)
store i32 %85, i32* %12
%86 = load i32, i32* %12
%87 = call i32 @read_ram(i32 %86)
store i32 %87, i32* %4
%88 = load i32, i32* %10
%89 = icmp eq i32 %88, 0
br i1 %89, label %90, label %108
90: ; preds = %79
%91 = load i32, i32* %6
%92 = load i32, i32* %24
%93 = load i32, i32* %20
%94 = call i32 @decode(i32 %91, i32 %92, i32 %93)
store i32 %94, i32* %11
%95 = load i32, i32* %6
%96 = load i32, i32* %25
%97 = load i32, i32* %21
%98 = call i32 @decode(i32 %95, i32 %96, i32 %97)
store i32 %98, i32* %8
%99 = load i32, i32* %6
%100 = load i32, i32* %26
%101 = load i32, i32* %22
%102 = call i32 @decode(i32 %99, i32 %100, i32 %101)
store i32 %102, i32* %9
%103 = load i32, i32* %5
%104 = load i32, i32* %4
%105 = load i32, i32* %11
%106 = load i32, i32* %8
%107 = call i32 @ALU(i32 %103, i32 %104, i32 %105, i32 %106, i32* %16, i32* %18, i32* %17)
store i32 %107, i32* %5
br label %156
108: ; preds = %79
%109 = load i32, i32* %6
%110 = icmp eq i32 %109, 17
br i1 %110, label %111, label %113
111: ; preds = %108
%112 = load i32, i32* %4
store i32 %112, i32* %5
br label %155
113: ; preds = %108
%114 = load i32, i32* %6
%115 = icmp eq i32 %114, 18
br i1 %115, label %116, label %118
116: ; preds = %113
%117 = load i32, i32* %12
store i32 %117, i32* %5
br label %154
118: ; preds = %113
%119 = load i32, i32* %6
%120 = icmp eq i32 %119, 19
br i1 %120, label %121, label %125
121: ; preds = %118
%122 = load i32, i32* %5
%123 = load i32, i32* %12
%124 = call i32 @write_ram(i32 %122, i32 %123)
br label %153
125: ; preds = %118
%126 = load i32, i32* %6
%127 = icmp eq i32 %126, 20
br i1 %127, label %128, label %131
128: ; preds = %125
%129 = load i32, i32* %5
%130 = add i32 %129, 1
store i32 %130, i32* %5
br label %152
131: ; preds = %125
%132 = load i32, i32* %6
%133 = icmp eq i32 %132, 28
br i1 %133, label %134, label %137
134: ; preds = %131
%135 = load i32, i32* %5
%136 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %135)
br label %151
137: ; preds = %131
%138 = load i32, i32* %6
%139 = icmp eq i32 %138, 29
br i1 %139, label %140, label %143
140: ; preds = %137
%141 = load i32, i32* %12
%142 = call i32 @jump_PC(i32* %2, i32 %141)
br label %150
143: ; preds = %137
%144 = load i32, i32* %6
%145 = icmp eq i32 %144, 31
br i1 %145, label %146, label %149
146: ; preds = %143
%147 = load i32, i32* %2
%148 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %147)
ret void
149: ; preds = %143
br label %150
150: ; preds = %149, %140
br label %151
151: ; preds = %150, %134
br label %152
152: ; preds = %151, %128
br label %153
153: ; preds = %152, %121
br label %154
154: ; preds = %153, %116
br label %155
155: ; preds = %154, %111
br label %156
156: ; preds = %155, %90
br label %157
157: ; preds = %156, %78
%158 = load i32, i32* %35
%159 = add nsw i32 %158, 1
store i32 %159, i32* %35
br label %37
}

LLVM IR (-O2):
@.str = [30 x i8] c"Instruction Cycle: %d\09PC: %d\0A\00"
@.str.1 = [11 x i8] c"A_reg: %d\0A\00"
@.str.2 = [36 x i8] c"Program halted execution at PC: %d\0A\00"
define void @CPU() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 (...) @start_PC()
store i32 %9, i32* %1
br label %10
10: ; preds = %56, %0
%11 = phi i32 [ %9, %0 ], [ %59, %56 ]
%12 = phi i32 [ undef, %0 ], [ %57, %56 ]
%13 = phi i32 [ 1, %0 ], [ %58, %56 ]
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %11)
%15 = load i32, i32* %1
%16 = call i32 @increment_PC(i32* %1)
%17 = call i32 @fetch_instruction(i32 %15)
%18 = call i32 @decode(i32 %17, i32 -67108864, i32 26)
%19 = call i32 @get_bit(i32 %18, i32 5)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %32
21: ; preds = %10
%22 = call i32 @decode(i32 %17, i32 65011712, i32 21)
%23 = call i32 @decode(i32 %17, i32 2031616, i32 16)
%24 = call i32 @decode(i32 %17, i32 65535, i32 0)
%25 = icmp eq i32 %18, 33
br i1 %25, label %26, label %56
26: ; preds = %21
%27 = call i32 @read_ram(i32 %22)
%28 = call i32 @read_ram(i32 %23)
%29 = icmp ugt i32 %27, %28
br i1 %29, label %30, label %56
30: ; preds = %26
%31 = call i32 @jump_PC(i32* %1, i32 %24)
br label %56
32: ; preds = %10
%33 = call i32 @get_bit(i32 %18, i32 4)
%34 = call i32 @decode(i32 %17, i32 67108863, i32 0)
%35 = call i32 @read_ram(i32 %34)
%36 = icmp eq i32 %33, 0
br i1 %36, label %37, label %42
37: ; preds = %32
%38 = call i32 @decode(i32 %18, i32 3, i32 0)
%39 = call i32 @decode(i32 %18, i32 4, i32 2)
%40 = call i32 @decode(i32 %18, i32 8, i32 3)
%41 = call i32 @ALU(i32 %12, i32 %35, i32 %38, i32 %39, i32* %2, i32* %4, i32* %3)
br label %56
42: ; preds = %32
switch i32 %18, label %55 [
i32 17, label %56
i32 18, label %43
i32 19, label %44
i32 20, label %46
i32 28, label %48
i32 29, label %50
i32 31, label %52
]
43: ; preds = %42
br label %56
44: ; preds = %42
%45 = call i32 @write_ram(i32 %12, i32 %34)
br label %56
46: ; preds = %42
%47 = add i32 %12, 1
br label %56
48: ; preds = %42
%49 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %56
50: ; preds = %42
%51 = call i32 @jump_PC(i32* %1, i32 %34)
br label %56
52: ; preds = %42
%53 = load i32, i32* %1
%54 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %53)
ret void
55: ; preds = %42
br label %56
56: ; preds = %42, %55, %37, %43, %46, %50, %48, %44, %21, %30, %26
%57 = phi i32 [ %12, %30 ], [ %12, %26 ], [ %12, %21 ], [ %41, %37 ], [ %34, %43 ], [ %12, %44 ], [ %47, %46 ], [ %12, %48 ], [ %12, %50 ], [ %35, %42 ], [ %12, %55 ]
%58 = add nuw nsw i32 %13, 1
%59 = load i32, i32* %1
br label %10
}