#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 */
typedef int uint8_t;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int cmd_flush(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int read_n(int, int *, int);
int send_chunk(int, int *, int);
int send_cmd(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int wait4buffers(int);
int send_file(int spi_fd, int file_fd) {
  int ret;
  if ((ret = cmd_flush(spi_fd)) < 0) {
    fprintf(stderr, "Unable to get SPI client into command mode\n");
    return ret;
  }
  if ((ret = send_cmd(spi_fd, 0x90, 0)) < 0) {
    fprintf(stderr, "Unable to reset the SPI client\n");
    return ret;
  }
  if (!ret)
    wait4buffers(spi_fd);
  while (1) {
    int buffers;
    uint8_t buffer[441];
    int size = read_n(file_fd, buffer, sizeof(buffer));
    int i;
    for (i = 0; i < size; i++)
      if (buffer[i] == 0x90)
        buffer[i] = 0x91;
    ;
    ;
    if (size == 441)
      ret = send_chunk(spi_fd, buffer, 0);
    else if (size > 0) {
      if (size > 255) {
        if ((ret = send_chunk(spi_fd, buffer, 255)) < 0)
          return ret;
        if (ret == 1)
          ret = wait4buffers(spi_fd);
        ret = send_chunk(spi_fd, buffer + 255, size - 255);
      } else
        ret = send_chunk(spi_fd, buffer, size);
    } else
      break;
    if (ret < 0)
      return ret;
    buffers = ret;
    if (buffers == 0)
      ;
    ;
    if (buffers == 1)
      buffers = wait4buffers(spi_fd);
  }
  return 0;
}


x86 assembly (clang, -O0):
<send_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x710,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <cmd_flush@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    11a5 <send_file+0x45>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1392 <send_file+0x232>
mov    -0x8(%rbp),%edi
mov    $0x90,%esi
xor    %edx,%edx
call   1080 <send_cmd@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    11e0 <send_file+0x80>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1392 <send_file+0x232>
cmpl   $0x0,-0x10(%rbp)
jne    11f2 <send_file+0x92>
mov    -0x8(%rbp),%edi
call   1030 <wait4buffers@plt>
jmp    11f7 <send_file+0x97>
mov    -0xc(%rbp),%edi
lea    -0x700(%rbp),%rsi
mov    $0x6e4,%edx
call   1040 <read_n@plt>
mov    %eax,-0x704(%rbp)
movl   $0x0,-0x708(%rbp)
mov    -0x708(%rbp),%eax
cmp    -0x704(%rbp),%eax
jge    1270 <send_file+0x110>
movslq -0x708(%rbp),%rax
cmpl   $0x90,-0x700(%rbp,%rax,4)
jne    1257 <send_file+0xf7>
movslq -0x708(%rbp),%rax
movl   $0x91,-0x700(%rbp,%rax,4)
jmp    125c <send_file+0xfc>
mov    -0x708(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x708(%rbp)
jmp    121b <send_file+0xbb>
cmpl   $0x1b9,-0x704(%rbp)
jne    1299 <send_file+0x139>
mov    -0x8(%rbp),%edi
lea    -0x700(%rbp),%rsi
xor    %edx,%edx
call   1070 <send_chunk@plt>
mov    %eax,-0x10(%rbp)
jmp    1347 <send_file+0x1e7>
cmpl   $0x0,-0x704(%rbp)
jle    133d <send_file+0x1dd>
cmpl   $0xff,-0x704(%rbp)
jle    1320 <send_file+0x1c0>
mov    -0x8(%rbp),%edi
lea    -0x700(%rbp),%rsi
mov    $0xff,%edx
call   1070 <send_chunk@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    12e1 <send_file+0x181>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1392 <send_file+0x232>
cmpl   $0x1,-0x10(%rbp)
jne    12f6 <send_file+0x196>
mov    -0x8(%rbp),%edi
call   1030 <wait4buffers@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x700(%rbp),%rsi
add    $0x3fc,%rsi
mov    -0x704(%rbp),%edx
sub    $0xff,%edx
call   1070 <send_chunk@plt>
mov    %eax,-0x10(%rbp)
jmp    1338 <send_file+0x1d8>
mov    -0x8(%rbp),%edi
lea    -0x700(%rbp),%rsi
mov    -0x704(%rbp),%edx
call   1070 <send_chunk@plt>
mov    %eax,-0x10(%rbp)
jmp    1342 <send_file+0x1e2>
jmp    138b <send_file+0x22b>
jmp    1347 <send_file+0x1e7>
cmpl   $0x0,-0x10(%rbp)
jge    135c <send_file+0x1fc>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1392 <send_file+0x232>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1371 <send_file+0x211>
jmp    1371 <send_file+0x211>
cmpl   $0x1,-0x14(%rbp)
jne    1386 <send_file+0x226>
mov    -0x8(%rbp),%edi
call   1030 <wait4buffers@plt>
mov    %eax,-0x14(%rbp)
jmp    11f7 <send_file+0x97>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x710,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x6e8,%rsp
mov    %esi,%r12d
mov    %edi,%r13d
call   1060 <cmd_flush@plt>
test   %eax,%eax
js     139f <send_file+0x23f>
mov    %r13d,%edi
mov    $0x90,%esi
xor    %edx,%edx
call   1080 <send_cmd@plt>
test   %eax,%eax
js     13b7 <send_file+0x257>
jne    11a5 <send_file+0x45>
mov    %r13d,%edi
call   1030 <wait4buffers@plt>
mov    %rsp,%rsi
mov    %r12d,%edi
mov    $0x6e4,%edx
call   1040 <read_n@plt>
test   %eax,%eax
setg   %cl
jle    13b3 <send_file+0x253>
lea    0x3fc(%rsp),%r14
mov    %rsp,%r15
movdqa 0xe2d(%rip),%xmm1
jmp    1203 <send_file+0xa3>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x6e4,%edx
call   1040 <read_n@plt>
test   %eax,%eax
setg   %cl
movdqa 0xe03(%rip),%xmm1
jle    13b3 <send_file+0x253>
mov    %eax,%ebx
cmp    $0x8,%eax
jae    1220 <send_file+0xc0>
xor    %eax,%eax
jmp    1329 <send_file+0x1c9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
and    $0xfffffff8,%eax
lea    0x0(,%rbx,4),%rdx
and    $0xffffffffffffffe0,%rdx
xor    %esi,%esi
jmp    124d <send_file+0xed>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x20,%rsi
cmp    %rsi,%rdx
je     1300 <send_file+0x1a0>
movdqa (%rsp,%rsi,1),%xmm0
pcmpeqd %xmm1,%xmm0
movd   %xmm0,%edi
test   $0x1,%dil
je     1267 <send_file+0x107>
movl   $0x91,(%rsp,%rsi,1)
pextrw $0x2,%xmm0,%edi
test   $0x1,%dil
je     127a <send_file+0x11a>
movl   $0x91,0x4(%rsp,%rsi,1)
pextrw $0x4,%xmm0,%edi
test   $0x1,%dil
je     128d <send_file+0x12d>
movl   $0x91,0x8(%rsp,%rsi,1)
pextrw $0x6,%xmm0,%edi
test   $0x1,%dil
je     12a0 <send_file+0x140>
movl   $0x91,0xc(%rsp,%rsi,1)
movdqa 0x10(%rsp,%rsi,1),%xmm0
pcmpeqd %xmm1,%xmm0
movd   %xmm0,%edi
test   $0x1,%dil
je     12bc <send_file+0x15c>
movl   $0x91,0x10(%rsp,%rsi,1)
pextrw $0x2,%xmm0,%edi
test   $0x1,%dil
je     12cf <send_file+0x16f>
movl   $0x91,0x14(%rsp,%rsi,1)
pextrw $0x4,%xmm0,%edi
test   $0x1,%dil
je     12e2 <send_file+0x182>
movl   $0x91,0x18(%rsp,%rsi,1)
pextrw $0x6,%xmm0,%edi
test   $0x1,%dil
je     1240 <send_file+0xe0>
movl   $0x91,0x1c(%rsp,%rsi,1)
jmp    1240 <send_file+0xe0>
xchg   %ax,%ax
cmp    %rbx,%rax
jne    1329 <send_file+0x1c9>
cmp    $0x1b9,%ebx
jne    1340 <send_file+0x1e0>
mov    %r13d,%edi
mov    %r15,%rsi
xor    %edx,%edx
jmp    137e <send_file+0x21e>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
cmp    %rax,%rbx
je     1305 <send_file+0x1a5>
cmpl   $0x90,(%rsp,%rax,4)
jne    1320 <send_file+0x1c0>
movl   $0x91,(%rsp,%rax,4)
jmp    1320 <send_file+0x1c0>
nopl   0x0(%rax,%rax,1)
test   $0x1,%cl
je     13b3 <send_file+0x253>
mov    %r13d,%edi
mov    %r15,%rsi
cmp    $0x100,%ebx
jb     137c <send_file+0x21c>
mov    $0xff,%edx
call   1070 <send_chunk@plt>
mov    %eax,%ebp
test   %eax,%eax
js     13ce <send_file+0x26e>
cmp    $0x1,%ebp
jne    1370 <send_file+0x210>
mov    %r13d,%edi
call   1030 <wait4buffers@plt>
add    $0xffffff01,%ebx
mov    %r13d,%edi
mov    %r14,%rsi
mov    %ebx,%edx
call   1070 <send_chunk@plt>
mov    %eax,%ebp
test   %eax,%eax
js     13ce <send_file+0x26e>
cmp    $0x1,%ebp
jne    11e0 <send_file+0x80>
mov    %r13d,%edi
call   1030 <wait4buffers@plt>
jmp    11e0 <send_file+0x80>
mov    %eax,%ebp
mov    0x2c38(%rip),%rax
mov    (%rax),%edi
lea    0xc5f(%rip),%rsi
jmp    13c9 <send_file+0x269>
xor    %ebp,%ebp
jmp    13ce <send_file+0x26e>
mov    %eax,%ebp
mov    0x2c20(%rip),%rax
mov    (%rax),%edi
lea    0xc73(%rip),%rsi
call   1050 <fprintf@plt>
mov    %ebp,%eax
add    $0x6e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"Unable to get SPI client into command mode\0A\00"
@.str.1 = [32 x i8] c"Unable to reset the SPI client\0A\00"
define i32 @send_file(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [441 x i32]
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%11 = load i32, i32* %4
%12 = call i32 @cmd_flush(i32 %11)
store i32 %12, i32* %6
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* %6
store i32 %17, i32* %3
br label %114
18: ; preds = %2
%19 = load i32, i32* %4
%20 = call i32 @send_cmd(i32 %19, i32 144, i32 0)
store i32 %20, i32* %6
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* %6
store i32 %25, i32* %3
br label %114
26: ; preds = %18
%27 = load i32, i32* %6
%28 = icmp ne i32 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i32, i32* %4
%31 = call i32 @wait4buffers(i32 %30)
br label %32
32: ; preds = %29, %26
br label %33
33: ; preds = %32, %112
%34 = load i32, i32* %5
%35 = getelementptr inbounds [441 x i32], [441 x i32]* %8, i64 0, i64 0
%36 = call i32 @read_n(i32 %34, i32* %35, i32 1764)
store i32 %36, i32* %9
store i32 0, i32* %10
br label %37
37: ; preds = %52, %33
%38 = load i32, i32* %10
%39 = load i32, i32* %9
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %55
41: ; preds = %37
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [441 x i32], [441 x i32]* %8, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = icmp eq i32 %45, 144
br i1 %46, label %47, label %51
47: ; preds = %41
%48 = load i32, i32* %10
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [441 x i32], [441 x i32]* %8, i64 0, i64 %49
store i32 145, i32* %50
br label %51
51: ; preds = %47, %41
br label %52
52: ; preds = %51
%53 = load i32, i32* %10
%54 = add nsw i32 %53, 1
store i32 %54, i32* %10
br label %37
55: ; preds = %37
%56 = load i32, i32* %9
%57 = icmp eq i32 %56, 441
br i1 %57, label %58, label %62
58: ; preds = %55
%59 = load i32, i32* %4
%60 = getelementptr inbounds [441 x i32], [441 x i32]* %8, i64 0, i64 0
%61 = call i32 @send_chunk(i32 %59, i32* %60, i32 0)
store i32 %61, i32* %6
br label %96
62: ; preds = %55
%63 = load i32, i32* %9
%64 = icmp sgt i32 %63, 0
br i1 %64, label %65, label %94
65: ; preds = %62
%66 = load i32, i32* %9
%67 = icmp sgt i32 %66, 255
br i1 %67, label %68, label %88
68: ; preds = %65
%69 = load i32, i32* %4
%70 = getelementptr inbounds [441 x i32], [441 x i32]* %8, i64 0, i64 0
%71 = call i32 @send_chunk(i32 %69, i32* %70, i32 255)
store i32 %71, i32* %6
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %68
%74 = load i32, i32* %6
store i32 %74, i32* %3
br label %114
75: ; preds = %68
%76 = load i32, i32* %6
%77 = icmp eq i32 %76, 1
br i1 %77, label %78, label %81
78: ; preds = %75
%79 = load i32, i32* %4
%80 = call i32 @wait4buffers(i32 %79)
store i32 %80, i32* %6
br label %81
81: ; preds = %78, %75
%82 = load i32, i32* %4
%83 = getelementptr inbounds [441 x i32], [441 x i32]* %8, i64 0, i64 0
%84 = getelementptr inbounds i32, i32* %83, i64 255
%85 = load i32, i32* %9
%86 = sub nsw i32 %85, 255
%87 = call i32 @send_chunk(i32 %82, i32* %84, i32 %86)
store i32 %87, i32* %6
br label %93
88: ; preds = %65
%89 = load i32, i32* %4
%90 = getelementptr inbounds [441 x i32], [441 x i32]* %8, i64 0, i64 0
%91 = load i32, i32* %9
%92 = call i32 @send_chunk(i32 %89, i32* %90, i32 %91)
store i32 %92, i32* %6
br label %93
93: ; preds = %88, %81
br label %95
94: ; preds = %62
br label %113
95: ; preds = %93
br label %96
96: ; preds = %95, %58
%97 = load i32, i32* %6
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %96
%100 = load i32, i32* %6
store i32 %100, i32* %3
br label %114
101: ; preds = %96
%102 = load i32, i32* %6
store i32 %102, i32* %7
%103 = load i32, i32* %7
%104 = icmp eq i32 %103, 0
br i1 %104, label %105, label %106
105: ; preds = %101
br label %106
106: ; preds = %105, %101
%107 = load i32, i32* %7
%108 = icmp eq i32 %107, 1
br i1 %108, label %109, label %112
109: ; preds = %106
%110 = load i32, i32* %4
%111 = call i32 @wait4buffers(i32 %110)
store i32 %111, i32* %7
br label %112
112: ; preds = %109, %106
br label %33
113: ; preds = %94
store i32 0, i32* %3
br label %114
114: ; preds = %113, %99, %73, %22, %14
%115 = load i32, i32* %3
ret i32 %115
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"Unable to get SPI client into command mode\0A\00"
@.str.1 = [32 x i8] c"Unable to reset the SPI client\0A\00"
define i32 @send_file(i32 %0, i32 %1) {
%3 = alloca [441 x i32]
%4 = tail call i32 @cmd_flush(i32 %0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %128
9: ; preds = %2
%10 = tail call i32 @send_cmd(i32 %0, i32 144, i32 0)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %128
15: ; preds = %9
%16 = icmp eq i32 %10, 0
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = tail call i32 @wait4buffers(i32 %0)
br label %19
19: ; preds = %17, %15
%20 = bitcast [441 x i32]* %3 to i8*
%21 = getelementptr inbounds [441 x i32], [441 x i32]* %3, i64 0, i64 0
%22 = getelementptr inbounds [441 x i32], [441 x i32]* %3, i64 0, i64 255
%23 = call i32 @read_n(i32 %1, i32* %21, i32 1764)
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %127
25: ; preds = %19, %124
%26 = phi i1 [ %126, %124 ], [ %24, %19 ]
%27 = phi i32 [ %125, %124 ], [ %23, %19 ]
%28 = zext i32 %27 to i64
%29 = icmp ult i32 %27, 8
br i1 %29, label %85, label %30
30: ; preds = %25
%31 = and i64 %28, 4294967288
br label %32
32: ; preds = %80, %30
%33 = phi i64 [ 0, %30 ], [ %81, %80 ]
%34 = or i64 %33, 4
%35 = getelementptr inbounds [441 x i32], [441 x i32]* %3, i64 0, i64 %33
%36 = bitcast i32* %35 to <4 x i32>*
%37 = load <4 x i32>, <4 x i32>* %36
%38 = getelementptr inbounds i32, i32* %35, i64 4
%39 = bitcast i32* %38 to <4 x i32>*
%40 = load <4 x i32>, <4 x i32>* %39
%41 = icmp eq <4 x i32> %37, <i32 144, i32 144, i32 144, i32 144>
%42 = icmp eq <4 x i32> %40, <i32 144, i32 144, i32 144, i32 144>
%43 = extractelement <4 x i1> %41, i64 0
br i1 %43, label %44, label %46
44: ; preds = %32
%45 = getelementptr inbounds [441 x i32], [441 x i32]* %3, i64 0, i64 %33
store i32 145, i32* %45
br label %46
46: ; preds = %44, %32
%47 = extractelement <4 x i1> %41, i64 1
br i1 %47, label %48, label %51
48: ; preds = %46
%49 = or i64 %33, 1
%50 = getelementptr inbounds [441 x i32], [441 x i32]* %3, i64 0, i64 %49
store i32 145, i32* %50
br label %51
51: ; preds = %48, %46
%52 = extractelement <4 x i1> %41, i64 2
br i1 %52, label %53, label %56
53: ; preds = %51
%54 = or i64 %33, 2
%55 = getelementptr inbounds [441 x i32], [441 x i32]* %3, i64 0, i64 %54
store i32 145, i32* %55
br label %56
56: ; preds = %53, %51
%57 = extractelement <4 x i1> %41, i64 3
br i1 %57, label %58, label %61
58: ; preds = %56
%59 = or i64 %33, 3
%60 = getelementptr inbounds [441 x i32], [441 x i32]* %3, i64 0, i64 %59
store i32 145, i32* %60
br label %61
61: ; preds = %58, %56
%62 = extractelement <4 x i1> %42, i64 0
br i1 %62, label %63, label %65
63: ; preds = %61
%64 = getelementptr inbounds [441 x i32], [441 x i32]* %3, i64 0, i64 %34
store i32 145, i32* %64
br label %65
65: ; preds = %63, %61
%66 = extractelement <4 x i1> %42, i64 1
br i1 %66, label %67, label %70
67: ; preds = %65
%68 = or i64 %33, 5
%69 = getelementptr inbounds [441 x i32], [441 x i32]* %3, i64 0, i64 %68
store i32 145, i32* %69
br label %70
70: ; preds = %67, %65
%71 = extractelement <4 x i1> %42, i64 2
br i1 %71, label %72, label %75
72: ; preds = %70
%73 = or i64 %33, 6
%74 = getelementptr inbounds [441 x i32], [441 x i32]* %3, i64 0, i64 %73
store i32 145, i32* %74
br label %75
75: ; preds = %72, %70
%76 = extractelement <4 x i1> %42, i64 3
br i1 %76, label %77, label %80
77: ; preds = %75
%78 = or i64 %33, 7
%79 = getelementptr inbounds [441 x i32], [441 x i32]* %3, i64 0, i64 %78
store i32 145, i32* %79
br label %80
80: ; preds = %77, %75
%81 = add nuw i64 %33, 8
%82 = icmp eq i64 %81, %31
br i1 %82, label %83, label %32
83: ; preds = %80
%84 = icmp eq i64 %31, %28
br i1 %84, label %96, label %85
85: ; preds = %25, %83
%86 = phi i64 [ 0, %25 ], [ %31, %83 ]
br label %87
87: ; preds = %85, %93
%88 = phi i64 [ %94, %93 ], [ %86, %85 ]
%89 = getelementptr inbounds [441 x i32], [441 x i32]* %3, i64 0, i64 %88
%90 = load i32, i32* %89
%91 = icmp eq i32 %90, 144
br i1 %91, label %92, label %93
92: ; preds = %87
store i32 145, i32* %89
br label %93
93: ; preds = %87, %92
%94 = add nuw nsw i64 %88, 1
%95 = icmp eq i64 %94, %28
br i1 %95, label %96, label %87
96: ; preds = %93, %83
%97 = icmp eq i32 %27, 441
br i1 %97, label %98, label %100
98: ; preds = %96
%99 = call i32 @send_chunk(i32 %0, i32* %21, i32 0)
br label %115
100: ; preds = %96
br i1 %26, label %101, label %127
101: ; preds = %100
%102 = icmp ugt i32 %27, 255
br i1 %102, label %103, label %113
103: ; preds = %101
%104 = call i32 @send_chunk(i32 %0, i32* %21, i32 255)
%105 = icmp slt i32 %104, 0
br i1 %105, label %122, label %106
106: ; preds = %103
%107 = icmp eq i32 %104, 1
br i1 %107, label %108, label %110
108: ; preds = %106
%109 = call i32 @wait4buffers(i32 %0)
br label %110
110: ; preds = %108, %106
%111 = add nsw i32 %27, -255
%112 = call i32 @send_chunk(i32 %0, i32* %22, i32 %111)
br label %115
113: ; preds = %101
%114 = call i32 @send_chunk(i32 %0, i32* %21, i32 %27)
br label %115
115: ; preds = %113, %110, %98
%116 = phi i32 [ %99, %98 ], [ %112, %110 ], [ %114, %113 ]
%117 = icmp slt i32 %116, 0
br i1 %117, label %122, label %118
118: ; preds = %115
%119 = icmp eq i32 %116, 1
br i1 %119, label %120, label %124
120: ; preds = %118
%121 = call i32 @wait4buffers(i32 %0)
br label %124
122: ; preds = %103, %115
%123 = phi i32 [ %116, %115 ], [ %104, %103 ]
br label %128
124: ; preds = %118, %120
%125 = call i32 @read_n(i32 %1, i32* %21, i32 1764)
%126 = icmp sgt i32 %125, 0
br i1 %126, label %25, label %127
127: ; preds = %100, %124, %19
br label %128
128: ; preds = %122, %127, %12, %6
%129 = phi i32 [ %4, %6 ], [ %10, %12 ], [ 0, %127 ], [ %123, %122 ]
ret i32 %129
}