#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 */
int /*<<< orphan*/ B115200;
int O_NOCTTY;
int O_RDWR;
int O_SYNC;
int errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(char *, int, int, int /*<<< orphan*/ *);
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int read(int, char *, int);
int /*<<< orphan*/ set_interface_attribs(int, int /*<<< orphan*/,
                                         int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
char *strerror(int);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  int n, tty, i;
  FILE *fw;
  char *portname = "/dev/ttyUSB0";
  char *rom_msg = "KPU ROM waiting for firmware...";
  char ch;
  char buf[100];
  if (argc > 1)
    portname = argv[1];
  tty = open(portname, O_RDWR | O_NOCTTY | O_SYNC);
  fw = stdin;
  if (tty < 0) {
    fprintf(stderr, " error %d opening %s: %s", errno, portname,
            strerror(errno));
    return -1;
  }
  if (!fw) {
    fprintf(stderr, "Could not find firmware image\n");
    return -1;
  }
  set_interface_attribs(tty, B115200, 0);
  n = read(tty, buf, 31);
  buf[32] = '0';
  printf("ROM msg: %s", buf);
  if (strcmp(buf, rom_msg)) {
    fprintf(stderr, "ROM init message mismatch\n");
    return -1;
  }
  printf("\nUploading firmware...\n");
  for (i = 0; i < (1024 << 2); i++) {
    n = fread(buf, 1, 1, fw);
    if (n != 1)
      buf[0] = 0;
    write(tty, buf, 1);
    read(tty, &ch, 1);
    if (ch != buf[0]) {
      fprintf(stderr, "Data mismatch\n");
      return -1;
    }
    if (!(i % 32)) {
      printf("Sent %d%%\r", 100 * i / (1024 << 2));
      fflush(stdout);
    }
  }
  printf("Sent 100%%\nROM msg: ");
  while (1) {
    n = read(tty, buf, 1);
    putchar(buf[0]);
    fflush(stdout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe30(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe32(%rip),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11f5 <main+0x45>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2de8(%rip),%rax
mov    (%rax),%esi
mov    0x2dbf(%rip),%rax
or     (%rax),%esi
mov    0x2dce(%rip),%rax
or     (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x18(%rbp)
mov    0x2db5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    129b <main+0xeb>
mov    0x2d85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb0(%rbp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0xb0(%rbp),%edi
mov    -0xac(%rbp),%edx
mov    -0xa8(%rbp),%rcx
mov    %rax,%r8
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1486 <main+0x2d6>
cmpq   $0x0,-0x28(%rbp)
jne    12c9 <main+0x119>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
lea    0xd90(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1486 <main+0x2d6>
mov    -0x18(%rbp),%edi
mov    0x2cd5(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <set_interface_attribs@plt>
mov    -0x18(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x1f,%edx
call   1080 <read@plt>
mov    %eax,-0x14(%rbp)
movb   $0x30,-0x80(%rbp)
lea    -0xa0(%rbp),%rsi
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     1349 <main+0x199>
mov    0x2c93(%rip),%rax
mov    (%rax),%edi
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1486 <main+0x2d6>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1000,-0x1c(%rbp)
jge    1442 <main+0x292>
lea    -0xa0(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     1396 <main+0x1e6>
movb   $0x0,-0xa0(%rbp)
mov    -0x18(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    -0x18(%rbp),%edi
lea    -0x39(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
movsbl -0x39(%rbp),%eax
movsbl -0xa0(%rbp),%ecx
cmp    %ecx,%eax
je     13f1 <main+0x241>
mov    0x2beb(%rip),%rax
mov    (%rax),%edi
lea    0xcc6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1486 <main+0x2d6>
mov    -0x1c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    142f <main+0x27f>
imul   $0x64,-0x1c(%rbp),%eax
mov    $0x1000,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xc99(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2b88(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    1434 <main+0x284>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    135e <main+0x1ae>
lea    0xc75(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    %eax,-0x14(%rbp)
movsbl -0xa0(%rbp),%edi
call   1030 <putchar@plt>
mov    0x2b36(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    1450 <main+0x2a0>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
cmp    $0x2,%edi
jl     11d9 <main+0x19>
mov    0x8(%rsi),%r14
jmp    11e0 <main+0x20>
lea    0xe20(%rip),%r14
mov    0x2e01(%rip),%rax
mov    0x2dda(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2de7(%rip),%rax
or     (%rax),%esi
mov    %r14,%rdi
call   10d0 <open@plt>
test   %eax,%eax
js     1281 <main+0xc1>
mov    %eax,%ebp
mov    0x2dc8(%rip),%rax
mov    (%rax),%r14
test   %r14,%r14
je     12b7 <main+0xf7>
mov    0x2d85(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %edx,%edx
call   1070 <set_interface_attribs@plt>
lea    0x10(%rsp),%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1f,%edx
call   1090 <read@plt>
movb   $0x30,0x30(%rsp)
lea    0xe17(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdae(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12cc <main+0x10c>
mov    0x2d4d(%rip),%rax
mov    (%rax),%edi
lea    0xdf5(%rip),%rsi
jmp    13b4 <main+0x1f4>
mov    0x2d38(%rip),%rax
mov    (%rax),%ebx
mov    0x2d27(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10e0 <strerror@plt>
lea    0xd8c(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    13bb <main+0x1fb>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
lea    0xd7f(%rip),%rsi
jmp    13b4 <main+0x1f4>
lea    0xde8(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%r15
mov    0x2ccc(%rip),%r13
xor    %ebx,%ebx
xor    %r12d,%r12d
jmp    12ff <main+0x13f>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12d
add    $0x64,%ebx
cmp    $0x64000,%ebx
je     136d <main+0x1ad>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fread@plt>
cmp    $0x1,%eax
je     131e <main+0x15e>
movb   $0x0,0x10(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1060 <write@plt>
mov    %ebp,%edi
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
movzbl 0xf(%rsp),%eax
cmp    0x10(%rsp),%al
jne    13a4 <main+0x1e4>
test   $0x1f,%r12b
jne    12f0 <main+0x130>
mov    %ebx,%esi
shr    $0xc,%esi
lea    0xd40(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x0(%r13),%edi
call   10c0 <fflush@plt>
jmp    12f0 <main+0x130>
lea    0xd32(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
movsbl 0x10(%rsp),%edi
call   1030 <putchar@plt>
mov    0x0(%r13),%edi
call   10c0 <fflush@plt>
jmp    1380 <main+0x1c0>
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
lea    0xcd8(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/ttyUSB0\00"
@.str.1 = [32 x i8] c"KPU ROM waiting for firmware...\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_SYNC = global i32 0
@stdin = global i32* null
@stderr = global i32 0
@.str.2 = [25 x i8] c" error %d opening %s: %s\00"
@errno = global i32 0
@.str.3 = [31 x i8] c"Could not find firmware image\0A\00"
@B115200 = global i32 0
@.str.4 = [12 x i8] c"ROM msg: %s\00"
@.str.5 = [27 x i8] c"ROM init message mismatch\0A\00"
@.str.6 = [24 x i8] c"\0AUploading firmware...\0A\00"
@.str.7 = [15 x i8] c"Data mismatch\0A\00"
@.str.8 = [11 x i8] c"Sent %d%%\0D\00"
@stdout = global i32 0
@.str.9 = [21 x i8] c"Sent 100%%\0AROM msg: \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 i8*
%12 = alloca i8
%13 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %10
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8** %11
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %10
br label %20
20: ; preds = %16, %2
%21 = load i8*, i8** %10
%22 = load i32, i32* @O_RDWR
%23 = load i32, i32* @O_NOCTTY
%24 = or i32 %22, %23
%25 = load i32, i32* @O_SYNC
%26 = or i32 %24, %25
%27 = call i32 @open(i8* %21, i32 %26)
store i32 %27, i32* %7
%28 = load i32*, i32** @stdin
store i32* %28, i32** %9
%29 = load i32, i32* %7
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %38
31: ; preds = %20
%32 = load i32, i32* @stderr
%33 = load i32, i32* @errno
%34 = load i8*, i8** %10
%35 = load i32, i32* @errno
%36 = call i8* @strerror(i32 %35)
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %33, i8* %34, i8* %36)
store i32 -1, i32* %3
br label %115
38: ; preds = %20
%39 = load i32*, i32** %9
%40 = icmp ne i32* %39, null
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %115
44: ; preds = %38
%45 = load i32, i32* %7
%46 = load i32, i32* @B115200
%47 = call i32 @set_interface_attribs(i32 %45, i32 %46, i32 0)
%48 = load i32, i32* %7
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%50 = call i32 @read(i32 %48, i8* %49, i32 31)
store i32 %50, i32* %6
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 32
store i8 48, i8* %51
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %52)
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%55 = load i8*, i8** %11
%56 = call i64 @strcmp(i8* %54, i8* %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %44
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %115
61: ; preds = %44
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %8
br label %63
63: ; preds = %101, %61
%64 = load i32, i32* %8
%65 = icmp slt i32 %64, 4096
br i1 %65, label %66, label %104
66: ; preds = %63
%67 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%68 = load i32*, i32** %9
%69 = call i32 @fread(i8* %67, i32 1, i32 1, i32* %68)
store i32 %69, i32* %6
%70 = load i32, i32* %6
%71 = icmp ne i32 %70, 1
br i1 %71, label %72, label %74
72: ; preds = %66
%73 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
store i8 0, i8* %73
br label %74
74: ; preds = %72, %66
%75 = load i32, i32* %7
%76 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%77 = call i32 @write(i32 %75, i8* %76, i32 1)
%78 = load i32, i32* %7
%79 = call i32 @read(i32 %78, i8* %12, i32 1)
%80 = load i8, i8* %12
%81 = sext i8 %80 to i32
%82 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp ne i32 %81, %84
br i1 %85, label %86, label %89
86: ; preds = %74
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %115
89: ; preds = %74
%90 = load i32, i32* %8
%91 = srem i32 %90, 32
%92 = icmp ne i32 %91, 0
br i1 %92, label %100, label %93
93: ; preds = %89
%94 = load i32, i32* %8
%95 = mul nsw i32 100, %94
%96 = sdiv i32 %95, 4096
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %96)
%98 = load i32, i32* @stdout
%99 = call i32 @fflush(i32 %98)
br label %100
100: ; preds = %93, %89
br label %101
101: ; preds = %100
%102 = load i32, i32* %8
%103 = add nsw i32 %102, 1
store i32 %103, i32* %8
br label %63
104: ; preds = %63
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
br label %106
106: ; preds = %104, %106
%107 = load i32, i32* %7
%108 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%109 = call i32 @read(i32 %107, i8* %108, i32 1)
store i32 %109, i32* %6
%110 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%111 = load i8, i8* %110
%112 = call i32 @putchar(i8 signext %111)
%113 = load i32, i32* @stdout
%114 = call i32 @fflush(i32 %113)
br label %106
115: ; preds = %86, %58, %41, %31
%116 = load i32, i32* %3
ret i32 %116
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/ttyUSB0\00"
@.str.1 = [32 x i8] c"KPU ROM waiting for firmware...\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_SYNC = global i32 0
@stdin = global i32* null
@stderr = global i32 0
@.str.2 = [25 x i8] c" error %d opening %s: %s\00"
@errno = global i32 0
@.str.3 = [31 x i8] c"Could not find firmware image\0A\00"
@B115200 = global i32 0
@.str.4 = [12 x i8] c"ROM msg: %s\00"
@.str.5 = [27 x i8] c"ROM init message mismatch\0A\00"
@.str.7 = [15 x i8] c"Data mismatch\0A\00"
@.str.8 = [11 x i8] c"Sent %d%%\0D\00"
@stdout = global i32 0
@.str.9 = [21 x i8] c"Sent 100%%\0AROM msg: \00"
@str = [23 x i8] c"\0AUploading firmware...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
br label %10
10: ; preds = %7, %2
%11 = phi i8* [ %9, %7 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %2 ]
%12 = load i32, i32* @O_RDWR
%13 = load i32, i32* @O_NOCTTY
%14 = or i32 %13, %12
%15 = load i32, i32* @O_SYNC
%16 = or i32 %14, %15
%17 = tail call i32 @open(i8* %11, i32 %16)
%18 = load i32*, i32** @stdin
%19 = icmp slt i32 %17, 0
br i1 %19, label %20, label %25
20: ; preds = %10
%21 = load i32, i32* @stderr
%22 = load i32, i32* @errno
%23 = tail call i8* @strerror(i32 %22)
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %22, i8* %11, i8* %23)
br label %77
25: ; preds = %10
%26 = icmp eq i32* %18, null
br i1 %26, label %27, label %30
27: ; preds = %25
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %77
30: ; preds = %25
%31 = load i32, i32* @B115200
%32 = tail call i32 @set_interface_attribs(i32 %17, i32 %31, i32 0)
%33 = call i32 @read(i32 %17, i8* %5, i32 31)
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 32
store i8 48, i8* %34
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%36 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %30
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %77
41: ; preds = %30
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %43
43: ; preds = %41, %66
%44 = phi i32 [ 0, %41 ], [ %67, %66 ]
%45 = call i32 @fread(i8* %5, i32 1, i32 1, i32* %18)
%46 = icmp eq i32 %45, 1
br i1 %46, label %48, label %47
47: ; preds = %43
store i8 0, i8* %5
br label %48
48: ; preds = %47, %43
%49 = call i32 @write(i32 %17, i8* %5, i32 1)
%50 = call i32 @read(i32 %17, i8* %3, i32 1)
%51 = load i8, i8* %3
%52 = load i8, i8* %5
%53 = icmp eq i8 %51, %52
br i1 %53, label %57, label %54
54: ; preds = %48
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %77
57: ; preds = %48
%58 = and i32 %44, 31
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %66
60: ; preds = %57
%61 = mul nuw nsw i32 %44, 100
%62 = lshr i32 %61, 12
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %62)
%64 = load i32, i32* @stdout
%65 = call i32 @fflush(i32 %64)
br label %66
66: ; preds = %57, %60
%67 = add nuw nsw i32 %44, 1
%68 = icmp eq i32 %67, 4096
br i1 %68, label %69, label %43
69: ; preds = %66
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
br label %71
71: ; preds = %71, %69
%72 = call i32 @read(i32 %17, i8* %5, i32 1)
%73 = load i8, i8* %5
%74 = call i32 @putchar(i8 signext %73)
%75 = load i32, i32* @stdout
%76 = call i32 @fflush(i32 %75)
br label %71
77: ; preds = %54, %38, %27, %20
ret i32 -1
}