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

/* Variables and functions */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned int, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
unsigned char genInstrStr(unsigned int, char *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int simMIPS(char *, char *, char *, int, int);
int main(int argc, char *argv[]) {
  FILE *infile;
  FILE *disfile;
  FILE *instrMem;
  FILE *dataMem;
  char c;
  unsigned int instrword = 0;
  int shiftby = 0;
  int prgMem_address = 128;
  unsigned char break_reached = 0;
  int dataMem_address = 0;
  char retStr[32];
  if (argc != 2) {
    printf("Incorrect input arguments");
    return 1;
  }
  infile = fopen(argv[1], "r");
  if (!infile) {
    printf("Invalid file name / file open error");
    return 1;
  }
  disfile = fopen("disassembly.txt", "w");
  if (!disfile) {
    printf("Invalid file name / file open error");
    return 1;
  }
  instrMem = fopen("instructionMemory.txt", "w");
  if (!instrMem) {
    printf("Invalid file name / file open error");
    return 1;
  }
  dataMem = fopen("dataMemory.txt", "w");
  if (!dataMem) {
    printf("Invalid file name / file open error");
    return 1;
  }
  printf("Starting Disassembly\n");
  while ((c = getc(infile)) != EOF) {
    if ('0' == c || '1' == c) {
      instrword <<= shiftby;
      instrword |= (c == '0' ? 0x00000000 : 0x00000001);
      fputc(c, disfile);
      shiftby = 1;
      continue;
    } else if ('\r' == c)
      continue;
    else if ('\n' == c) {
      if (break_reached == 0) {
        break_reached = genInstrStr(instrword, retStr);
        fprintf(disfile, "\t%d\t%s\n", prgMem_address, retStr);
        fprintf(instrMem, "%d\n", instrword);
      } else {
        if (dataMem_address == 0)
          dataMem_address = prgMem_address;
        fprintf(disfile, "\t%d\t%d\n", prgMem_address, instrword);
        fprintf(dataMem, "%d\n", instrword);
      }
      prgMem_address += 4;
      instrword = 0;
      shiftby = 0;
    }
  }
  fclose(infile);
  fclose(disfile);
  fclose(instrMem);
  fclose(dataMem);
  return simMIPS("disassembly.txt", "instructionMemory.txt", "dataMemory.txt",
                 128, dataMem_address);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x80,-0x40(%rbp)
movb   $0x0,-0x41(%rbp)
movl   $0x0,-0x48(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11d8 <main+0x58>
lea    0xe39(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1470 <main+0x2f0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe55(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1213 <main+0x93>
lea    0xe18(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1470 <main+0x2f0>
lea    0xe24(%rip),%rdi
lea    0xe2d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    124d <main+0xcd>
lea    0xdde(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1470 <main+0x2f0>
lea    0xdfc(%rip),%rdi
lea    0xdf3(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1287 <main+0x107>
lea    0xda4(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1470 <main+0x2f0>
lea    0xdd8(%rip),%rdi
lea    0xdb9(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12c1 <main+0x141>
lea    0xd6a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1470 <main+0x2f0>
lea    0xdad(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <getc@plt>
mov    %al,-0x31(%rbp)
movsbl %al,%eax
mov    0x2d05(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1426 <main+0x2a6>
movsbl -0x31(%rbp),%ecx
mov    $0x30,%eax
cmp    %ecx,%eax
je     1310 <main+0x190>
movsbl -0x31(%rbp),%ecx
mov    $0x31,%eax
cmp    %ecx,%eax
jne    134d <main+0x1cd>
mov    -0x3c(%rbp),%ecx
mov    -0x38(%rbp),%eax
shl    %cl,%eax
mov    %eax,-0x38(%rbp)
movsbl -0x31(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x30,%edx
cmove  %ecx,%eax
or     -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x31(%rbp),%al
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
movl   $0x1,-0x3c(%rbp)
jmp    12cd <main+0x14d>
movsbl -0x31(%rbp),%ecx
mov    $0xd,%eax
cmp    %ecx,%eax
jne    1363 <main+0x1e3>
jmp    12cd <main+0x14d>
movsbl -0x31(%rbp),%ecx
mov    $0xa,%eax
cmp    %ecx,%eax
jne    1417 <main+0x297>
movzbl -0x41(%rbp),%eax
cmp    $0x0,%eax
jne    13c3 <main+0x243>
mov    -0x38(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1070 <genInstrStr@plt>
mov    %al,-0x41(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%edx
lea    -0x70(%rbp),%rcx
lea    0xce9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%edx
lea    0xce0(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1400 <main+0x280>
cmpl   $0x0,-0x48(%rbp)
jne    13d3 <main+0x253>
mov    -0x40(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%edx
mov    -0x38(%rbp),%ecx
lea    0xcaf(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%edx
lea    0xc9e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x40(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
jmp    141c <main+0x29c>
jmp    1421 <main+0x2a1>
jmp    12cd <main+0x14d>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x48(%rbp),%r8d
lea    0xbe9(%rip),%rdi
lea    0xbf4(%rip),%rsi
lea    0xc03(%rip),%rdx
mov    $0x80,%ecx
call   1090 <simMIPS@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
cmp    $0x2,%edi
jne    1331 <main+0x1a1>
mov    0x8(%rsi),%rdi
lea    0xe8a(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     133a <main+0x1aa>
mov    %rax,%rbx
lea    0xe74(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     133a <main+0x1aa>
mov    %rax,%r14
lea    0xe67(%rip),%rdi
lea    0xe5e(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     133a <main+0x1aa>
mov    %rax,%r15
lea    0xe5e(%rip),%rdi
lea    0xe3f(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     133a <main+0x1aa>
mov    %rax,0x18(%rsp)
lea    0xe5c(%rip),%rdi
call   1030 <puts@plt>
movl   $0x80,0xc(%rsp)
mov    0x2dab(%rip),%rbp
movl   $0x0,0x10(%rsp)
movl   $0x0,0x14(%rsp)
xor    %r13d,%r13d
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   10b0 <getc@plt>
cmp    0x0(%rbp),%al
je     135a <main+0x1ca>
mov    %eax,%ecx
and    $0xfe,%cl
cmp    $0x30,%cl
je     1285 <main+0xf5>
cmp    $0xd,%al
je     1260 <main+0xd0>
cmp    $0xa,%al
jne    1260 <main+0xd0>
jmp    12a8 <main+0x118>
xor    %edx,%edx
cmp    $0x30,%al
setne  %dl
mov    %r12d,%ecx
shl    %cl,%r13d
or     %edx,%r13d
movsbl %al,%edi
mov    %r14,%rsi
call   1060 <fputc@plt>
mov    $0x1,%r12d
jmp    1260 <main+0xd0>
cmpb   $0x0,0x14(%rsp)
je     12e0 <main+0x150>
mov    0x10(%rsp),%eax
test   %eax,%eax
mov    0xc(%rsp),%r12d
cmove  %r12d,%eax
mov    %eax,0x10(%rsp)
mov    %r14,%rdi
lea    0xdb1(%rip),%rsi
mov    %r12d,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x18(%rsp),%rdi
jmp    1312 <main+0x182>
mov    %r13d,%edi
lea    0x20(%rsp),%rsi
call   1080 <genInstrStr@plt>
mov    %eax,0x14(%rsp)
mov    %r14,%rdi
lea    0xd7a(%rip),%rsi
mov    0xc(%rsp),%r12d
mov    %r12d,%edx
lea    0x20(%rsp),%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r15,%rdi
lea    0xd68(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x4,%r12d
mov    %r12d,0xc(%rsp)
jmp    124d <main+0xbd>
lea    0xcc8(%rip),%rdi
jmp    1341 <main+0x1b1>
lea    0xcd9(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x18(%rsp),%rdi
call   1040 <fclose@plt>
lea    0xcbb(%rip),%rdi
lea    0xcc6(%rip),%rsi
lea    0xcd5(%rip),%rdx
mov    $0x80,%ecx
mov    0x10(%rsp),%r8d
call   10a0 <simMIPS@plt>
jmp    134b <main+0x1bb>

LLVM IR (-O0):
@.str = [26 x i8] c"Incorrect input arguments\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [36 x i8] c"Invalid file name / file open error\00"
@.str.3 = [16 x i8] c"disassembly.txt\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [22 x i8] c"instructionMemory.txt\00"
@.str.6 = [15 x i8] c"dataMemory.txt\00"
@.str.7 = [22 x i8] c"Starting Disassembly\0A\00"
@EOF = global i8 0
@.str.8 = [8 x i8] c"\09%d\09%s\0A\00"
@.str.9 = [4 x i8] c"%d\0A\00"
@.str.10 = [8 x i8] c"\09%d\09%d\0A\00"
define i32 @main(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 i8
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
%15 = alloca i32
%16 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
store i32 0, i32* %12
store i32 128, i32* %13
store i8 0, i8* %14
store i32 0, i32* %15
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 2
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %133
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %6
%26 = load i32*, i32** %6
%27 = icmp ne i32* %26, null
br i1 %27, label %30, label %28
28: ; preds = %21
%29 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %133
30: ; preds = %21
%31 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %31, i32** %7
%32 = load i32*, i32** %7
%33 = icmp ne i32* %32, null
br i1 %33, label %36, label %34
34: ; preds = %30
%35 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %133
36: ; preds = %30
%37 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %37, i32** %8
%38 = load i32*, i32** %8
%39 = icmp ne i32* %38, null
br i1 %39, label %42, label %40
40: ; preds = %36
%41 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %133
42: ; preds = %36
%43 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %43, i32** %9
%44 = load i32*, i32** %9
%45 = icmp ne i32* %44, null
br i1 %45, label %48, label %46
46: ; preds = %42
%47 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %133
48: ; preds = %42
%49 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
br label %50
50: ; preds = %121, %83, %65, %48
%51 = load i32*, i32** %6
%52 = call signext i8 @getc(i32* %51)
store i8 %52, i8* %10
%53 = sext i8 %52 to i32
%54 = load i8, i8* @EOF
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %53, %55
br i1 %56, label %57, label %122
57: ; preds = %50
%58 = load i8, i8* %10
%59 = sext i8 %58 to i32
%60 = icmp eq i32 48, %59
br i1 %60, label %65, label %61
61: ; preds = %57
%62 = load i8, i8* %10
%63 = sext i8 %62 to i32
%64 = icmp eq i32 49, %63
br i1 %64, label %65, label %79
65: ; preds = %61, %57
%66 = load i32, i32* %12
%67 = load i32, i32* %11
%68 = shl i32 %67, %66
store i32 %68, i32* %11
%69 = load i8, i8* %10
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 48
%72 = zext i1 %71 to i64
%73 = select i1 %71, i32 0, i32 1
%74 = load i32, i32* %11
%75 = or i32 %74, %73
store i32 %75, i32* %11
%76 = load i8, i8* %10
%77 = load i32*, i32** %7
%78 = call i32 @fputc(i8 signext %76, i32* %77)
store i32 1, i32* %12
br label %50
79: ; preds = %61
%80 = load i8, i8* %10
%81 = sext i8 %80 to i32
%82 = icmp eq i32 13, %81
br i1 %82, label %83, label %84
83: ; preds = %79
br label %50
84: ; preds = %79
%85 = load i8, i8* %10
%86 = sext i8 %85 to i32
%87 = icmp eq i32 10, %86
br i1 %87, label %88, label %119
88: ; preds = %84
%89 = load i8, i8* %14
%90 = zext i8 %89 to i32
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %103
92: ; preds = %88
%93 = load i32, i32* %11
%94 = getelementptr inbounds [32 x i8], [32 x i8]* %16, i64 0, i64 0
%95 = call zeroext i8 @genInstrStr(i32 %93, i8* %94)
store i8 %95, i8* %14
%96 = load i32*, i32** %7
%97 = load i32, i32* %13
%98 = getelementptr inbounds [32 x i8], [32 x i8]* %16, i64 0, i64 0
%99 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %96, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 %97, i8* %98)
%100 = load i32*, i32** %8
%101 = load i32, i32* %11
%102 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %100, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %101)
br label %116
103: ; preds = %88
%104 = load i32, i32* %15
%105 = icmp eq i32 %104, 0
br i1 %105, label %106, label %108
106: ; preds = %103
%107 = load i32, i32* %13
store i32 %107, i32* %15
br label %108
108: ; preds = %106, %103
%109 = load i32*, i32** %7
%110 = load i32, i32* %13
%111 = load i32, i32* %11
%112 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %109, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 %110, i32 %111)
%113 = load i32*, i32** %9
%114 = load i32, i32* %11
%115 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %113, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %114)
br label %116
116: ; preds = %108, %92
%117 = load i32, i32* %13
%118 = add nsw i32 %117, 4
store i32 %118, i32* %13
store i32 0, i32* %11
store i32 0, i32* %12
br label %119
119: ; preds = %116, %84
br label %120
120: ; preds = %119
br label %121
121: ; preds = %120
br label %50
122: ; preds = %50
%123 = load i32*, i32** %6
%124 = call i32 @fclose(i32* %123)
%125 = load i32*, i32** %7
%126 = call i32 @fclose(i32* %125)
%127 = load i32*, i32** %8
%128 = call i32 @fclose(i32* %127)
%129 = load i32*, i32** %9
%130 = call i32 @fclose(i32* %129)
%131 = load i32, i32* %15
%132 = call i32 @simMIPS(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 128, i32 %131)
store i32 %132, i32* %3
br label %133
133: ; preds = %122, %46, %40, %34, %28, %19
%134 = load i32, i32* %3
ret i32 %134
}

LLVM IR (-O2):
@.str = [26 x i8] c"Incorrect input arguments\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [36 x i8] c"Invalid file name / file open error\00"
@.str.3 = [16 x i8] c"disassembly.txt\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [22 x i8] c"instructionMemory.txt\00"
@.str.6 = [15 x i8] c"dataMemory.txt\00"
@EOF = global i8 0
@.str.8 = [8 x i8] c"\09%d\09%s\0A\00"
@.str.9 = [4 x i8] c"%d\0A\00"
@.str.10 = [8 x i8] c"\09%d\09%d\0A\00"
@str = [21 x i8] c"Starting Disassembly\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %77
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %77
15: ; preds = %8
%16 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %77
20: ; preds = %15
%21 = tail call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %77
25: ; preds = %20
%26 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %77
30: ; preds = %25
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %65, %30
%33 = phi i32 [ %70, %65 ], [ 128, %30 ]
%34 = phi i8 [ %67, %65 ], [ 0, %30 ]
%35 = phi i32 [ %68, %65 ], [ 0, %30 ]
br label %36
36: ; preds = %55, %32
%37 = phi i32 [ 0, %32 ], [ %40, %55 ]
%38 = phi i32 [ 0, %32 ], [ %41, %55 ]
br label %39
39: ; preds = %36, %49
%40 = phi i32 [ %53, %49 ], [ %37, %36 ]
%41 = phi i32 [ 1, %49 ], [ %38, %36 ]
br label %42
42: ; preds = %39, %55
%43 = call signext i8 @getc(i32* %11)
%44 = load i8, i8* @EOF
%45 = icmp eq i8 %43, %44
br i1 %45, label %71, label %46
46: ; preds = %42
%47 = and i8 %43, -2
%48 = icmp eq i8 %47, 48
br i1 %48, label %49, label %55
49: ; preds = %46
%50 = icmp ne i8 %43, 48
%51 = shl i32 %40, %41
%52 = zext i1 %50 to i32
%53 = or i32 %51, %52
%54 = call i32 @fputc(i8 signext %43, i32* %16)
br label %39
55: ; preds = %46
switch i8 %43, label %36 [
i8 13, label %42
i8 10, label %56
]
56: ; preds = %55
%57 = icmp eq i8 %34, 0
br i1 %57, label %58, label %61
58: ; preds = %56
%59 = call zeroext i8 @genInstrStr(i32 %40, i8* %4)
%60 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 %33, i8* %4)
br label %65
61: ; preds = %56
%62 = icmp eq i32 %35, 0
%63 = select i1 %62, i32 %33, i32 %35
%64 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 %33, i32 %40)
br label %65
65: ; preds = %61, %58
%66 = phi i32* [ %26, %61 ], [ %21, %58 ]
%67 = phi i8 [ %34, %61 ], [ %59, %58 ]
%68 = phi i32 [ %63, %61 ], [ %35, %58 ]
%69 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %66, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %40)
%70 = add nuw nsw i32 %33, 4
br label %32
71: ; preds = %42
%72 = call i32 @fclose(i32* %11)
%73 = call i32 @fclose(i32* %16)
%74 = call i32 @fclose(i32* %21)
%75 = call i32 @fclose(i32* %26)
%76 = call i32 @simMIPS(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 128, i32 %35)
br label %77
77: ; preds = %71, %28, %23, %18, %13, %6
%78 = phi i32 [ 1, %6 ], [ %76, %71 ], [ 1, %28 ], [ 1, %23 ], [ 1, %18 ], [ 1, %13 ]
ret i32 %78
}