#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*/ O_RDONLY;
int /*<<< orphan*/ O_RDWR;
int close(int);
int dl_read_cmd(int);
int /*<<< orphan*/ dl_write_cmd(int, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int fd, file_fd, total_r = 0, i;
  int rc = 10, data, cmd, c, len, buf_size = 0, file_size = 0;
  char *p, wait_done_count = 0;
  int ret;
  char *buf = (char *)malloc(65536);
  printf("\n done = 0x%x", dl_read_cmd(4));
  do {
    dl_write_cmd(9, 0);
    while (dl_read_cmd(3) == 0)
      ;
    printf("\n done = 0x%x", dl_read_cmd(4));
    file_fd = open("/home/sq8006gdr.bit", O_RDONLY);
    if (file_fd == -1) {
      perror("\nopen faild");
      exit(-1);
    }
    do {
      total_r = read(file_fd, buf, 65536);
      if (total_r == 0) {
        printf("\n^^ read ok\n");
        rc = close(file_fd);
        if (rc == -1) {
          perror("\nclose faild");
          exit(-1);
        };
        break;
      }
      if (total_r == -1) {
        perror("\n^^ read err\n");
        rc = close(file_fd);
        if (rc == -1) {
          perror("\nclose faild");
          exit(-1);
        };
        break;
      }
      file_size += total_r;
      if (total_r) {
        fd = open("/dev/spi_download", O_RDWR);
        if (fd == -1) {
          perror("\nopen faild");
          exit(-1);
        };
        rc = write(fd, buf, total_r);
        if (rc == -1) {
          perror("\nread faild\n");
          exit(-1);
        };
        rc = close(fd);
        if (rc == -1) {
          perror("\nclose faild");
          exit(-1);
        };
      }
    } while (1);
    wait_done_count++;
    if (wait_done_count > 10) {
      printf("ERR:No Done\n");
      return -1;
    }
  } while (dl_read_cmd(4) == 0);
  dl_write_cmd(7, 0);
  printf("^^ send rst ok\n");
  printf("\ntotal_r = %d file_size = %d ", total_r, file_size);
  free(buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0xa,-0x24(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movb   $0x0,-0x49(%rbp)
mov    $0x10000,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    $0x4,%edi
call   1070 <dl_read_cmd@plt>
mov    %eax,%esi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x9,%edi
xor    %esi,%esi
call   1050 <dl_write_cmd@plt>
mov    $0x3,%edi
call   1070 <dl_read_cmd@plt>
cmp    $0x0,%eax
jne    1232 <main+0x82>
jmp    121a <main+0x6a>
mov    $0x4,%edi
call   1070 <dl_read_cmd@plt>
mov    %eax,%esi
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d8d(%rip),%rax
mov    (%rax),%esi
lea    0xdb2(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1284 <main+0xd4>
lea    0xdad(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
jmp    1289 <main+0xd9>
mov    -0x18(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    $0x10000,%edx
call   1090 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    12e5 <main+0x135>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    12e0 <main+0x130>
lea    0xd6a(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
jmp    13ec <main+0x23c>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    132b <main+0x17b>
lea    0xd52(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1326 <main+0x176>
lea    0xd24(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
jmp    13ec <main+0x23c>
mov    -0x1c(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     13d8 <main+0x228>
mov    0x2ca3(%rip),%rax
mov    (%rax),%esi
lea    0xd08(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1376 <main+0x1c6>
lea    0xcbb(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    13a8 <main+0x1f8>
lea    0xccf(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    13d3 <main+0x223>
lea    0xc77(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
jmp    13d8 <main+0x228>
jmp    13dd <main+0x22d>
mov    $0x1,%al
test   $0x1,%al
jne    1289 <main+0xd9>
jmp    13ec <main+0x23c>
mov    -0x49(%rbp),%al
add    $0x1,%al
mov    %al,-0x49(%rbp)
movsbl -0x49(%rbp),%eax
cmp    $0xa,%eax
jle    141b <main+0x26b>
lea    0xc6d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1471 <main+0x2c1>
jmp    1420 <main+0x270>
mov    $0x4,%edi
call   1070 <dl_read_cmd@plt>
cmp    $0x0,%eax
je     120e <main+0x5e>
mov    $0x7,%edi
xor    %esi,%esi
call   1050 <dl_write_cmd@plt>
lea    0xc3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%esi
mov    -0x3c(%rbp),%edx
lea    0xc38(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x10000,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1080 <dl_read_cmd@plt>
lea    0xe17(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe50(%rip),%r13
xor    %ebp,%ebp
xor    %r14d,%r14d
xchg   %ax,%ax
mov    $0x9,%edi
xor    %esi,%esi
call   1060 <dl_write_cmd@plt>
nopl   0x0(%rax)
mov    $0x3,%edi
call   1080 <dl_read_cmd@plt>
test   %eax,%eax
je     1210 <main+0x50>
mov    %r14d,0x4(%rsp)
mov    $0x4,%edi
call   1080 <dl_read_cmd@plt>
lea    0xdcc(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%esi
lea    0xdc1(%rip),%rdi
call   10c0 <open@plt>
mov    %eax,%r12d
cmp    $0xffffffff,%eax
je     1393 <main+0x1d3>
xchg   %ax,%ax
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x10000,%edx
call   10a0 <read@plt>
test   %eax,%eax
je     12d0 <main+0x110>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
je     130f <main+0x14f>
mov    0x2d61(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
call   10c0 <open@plt>
cmp    $0xffffffff,%eax
je     1393 <main+0x1d3>
mov    %eax,%r15d
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
je     139c <main+0x1dc>
add    %r14d,%ebp
mov    %r15d,%edi
call   1090 <close@plt>
cmp    $0xffffffff,%eax
jne    1260 <main+0xa0>
jmp    132e <main+0x16e>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xdca(%rip),%rdi
call   1040 <puts@plt>
mov    %r12d,%edi
call   1090 <close@plt>
xor    %r12d,%r12d
cmp    $0xffffffff,%eax
je     132e <main+0x16e>
mov    0x4(%rsp),%r14d
cmp    $0xa,%r14b
je     1337 <main+0x177>
add    $0x1,%r14b
mov    $0x4,%edi
call   1080 <dl_read_cmd@plt>
test   %eax,%eax
je     1200 <main+0x40>
jmp    134b <main+0x18b>
lea    0xd25(%rip),%rdi
call   10d0 <perror@plt>
mov    %r12d,%edi
call   1090 <close@plt>
mov    $0xffffffff,%r12d
cmp    $0xffffffff,%eax
jne    12ec <main+0x12c>
lea    0xcf9(%rip),%rdi
jmp    13a3 <main+0x1e3>
lea    0xd57(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%r14d
jmp    1381 <main+0x1c1>
xor    %r14d,%r14d
mov    $0x7,%edi
xor    %esi,%esi
call   1060 <dl_write_cmd@plt>
lea    0xd25(%rip),%rdi
call   1040 <puts@plt>
lea    0xcfb(%rip),%rdi
mov    %r12d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc88(%rip),%rdi
jmp    13a3 <main+0x1e3>
lea    0xcb8(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"\0A done = 0x%x\00"
@.str.1 = [20 x i8] c"/home/sq8006gdr.bit\00"
@O_RDONLY = global i32 0
@.str.2 = [12 x i8] c"\0Aopen faild\00"
@.str.3 = [13 x i8] c"\0A^^ read ok\0A\00"
@.str.4 = [13 x i8] c"\0Aclose faild\00"
@.str.5 = [14 x i8] c"\0A^^ read err\0A\00"
@.str.6 = [18 x i8] c"/dev/spi_download\00"
@O_RDWR = global i32 0
@.str.7 = [13 x i8] c"\0Aread faild\0A\00"
@.str.8 = [13 x i8] c"ERR:No Done\0A\00"
@.str.9 = [16 x i8] c"^^ send rst ok\0A\00"
@.str.10 = [30 x i8] c"\0Atotal_r = %d file_size = %d \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 i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i8
%19 = alloca i32
%20 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 10, i32* %10
store i32 0, i32* %15
store i32 0, i32* %16
store i8 0, i8* %18
%21 = call i64 @malloc(i32 65536)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %20
%23 = call i32 @dl_read_cmd(i32 4)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %115, %2
%26 = call i32 @dl_write_cmd(i32 9, i32 0)
br label %27
27: ; preds = %30, %25
%28 = call i32 @dl_read_cmd(i32 3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %27
br label %27
31: ; preds = %27
%32 = call i32 @dl_read_cmd(i32 4)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = load i32, i32* @O_RDONLY
%35 = call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %34)
store i32 %35, i32* %7
%36 = load i32, i32* %7
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %41
38: ; preds = %31
%39 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 @exit(i32 -1)
unreachable
41: ; preds = %31
br label %42
42: ; preds = %105, %41
%43 = load i32, i32* %7
%44 = load i8*, i8** %20
%45 = call i32 @read(i32 %43, i8* %44, i32 65536)
store i32 %45, i32* %8
%46 = load i32, i32* %8
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %58
48: ; preds = %42
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%50 = load i32, i32* %7
%51 = call i32 @close(i32 %50)
store i32 %51, i32* %10
%52 = load i32, i32* %10
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %57
54: ; preds = %48
%55 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%56 = call i32 @exit(i32 -1)
unreachable
57: ; preds = %48
br label %106
58: ; preds = %42
%59 = load i32, i32* %8
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %71
61: ; preds = %58
%62 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%63 = load i32, i32* %7
%64 = call i32 @close(i32 %63)
store i32 %64, i32* %10
%65 = load i32, i32* %10
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %70
67: ; preds = %61
%68 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%69 = call i32 @exit(i32 -1)
unreachable
70: ; preds = %61
br label %106
71: ; preds = %58
%72 = load i32, i32* %8
%73 = load i32, i32* %16
%74 = add nsw i32 %73, %72
store i32 %74, i32* %16
%75 = load i32, i32* %8
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %104
77: ; preds = %71
%78 = load i32, i32* @O_RDWR
%79 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %78)
store i32 %79, i32* %6
%80 = load i32, i32* %6
%81 = icmp eq i32 %80, -1
br i1 %81, label %82, label %85
82: ; preds = %77
%83 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%84 = call i32 @exit(i32 -1)
unreachable
85: ; preds = %77
%86 = load i32, i32* %6
%87 = load i8*, i8** %20
%88 = load i32, i32* %8
%89 = call i32 @write(i32 %86, i8* %87, i32 %88)
store i32 %89, i32* %10
%90 = load i32, i32* %10
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %95
92: ; preds = %85
%93 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%94 = call i32 @exit(i32 -1)
unreachable
95: ; preds = %85
%96 = load i32, i32* %6
%97 = call i32 @close(i32 %96)
store i32 %97, i32* %10
%98 = load i32, i32* %10
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %103
100: ; preds = %95
%101 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%102 = call i32 @exit(i32 -1)
unreachable
103: ; preds = %95
br label %104
104: ; preds = %103, %71
br label %105
105: ; preds = %104
br i1 true, label %42, label %106
106: ; preds = %105, %70, %57
%107 = load i8, i8* %18
%108 = add i8 %107, 1
store i8 %108, i8* %18
%109 = load i8, i8* %18
%110 = sext i8 %109 to i32
%111 = icmp sgt i32 %110, 10
br i1 %111, label %112, label %114
112: ; preds = %106
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %3
br label %126
114: ; preds = %106
br label %115
115: ; preds = %114
%116 = call i32 @dl_read_cmd(i32 4)
%117 = icmp eq i32 %116, 0
br i1 %117, label %25, label %118
118: ; preds = %115
%119 = call i32 @dl_write_cmd(i32 7, i32 0)
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%121 = load i32, i32* %8
%122 = load i32, i32* %16
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), i32 %121, i32 %122)
%124 = load i8*, i8** %20
%125 = call i32 @free(i8* %124)
store i32 0, i32* %3
br label %126
126: ; preds = %118, %112
%127 = load i32, i32* %3
ret i32 %127
}

LLVM IR (-O2):
@.str = [14 x i8] c"\0A done = 0x%x\00"
@.str.1 = [20 x i8] c"/home/sq8006gdr.bit\00"
@O_RDONLY = global i32 0
@.str.2 = [12 x i8] c"\0Aopen faild\00"
@.str.4 = [13 x i8] c"\0Aclose faild\00"
@.str.5 = [14 x i8] c"\0A^^ read err\0A\00"
@.str.6 = [18 x i8] c"/dev/spi_download\00"
@O_RDWR = global i32 0
@.str.7 = [13 x i8] c"\0Aread faild\0A\00"
@.str.10 = [30 x i8] c"\0Atotal_r = %d file_size = %d \00"
@str = [15 x i8] c"^^ send rst ok\00"
@str.11 = [12 x i8] c"ERR:No Done\00"
@str.12 = [12 x i8] c"\0A^^ read ok\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 65536)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @dl_read_cmd(i32 4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %65, %2
%8 = phi i32 [ 0, %2 ], [ %24, %65 ]
%9 = phi i8 [ 0, %2 ], [ %66, %65 ]
%10 = tail call i32 @dl_write_cmd(i32 9, i32 0)
br label %11
11: ; preds = %11, %7
%12 = tail call i32 @dl_read_cmd(i32 3)
%13 = icmp eq i32 %12, 0
br i1 %13, label %11, label %14
14: ; preds = %11
%15 = tail call i32 @dl_read_cmd(i32 4)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* @O_RDONLY
%18 = tail call i32 @open(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call i32 @exit(i32 -1)
unreachable
23: ; preds = %14, %54
%24 = phi i32 [ %41, %54 ], [ %8, %14 ]
%25 = tail call i32 @read(i32 %18, i8* %4, i32 65536)
switch i32 %25, label %40 [
i32 0, label %26
i32 -1, label %33
]
26: ; preds = %23
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.12, i64 0, i64 0))
%28 = tail call i32 @close(i32 %18)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %60
30: ; preds = %26
%31 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%32 = tail call i32 @exit(i32 -1)
unreachable
33: ; preds = %23
%34 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%35 = tail call i32 @close(i32 %18)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %60
37: ; preds = %33
%38 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%39 = tail call i32 @exit(i32 -1)
unreachable
40: ; preds = %23
%41 = add nsw i32 %25, %24
%42 = load i32, i32* @O_RDWR
%43 = tail call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 %42)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%47 = tail call i32 @exit(i32 -1)
unreachable
48: ; preds = %40
%49 = tail call i32 @write(i32 %43, i8* %4, i32 %25)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%53 = tail call i32 @exit(i32 -1)
unreachable
54: ; preds = %48
%55 = tail call i32 @close(i32 %43)
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %23
57: ; preds = %54
%58 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%59 = tail call i32 @exit(i32 -1)
unreachable
60: ; preds = %33, %26
%61 = phi i32 [ -1, %33 ], [ 0, %26 ]
%62 = icmp eq i8 %9, 10
br i1 %62, label %63, label %65
63: ; preds = %60
%64 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.11, i64 0, i64 0))
br label %74
65: ; preds = %60
%66 = add nuw nsw i8 %9, 1
%67 = tail call i32 @dl_read_cmd(i32 4)
%68 = icmp eq i32 %67, 0
br i1 %68, label %7, label %69
69: ; preds = %65
%70 = tail call i32 @dl_write_cmd(i32 7, i32 0)
%71 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), i32 %61, i32 %24)
%73 = tail call i32 @free(i8* %4)
br label %74
74: ; preds = %69, %63
%75 = phi i32 [ -1, %63 ], [ 0, %69 ]
ret i32 %75
}