#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*/ draw_codebug();
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char get_channel(int);
int openpt();
int /*<<< orphan*/ printf(char *, ...);
char *ptsname(int);
int read(int, char *, int);
int /*<<< orphan*/ send_ack(int);
int /*<<< orphan*/ set_channel(int, char, char);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ write(int, char *, int);
int main(void) {
  char cv;
  char buf[256];
  int start_ch, i, len, read_count;
  int fd = openpt();
  if (fd < 0) {
    return 1;
  }
  printf("Fake CodeBug serial port is: %s\n", ptsname(fd));
  while (1) {
    read_count = read(fd, buf, 256);
    if (read_count < 0) {
      fprintf(stderr, "%s\n", strerror(errno));
      break;
    }
    switch (((buf[0] >> 5) & 0x7)) {
    case 0:
      cv = get_channel(((buf[0] >> 2) & 0x7));
      write(fd, &cv, 1);
      break;
    case 1:
      set_channel(((buf[0] >> 2) & 0x7), buf[1], ((buf[0] >> 1) & 0x1));
      send_ack(fd);
      break;
    case 2:
      start_ch = ((buf[0] >> 2) & 0x7);
      len = buf[1];
      for (i = 0; i < len; i++) {
        buf[i] = get_channel(start_ch + i);
      }
      write(fd, buf, len);
      break;
    case 3:
      start_ch = ((buf[0] >> 2) & 0x7);
      len = buf[1];
      for (i = 0; i < len; i++) {
        set_channel(start_ch + i, buf[2 + i], ((buf[0] >> 1) & 0x1));
      }
      send_ack(fd);
      break;
    case 4:
      printf("cmd: CMD_ID_READ\n");
      break;
    case 5:
      printf("cmd: CMD_ID_WRITE\n");
      break;
    default:
      printf("ERR:Could not determine cmd.\n");
      return 1;
    }
    system("clear");
    draw_codebug();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <openpt@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
jge    11f8 <main+0x38>
movl   $0x1,-0x4(%rbp)
jmp    1496 <main+0x2d6>
mov    -0x124(%rbp),%edi
call   1030 <ptsname@plt>
mov    %rax,%rsi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x124(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x100,%edx
call   1080 <read@plt>
mov    %eax,-0x120(%rbp)
cmpl   $0x0,-0x120(%rbp)
jge    1275 <main+0xb5>
mov    0x2d9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x128(%rbp)
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x128(%rbp),%edi
mov    %rax,%rdx
lea    0xdca(%rip),%rsi
call   1090 <fprintf@plt>
jmp    148f <main+0x2cf>
mov    -0x110(%rbp),%eax
shr    $0x5,%eax
and    $0x7,%eax
mov    %eax,%ecx
mov    %rcx,-0x130(%rbp)
sub    $0x5,%eax
ja     145d <main+0x29d>
mov    -0x130(%rbp),%rax
lea    0xd5f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl -0x110(%rbp),%edi
sar    $0x2,%edi
and    $0x7,%edi
call   10b0 <get_channel@plt>
mov    %al,-0x5(%rbp)
mov    -0x124(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
jmp    1477 <main+0x2b7>
movsbl -0x110(%rbp),%edi
sar    $0x2,%edi
and    $0x7,%edi
mov    -0x10f(%rbp),%cl
movsbl -0x110(%rbp),%eax
sar    $0x1,%eax
and    $0x1,%eax
movsbl %cl,%esi
movsbl %al,%edx
call   10d0 <set_channel@plt>
mov    -0x124(%rbp),%edi
call   10c0 <send_ack@plt>
jmp    1477 <main+0x2b7>
movsbl -0x110(%rbp),%eax
sar    $0x2,%eax
and    $0x7,%eax
mov    %eax,-0x114(%rbp)
movsbl -0x10f(%rbp),%eax
mov    %eax,-0x11c(%rbp)
movl   $0x0,-0x118(%rbp)
mov    -0x118(%rbp),%eax
cmp    -0x11c(%rbp),%eax
jge    1384 <main+0x1c4>
mov    -0x114(%rbp),%edi
add    -0x118(%rbp),%edi
call   10b0 <get_channel@plt>
mov    %al,%cl
movslq -0x118(%rbp),%rax
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    133d <main+0x17d>
mov    -0x124(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    -0x11c(%rbp),%edx
call   1050 <write@plt>
jmp    1477 <main+0x2b7>
movsbl -0x110(%rbp),%eax
sar    $0x2,%eax
and    $0x7,%eax
mov    %eax,-0x114(%rbp)
movsbl -0x10f(%rbp),%eax
mov    %eax,-0x11c(%rbp)
movl   $0x0,-0x118(%rbp)
mov    -0x118(%rbp),%eax
cmp    -0x11c(%rbp),%eax
jge    1427 <main+0x267>
mov    -0x114(%rbp),%edi
add    -0x118(%rbp),%edi
mov    -0x118(%rbp),%eax
add    $0x2,%eax
cltq
mov    -0x110(%rbp,%rax,1),%cl
movsbl -0x110(%rbp),%eax
sar    $0x1,%eax
and    $0x1,%eax
movsbl %cl,%esi
movsbl %al,%edx
call   10d0 <set_channel@plt>
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    13cb <main+0x20b>
mov    -0x124(%rbp),%edi
call   10c0 <send_ack@plt>
jmp    1477 <main+0x2b7>
lea    0xbfb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1477 <main+0x2b7>
lea    0xbfa(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1477 <main+0x2b7>
lea    0xbfa(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1496 <main+0x2d6>
lea    0xbfe(%rip),%rdi
call   1060 <system@plt>
mov    $0x0,%al
call   10a0 <draw_codebug@plt>
jmp    1214 <main+0x54>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
xor    %eax,%eax
call   1050 <openpt@plt>
test   %eax,%eax
js     13dd <main+0x20d>
mov    %eax,%r12d
mov    %eax,%edi
call   1030 <ptsname@plt>
lea    0xe17(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %r12d,%edi
mov    $0x100,%edx
call   1090 <read@plt>
test   %eax,%eax
js     13a5 <main+0x1d5>
lea    0xdd4(%rip),%r15
lea    0xe06(%rip),%rbx
lea    0x10(%rsp),%rbp
jmp    1287 <main+0xb7>
shr    $0x2,%r13d
and    $0x7,%r13d
mov    %r13d,%edi
call   10c0 <get_channel@plt>
mov    %al,0xf(%rsp)
mov    %r12d,%edi
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
call   1060 <write@plt>
mov    %rbx,%rdi
call   1070 <system@plt>
xor    %eax,%eax
call   10b0 <draw_codebug@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x100,%edx
call   1090 <read@plt>
test   %eax,%eax
js     13a5 <main+0x1d5>
movzbl 0x10(%rsp),%r13d
mov    %r13d,%eax
shr    $0x5,%eax
cmp    $0x5,%eax
ja     13d1 <main+0x201>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    %r13d,%edi
shr    $0x2,%edi
and    $0x7,%edi
movsbl 0x11(%rsp),%esi
shr    %r13b
and    $0x1,%r13b
movzbl %r13b,%edx
call   10e0 <set_channel@plt>
mov    %r12d,%edi
call   10d0 <send_ack@plt>
jmp    1260 <main+0x90>
movsbl 0x11(%rsp),%r14d
test   %r14d,%r14d
jle    1307 <main+0x137>
shr    $0x2,%r13d
mov    %r14d,%ebx
and    $0x7,%r13d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x0(%r13,%rbp,1),%edi
call   10c0 <get_channel@plt>
mov    %al,0x10(%rsp,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    12f0 <main+0x120>
mov    %r12d,%edi
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
mov    %r14d,%edx
call   1060 <write@plt>
lea    0xd18(%rip),%rbx
jmp    1260 <main+0x90>
movzbl 0x11(%rsp),%r14d
test   %r14b,%r14b
jle    136a <main+0x19a>
mov    %r13d,%ebp
shr    $0x2,%ebp
shr    %r13b
and    $0x1,%r13b
and    $0x7,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl 0x12(%rsp,%rbx,1),%esi
lea    (%rbx,%rbp,1),%edi
movzbl %r13b,%edx
call   10e0 <set_channel@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1350 <main+0x180>
mov    %r12d,%edi
call   10d0 <send_ack@plt>
lea    0xcc0(%rip),%rbx
lea    0x10(%rsp),%rbp
jmp    1260 <main+0x90>
lea    0xcc7(%rip),%rdi
call   1040 <puts@plt>
jmp    1260 <main+0x90>
lea    0xca4(%rip),%rdi
call   1040 <puts@plt>
jmp    1260 <main+0x90>
mov    0x2c34(%rip),%rax
mov    (%rax),%ebx
mov    0x2c23(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xc72(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   10a0 <fprintf@plt>
xor    %eax,%eax
jmp    13e2 <main+0x212>
lea    0xc8a(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Fake CodeBug serial port is: %s\0A\00"
@stderr = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
@errno = global i32 0
@.str.2 = [18 x i8] c"cmd: CMD_ID_READ\0A\00"
@.str.3 = [19 x i8] c"cmd: CMD_ID_WRITE\0A\00"
@.str.4 = [30 x i8] c"ERR:Could not determine cmd.\0A\00"
@.str.5 = [6 x i8] c"clear\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (...) @openpt()
store i32 %9, i32* %8
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %0
store i32 1, i32* %1
br label %134
13: ; preds = %0
%14 = load i32, i32* %8
%15 = call i8* @ptsname(i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %13, %130
%18 = load i32, i32* %8
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%20 = call i32 @read(i32 %18, i8* %19, i32 256)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %133
28: ; preds = %17
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = ashr i32 %31, 5
%33 = and i32 %32, 7
switch i32 %33, label %128 [
i32 0, label %34
i32 1, label %43
i32 2, label %60
i32 3, label %89
i32 4, label %124
i32 5, label %126
]
34: ; preds = %28
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = ashr i32 %37, 2
%39 = and i32 %38, 7
%40 = call signext i8 @get_channel(i32 %39)
store i8 %40, i8* %2
%41 = load i32, i32* %8
%42 = call i32 @write(i32 %41, i8* %2, i32 1)
br label %130
43: ; preds = %28
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = ashr i32 %46, 2
%48 = and i32 %47, 7
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 1
%50 = load i8, i8* %49
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = ashr i32 %53, 1
%55 = and i32 %54, 1
%56 = trunc i32 %55 to i8
%57 = call i32 @set_channel(i32 %48, i8 signext %50, i8 signext %56)
%58 = load i32, i32* %8
%59 = call i32 @send_ack(i32 %58)
br label %130
60: ; preds = %28
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = ashr i32 %63, 2
%65 = and i32 %64, 7
store i32 %65, i32* %4
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 1
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
store i32 %68, i32* %6
store i32 0, i32* %5
br label %69
69: ; preds = %81, %60
%70 = load i32, i32* %5
%71 = load i32, i32* %6
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %84
73: ; preds = %69
%74 = load i32, i32* %4
%75 = load i32, i32* %5
%76 = add nsw i32 %74, %75
%77 = call signext i8 @get_channel(i32 %76)
%78 = load i32, i32* %5
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %79
store i8 %77, i8* %80
br label %81
81: ; preds = %73
%82 = load i32, i32* %5
%83 = add nsw i32 %82, 1
store i32 %83, i32* %5
br label %69
84: ; preds = %69
%85 = load i32, i32* %8
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%87 = load i32, i32* %6
%88 = call i32 @write(i32 %85, i8* %86, i32 %87)
br label %130
89: ; preds = %28
%90 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = ashr i32 %92, 2
%94 = and i32 %93, 7
store i32 %94, i32* %4
%95 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 1
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
store i32 %97, i32* %6
store i32 0, i32* %5
br label %98
98: ; preds = %118, %89
%99 = load i32, i32* %5
%100 = load i32, i32* %6
%101 = icmp slt i32 %99, %100
br i1 %101, label %102, label %121
102: ; preds = %98
%103 = load i32, i32* %4
%104 = load i32, i32* %5
%105 = add nsw i32 %103, %104
%106 = load i32, i32* %5
%107 = add nsw i32 2, %106
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %108
%110 = load i8, i8* %109
%111 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = ashr i32 %113, 1
%115 = and i32 %114, 1
%116 = trunc i32 %115 to i8
%117 = call i32 @set_channel(i32 %105, i8 signext %110, i8 signext %116)
br label %118
118: ; preds = %102
%119 = load i32, i32* %5
%120 = add nsw i32 %119, 1
store i32 %120, i32* %5
br label %98
121: ; preds = %98
%122 = load i32, i32* %8
%123 = call i32 @send_ack(i32 %122)
br label %130
124: ; preds = %28
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %130
126: ; preds = %28
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %130
128: ; preds = %28
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %1
br label %134
130: ; preds = %126, %124, %121, %84, %43, %34
%131 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%132 = call i32 (...) @draw_codebug()
br label %17
133: ; preds = %23
store i32 0, i32* %1
br label %134
134: ; preds = %133, %128, %12
%135 = load i32, i32* %1
ret i32 %135
}

LLVM IR (-O2):
@.str = [33 x i8] c"Fake CodeBug serial port is: %s\0A\00"
@stderr = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
@errno = global i32 0
@.str.5 = [6 x i8] c"clear\00"
@str = [18 x i8] c"cmd: CMD_ID_WRITE\00"
@str.6 = [17 x i8] c"cmd: CMD_ID_READ\00"
@str.7 = [29 x i8] c"ERR:Could not determine cmd.\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (...) @openpt()
%5 = icmp slt i32 %4, 0
br i1 %5, label %85, label %6
6: ; preds = %0
%7 = tail call i8* @ptsname(i32 %4)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = call i32 @read(i32 %4, i8* %3, i32 256)
%10 = icmp slt i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 1
br label %18
13: ; preds = %80, %6
%14 = load i32, i32* @stderr
%15 = load i32, i32* @errno
%16 = tail call i8* @strerror(i32 %15)
%17 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %85
18: ; preds = %11, %80
%19 = load i8, i8* %3
%20 = zext i8 %19 to i32
%21 = lshr i32 %20, 5
switch i32 %21, label %78 [
i32 0, label %22
i32 1, label %27
i32 2, label %35
i32 3, label %53
i32 4, label %74
i32 5, label %76
]
22: ; preds = %18
%23 = lshr i32 %20, 2
%24 = and i32 %23, 7
%25 = tail call signext i8 @get_channel(i32 %24)
store i8 %25, i8* %1
%26 = call i32 @write(i32 %4, i8* %1, i32 1)
br label %80
27: ; preds = %18
%28 = lshr i32 %20, 2
%29 = and i32 %28, 7
%30 = load i8, i8* %12
%31 = lshr i8 %19, 1
%32 = and i8 %31, 1
%33 = tail call i32 @set_channel(i32 %29, i8 signext %30, i8 signext %32)
%34 = tail call i32 @send_ack(i32 %4)
br label %80
35: ; preds = %18
%36 = load i8, i8* %12
%37 = sext i8 %36 to i32
%38 = icmp sgt i8 %36, 0
br i1 %38, label %39, label %51
39: ; preds = %35
%40 = lshr i32 %20, 2
%41 = and i32 %40, 7
%42 = zext i32 %37 to i64
br label %43
43: ; preds = %39, %43
%44 = phi i64 [ 0, %39 ], [ %49, %43 ]
%45 = trunc i64 %44 to i32
%46 = add i32 %41, %45
%47 = tail call signext i8 @get_channel(i32 %46)
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %44
store i8 %47, i8* %48
%49 = add nuw nsw i64 %44, 1
%50 = icmp eq i64 %49, %42
br i1 %50, label %51, label %43
51: ; preds = %43, %35
%52 = call i32 @write(i32 %4, i8* %3, i32 %37)
br label %80
53: ; preds = %18
%54 = load i8, i8* %12
%55 = icmp sgt i8 %54, 0
br i1 %55, label %56, label %72
56: ; preds = %53
%57 = zext i8 %54 to i64
%58 = lshr i32 %20, 2
%59 = and i32 %58, 7
%60 = lshr i8 %19, 1
%61 = and i8 %60, 1
br label %62
62: ; preds = %56, %62
%63 = phi i64 [ 0, %56 ], [ %70, %62 ]
%64 = add nuw nsw i64 %63, 2
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %64
%66 = load i8, i8* %65
%67 = trunc i64 %63 to i32
%68 = add i32 %59, %67
%69 = tail call i32 @set_channel(i32 %68, i8 signext %66, i8 signext %61)
%70 = add nuw nsw i64 %63, 1
%71 = icmp eq i64 %70, %57
br i1 %71, label %72, label %62
72: ; preds = %62, %53
%73 = tail call i32 @send_ack(i32 %4)
br label %80
74: ; preds = %18
%75 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
br label %80
76: ; preds = %18
%77 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %80
78: ; preds = %18
%79 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.7, i64 0, i64 0))
br label %85
80: ; preds = %76, %74, %72, %51, %27, %22
%81 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%82 = tail call i32 (...) @draw_codebug()
%83 = call i32 @read(i32 %4, i8* %3, i32 256)
%84 = icmp slt i32 %83, 0
br i1 %84, label %13, label %18
85: ; preds = %0, %13, %78
%86 = phi i32 [ 0, %13 ], [ 1, %78 ], [ 1, %0 ]
ret i32 %86
}