#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 */
struct beri_debug {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int berictl_breakpoint(struct beri_debug *, char *, int /*<<< orphan*/);
int berictl_c0regs(struct beri_debug *);
int berictl_c2regs(struct beri_debug *);
int berictl_console(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *);
int berictl_lbu(struct beri_debug *, char *);
int berictl_ld(struct beri_debug *, char *);
int berictl_pause(struct beri_debug *);
int berictl_pc(struct beri_debug *);
int berictl_regs(struct beri_debug *);
int berictl_resume(struct beri_debug *);
int berictl_sb(struct beri_debug *, char *, char *);
int berictl_sd(struct beri_debug *, char *, char *);
int berictl_setpc(struct beri_debug *, char *);
int berictl_setreg(struct beri_debug *, char *, char *);
int berictl_step(struct beri_debug *);
int berictl_test_report(struct beri_debug *);
int berictl_test_run(struct beri_debug *);
int berictl_unpipeline(struct beri_debug *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int sscanf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usleep(int);
int berictl_docontrol(struct beri_debug *bdp, const char *controlp) {
  FILE *fp = NULL;
  char str[1024];
  char cmd[128], op1[128], op2[128];
  int len = 0, i;
  fp = fopen(controlp, "r");
  if (fp == NULL) {
    fprintf(stderr, "Cannot open control command file %s", controlp);
    return ((-1));
  }
  int ret = 0;
  while (!feof(fp)) {
    if (ret != 0) {
      break;
    }
    for (i = 0; i <= 1024; i++) {
      str[i] = fgetc(fp);
      if (str[i] == '\n') {
        str[i] = 0;
        break;
      }
    }
    memset(cmd, 0, 128);
    memset(op1, 0, 128);
    memset(op2, 0, 128);
    len = sscanf(str, "%s %s %s", cmd, op1, op2);
    fprintf(stderr, "%s => len (cmd,op1,op2): %d (%s,%s,%s)\n", str, len, cmd,
            op1, op2);
    if ((len == 2) && strcmp(cmd, "breakpoint") == 0) {
      printf("breakpoint!");
      ret = berictl_breakpoint(bdp, op1, 0);
    } else if ((len == 2) && strcmp(cmd, "console") == 0) {
      printf("console!");
      ret = berictl_console(NULL, op1, NULL, NULL);
    } else if ((len == 1) && strcmp(cmd, "c0regs") == 0) {
      printf("c0regs!");
      ret = berictl_c0regs(bdp);
    } else if ((len == 2) && strcmp(cmd, "lbu") == 0) {
      printf("lbu!");
      ret = berictl_lbu(bdp, op1);
    } else if ((len == 2) && strcmp(cmd, "ld") == 0) {
      printf("ld!");
      ret = berictl_ld(bdp, op1);
    } else if ((len == 1) && strcmp(cmd, "pause") == 0) {
      printf("pause!");
      ret = berictl_pause(bdp);
    } else if ((len == 1) && strcmp(cmd, "pc") == 0) {
      printf("pc!");
      ret = berictl_pc(bdp);
    } else if ((len == 1) && strcmp(cmd, "regs") == 0) {
      printf("regs!");
      ret = berictl_regs(bdp);
    } else if ((len == 1) && strcmp(cmd, "c2regs") == 0) {
      printf("c2regs!");
      ret = berictl_c2regs(bdp);
    } else if ((len == 1) && strcmp(cmd, "resume") == 0) {
      printf("resume!");
      ret = berictl_resume(bdp);
    } else if ((len == 3) && strcmp(cmd, "sb") == 0) {
      printf("sb!");
      ret = berictl_sb(bdp, op1, op2);
    } else if ((len == 3) && strcmp(cmd, "sd") == 0) {
      printf("sd!");
      ret = berictl_sd(bdp, op1, op2);
    } else if ((len == 2) && strcmp(cmd, "setpc") == 0) {
      printf("setpc!");
      ret = berictl_setpc(bdp, op1);
    } else if ((len == 3) && strcmp(cmd, "setreg") == 0) {
      printf("setreg!");
      ret = berictl_setreg(bdp, op1, op2);
    } else if ((len == 1) && strcmp(cmd, "step") == 0) {
      printf("step!");
      ret = berictl_step(bdp);
    } else if ((len == 1) && strcmp(cmd, "unpipeline") == 0) {
      printf("unpipeline!");
      ret = berictl_unpipeline(bdp);
    } else if ((len == 2) && strcmp(cmd, "test") == 0) {
      printf("test?");
      ret = berictl_test_run(bdp);
      ret = berictl_test_report(bdp);
    } else {
      fprintf(stderr, "Unrecognized Command: %s (len %d)", cmd, len);
      ret = (-1);
    }
    fprintf(stderr, "Finished operation\n");
    usleep(200000);
  }
  fprintf(stderr, "Done!\n");
  fclose(fp);
  return (ret);
}


x86 assembly (clang, -O0):
<berictl_docontrol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5c0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x5a4(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xd10(%rip),%rsi
call   1180 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    132b <berictl_docontrol+0x6b>
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xcea(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1a9c <berictl_docontrol+0x7dc>
movl   $0x0,-0x5ac(%rbp)
mov    -0x20(%rbp),%rdi
call   10f0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1353 <berictl_docontrol+0x93>
jmp    1a73 <berictl_docontrol+0x7b3>
cmpl   $0x0,-0x5ac(%rbp)
je     1365 <berictl_docontrol+0xa5>
jmp    1a73 <berictl_docontrol+0x7b3>
movl   $0x0,-0x5a8(%rbp)
cmpl   $0x400,-0x5a8(%rbp)
jg     13dd <berictl_docontrol+0x11d>
mov    -0x20(%rbp),%rdi
call   10a0 <fgetc@plt>
mov    %al,%cl
movslq -0x5a8(%rbp),%rax
mov    %cl,-0x420(%rbp,%rax,1)
movslq -0x5a8(%rbp),%rax
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    13c4 <berictl_docontrol+0x104>
movslq -0x5a8(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
jmp    13dd <berictl_docontrol+0x11d>
jmp    13c9 <berictl_docontrol+0x109>
mov    -0x5a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5a8(%rbp)
jmp    136f <berictl_docontrol+0xaf>
lea    -0x4a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1080 <memset@plt>
lea    -0x520(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1080 <memset@plt>
lea    -0x5a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1080 <memset@plt>
lea    -0x420(%rbp),%rdi
lea    -0x4a0(%rbp),%rdx
lea    -0x520(%rbp),%rcx
lea    -0x5a0(%rbp),%r8
lea    0xbed(%rip),%rsi
call   1110 <sscanf@plt>
mov    %eax,-0x5a4(%rbp)
mov    0x2b95(%rip),%rax
mov    (%rax),%edi
lea    -0x420(%rbp),%rdx
mov    -0x5a4(%rbp),%ecx
lea    -0x4a0(%rbp),%r8
lea    -0x520(%rbp),%r9
lea    -0x5a0(%rbp),%rax
lea    0xbb9(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x0,%al
call   10d0 <fprintf@plt>
cmpl   $0x2,-0x5a4(%rbp)
jne    14d4 <berictl_docontrol+0x214>
lea    -0x4a0(%rbp),%rdi
lea    0xbbb(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    14d4 <berictl_docontrol+0x214>
lea    0xbb0(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x520(%rbp),%rsi
xor    %edx,%edx
call   1160 <berictl_breakpoint@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a4d <berictl_docontrol+0x78d>
cmpl   $0x2,-0x5a4(%rbp)
jne    152b <berictl_docontrol+0x26b>
lea    -0x4a0(%rbp),%rdi
lea    0xb7f(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    152b <berictl_docontrol+0x26b>
lea    0xb71(%rip),%rdi
call   1070 <printf@plt>
lea    -0x520(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdi
mov    %rcx,%rdx
call   1190 <berictl_console@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a48 <berictl_docontrol+0x788>
cmpl   $0x1,-0x5a4(%rbp)
jne    1575 <berictl_docontrol+0x2b5>
lea    -0x4a0(%rbp),%rdi
lea    0xb39(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1575 <berictl_docontrol+0x2b5>
lea    0xb2a(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1100 <berictl_c0regs@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a43 <berictl_docontrol+0x783>
cmpl   $0x2,-0x5a4(%rbp)
jne    15c6 <berictl_docontrol+0x306>
lea    -0x4a0(%rbp),%rdi
lea    0xafe(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    15c6 <berictl_docontrol+0x306>
lea    0xaec(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x520(%rbp),%rsi
call   1040 <berictl_lbu@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a3e <berictl_docontrol+0x77e>
cmpl   $0x2,-0x5a4(%rbp)
jne    1617 <berictl_docontrol+0x357>
lea    -0x4a0(%rbp),%rdi
lea    0xab6(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1617 <berictl_docontrol+0x357>
lea    0xaa3(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x520(%rbp),%rsi
call   1170 <berictl_ld@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a39 <berictl_docontrol+0x779>
cmpl   $0x1,-0x5a4(%rbp)
jne    1661 <berictl_docontrol+0x3a1>
lea    -0x4a0(%rbp),%rdi
lea    0xa6c(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1661 <berictl_docontrol+0x3a1>
lea    0xa5c(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   10e0 <berictl_pause@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a34 <berictl_docontrol+0x774>
cmpl   $0x1,-0x5a4(%rbp)
jne    16ab <berictl_docontrol+0x3eb>
lea    -0x4a0(%rbp),%rdi
lea    0xa5e(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    16ab <berictl_docontrol+0x3eb>
lea    0xa4e(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   11b0 <berictl_pc@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a2f <berictl_docontrol+0x76f>
cmpl   $0x1,-0x5a4(%rbp)
jne    16f5 <berictl_docontrol+0x435>
lea    -0x4a0(%rbp),%rdi
lea    0x9bb(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    16f5 <berictl_docontrol+0x435>
lea    0x9ac(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1120 <berictl_regs@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a2a <berictl_docontrol+0x76a>
cmpl   $0x1,-0x5a4(%rbp)
jne    173f <berictl_docontrol+0x47f>
lea    -0x4a0(%rbp),%rdi
lea    0x99b(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    173f <berictl_docontrol+0x47f>
lea    0x98c(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <berictl_c2regs@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a25 <berictl_docontrol+0x765>
cmpl   $0x1,-0x5a4(%rbp)
jne    1789 <berictl_docontrol+0x4c9>
lea    -0x4a0(%rbp),%rdi
lea    0x960(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1789 <berictl_docontrol+0x4c9>
lea    0x951(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <berictl_resume@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a20 <berictl_docontrol+0x760>
cmpl   $0x3,-0x5a4(%rbp)
jne    17e1 <berictl_docontrol+0x521>
lea    -0x4a0(%rbp),%rdi
lea    0x925(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    17e1 <berictl_docontrol+0x521>
lea    0x912(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x520(%rbp),%rsi
lea    -0x5a0(%rbp),%rdx
call   1150 <berictl_sb@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a1b <berictl_docontrol+0x75b>
cmpl   $0x3,-0x5a4(%rbp)
jne    1839 <berictl_docontrol+0x579>
lea    -0x4a0(%rbp),%rdi
lea    0x8d4(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1839 <berictl_docontrol+0x579>
lea    0x8c1(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x520(%rbp),%rsi
lea    -0x5a0(%rbp),%rdx
call   1140 <berictl_sd@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a16 <berictl_docontrol+0x756>
cmpl   $0x2,-0x5a4(%rbp)
jne    188a <berictl_docontrol+0x5ca>
lea    -0x4a0(%rbp),%rdi
lea    0x883(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    188a <berictl_docontrol+0x5ca>
lea    0x873(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x520(%rbp),%rsi
call   11d0 <berictl_setpc@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a11 <berictl_docontrol+0x751>
cmpl   $0x3,-0x5a4(%rbp)
jne    18e2 <berictl_docontrol+0x622>
lea    -0x4a0(%rbp),%rdi
lea    0x83f(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    18e2 <berictl_docontrol+0x622>
lea    0x830(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x520(%rbp),%rsi
lea    -0x5a0(%rbp),%rdx
call   11a0 <berictl_setreg@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a0c <berictl_docontrol+0x74c>
cmpl   $0x1,-0x5a4(%rbp)
jne    192c <berictl_docontrol+0x66c>
lea    -0x4a0(%rbp),%rdi
lea    0x7f6(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    192c <berictl_docontrol+0x66c>
lea    0x7e5(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1090 <berictl_step@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a07 <berictl_docontrol+0x747>
cmpl   $0x1,-0x5a4(%rbp)
jne    1976 <berictl_docontrol+0x6b6>
lea    -0x4a0(%rbp),%rdi
lea    0x7b7(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    1976 <berictl_docontrol+0x6b6>
lea    0x7ac(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <berictl_unpipeline@plt>
mov    %eax,-0x5ac(%rbp)
jmp    1a02 <berictl_docontrol+0x742>
cmpl   $0x2,-0x5a4(%rbp)
jne    19cf <berictl_docontrol+0x70f>
lea    -0x4a0(%rbp),%rdi
lea    0x784(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    19cf <berictl_docontrol+0x70f>
lea    0x773(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
call   11c0 <berictl_test_run@plt>
mov    %eax,-0x5ac(%rbp)
mov    -0x10(%rbp),%rdi
call   1130 <berictl_test_report@plt>
mov    %eax,-0x5ac(%rbp)
jmp    19fd <berictl_docontrol+0x73d>
mov    0x260a(%rip),%rax
mov    (%rax),%edi
lea    -0x4a0(%rbp),%rdx
mov    -0x5a4(%rbp),%ecx
lea    0x734(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0xffffffff,-0x5ac(%rbp)
ff ff ff
jmp    1a02 <berictl_docontrol+0x742>
jmp    1a07 <berictl_docontrol+0x747>
jmp    1a0c <berictl_docontrol+0x74c>
jmp    1a11 <berictl_docontrol+0x751>
jmp    1a16 <berictl_docontrol+0x756>
jmp    1a1b <berictl_docontrol+0x75b>
jmp    1a20 <berictl_docontrol+0x760>
jmp    1a25 <berictl_docontrol+0x765>
jmp    1a2a <berictl_docontrol+0x76a>
jmp    1a2f <berictl_docontrol+0x76f>
jmp    1a34 <berictl_docontrol+0x774>
jmp    1a39 <berictl_docontrol+0x779>
jmp    1a3e <berictl_docontrol+0x77e>
jmp    1a43 <berictl_docontrol+0x783>
jmp    1a48 <berictl_docontrol+0x788>
jmp    1a4d <berictl_docontrol+0x78d>
mov    0x258c(%rip),%rax
mov    (%rax),%edi
lea    0x6e5(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x30d40,%edi
call   11e0 <usleep@plt>
jmp    1335 <berictl_docontrol+0x75>
mov    0x2566(%rip),%rax
mov    (%rax),%edi
lea    0x6d3(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x5ac(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x5c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<berictl_docontrol>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x598,%rsp
mov    %rsi,%rbp
mov    %rdi,0x8(%rsp)
lea    0xd20(%rip),%rsi
mov    %rbp,%rdi
call   1180 <fopen@plt>
test   %rax,%rax
je     131f <berictl_docontrol+0x5f>
mov    %rax,%r13
mov    %rax,%rdi
call   10f0 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1352 <berictl_docontrol+0x92>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    %r13,%rdi
call   1050 <fclose@plt>
jmp    133e <berictl_docontrol+0x7e>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
lea    0xcd3(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x598,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x110(%rsp),%r15
lea    0x90(%rsp),%r12
xor    %ebx,%ebx
jmp    13ba <berictl_docontrol+0xfa>
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%edi
lea    0xda7(%rip),%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    (%rbx),%edi
lea    0xdae(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x30d40,%edi
call   11e0 <usleep@plt>
mov    %r13,%rdi
call   10f0 <feof@plt>
or     %ebp,%eax
mov    $0x0,%ebx
jne    12fe <berictl_docontrol+0x3e>
mov    %r13,%rdi
call   10a0 <fgetc@plt>
mov    %al,0x190(%rsp,%rbx,1)
cmp    $0xa,%al
jne    13e0 <berictl_docontrol+0x120>
mov    %ebx,%eax
movb   $0x0,0x190(%rsp,%rax,1)
jmp    13ed <berictl_docontrol+0x12d>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x401,%rbx
jne    13ba <berictl_docontrol+0xfa>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1080 <memset@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1080 <memset@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1080 <memset@plt>
lea    0x190(%rsp),%rbp
mov    %rbp,%rdi
lea    0xbf5(%rip),%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %rbx,%r8
call   1110 <sscanf@plt>
mov    %eax,%r14d
mov    0x2b97(%rip),%rax
mov    (%rax),%edi
mov    %rbx,(%rsp)
lea    0xbd9(%rip),%rsi
mov    %rbp,%rdx
mov    %r14d,%ecx
mov    %r15,%r8
mov    %r12,%r9
xor    %eax,%eax
call   10d0 <fprintf@plt>
cmp    $0x1,%r14d
je     154d <berictl_docontrol+0x28d>
cmp    $0x3,%r14d
je     1631 <berictl_docontrol+0x371>
cmp    $0x2,%r14d
mov    0x2b58(%rip),%rbx
jne    1370 <berictl_docontrol+0xb0>
mov    %r15,%rdi
lea    0xbbf(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     16a5 <berictl_docontrol+0x3e5>
mov    %r15,%rdi
lea    0xbbe(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1704 <berictl_docontrol+0x444>
mov    %r15,%rdi
lea    0xbc6(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     176e <berictl_docontrol+0x4ae>
mov    %r15,%rdi
lea    0xbb7(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     17ab <berictl_docontrol+0x4eb>
mov    %r15,%rdi
lea    0xbdf(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     17e8 <berictl_docontrol+0x528>
mov    %r15,%rdi
lea    0xc05(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
jne    1370 <berictl_docontrol+0xb0>
lea    0xbf5(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   11c0 <berictl_test_run@plt>
mov    %rbx,%rdi
mov    0x2a9f(%rip),%rbx
call   1130 <berictl_test_report@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
mov    %r15,%rdi
lea    0xb28(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     16c7 <berictl_docontrol+0x407>
mov    %r15,%rdi
lea    0xb2f(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1725 <berictl_docontrol+0x465>
mov    %r15,%rdi
lea    0xb53(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
mov    0x2a4a(%rip),%rbx
je     178e <berictl_docontrol+0x4ce>
mov    %r15,%rdi
lea    0xadb(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     17cb <berictl_docontrol+0x50b>
mov    %r15,%rdi
lea    0xaed(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1808 <berictl_docontrol+0x548>
mov    %r15,%rdi
lea    0xae4(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1825 <berictl_docontrol+0x565>
mov    %r15,%rdi
lea    0xb05(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1842 <berictl_docontrol+0x582>
mov    %r15,%rdi
lea    0xaf8(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
jne    1370 <berictl_docontrol+0xb0>
lea    0xaee(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <berictl_unpipeline@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
mov    %r15,%rdi
lea    0xa8e(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
mov    0x2996(%rip),%rbx
je     16df <berictl_docontrol+0x41f>
mov    %r15,%rdi
lea    0xa76(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1749 <berictl_docontrol+0x489>
mov    %r15,%rdi
lea    0xa72(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
jne    1370 <berictl_docontrol+0xb0>
lea    0xa64(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
lea    0x10(%rsp),%rdx
call   11a0 <berictl_setreg@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
lea    0x9b6(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
xor    %edx,%edx
call   1160 <berictl_breakpoint@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
lea    0x9b8(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
call   1100 <berictl_c0regs@plt>
jmp    173b <berictl_docontrol+0x47b>
lea    0x9e6(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
lea    0x10(%rsp),%rdx
call   1150 <berictl_sb@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
lea    0x96b(%rip),%rdi
call   1070 <printf@plt>
xor    %edi,%edi
mov    %r12,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1190 <berictl_console@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
lea    0x978(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
call   10e0 <berictl_pause@plt>
mov    %eax,%ebp
mov    0x289c(%rip),%rbx
jmp    138b <berictl_docontrol+0xcb>
lea    0x983(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
lea    0x10(%rsp),%rdx
call   1140 <berictl_sd@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
lea    0x91d(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
call   1040 <berictl_lbu@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
lea    0x94b(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
call   11b0 <berictl_pc@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
lea    0x8e8(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
call   1170 <berictl_ld@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
lea    0x8b6(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
call   1120 <berictl_regs@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
lea    0x8ee(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
call   11d0 <berictl_setpc@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
lea    0x8a3(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
call   10b0 <berictl_c2regs@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
lea    0x895(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
call   1060 <berictl_resume@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>
lea    0x8af(%rip),%rdi
call   1070 <printf@plt>
mov    0x8(%rsp),%rdi
call   1090 <berictl_step@plt>
mov    %eax,%ebp
jmp    138b <berictl_docontrol+0xcb>

LLVM IR (-O0):
%struct.beri_debug = type { i32 }
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [36 x i8] c"Cannot open control command file %s\00"
@.str.2 = [9 x i8] c"%s %s %s\00"
@.str.3 = [40 x i8] c"%s => len (cmd,op1,op2): %d (%s,%s,%s)\0A\00"
@.str.4 = [11 x i8] c"breakpoint\00"
@.str.5 = [12 x i8] c"breakpoint!\00"
@.str.6 = [8 x i8] c"console\00"
@.str.7 = [9 x i8] c"console!\00"
@.str.8 = [7 x i8] c"c0regs\00"
@.str.9 = [8 x i8] c"c0regs!\00"
@.str.10 = [4 x i8] c"lbu\00"
@.str.11 = [5 x i8] c"lbu!\00"
@.str.12 = [3 x i8] c"ld\00"
@.str.13 = [4 x i8] c"ld!\00"
@.str.14 = [6 x i8] c"pause\00"
@.str.15 = [7 x i8] c"pause!\00"
@.str.16 = [3 x i8] c"pc\00"
@.str.17 = [4 x i8] c"pc!\00"
@.str.18 = [5 x i8] c"regs\00"
@.str.19 = [6 x i8] c"regs!\00"
@.str.20 = [7 x i8] c"c2regs\00"
@.str.21 = [8 x i8] c"c2regs!\00"
@.str.22 = [7 x i8] c"resume\00"
@.str.23 = [8 x i8] c"resume!\00"
@.str.24 = [3 x i8] c"sb\00"
@.str.25 = [4 x i8] c"sb!\00"
@.str.26 = [3 x i8] c"sd\00"
@.str.27 = [4 x i8] c"sd!\00"
@.str.28 = [6 x i8] c"setpc\00"
@.str.29 = [7 x i8] c"setpc!\00"
@.str.30 = [7 x i8] c"setreg\00"
@.str.31 = [8 x i8] c"setreg!\00"
@.str.32 = [5 x i8] c"step\00"
@.str.33 = [6 x i8] c"step!\00"
@.str.34 = [11 x i8] c"unpipeline\00"
@.str.35 = [12 x i8] c"unpipeline!\00"
@.str.36 = [5 x i8] c"test\00"
@.str.37 = [6 x i8] c"test?\00"
@.str.38 = [34 x i8] c"Unrecognized Command: %s (len %d)\00"
@.str.39 = [20 x i8] c"Finished operation\0A\00"
@.str.40 = [7 x i8] c"Done!\0A\00"
define i32 @berictl_docontrol(%struct.beri_debug* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.beri_debug*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca [1024 x i8]
%8 = alloca [128 x i8]
%9 = alloca [128 x i8]
%10 = alloca [128 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store %struct.beri_debug* %0, %struct.beri_debug** %4
store i8* %1, i8** %5
store i32* null, i32** %6
store i32 0, i32* %11
%14 = load i8*, i8** %5
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %6
%16 = load i32*, i32** %6
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %5
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %20)
store i32 -1, i32* %3
br label %304
22: ; preds = %2
store i32 0, i32* %13
br label %23
23: ; preds = %294, %22
%24 = load i32*, i32** %6
%25 = call i32 @feof(i32* %24)
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
br i1 %27, label %28, label %298
28: ; preds = %23
%29 = load i32, i32* %13
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %28
br label %298
32: ; preds = %28
store i32 0, i32* %12
br label %33
33: ; preds = %53, %32
%34 = load i32, i32* %12
%35 = icmp sle i32 %34, 1024
br i1 %35, label %36, label %56
36: ; preds = %33
%37 = load i32*, i32** %6
%38 = call signext i8 @fgetc(i32* %37)
%39 = load i32, i32* %12
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %40
store i8 %38, i8* %41
%42 = load i32, i32* %12
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 10
br i1 %47, label %48, label %52
48: ; preds = %36
%49 = load i32, i32* %12
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %50
store i8 0, i8* %51
br label %56
52: ; preds = %36
br label %53
53: ; preds = %52
%54 = load i32, i32* %12
%55 = add nsw i32 %54, 1
store i32 %55, i32* %12
br label %33
56: ; preds = %48, %33
%57 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%58 = call i32 @memset(i8* %57, i32 0, i32 128)
%59 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%60 = call i32 @memset(i8* %59, i32 0, i32 128)
%61 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%62 = call i32 @memset(i8* %61, i32 0, i32 128)
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%64 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%65 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%66 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%67 = call i32 @sscanf(i8* %63, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %64, i8* %65, i8* %66)
store i32 %67, i32* %11
%68 = load i32, i32* @stderr
%69 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%70 = load i32, i32* %11
%71 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%72 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%73 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %69, i32 %70, i8* %71, i8* %72, i8* %73)
%75 = load i32, i32* %11
%76 = icmp eq i32 %75, 2
br i1 %76, label %77, label %86
77: ; preds = %56
%78 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%79 = call i64 @strcmp(i8* %78, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %86
81: ; preds = %77
%82 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%83 = load %struct.beri_debug*, %struct.beri_debug** %4
%84 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%85 = call i32 @berictl_breakpoint(%struct.beri_debug* %83, i8* %84, i32 0)
store i32 %85, i32* %13
br label %294
86: ; preds = %77, %56
%87 = load i32, i32* %11
%88 = icmp eq i32 %87, 2
br i1 %88, label %89, label %97
89: ; preds = %86
%90 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%91 = call i64 @strcmp(i8* %90, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %97
93: ; preds = %89
%94 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%95 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%96 = call i32 @berictl_console(i32* null, i8* %95, i32* null, i32* null)
store i32 %96, i32* %13
br label %293
97: ; preds = %89, %86
%98 = load i32, i32* %11
%99 = icmp eq i32 %98, 1
br i1 %99, label %100, label %108
100: ; preds = %97
%101 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%102 = call i64 @strcmp(i8* %101, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%103 = icmp eq i64 %102, 0
br i1 %103, label %104, label %108
104: ; preds = %100
%105 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%106 = load %struct.beri_debug*, %struct.beri_debug** %4
%107 = call i32 @berictl_c0regs(%struct.beri_debug* %106)
store i32 %107, i32* %13
br label %292
108: ; preds = %100, %97
%109 = load i32, i32* %11
%110 = icmp eq i32 %109, 2
br i1 %110, label %111, label %120
111: ; preds = %108
%112 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%113 = call i64 @strcmp(i8* %112, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %120
115: ; preds = %111
%116 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%117 = load %struct.beri_debug*, %struct.beri_debug** %4
%118 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%119 = call i32 @berictl_lbu(%struct.beri_debug* %117, i8* %118)
store i32 %119, i32* %13
br label %291
120: ; preds = %111, %108
%121 = load i32, i32* %11
%122 = icmp eq i32 %121, 2
br i1 %122, label %123, label %132
123: ; preds = %120
%124 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%125 = call i64 @strcmp(i8* %124, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%126 = icmp eq i64 %125, 0
br i1 %126, label %127, label %132
127: ; preds = %123
%128 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
%129 = load %struct.beri_debug*, %struct.beri_debug** %4
%130 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%131 = call i32 @berictl_ld(%struct.beri_debug* %129, i8* %130)
store i32 %131, i32* %13
br label %290
132: ; preds = %123, %120
%133 = load i32, i32* %11
%134 = icmp eq i32 %133, 1
br i1 %134, label %135, label %143
135: ; preds = %132
%136 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%137 = call i64 @strcmp(i8* %136, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
%138 = icmp eq i64 %137, 0
br i1 %138, label %139, label %143
139: ; preds = %135
%140 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
%141 = load %struct.beri_debug*, %struct.beri_debug** %4
%142 = call i32 @berictl_pause(%struct.beri_debug* %141)
store i32 %142, i32* %13
br label %289
143: ; preds = %135, %132
%144 = load i32, i32* %11
%145 = icmp eq i32 %144, 1
br i1 %145, label %146, label %154
146: ; preds = %143
%147 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%148 = call i64 @strcmp(i8* %147, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%149 = icmp eq i64 %148, 0
br i1 %149, label %150, label %154
150: ; preds = %146
%151 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%152 = load %struct.beri_debug*, %struct.beri_debug** %4
%153 = call i32 @berictl_pc(%struct.beri_debug* %152)
store i32 %153, i32* %13
br label %288
154: ; preds = %146, %143
%155 = load i32, i32* %11
%156 = icmp eq i32 %155, 1
br i1 %156, label %157, label %165
157: ; preds = %154
%158 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%159 = call i64 @strcmp(i8* %158, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0))
%160 = icmp eq i64 %159, 0
br i1 %160, label %161, label %165
161: ; preds = %157
%162 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%163 = load %struct.beri_debug*, %struct.beri_debug** %4
%164 = call i32 @berictl_regs(%struct.beri_debug* %163)
store i32 %164, i32* %13
br label %287
165: ; preds = %157, %154
%166 = load i32, i32* %11
%167 = icmp eq i32 %166, 1
br i1 %167, label %168, label %176
168: ; preds = %165
%169 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%170 = call i64 @strcmp(i8* %169, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0))
%171 = icmp eq i64 %170, 0
br i1 %171, label %172, label %176
172: ; preds = %168
%173 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.21, i64 0, i64 0))
%174 = load %struct.beri_debug*, %struct.beri_debug** %4
%175 = call i32 @berictl_c2regs(%struct.beri_debug* %174)
store i32 %175, i32* %13
br label %286
176: ; preds = %168, %165
%177 = load i32, i32* %11
%178 = icmp eq i32 %177, 1
br i1 %178, label %179, label %187
179: ; preds = %176
%180 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%181 = call i64 @strcmp(i8* %180, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.22, i64 0, i64 0))
%182 = icmp eq i64 %181, 0
br i1 %182, label %183, label %187
183: ; preds = %179
%184 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0))
%185 = load %struct.beri_debug*, %struct.beri_debug** %4
%186 = call i32 @berictl_resume(%struct.beri_debug* %185)
store i32 %186, i32* %13
br label %285
187: ; preds = %179, %176
%188 = load i32, i32* %11
%189 = icmp eq i32 %188, 3
br i1 %189, label %190, label %200
190: ; preds = %187
%191 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%192 = call i64 @strcmp(i8* %191, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0))
%193 = icmp eq i64 %192, 0
br i1 %193, label %194, label %200
194: ; preds = %190
%195 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i64 0, i64 0))
%196 = load %struct.beri_debug*, %struct.beri_debug** %4
%197 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%198 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%199 = call i32 @berictl_sb(%struct.beri_debug* %196, i8* %197, i8* %198)
store i32 %199, i32* %13
br label %284
200: ; preds = %190, %187
%201 = load i32, i32* %11
%202 = icmp eq i32 %201, 3
br i1 %202, label %203, label %213
203: ; preds = %200
%204 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%205 = call i64 @strcmp(i8* %204, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.26, i64 0, i64 0))
%206 = icmp eq i64 %205, 0
br i1 %206, label %207, label %213
207: ; preds = %203
%208 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i64 0, i64 0))
%209 = load %struct.beri_debug*, %struct.beri_debug** %4
%210 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%211 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%212 = call i32 @berictl_sd(%struct.beri_debug* %209, i8* %210, i8* %211)
store i32 %212, i32* %13
br label %283
213: ; preds = %203, %200
%214 = load i32, i32* %11
%215 = icmp eq i32 %214, 2
br i1 %215, label %216, label %225
216: ; preds = %213
%217 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%218 = call i64 @strcmp(i8* %217, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.28, i64 0, i64 0))
%219 = icmp eq i64 %218, 0
br i1 %219, label %220, label %225
220: ; preds = %216
%221 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.29, i64 0, i64 0))
%222 = load %struct.beri_debug*, %struct.beri_debug** %4
%223 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%224 = call i32 @berictl_setpc(%struct.beri_debug* %222, i8* %223)
store i32 %224, i32* %13
br label %282
225: ; preds = %216, %213
%226 = load i32, i32* %11
%227 = icmp eq i32 %226, 3
br i1 %227, label %228, label %238
228: ; preds = %225
%229 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%230 = call i64 @strcmp(i8* %229, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.30, i64 0, i64 0))
%231 = icmp eq i64 %230, 0
br i1 %231, label %232, label %238
232: ; preds = %228
%233 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.31, i64 0, i64 0))
%234 = load %struct.beri_debug*, %struct.beri_debug** %4
%235 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%236 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%237 = call i32 @berictl_setreg(%struct.beri_debug* %234, i8* %235, i8* %236)
store i32 %237, i32* %13
br label %281
238: ; preds = %228, %225
%239 = load i32, i32* %11
%240 = icmp eq i32 %239, 1
br i1 %240, label %241, label %249
241: ; preds = %238
%242 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%243 = call i64 @strcmp(i8* %242, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.32, i64 0, i64 0))
%244 = icmp eq i64 %243, 0
br i1 %244, label %245, label %249
245: ; preds = %241
%246 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.33, i64 0, i64 0))
%247 = load %struct.beri_debug*, %struct.beri_debug** %4
%248 = call i32 @berictl_step(%struct.beri_debug* %247)
store i32 %248, i32* %13
br label %280
249: ; preds = %241, %238
%250 = load i32, i32* %11
%251 = icmp eq i32 %250, 1
br i1 %251, label %252, label %260
252: ; preds = %249
%253 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%254 = call i64 @strcmp(i8* %253, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.34, i64 0, i64 0))
%255 = icmp eq i64 %254, 0
br i1 %255, label %256, label %260
256: ; preds = %252
%257 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.35, i64 0, i64 0))
%258 = load %struct.beri_debug*, %struct.beri_debug** %4
%259 = call i32 @berictl_unpipeline(%struct.beri_debug* %258)
store i32 %259, i32* %13
br label %279
260: ; preds = %252, %249
%261 = load i32, i32* %11
%262 = icmp eq i32 %261, 2
br i1 %262, label %263, label %273
263: ; preds = %260
%264 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%265 = call i64 @strcmp(i8* %264, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.36, i64 0, i64 0))
%266 = icmp eq i64 %265, 0
br i1 %266, label %267, label %273
267: ; preds = %263
%268 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.37, i64 0, i64 0))
%269 = load %struct.beri_debug*, %struct.beri_debug** %4
%270 = call i32 @berictl_test_run(%struct.beri_debug* %269)
store i32 %270, i32* %13
%271 = load %struct.beri_debug*, %struct.beri_debug** %4
%272 = call i32 @berictl_test_report(%struct.beri_debug* %271)
store i32 %272, i32* %13
br label %278
273: ; preds = %263, %260
%274 = load i32, i32* @stderr
%275 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%276 = load i32, i32* %11
%277 = call i32 (i32, i8*, ...) @fprintf(i32 %274, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.38, i64 0, i64 0), i8* %275, i32 %276)
store i32 -1, i32* %13
br label %278
278: ; preds = %273, %267
br label %279
279: ; preds = %278, %256
br label %280
280: ; preds = %279, %245
br label %281
281: ; preds = %280, %232
br label %282
282: ; preds = %281, %220
br label %283
283: ; preds = %282, %207
br label %284
284: ; preds = %283, %194
br label %285
285: ; preds = %284, %183
br label %286
286: ; preds = %285, %172
br label %287
287: ; preds = %286, %161
br label %288
288: ; preds = %287, %150
br label %289
289: ; preds = %288, %139
br label %290
290: ; preds = %289, %127
br label %291
291: ; preds = %290, %115
br label %292
292: ; preds = %291, %104
br label %293
293: ; preds = %292, %93
br label %294
294: ; preds = %293, %81
%295 = load i32, i32* @stderr
%296 = call i32 (i32, i8*, ...) @fprintf(i32 %295, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.39, i64 0, i64 0))
%297 = call i32 @usleep(i32 200000)
br label %23
298: ; preds = %31, %23
%299 = load i32, i32* @stderr
%300 = call i32 (i32, i8*, ...) @fprintf(i32 %299, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.40, i64 0, i64 0))
%301 = load i32*, i32** %6
%302 = call i32 @fclose(i32* %301)
%303 = load i32, i32* %13
store i32 %303, i32* %3
br label %304
304: ; preds = %298, %18
%305 = load i32, i32* %3
ret i32 %305
}

LLVM IR (-O2):
%struct.beri_debug = type { i32 }
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [36 x i8] c"Cannot open control command file %s\00"
@.str.2 = [9 x i8] c"%s %s %s\00"
@.str.3 = [40 x i8] c"%s => len (cmd,op1,op2): %d (%s,%s,%s)\0A\00"
@.str.4 = [11 x i8] c"breakpoint\00"
@.str.5 = [12 x i8] c"breakpoint!\00"
@.str.6 = [8 x i8] c"console\00"
@.str.7 = [9 x i8] c"console!\00"
@.str.8 = [7 x i8] c"c0regs\00"
@.str.9 = [8 x i8] c"c0regs!\00"
@.str.10 = [4 x i8] c"lbu\00"
@.str.11 = [5 x i8] c"lbu!\00"
@.str.12 = [3 x i8] c"ld\00"
@.str.13 = [4 x i8] c"ld!\00"
@.str.14 = [6 x i8] c"pause\00"
@.str.15 = [7 x i8] c"pause!\00"
@.str.16 = [3 x i8] c"pc\00"
@.str.17 = [4 x i8] c"pc!\00"
@.str.18 = [5 x i8] c"regs\00"
@.str.19 = [6 x i8] c"regs!\00"
@.str.20 = [7 x i8] c"c2regs\00"
@.str.21 = [8 x i8] c"c2regs!\00"
@.str.22 = [7 x i8] c"resume\00"
@.str.23 = [8 x i8] c"resume!\00"
@.str.24 = [3 x i8] c"sb\00"
@.str.25 = [4 x i8] c"sb!\00"
@.str.26 = [3 x i8] c"sd\00"
@.str.27 = [4 x i8] c"sd!\00"
@.str.28 = [6 x i8] c"setpc\00"
@.str.29 = [7 x i8] c"setpc!\00"
@.str.30 = [7 x i8] c"setreg\00"
@.str.31 = [8 x i8] c"setreg!\00"
@.str.32 = [5 x i8] c"step\00"
@.str.33 = [6 x i8] c"step!\00"
@.str.34 = [11 x i8] c"unpipeline\00"
@.str.35 = [12 x i8] c"unpipeline!\00"
@.str.36 = [5 x i8] c"test\00"
@.str.37 = [6 x i8] c"test?\00"
@.str.38 = [34 x i8] c"Unrecognized Command: %s (len %d)\00"
@.str.39 = [20 x i8] c"Finished operation\0A\00"
@.str.40 = [7 x i8] c"Done!\0A\00"
define i32 @berictl_docontrol(%struct.beri_debug* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = alloca [128 x i8]
%5 = alloca [128 x i8]
%6 = alloca [128 x i8]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%11 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = call i32 @feof(i32* %11)
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %154
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %159
19: ; preds = %13, %30
%20 = phi i64 [ %31, %30 ], [ 0, %13 ]
%21 = call signext i8 @fgetc(i32* %11)
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %20
store i8 %21, i8* %22
%23 = icmp eq i8 %21, 10
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = and i64 %20, 4294967295
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %25
store i8 0, i8* %26
br label %32
27: ; preds = %19
%28 = add nuw nsw i64 %20, 1
%29 = icmp eq i64 %28, 1025
br i1 %29, label %32, label %30
30: ; preds = %27, %145
%31 = phi i64 [ %28, %27 ], [ 0, %145 ]
br label %19
32: ; preds = %27, %24
%33 = call i32 @memset(i8* %8, i32 0, i32 128)
%34 = call i32 @memset(i8* %9, i32 0, i32 128)
%35 = call i32 @memset(i8* %10, i32 0, i32 128)
%36 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %9, i8* %10)
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %7, i32 %36, i8* %8, i8* %9, i8* %10)
switch i32 %36, label %142 [
i32 2, label %39
i32 1, label %51
i32 3, label %99
]
39: ; preds = %32
%40 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
%44 = call i32 @berictl_breakpoint(%struct.beri_debug* %0, i8* %9, i32 0)
br label %145
45: ; preds = %39
%46 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %57
48: ; preds = %45
%49 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%50 = call i32 @berictl_console(i32* null, i8* %9, i32* null, i32* null)
br label %145
51: ; preds = %32
%52 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %69
54: ; preds = %51
%55 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%56 = call i32 @berictl_c0regs(%struct.beri_debug* %0)
br label %145
57: ; preds = %45
%58 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%62 = call i32 @berictl_lbu(%struct.beri_debug* %0, i8* %9)
br label %145
63: ; preds = %57
%64 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %111
66: ; preds = %63
%67 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
%68 = call i32 @berictl_ld(%struct.beri_debug* %0, i8* %9)
br label %145
69: ; preds = %51
%70 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %69
%73 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
%74 = call i32 @berictl_pause(%struct.beri_debug* %0)
br label %145
75: ; preds = %69
%76 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %75
%79 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i64 0, i64 0))
%80 = call i32 @berictl_pc(%struct.beri_debug* %0)
br label %145
81: ; preds = %75
%82 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0))
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %81
%85 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%86 = call i32 @berictl_regs(%struct.beri_debug* %0)
br label %145
87: ; preds = %81
%88 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.21, i64 0, i64 0))
%92 = call i32 @berictl_c2regs(%struct.beri_debug* %0)
br label %145
93: ; preds = %87
%94 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.22, i64 0, i64 0))
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %123
96: ; preds = %93
%97 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0))
%98 = call i32 @berictl_resume(%struct.beri_debug* %0)
br label %145
99: ; preds = %32
%100 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.24, i64 0, i64 0))
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %99
%103 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i64 0, i64 0))
%104 = call i32 @berictl_sb(%struct.beri_debug* %0, i8* %9, i8* %10)
br label %145
105: ; preds = %99
%106 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.26, i64 0, i64 0))
%107 = icmp eq i64 %106, 0
br i1 %107, label %108, label %117
108: ; preds = %105
%109 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i64 0, i64 0))
%110 = call i32 @berictl_sd(%struct.beri_debug* %0, i8* %9, i8* %10)
br label %145
111: ; preds = %63
%112 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.28, i64 0, i64 0))
%113 = icmp eq i64 %112, 0
br i1 %113, label %114, label %135
114: ; preds = %111
%115 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.29, i64 0, i64 0))
%116 = call i32 @berictl_setpc(%struct.beri_debug* %0, i8* %9)
br label %145
117: ; preds = %105
%118 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.30, i64 0, i64 0))
%119 = icmp eq i64 %118, 0
br i1 %119, label %120, label %142
120: ; preds = %117
%121 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.31, i64 0, i64 0))
%122 = call i32 @berictl_setreg(%struct.beri_debug* %0, i8* %9, i8* %10)
br label %145
123: ; preds = %93
%124 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.32, i64 0, i64 0))
%125 = icmp eq i64 %124, 0
br i1 %125, label %126, label %129
126: ; preds = %123
%127 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.33, i64 0, i64 0))
%128 = call i32 @berictl_step(%struct.beri_debug* %0)
br label %145
129: ; preds = %123
%130 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.34, i64 0, i64 0))
%131 = icmp eq i64 %130, 0
br i1 %131, label %132, label %142
132: ; preds = %129
%133 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.35, i64 0, i64 0))
%134 = call i32 @berictl_unpipeline(%struct.beri_debug* %0)
br label %145
135: ; preds = %111
%136 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.36, i64 0, i64 0))
%137 = icmp eq i64 %136, 0
br i1 %137, label %138, label %142
138: ; preds = %135
%139 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.37, i64 0, i64 0))
%140 = call i32 @berictl_test_run(%struct.beri_debug* %0)
%141 = call i32 @berictl_test_report(%struct.beri_debug* %0)
br label %145
142: ; preds = %32, %129, %117, %135
%143 = load i32, i32* @stderr
%144 = call i32 (i32, i8*, ...) @fprintf(i32 %143, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.38, i64 0, i64 0), i8* %8, i32 %36)
br label %145
145: ; preds = %48, %60, %72, %84, %96, %108, %120, %132, %142, %138, %126, %114, %102, %90, %78, %66, %54, %42
%146 = phi i32 [ %44, %42 ], [ %50, %48 ], [ %56, %54 ], [ %62, %60 ], [ %68, %66 ], [ %74, %72 ], [ %80, %78 ], [ %86, %84 ], [ %92, %90 ], [ %98, %96 ], [ %104, %102 ], [ %110, %108 ], [ %116, %114 ], [ %122, %120 ], [ %128, %126 ], [ %134, %132 ], [ %141, %138 ], [ -1, %142 ]
%147 = load i32, i32* @stderr
%148 = call i32 (i32, i8*, ...) @fprintf(i32 %147, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.39, i64 0, i64 0))
%149 = call i32 @usleep(i32 200000)
%150 = call i32 @feof(i32* %11)
%151 = icmp ne i32 %150, 0
%152 = icmp ne i32 %146, 0
%153 = select i1 %151, i1 true, i1 %152
br i1 %153, label %154, label %30
154: ; preds = %145, %13
%155 = phi i32 [ 0, %13 ], [ %146, %145 ]
%156 = load i32, i32* @stderr
%157 = call i32 (i32, i8*, ...) @fprintf(i32 %156, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.40, i64 0, i64 0))
%158 = call i32 @fclose(i32* %11)
br label %159
159: ; preds = %154, %16
%160 = phi i32 [ -1, %16 ], [ %155, %154 ]
ret i32 %160
}