#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ perror(char *);
int power_up_iso(int, char *);
int /*<<< orphan*/ printf(char *, ...);
int read_binary(int, int /*<<< orphan*/, int, char *);
scalar_t__ select_file(int, int);
scalar_t__ send_num_mask(int, char *);
int /*<<< orphan*/ serial_deinit(int);
int serial_init(char *);
scalar_t__ update_binary(int, int, int, char *);
int main() {
  int fd, atrlen, i, j, len;
  char mask[100], atr[100], data[100];
  fd = serial_init("/dev/smartpoll");
  if (send_num_mask(fd, mask) < 0) {
    perror("send_num_mask failed");
    return -1;
  }
  printf("Mask is : %s\n", mask);
  if ((atrlen = power_up_iso(fd, atr)) < 0) {
    perror("power_up_iso failed");
    return -1;
  }
  printf("ATR: ");
  for (i = 0; i < atrlen; i++)
    printf("%x ", (unsigned char)atr[i]);
  printf("\n");
  if (select_file(fd, 0x5f00) < 0) {
    printf("Select file failed\n");
    return -1;
  }
  printf("Selected file 0x5f00\n");
  if ((len = read_binary(fd, 0, 50, data)) < 0) {
    printf("read_binary failed\n");
    return -1;
  }
  printf("Data (b4 write): ");
  for (i = 0; i < len; i++)
    printf("%x ", (unsigned char)data[i]);
  printf("\n");
  memset(data, 0x05, 10);
  if (update_binary(fd, 0x14, 10, data) < 0)
    return -1;
  printf("Wrote to file 0x5f00\n");
  if ((len = read_binary(fd, 0, 50, data)) < 0)
    return -1;
  printf("Data (after write): ");
  for (i = 0; i < len; i++)
    printf("%x ", (unsigned char)data[i]);
  printf("\n");
  serial_deinit(fd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe47(%rip),%rdi
call   10c0 <serial_init@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x80(%rbp),%rsi
call   1070 <send_num_mask@plt>
cmp    $0x0,%rax
jge    11ef <main+0x4f>
lea    0xe31(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143d <main+0x29d>
lea    -0x80(%rbp),%rsi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0xf0(%rbp),%rsi
call   1060 <power_up_iso@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    1234 <main+0x94>
lea    0xe0f(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143d <main+0x29d>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    127d <main+0xdd>
movslq -0x10(%rbp),%rax
movzbl -0xf0(%rbp,%rax,1),%esi
ff
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1249 <main+0xa9>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0x5f00,%esi
call   1080 <select_file@plt>
cmp    $0x0,%rax
jge    12bc <main+0x11c>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143d <main+0x29d>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0x160(%rbp),%rcx
xor    %esi,%esi
mov    $0x32,%edx
call   1030 <read_binary@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1306 <main+0x166>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    143d <main+0x29d>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    134f <main+0x1af>
movslq -0x10(%rbp),%rax
movzbl -0x160(%rbp,%rax,1),%esi
ff
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    131b <main+0x17b>
lea    0xd22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x160(%rbp),%rdi
mov    $0x5,%esi
mov    $0xa,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%edi
lea    -0x160(%rbp),%rcx
mov    $0x14,%esi
mov    $0xa,%edx
call   10b0 <update_binary@plt>
cmp    $0x0,%rax
jge    13a2 <main+0x202>
movl   $0xffffffff,-0x4(%rbp)
jmp    143d <main+0x29d>
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
lea    -0x160(%rbp),%rcx
xor    %esi,%esi
mov    $0x32,%edx
call   1030 <read_binary@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    13de <main+0x23e>
movl   $0xffffffff,-0x4(%rbp)
jmp    143d <main+0x29d>
lea    0xcd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1427 <main+0x287>
movslq -0x10(%rbp),%rax
movzbl -0x160(%rbp,%rax,1),%esi
ff
lea    0xc3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    13f3 <main+0x253>
lea    0xc4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1090 <serial_deinit@plt>
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x150,%rsp
lea    0xe2a(%rip),%rdi
call   10e0 <serial_init@plt>
mov    %eax,%r12d
lea    0xe0(%rsp),%rsi
mov    %eax,%edi
call   1090 <send_num_mask@plt>
test   %rax,%rax
js     13c9 <main+0x209>
lea    0xe27(%rip),%rdi
lea    0xe0(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x70(%rsp),%rsi
mov    %r12d,%edi
call   1080 <power_up_iso@plt>
test   %eax,%eax
js     13d2 <main+0x212>
mov    %eax,%ebp
lea    0xe1c(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebp,%ebp
je     1258 <main+0x98>
mov    %ebp,%ebx
lea    0xe0e(%rip),%r14
xor    %ebp,%ebp
movzbl 0x70(%rsp,%rbp,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1240 <main+0x80>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r12d,%edi
mov    $0x5f00,%esi
call   10a0 <select_file@plt>
test   %rax,%rax
js     139b <main+0x1db>
lea    0xdf8(%rip),%rdi
call   1050 <puts@plt>
mov    %rsp,%rcx
mov    %r12d,%edi
xor    %esi,%esi
mov    $0x32,%edx
call   1030 <read_binary@plt>
test   %eax,%eax
js     13a4 <main+0x1e4>
mov    %eax,%ebp
lea    0xda9(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %ebp,%ebp
je     12d7 <main+0x117>
mov    %ebp,%ebx
lea    0xd91(%rip),%r14
xor    %ebp,%ebp
nopl   (%rax)
movzbl (%rsp,%rbp,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    12c0 <main+0x100>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x5,%esi
mov    $0xa,%edx
call   1070 <memset@plt>
mov    %r12d,%edi
mov    $0x14,%esi
mov    $0xa,%edx
mov    %rbp,%rcx
call   10d0 <update_binary@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
js     13b6 <main+0x1f6>
lea    0xd6b(%rip),%rdi
call   1050 <puts@plt>
mov    %rsp,%rcx
mov    %r12d,%edi
xor    %esi,%esi
mov    $0x32,%edx
call   1030 <read_binary@plt>
test   %eax,%eax
js     13b6 <main+0x1f6>
mov    %eax,%r14d
lea    0xd1c(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1060 <printf@plt>
test   %r14d,%r14d
je     1387 <main+0x1c7>
mov    %r14d,%ebx
lea    0xced(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rsp,%rbp,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1370 <main+0x1b0>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r12d,%edi
call   10b0 <serial_deinit@plt>
jmp    13b6 <main+0x1f6>
lea    0xd12(%rip),%rdi
jmp    13ab <main+0x1eb>
lea    0xcf6(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x150,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc3f(%rip),%rdi
jmp    13d9 <main+0x219>
lea    0xc59(%rip),%rdi
call   10c0 <perror@plt>
jmp    13b0 <main+0x1f0>

LLVM IR (-O0):
@.str = [15 x i8] c"/dev/smartpoll\00"
@.str.1 = [21 x i8] c"send_num_mask failed\00"
@.str.2 = [14 x i8] c"Mask is : %s\0A\00"
@.str.3 = [20 x i8] c"power_up_iso failed\00"
@.str.4 = [6 x i8] c"ATR: \00"
@.str.5 = [4 x i8] c"%x \00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [20 x i8] c"Select file failed\0A\00"
@.str.8 = [22 x i8] c"Selected file 0x5f00\0A\00"
@.str.9 = [20 x i8] c"read_binary failed\0A\00"
@.str.10 = [18 x i8] c"Data (b4 write): \00"
@.str.11 = [22 x i8] c"Wrote to file 0x5f00\0A\00"
@.str.12 = [21 x i8] c"Data (after write): \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca [100 x i8]
store i32 0, i32* %1
%10 = call i32 @serial_init(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%13 = call i64 @send_num_mask(i32 %11, i8* %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %109
17: ; preds = %0
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %2
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%22 = call i32 @power_up_iso(i32 %20, i8* %21)
store i32 %22, i32* %3
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %109
26: ; preds = %17
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %28
28: ; preds = %39, %26
%29 = load i32, i32* %4
%30 = load i32, i32* %3
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %28
42: ; preds = %28
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%44 = load i32, i32* %2
%45 = call i64 @select_file(i32 %44, i32 24320)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %42
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %1
br label %109
49: ; preds = %42
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%51 = load i32, i32* %2
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%53 = call i32 @read_binary(i32 %51, i32 0, i32 50, i8* %52)
store i32 %53, i32* %6
%54 = icmp slt i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %49
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
store i32 -1, i32* %1
br label %109
57: ; preds = %49
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %4
br label %59
59: ; preds = %70, %57
%60 = load i32, i32* %4
%61 = load i32, i32* %6
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %73
63: ; preds = %59
%64 = load i32, i32* %4
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %63
%71 = load i32, i32* %4
%72 = add nsw i32 %71, 1
store i32 %72, i32* %4
br label %59
73: ; preds = %59
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%75 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%76 = call i32 @memset(i8* %75, i32 5, i32 10)
%77 = load i32, i32* %2
%78 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%79 = call i64 @update_binary(i32 %77, i32 20, i32 10, i8* %78)
%80 = icmp slt i64 %79, 0
br i1 %80, label %81, label %82
81: ; preds = %73
store i32 -1, i32* %1
br label %109
82: ; preds = %73
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
%84 = load i32, i32* %2
%85 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%86 = call i32 @read_binary(i32 %84, i32 0, i32 50, i8* %85)
store i32 %86, i32* %6
%87 = icmp slt i32 %86, 0
br i1 %87, label %88, label %89
88: ; preds = %82
store i32 -1, i32* %1
br label %109
89: ; preds = %82
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %4
br label %91
91: ; preds = %102, %89
%92 = load i32, i32* %4
%93 = load i32, i32* %6
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %105
95: ; preds = %91
%96 = load i32, i32* %4
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %97
%99 = load i8, i8* %98
%100 = zext i8 %99 to i32
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %100)
br label %102
102: ; preds = %95
%103 = load i32, i32* %4
%104 = add nsw i32 %103, 1
store i32 %104, i32* %4
br label %91
105: ; preds = %91
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%107 = load i32, i32* %2
%108 = call i32 @serial_deinit(i32 %107)
br label %109
109: ; preds = %105, %88, %81, %55, %47, %24, %15
%110 = load i32, i32* %1
ret i32 %110
}

LLVM IR (-O2):
@.str = [15 x i8] c"/dev/smartpoll\00"
@.str.1 = [21 x i8] c"send_num_mask failed\00"
@.str.2 = [14 x i8] c"Mask is : %s\0A\00"
@.str.3 = [20 x i8] c"power_up_iso failed\00"
@.str.4 = [6 x i8] c"ATR: \00"
@.str.5 = [4 x i8] c"%x \00"
@.str.10 = [18 x i8] c"Data (b4 write): \00"
@.str.12 = [21 x i8] c"Data (after write): \00"
@str = [21 x i8] c"Selected file 0x5f00\00"
@str.13 = [21 x i8] c"Wrote to file 0x5f00\00"
@str.14 = [19 x i8] c"read_binary failed\00"
@str.15 = [19 x i8] c"Select file failed\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @serial_init(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%8 = call i64 @send_num_mask(i32 %7, i8* %4)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %81
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%14 = call i32 @power_up_iso(i32 %7, i8* %5)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %81
18: ; preds = %12
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp eq i32 %14, 0
br i1 %20, label %31, label %21
21: ; preds = %18
%22 = zext i32 %14 to i64
br label %23
23: ; preds = %21, %23
%24 = phi i64 [ 0, %21 ], [ %29, %23 ]
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = add nuw nsw i64 %24, 1
%30 = icmp eq i64 %29, %22
br i1 %30, label %31, label %23
31: ; preds = %23, %18
%32 = call i32 @putchar(i32 10)
%33 = call i64 @select_file(i32 %7, i32 24320)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.15, i64 0, i64 0))
br label %81
37: ; preds = %31
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%39 = call i32 @read_binary(i32 %7, i32 0, i32 50, i8* %6)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.14, i64 0, i64 0))
br label %81
43: ; preds = %37
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%45 = icmp eq i32 %39, 0
br i1 %45, label %56, label %46
46: ; preds = %43
%47 = zext i32 %39 to i64
br label %48
48: ; preds = %46, %48
%49 = phi i64 [ 0, %46 ], [ %54, %48 ]
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %52)
%54 = add nuw nsw i64 %49, 1
%55 = icmp eq i64 %54, %47
br i1 %55, label %56, label %48
56: ; preds = %48, %43
%57 = call i32 @putchar(i32 10)
%58 = call i32 @memset(i8* %6, i32 5, i32 10)
%59 = call i64 @update_binary(i32 %7, i32 20, i32 10, i8* %6)
%60 = icmp slt i64 %59, 0
br i1 %60, label %81, label %61
61: ; preds = %56
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.13, i64 0, i64 0))
%63 = call i32 @read_binary(i32 %7, i32 0, i32 50, i8* %6)
%64 = icmp slt i32 %63, 0
br i1 %64, label %81, label %65
65: ; preds = %61
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
%67 = icmp eq i32 %63, 0
br i1 %67, label %78, label %68
68: ; preds = %65
%69 = zext i32 %63 to i64
br label %70
70: ; preds = %68, %70
%71 = phi i64 [ 0, %68 ], [ %76, %70 ]
%72 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %71
%73 = load i8, i8* %72
%74 = zext i8 %73 to i32
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %74)
%76 = add nuw nsw i64 %71, 1
%77 = icmp eq i64 %76, %69
br i1 %77, label %78, label %70
78: ; preds = %70, %65
%79 = call i32 @putchar(i32 10)
%80 = call i32 @serial_deinit(i32 %7)
br label %81
81: ; preds = %61, %56, %78, %41, %35, %16, %10
%82 = phi i32 [ -1, %10 ], [ -1, %16 ], [ -1, %35 ], [ -1, %41 ], [ 0, %78 ], [ -1, %56 ], [ -1, %61 ]
ret i32 %82
}