#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;
void *atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
short htons(short);
scalar_t__ malloc(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, ...);
int sendprog(char *filen, int sfd) {
  int fd, i = 0;
  short int length;
  char ch;
  char *buf;
  buf = (char *)malloc(255);
  fd = open(filen, O_RDONLY);
  if (fd == -1) {
    fprintf(stderr, "Unable to open %s\n", filen);
    return -1;
  }
  while (ch != '\n') {
    read(fd, &ch, sizeof(char));
    buf[i] = ch;
    i++;
  }
  buf[i] = '\0';
  if (strcmp(buf, "CCTRL-BASIC\n") != 0) {
    printf("Wrong file format.\n");
    return -1;
  } else
    printf("dat file header is correct\n");
  i = 0;
  ch = 0;
  buf[i] = '\0';
  while (ch != '\n') {
    read(fd, &ch, sizeof(char));
    buf[i] = ch;
    i++;
    buf[i] = '\0';
  }
  length = atoi(buf);
  buf[0] = 2;
  write(sfd, buf, 1);
  printf("sent ascii 2 (prepare for writing program)\n");
  printf("program length: %i\n", length);
  length = htons(length);
  write(sfd, &length, sizeof(short int));
  buf[0] = '\0';
  i = 0;
  ch = 'x';
  while (read(fd, &ch, sizeof(char)) > 0) {
    if (ch == 32) {
      ch = atoi(buf);
      write(sfd, &ch, sizeof(char));
      ch = 0;
      usleep(20000);
      i = 0;
      buf[i] = '\0';
    } else {
      buf[i] = ch;
      ch = 0;
      i++;
      buf[i] = '\0';
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<sendprog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0xff,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1208 <sendprog+0x68>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe09(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140b <sendprog+0x26b>
jmp    120d <sendprog+0x6d>
movsbl -0x1f(%rbp),%eax
cmp    $0xa,%eax
je     1247 <sendprog+0xa7>
mov    -0x18(%rbp),%edi
lea    -0x1f(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
mov    -0x1f(%rbp),%dl
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    120d <sendprog+0x6d>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
lea    0xdb5(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1287 <sendprog+0xe7>
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140b <sendprog+0x26b>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movb   $0x0,-0x1f(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movsbl -0x1f(%rbp),%eax
cmp    $0xa,%eax
je     12f2 <sendprog+0x152>
mov    -0x18(%rbp),%edi
lea    -0x1f(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
mov    -0x1f(%rbp),%dl
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    12ac <sendprog+0x10c>
mov    -0x28(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %ax,-0x1e(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x2,(%rax)
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <write@plt>
lea    0xd30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movswl -0x1e(%rbp),%esi
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movswl -0x1e(%rbp),%edi
call   1040 <htons@plt>
mov    %ax,-0x1e(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0x2,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x1c(%rbp)
movb   $0x78,-0x1f(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x1f(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
cmp    $0x0,%rax
jle    1404 <sendprog+0x264>
movsbl -0x1f(%rbp),%eax
cmp    $0x20,%eax
jne    13d8 <sendprog+0x238>
mov    -0x28(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %al,-0x1f(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x1f(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <write@plt>
movb   $0x0,-0x1f(%rbp)
mov    $0x4e20,%edi
call   10c0 <usleep@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    13ff <sendprog+0x25f>
mov    -0x1f(%rbp),%dl
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movb   $0x0,-0x1f(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    136b <sendprog+0x1cb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendprog>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
mov    $0xff,%edi
call   10a0 <malloc@plt>
mov    %rax,%r13
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     1248 <sendprog+0x98>
mov    %eax,%r12d
xor    %ebx,%ebx
lea    0x5(%rsp),%rbp
xchg   %ax,%ax
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1070 <read@plt>
movzbl 0x5(%rsp),%eax
mov    %al,0x0(%r13,%rbx,1)
add    $0x1,%rbx
cmpb   $0xa,0x5(%rsp)
jne    11f0 <sendprog+0x40>
mov    %ebx,%eax
movb   $0x0,0x0(%r13,%rax,1)
lea    0xdef(%rip),%rsi
mov    %r13,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     126b <sendprog+0xbb>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r15d
jmp    13d0 <sendprog+0x220>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
lea    0xda8(%rip),%rsi
mov    %r15,%rdx
call   1090 <fprintf@plt>
mov    $0xffffffff,%r15d
jmp    13d0 <sendprog+0x220>
lea    0xdc2(%rip),%rdi
call   1030 <puts@plt>
movb   $0x0,0x5(%rsp)
movb   $0x0,0x0(%r13)
cmpb   $0xa,0x5(%rsp)
je     12c6 <sendprog+0x116>
lea    0x1(%r13),%rbx
lea    0x5(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1070 <read@plt>
movzbl 0x5(%rsp),%eax
mov    %al,-0x1(%rbx)
movb   $0x0,(%rbx)
add    $0x1,%rbx
cmpb   $0xa,0x5(%rsp)
jne    12a0 <sendprog+0xf0>
mov    %r13,%rdi
call   10c0 <atoi@plt>
mov    %ax,0x6(%rsp)
movb   $0x2,0x0(%r13)
xor    %r15d,%r15d
mov    %r14d,%edi
mov    %r13,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <write@plt>
lea    0xd5b(%rip),%rdi
call   1030 <puts@plt>
movswl 0x6(%rsp),%ebp
lea    0xd1b(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebp,%edi
call   1050 <htons@plt>
mov    %ax,0x6(%rsp)
lea    0x6(%rsp),%rsi
mov    $0x2,%edx
mov    %r14d,%edi
xor    %eax,%eax
call   1040 <write@plt>
movb   $0x0,0x0(%r13)
movb   $0x78,0x5(%rsp)
lea    0x5(%rsp),%rsi
mov    %r12d,%edi
mov    $0x1,%edx
call   1070 <read@plt>
test   %rax,%rax
jle    13d0 <sendprog+0x220>
xor    %ebp,%ebp
lea    0x5(%rsp),%r15
jmp    1390 <sendprog+0x1e0>
nopl   0x0(%rax)
movslq %ebp,%rcx
mov    %al,0x0(%r13,%rcx,1)
movb   $0x0,0x5(%rsp)
lea    0x1(%rcx),%ebp
lea    (%rcx,%r13,1),%rax
add    $0x1,%rax
movb   $0x0,(%rax)
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1070 <read@plt>
test   %rax,%rax
jle    13cd <sendprog+0x21d>
movzbl 0x5(%rsp),%eax
cmp    $0x20,%al
jne    1360 <sendprog+0x1b0>
mov    %r13,%rdi
call   10c0 <atoi@plt>
mov    %al,0x5(%rsp)
xor    %ebp,%ebp
mov    $0x1,%edx
mov    %r14d,%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <write@plt>
movb   $0x0,0x5(%rsp)
mov    $0x4e20,%edi
call   10d0 <usleep@plt>
mov    %r13,%rax
jmp    1378 <sendprog+0x1c8>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [19 x i8] c"Unable to open %s\0A\00"
@.str.1 = [13 x i8] c"CCTRL-BASIC\0A\00"
@.str.2 = [20 x i8] c"Wrong file format.\0A\00"
@.str.3 = [28 x i8] c"dat file header is correct\0A\00"
@.str.4 = [44 x i8] c"sent ascii 2 (prepare for writing program)\0A\00"
@.str.5 = [20 x i8] c"program length: %i\0A\00"
define i32 @sendprog(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i16
%9 = alloca i8
%10 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %7
%11 = call i64 @malloc(i32 255)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %10
%13 = load i8*, i8** %4
%14 = load i32, i32* @O_RDONLY
%15 = call i32 @open(i8* %13, i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %4
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 -1, i32* %3
br label %124
22: ; preds = %2
br label %23
23: ; preds = %27, %22
%24 = load i8, i8* %9
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 10
br i1 %26, label %27, label %37
27: ; preds = %23
%28 = load i32, i32* %6
%29 = call i64 @read(i32 %28, i8* %9, i32 1)
%30 = load i8, i8* %9
%31 = load i8*, i8** %10
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 %30, i8* %34
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %23
37: ; preds = %23
%38 = load i8*, i8** %10
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 0, i8* %41
%42 = load i8*, i8** %10
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %37
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %124
47: ; preds = %37
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %47
store i32 0, i32* %7
store i8 0, i8* %9
%50 = load i8*, i8** %10
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
store i8 0, i8* %53
br label %54
54: ; preds = %58, %49
%55 = load i8, i8* %9
%56 = sext i8 %55 to i32
%57 = icmp ne i32 %56, 10
br i1 %57, label %58, label %72
58: ; preds = %54
%59 = load i32, i32* %6
%60 = call i64 @read(i32 %59, i8* %9, i32 1)
%61 = load i8, i8* %9
%62 = load i8*, i8** %10
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
store i8 %61, i8* %65
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
%68 = load i8*, i8** %10
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
store i8 0, i8* %71
br label %54
72: ; preds = %54
%73 = load i8*, i8** %10
%74 = call i8* @atoi(i8* %73)
%75 = ptrtoint i8* %74 to i16
store i16 %75, i16* %8
%76 = load i8*, i8** %10
%77 = getelementptr inbounds i8, i8* %76, i64 0
store i8 2, i8* %77
%78 = load i32, i32* %5
%79 = load i8*, i8** %10
%80 = call i32 (i32, ...) @write(i32 %78, i8* %79, i32 1)
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%82 = load i16, i16* %8
%83 = sext i16 %82 to i32
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %83)
%85 = load i16, i16* %8
%86 = call signext i16 @htons(i16 signext %85)
store i16 %86, i16* %8
%87 = load i32, i32* %5
%88 = call i32 (i32, ...) @write(i32 %87, i16* %8, i64 2)
%89 = load i8*, i8** %10
%90 = getelementptr inbounds i8, i8* %89, i64 0
store i8 0, i8* %90
store i32 0, i32* %7
store i8 120, i8* %9
br label %91
91: ; preds = %122, %72
%92 = load i32, i32* %6
%93 = call i64 @read(i32 %92, i8* %9, i32 1)
%94 = icmp sgt i64 %93, 0
br i1 %94, label %95, label %123
95: ; preds = %91
%96 = load i8, i8* %9
%97 = sext i8 %96 to i32
%98 = icmp eq i32 %97, 32
br i1 %98, label %99, label %110
99: ; preds = %95
%100 = load i8*, i8** %10
%101 = call i8* @atoi(i8* %100)
%102 = ptrtoint i8* %101 to i8
store i8 %102, i8* %9
%103 = load i32, i32* %5
%104 = call i32 (i32, ...) @write(i32 %103, i8* %9, i64 1)
store i8 0, i8* %9
%105 = call i32 @usleep(i32 20000)
store i32 0, i32* %7
%106 = load i8*, i8** %10
%107 = load i32, i32* %7
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %106, i64 %108
store i8 0, i8* %109
br label %122
110: ; preds = %95
%111 = load i8, i8* %9
%112 = load i8*, i8** %10
%113 = load i32, i32* %7
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %112, i64 %114
store i8 %111, i8* %115
store i8 0, i8* %9
%116 = load i32, i32* %7
%117 = add nsw i32 %116, 1
store i32 %117, i32* %7
%118 = load i8*, i8** %10
%119 = load i32, i32* %7
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i8, i8* %118, i64 %120
store i8 0, i8* %121
br label %122
122: ; preds = %110, %99
br label %91
123: ; preds = %91
store i32 0, i32* %3
br label %124
124: ; preds = %123, %45, %18
%125 = load i32, i32* %3
ret i32 %125
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [19 x i8] c"Unable to open %s\0A\00"
@.str.1 = [13 x i8] c"CCTRL-BASIC\0A\00"
@.str.5 = [20 x i8] c"program length: %i\0A\00"
@str = [27 x i8] c"dat file header is correct\00"
@str.6 = [43 x i8] c"sent ascii 2 (prepare for writing program)\00"
@str.7 = [19 x i8] c"Wrong file format.\00"
define i32 @sendprog(i8* %0, i32 %1) {
%3 = alloca i16
%4 = alloca i8
%5 = bitcast i16* %3 to i8*
%6 = tail call i64 @malloc(i32 255)
%7 = inttoptr i64 %6 to i8*
%8 = load i32, i32* @O_RDONLY
%9 = tail call i32 @open(i8* %0, i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %76
14: ; preds = %2, %14
%15 = phi i64 [ %19, %14 ], [ 0, %2 ]
%16 = call i64 @read(i32 %9, i8* %4, i32 1)
%17 = load i8, i8* %4
%18 = getelementptr inbounds i8, i8* %7, i64 %15
store i8 %17, i8* %18
%19 = add nuw i64 %15, 1
%20 = load i8, i8* %4
%21 = icmp eq i8 %20, 10
br i1 %21, label %22, label %14
22: ; preds = %14
%23 = and i64 %19, 4294967295
%24 = getelementptr inbounds i8, i8* %7, i64 %23
store i8 0, i8* %24
%25 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %22
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
br label %76
29: ; preds = %22
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
store i8 0, i8* %4
store i8 0, i8* %7
%31 = load i8, i8* %4
%32 = icmp eq i8 %31, 10
br i1 %32, label %42, label %33
33: ; preds = %29, %33
%34 = phi i64 [ %38, %33 ], [ 0, %29 ]
%35 = call i64 @read(i32 %9, i8* %4, i32 1)
%36 = load i8, i8* %4
%37 = getelementptr inbounds i8, i8* %7, i64 %34
store i8 %36, i8* %37
%38 = add nuw i64 %34, 1
%39 = getelementptr inbounds i8, i8* %7, i64 %38
store i8 0, i8* %39
%40 = load i8, i8* %4
%41 = icmp eq i8 %40, 10
br i1 %41, label %42, label %33
42: ; preds = %33, %29
%43 = tail call i8* @atoi(i8* %7)
%44 = ptrtoint i8* %43 to i64
%45 = trunc i64 %44 to i16
store i16 %45, i16* %3
store i8 2, i8* %7
%46 = tail call i32 (i32, ...) @write(i32 %1, i8* %7, i32 1)
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.6, i64 0, i64 0))
%48 = load i16, i16* %3
%49 = sext i16 %48 to i32
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %49)
%51 = tail call signext i16 @htons(i16 signext %48)
store i16 %51, i16* %3
%52 = call i32 (i32, ...) @write(i32 %1, i16* %3, i64 2)
store i8 0, i8* %7
store i8 120, i8* %4
%53 = call i64 @read(i32 %9, i8* %4, i32 1)
%54 = icmp sgt i64 %53, 0
br i1 %54, label %55, label %76
55: ; preds = %42, %71
%56 = phi i32 [ %73, %71 ], [ 0, %42 ]
%57 = load i8, i8* %4
%58 = icmp eq i8 %57, 32
br i1 %58, label %59, label %65
59: ; preds = %55
%60 = call i8* @atoi(i8* %7)
%61 = ptrtoint i8* %60 to i64
%62 = trunc i64 %61 to i8
store i8 %62, i8* %4
%63 = call i32 (i32, ...) @write(i32 %1, i8* %4, i64 1)
store i8 0, i8* %4
%64 = call i32 @usleep(i32 20000)
br label %71
65: ; preds = %55
%66 = sext i32 %56 to i64
%67 = getelementptr inbounds i8, i8* %7, i64 %66
store i8 %57, i8* %67
store i8 0, i8* %4
%68 = add nsw i32 %56, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %7, i64 %69
br label %71
71: ; preds = %65, %59
%72 = phi i8* [ %70, %65 ], [ %7, %59 ]
%73 = phi i32 [ %68, %65 ], [ 0, %59 ]
store i8 0, i8* %72
%74 = call i64 @read(i32 %9, i8* %4, i32 1)
%75 = icmp sgt i64 %74, 0
br i1 %75, label %55, label %76
76: ; preds = %71, %42, %27, %11
%77 = phi i32 [ -1, %11 ], [ -1, %27 ], [ 0, %42 ], [ 0, %71 ]
ret i32 %77
}