#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 /*<<< orphan*/ 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);
      printf("\ntotal_r = %d ", total_r);
      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);
        };
        write(fd, buf, total_r);
        ;
        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)
mov    -0x1c(%rbp),%esi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    12f6 <main+0x146>
lea    0xd7e(%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    12f1 <main+0x141>
lea    0xd68(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
jmp    13da <main+0x22a>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    133c <main+0x18c>
lea    0xd50(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1337 <main+0x187>
lea    0xd22(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
jmp    13da <main+0x22a>
mov    -0x1c(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     13c6 <main+0x216>
mov    0x2c92(%rip),%rax
mov    (%rax),%esi
lea    0xd06(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1387 <main+0x1d7>
lea    0xcaa(%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    -0x14(%rbp),%edi
call   1080 <close@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    13c1 <main+0x211>
lea    0xc98(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
jmp    13c6 <main+0x216>
jmp    13cb <main+0x21b>
mov    $0x1,%al
test   $0x1,%al
jne    1289 <main+0xd9>
jmp    13da <main+0x22a>
mov    -0x49(%rbp),%al
add    $0x1,%al
mov    %al,-0x49(%rbp)
movsbl -0x49(%rbp),%eax
cmp    $0xa,%eax
jle    1409 <main+0x259>
lea    0xc81(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    145f <main+0x2af>
jmp    140e <main+0x25e>
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    0xc50(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%esi
mov    -0x3c(%rbp),%edx
lea    0xc4c(%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    0xe35(%rip),%r12
xor    %ebp,%ebp
xor    %r15d,%r15d
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    %r15d,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,%r14d
cmp    $0xffffffff,%eax
je     1393 <main+0x1d3>
xchg   %ax,%ax
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x10000,%edx
call   10a0 <read@plt>
mov    %eax,%r15d
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
test   %r15d,%r15d
je     12d0 <main+0x110>
cmp    $0xffffffff,%r15d
je     130f <main+0x14f>
mov    0x2d53(%rip),%rax
mov    (%rax),%esi
lea    0xdba(%rip),%rdi
call   10c0 <open@plt>
cmp    $0xffffffff,%eax
je     1393 <main+0x1d3>
mov    %eax,%r13d
add    %r15d,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1050 <write@plt>
mov    %r13d,%edi
call   1090 <close@plt>
cmp    $0xffffffff,%eax
jne    1260 <main+0xa0>
jmp    132e <main+0x16e>
xchg   %ax,%ax
lea    0xdcc(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%edi
call   1090 <close@plt>
xor    %r14d,%r14d
cmp    $0xffffffff,%eax
je     132e <main+0x16e>
mov    0x4(%rsp),%r15d
cmp    $0xa,%r15b
je     1337 <main+0x177>
add    $0x1,%r15b
mov    $0x4,%edi
call   1080 <dl_read_cmd@plt>
test   %eax,%eax
je     1200 <main+0x40>
jmp    134b <main+0x18b>
lea    0xd34(%rip),%rdi
call   10d0 <perror@plt>
mov    %r14d,%edi
call   1090 <close@plt>
mov    $0xffffffff,%r14d
cmp    $0xffffffff,%eax
jne    12ec <main+0x12c>
lea    0xd08(%rip),%rdi
jmp    139a <main+0x1da>
lea    0xd59(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%r15d
jmp    1381 <main+0x1c1>
xor    %r15d,%r15d
mov    $0x7,%edi
xor    %esi,%esi
call   1060 <dl_write_cmd@plt>
lea    0xd27(%rip),%rdi
call   1040 <puts@plt>
lea    0xcfd(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc88(%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 = [15 x i8] c"\0Atotal_r = %d \00"
@.str.4 = [13 x i8] c"\0A^^ read ok\0A\00"
@.str.5 = [13 x i8] c"\0Aclose faild\00"
@.str.6 = [14 x i8] c"\0A^^ read err\0A\00"
@.str.7 = [18 x i8] c"/dev/spi_download\00"
@O_RDWR = global i32 0
@.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 = %111, %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 = %101, %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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %8
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %60
50: ; preds = %42
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%52 = load i32, i32* %7
%53 = call i32 @close(i32 %52)
store i32 %53, i32* %10
%54 = load i32, i32* %10
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %59
56: ; preds = %50
%57 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%58 = call i32 @exit(i32 -1)
unreachable
59: ; preds = %50
br label %102
60: ; preds = %42
%61 = load i32, i32* %8
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %73
63: ; preds = %60
%64 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%65 = load i32, i32* %7
%66 = call i32 @close(i32 %65)
store i32 %66, i32* %10
%67 = load i32, i32* %10
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %72
69: ; preds = %63
%70 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%71 = call i32 @exit(i32 -1)
unreachable
72: ; preds = %63
br label %102
73: ; preds = %60
%74 = load i32, i32* %8
%75 = load i32, i32* %16
%76 = add nsw i32 %75, %74
store i32 %76, i32* %16
%77 = load i32, i32* %8
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %100
79: ; preds = %73
%80 = load i32, i32* @O_RDWR
%81 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %80)
store i32 %81, i32* %6
%82 = load i32, i32* %6
%83 = icmp eq i32 %82, -1
br i1 %83, label %84, label %87
84: ; preds = %79
%85 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%86 = call i32 @exit(i32 -1)
unreachable
87: ; preds = %79
%88 = load i32, i32* %6
%89 = load i8*, i8** %20
%90 = load i32, i32* %8
%91 = call i32 @write(i32 %88, i8* %89, i32 %90)
%92 = load i32, i32* %6
%93 = call i32 @close(i32 %92)
store i32 %93, i32* %10
%94 = load i32, i32* %10
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %99
96: ; preds = %87
%97 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%98 = call i32 @exit(i32 -1)
unreachable
99: ; preds = %87
br label %100
100: ; preds = %99, %73
br label %101
101: ; preds = %100
br i1 true, label %42, label %102
102: ; preds = %101, %72, %59
%103 = load i8, i8* %18
%104 = add i8 %103, 1
store i8 %104, i8* %18
%105 = load i8, i8* %18
%106 = sext i8 %105 to i32
%107 = icmp sgt i32 %106, 10
br i1 %107, label %108, label %110
108: ; preds = %102
%109 = 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 %122
110: ; preds = %102
br label %111
111: ; preds = %110
%112 = call i32 @dl_read_cmd(i32 4)
%113 = icmp eq i32 %112, 0
br i1 %113, label %25, label %114
114: ; preds = %111
%115 = call i32 @dl_write_cmd(i32 7, i32 0)
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%117 = load i32, i32* %8
%118 = load i32, i32* %16
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), i32 %117, i32 %118)
%120 = load i8*, i8** %20
%121 = call i32 @free(i8* %120)
store i32 0, i32* %3
br label %122
122: ; preds = %114, %108
%123 = load i32, i32* %3
ret i32 %123
}

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.3 = [15 x i8] c"\0Atotal_r = %d \00"
@.str.5 = [13 x i8] c"\0Aclose faild\00"
@.str.6 = [14 x i8] c"\0A^^ read err\0A\00"
@.str.7 = [18 x i8] c"/dev/spi_download\00"
@O_RDWR = global i32 0
@.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 = %61, %2
%8 = phi i32 [ 0, %2 ], [ %24, %61 ]
%9 = phi i8 [ 0, %2 ], [ %62, %61 ]
%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, %48
%24 = phi i32 [ %49, %48 ], [ %8, %14 ]
%25 = tail call i32 @read(i32 %18, i8* %4, i32 65536)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %25)
switch i32 %25, label %41 [
i32 0, label %27
i32 -1, label %34
]
27: ; preds = %23
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.12, i64 0, i64 0))
%29 = tail call i32 @close(i32 %18)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %56
31: ; preds = %27
%32 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%33 = tail call i32 @exit(i32 -1)
unreachable
34: ; preds = %23
%35 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%36 = tail call i32 @close(i32 %18)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %56
38: ; preds = %34
%39 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%40 = tail call i32 @exit(i32 -1)
unreachable
41: ; preds = %23
%42 = load i32, i32* @O_RDWR
%43 = tail call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %42)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %48
45: ; preds = %41
%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 = %41
%49 = add nsw i32 %25, %24
%50 = tail call i32 @write(i32 %43, i8* %4, i32 %25)
%51 = tail call i32 @close(i32 %43)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %23
53: ; preds = %48
%54 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%55 = tail call i32 @exit(i32 -1)
unreachable
56: ; preds = %34, %27
%57 = phi i32 [ -1, %34 ], [ 0, %27 ]
%58 = icmp eq i8 %9, 10
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.11, i64 0, i64 0))
br label %70
61: ; preds = %56
%62 = add nuw nsw i8 %9, 1
%63 = tail call i32 @dl_read_cmd(i32 4)
%64 = icmp eq i32 %63, 0
br i1 %64, label %7, label %65
65: ; preds = %61
%66 = tail call i32 @dl_write_cmd(i32 7, i32 0)
%67 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0), i32 %57, i32 %24)
%69 = tail call i32 @free(i8* %4)
br label %70
70: ; preds = %65, %59
%71 = phi i32 [ -1, %59 ], [ 0, %65 ]
ret i32 %71
}