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

/* Variables and functions */
scalar_t__ EAGAIN;
scalar_t__ errno;
int /*<<< orphan*/ error(int, scalar_t__, char *, char *, int, ...);
int /*<<< orphan*/ memcpy(unsigned char *, char *, int);
int /*<<< orphan*/ progress_bar(long, long);
int read(int, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char, char);
int /*<<< orphan*/ usleep(int);
int write(int, char *, int);
void comm_get_picture_data(int tty, char picture_no, long size,
                           unsigned char *out) {
  char buffer[2048];
  int buffer_size, limit, data_read, data_written;
  long original_size = size;
  snprintf(buffer, sizeof(buffer),
           "\xE6\xE6\xE6\xE6\x05"
           "%c"
           "\xFA"
           "%c",
           picture_no, picture_no ^ 0xFF);
  buffer_size = 8;
  if (write(tty, buffer, buffer_size) == -1)
    error(1, errno, "%s.%d: write()",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/kobolt/polaroid-320/refs/heads/master/"
          "comm.c",
          120);
  data_written = 0;
  while (size > 0) {
    usleep(10000);
    data_read = read(tty, buffer, 5);
    if (data_read == -1)
      error(1, errno, "%s.%d: read()",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/kobolt/polaroid-320/refs/heads/master/"
            "comm.c",
            129);
    if (buffer[0] != 0x04)
      error(0, 0, "%s.%d: Wrong picture data frame header: 0x%02X",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/kobolt/polaroid-320/refs/heads/master/"
            "comm.c",
            139, buffer[0]);
    if (size > 2000)
      limit = 2000;
    else
      limit = size;
    data_read = 0;
    while (limit > 0) {
      data_read = read(tty, buffer, limit);
      if (data_read == -1) {
        if (errno == EAGAIN) {
          usleep(1000);
          continue;
        } else
          error(1, errno, "%s.%d: read()",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/kobolt/polaroid-320/refs/"
                "heads/master/comm.c",
                154);
      }
      limit -= data_read;
      size -= data_read;
      memcpy(out + data_written, buffer, data_read);
      data_written += data_read;
      progress_bar(original_size, size);
      usleep(1000);
    }
    data_read = read(tty, buffer, 2);
    if (data_read == -1)
      error(1, errno, "%s.%d: read()",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/kobolt/polaroid-320/refs/heads/master/"
            "comm.c",
            176);
  }
}


x86 assembly (clang, -O0):
<comm_get_picture_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x838(%rbp)
lea    -0x820(%rbp),%rdi
mov    -0x5(%rbp),%cl
movsbl -0x5(%rbp),%eax
xor    $0xff,%eax
mov    $0x800,%esi
lea    0xe4a(%rip),%rdx
movsbl %cl,%ecx
movsbl %al,%r8d
call   1040 <snprintf@plt>
movl   $0x8,-0x824(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    -0x824(%rbp),%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    1214 <comm_get_picture_data+0xa4>
mov    0x2def(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xe0b(%rip),%rdx
lea    0xe13(%rip),%rcx
mov    $0x78,%r8d
mov    $0x0,%al
call   1080 <error@plt>
movl   $0x0,-0x830(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    1448 <comm_get_picture_data+0x2d8>
mov    $0x2710,%edi
call   1090 <usleep@plt>
mov    -0x4(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x5,%edx
call   1050 <read@plt>
mov    %eax,-0x82c(%rbp)
cmpl   $0xffffffff,-0x82c(%rbp)
jne    1284 <comm_get_picture_data+0x114>
mov    0x2d7f(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xe31(%rip),%rdx
lea    0xda3(%rip),%rcx
mov    $0x81,%r8d
mov    $0x0,%al
call   1080 <error@plt>
movsbl -0x820(%rbp),%eax
cmp    $0x4,%eax
je     12bd <comm_get_picture_data+0x14d>
movsbl -0x820(%rbp),%r9d
ff
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xe06(%rip),%rdx
lea    0xd6a(%rip),%rcx
mov    $0x8b,%r8d
mov    $0x0,%al
call   1080 <error@plt>
cmpq   $0x7d0,-0x10(%rbp)
jle    12da <comm_get_picture_data+0x16a>
movl   $0x7d0,-0x828(%rbp)
jmp    12e4 <comm_get_picture_data+0x174>
mov    -0x10(%rbp),%rax
mov    %eax,-0x828(%rbp)
movl   $0x0,-0x82c(%rbp)
cmpl   $0x0,-0x828(%rbp)
jle    13f2 <comm_get_picture_data+0x282>
mov    -0x4(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    -0x828(%rbp),%edx
call   1050 <read@plt>
mov    %eax,-0x82c(%rbp)
cmpl   $0xffffffff,-0x82c(%rbp)
jne    137b <comm_get_picture_data+0x20b>
mov    0x2cb6(%rip),%rax
mov    (%rax),%rax
mov    0x2c9c(%rip),%rcx
cmp    (%rcx),%rax
jne    134c <comm_get_picture_data+0x1dc>
mov    $0x3e8,%edi
call   1090 <usleep@plt>
jmp    12ee <comm_get_picture_data+0x17e>
mov    0x2c8d(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xd3f(%rip),%rdx
lea    0xcb1(%rip),%rcx
mov    $0x9a,%r8d
mov    $0x0,%al
call   1080 <error@plt>
jmp    137b <comm_get_picture_data+0x20b>
mov    -0x82c(%rbp),%ecx
mov    -0x828(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x828(%rbp)
movslq -0x82c(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x830(%rbp),%rax
add    %rax,%rdi
lea    -0x820(%rbp),%rsi
mov    -0x82c(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0x82c(%rbp),%eax
add    -0x830(%rbp),%eax
mov    %eax,-0x830(%rbp)
mov    -0x838(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <progress_bar@plt>
mov    $0x3e8,%edi
call   1090 <usleep@plt>
jmp    12ee <comm_get_picture_data+0x17e>
mov    -0x4(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x2,%edx
call   1050 <read@plt>
mov    %eax,-0x82c(%rbp)
cmpl   $0xffffffff,-0x82c(%rbp)
jne    1443 <comm_get_picture_data+0x2d3>
mov    0x2bc0(%rip),%rax
mov    (%rax),%rsi
mov    $0x1,%edi
lea    0xc72(%rip),%rdx
lea    0xbe4(%rip),%rcx
mov    $0xb0,%r8d
mov    $0x0,%al
call   1080 <error@plt>
jmp    121e <comm_get_picture_data+0xae>
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comm_get_picture_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
mov    %rcx,0x18(%rsp)
mov    %rdx,%r14
mov    %esi,%ecx
mov    %edi,%r15d
mov    %ecx,%eax
not    %al
movsbl %al,%r8d
lea    0xe63(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x800,%esi
call   1040 <snprintf@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
je     11ce <comm_get_picture_data+0x5e>
test   %r14,%r14
jg     1201 <comm_get_picture_data+0x91>
jmp    13d9 <comm_get_picture_data+0x269>
mov    0x2e0b(%rip),%rax
mov    (%rax),%rsi
lea    0xe2c(%rip),%rdx
lea    0xe34(%rip),%rcx
mov    $0x1,%edi
mov    $0x78,%r8d
xor    %eax,%eax
call   1080 <error@plt>
test   %r14,%r14
jle    13d9 <comm_get_picture_data+0x269>
lea    0x20(%rsp),%rbx
mov    0x2dd3(%rip),%rbp
mov    %r14,0x8(%rsp)
xor    %r12d,%r12d
mov    %r14,0x10(%rsp)
jmp    122c <comm_get_picture_data+0xbc>
nopl   0x0(%rax)
cmpq   $0x0,0x8(%rsp)
jle    13d9 <comm_get_picture_data+0x269>
mov    $0x2710,%edi
call   1090 <usleep@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1050 <read@plt>
cmp    $0xffffffff,%eax
jne    126f <comm_get_picture_data+0xff>
mov    0x0(%rbp),%rsi
mov    $0x1,%edi
lea    0xe46(%rip),%rdx
lea    0xdb8(%rip),%rcx
mov    $0x81,%r8d
xor    %eax,%eax
call   1080 <error@plt>
movsbl 0x20(%rsp),%r9d
cmp    $0x4,%r9d
je     129a <comm_get_picture_data+0x12a>
xor    %edi,%edi
xor    %esi,%esi
lea    0xe29(%rip),%rdx
lea    0xd8d(%rip),%rcx
mov    $0x8b,%r8d
xor    %eax,%eax
call   1080 <error@plt>
mov    0x8(%rsp),%rax
cmp    $0x7d0,%rax
mov    $0x7d0,%r13d
cmovb  %eax,%r13d
test   %r13d,%r13d
jne    137f <comm_get_picture_data+0x20f>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1050 <read@plt>
cmp    $0xffffffff,%eax
mov    0x2d0e(%rip),%rbp
jne    1220 <comm_get_picture_data+0xb0>
mov    0x0(%rbp),%rsi
mov    $0x1,%edi
lea    0xdb9(%rip),%rdx
lea    0xd2b(%rip),%rcx
mov    $0xb0,%r8d
xor    %eax,%eax
call   1080 <error@plt>
jmp    1220 <comm_get_picture_data+0xb0>
mov    $0x1,%edi
lea    0xd94(%rip),%rdx
lea    0xd06(%rip),%rcx
mov    $0x9a,%r8d
xor    %eax,%eax
call   1080 <error@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rbp
movslq %r14d,%rbx
mov    0x8(%rsp),%r14
sub    %rbx,%r14
movslq %r12d,%r12
mov    0x18(%rsp),%rax
lea    (%rax,%r12,1),%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1060 <memcpy@plt>
add    %ebx,%r12d
mov    0x10(%rsp),%rdi
mov    %r14,0x8(%rsp)
mov    %r14,%rsi
call   1070 <progress_bar@plt>
mov    $0x3e8,%edi
call   1090 <usleep@plt>
sub    %ebx,%r13d
mov    %rbp,%rbx
jle    12b8 <comm_get_picture_data+0x148>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r13d,%edx
call   1050 <read@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    1330 <comm_get_picture_data+0x1c0>
mov    0x2c44(%rip),%rbp
nopl   0x0(%rax)
mov    0x0(%rbp),%rsi
mov    0x2c25(%rip),%rax
cmp    (%rax),%rsi
jne    1301 <comm_get_picture_data+0x191>
mov    $0x3e8,%edi
call   1090 <usleep@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r13d,%edx
call   1050 <read@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
je     13a0 <comm_get_picture_data+0x230>
jmp    1330 <comm_get_picture_data+0x1c0>
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"\E6\E6\E6\E6\05%c\FA%c\00"
@errno = global i64 0
@.str.1 = [15 x i8] c"%s.%d: write()\00"
@.str.2 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kobolt/polaroid-320/refs/heads/master/comm.c\00"
@.str.3 = [14 x i8] c"%s.%d: read()\00"
@.str.4 = [47 x i8] c"%s.%d: Wrong picture data frame header: 0x%02X\00"
@EAGAIN = global i64 0
define void @comm_get_picture_data(i32 %0, i8 signext %1, i64 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8
%7 = alloca i64
%8 = alloca i8*
%9 = alloca [2048 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
store i32 %0, i32* %5
store i8 %1, i8* %6
store i64 %2, i64* %7
store i8* %3, i8** %8
%15 = load i64, i64* %7
store i64 %15, i64* %14
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%17 = load i8, i8* %6
%18 = load i8, i8* %6
%19 = sext i8 %18 to i32
%20 = xor i32 %19, 255
%21 = trunc i32 %20 to i8
%22 = call i32 @snprintf(i8* %16, i32 2048, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %17, i8 signext %21)
store i32 8, i32* %10
%23 = load i32, i32* %5
%24 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%25 = load i32, i32* %10
%26 = call i32 @write(i32 %23, i8* %24, i32 %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %4
%29 = load i64, i64* @errno
%30 = call i32 (i32, i64, i8*, i8*, i32, ...) @error(i32 1, i64 %29, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 120)
br label %31
31: ; preds = %28, %4
store i32 0, i32* %13
br label %32
32: ; preds = %114, %31
%33 = load i64, i64* %7
%34 = icmp sgt i64 %33, 0
br i1 %34, label %35, label %115
35: ; preds = %32
%36 = call i32 @usleep(i32 10000)
%37 = load i32, i32* %5
%38 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%39 = call i32 @read(i32 %37, i8* %38, i32 5)
store i32 %39, i32* %12
%40 = load i32, i32* %12
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %45
42: ; preds = %35
%43 = load i64, i64* @errno
%44 = call i32 (i32, i64, i8*, i8*, i32, ...) @error(i32 1, i64 %43, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 129)
br label %45
45: ; preds = %42, %35
%46 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 4
br i1 %49, label %50, label %55
50: ; preds = %45
%51 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = call i32 (i32, i64, i8*, i8*, i32, ...) @error(i32 0, i64 0, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 139, i32 %53)
br label %55
55: ; preds = %50, %45
%56 = load i64, i64* %7
%57 = icmp sgt i64 %56, 2000
br i1 %57, label %58, label %59
58: ; preds = %55
store i32 2000, i32* %11
br label %62
59: ; preds = %55
%60 = load i64, i64* %7
%61 = trunc i64 %60 to i32
store i32 %61, i32* %11
br label %62
62: ; preds = %59, %58
store i32 0, i32* %12
br label %63
63: ; preds = %83, %77, %62
%64 = load i32, i32* %11
%65 = icmp sgt i32 %64, 0
br i1 %65, label %66, label %105
66: ; preds = %63
%67 = load i32, i32* %5
%68 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%69 = load i32, i32* %11
%70 = call i32 @read(i32 %67, i8* %68, i32 %69)
store i32 %70, i32* %12
%71 = load i32, i32* %12
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %83
73: ; preds = %66
%74 = load i64, i64* @errno
%75 = load i64, i64* @EAGAIN
%76 = icmp eq i64 %74, %75
br i1 %76, label %77, label %79
77: ; preds = %73
%78 = call i32 @usleep(i32 1000)
br label %63
79: ; preds = %73
%80 = load i64, i64* @errno
%81 = call i32 (i32, i64, i8*, i8*, i32, ...) @error(i32 1, i64 %80, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 154)
br label %82
82: ; preds = %79
br label %83
83: ; preds = %82, %66
%84 = load i32, i32* %12
%85 = load i32, i32* %11
%86 = sub nsw i32 %85, %84
store i32 %86, i32* %11
%87 = load i32, i32* %12
%88 = sext i32 %87 to i64
%89 = load i64, i64* %7
%90 = sub nsw i64 %89, %88
store i64 %90, i64* %7
%91 = load i8*, i8** %8
%92 = load i32, i32* %13
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %91, i64 %93
%95 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%96 = load i32, i32* %12
%97 = call i32 @memcpy(i8* %94, i8* %95, i32 %96)
%98 = load i32, i32* %12
%99 = load i32, i32* %13
%100 = add nsw i32 %99, %98
store i32 %100, i32* %13
%101 = load i64, i64* %14
%102 = load i64, i64* %7
%103 = call i32 @progress_bar(i64 %101, i64 %102)
%104 = call i32 @usleep(i32 1000)
br label %63
105: ; preds = %63
%106 = load i32, i32* %5
%107 = getelementptr inbounds [2048 x i8], [2048 x i8]* %9, i64 0, i64 0
%108 = call i32 @read(i32 %106, i8* %107, i32 2)
store i32 %108, i32* %12
%109 = load i32, i32* %12
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %114
111: ; preds = %105
%112 = load i64, i64* @errno
%113 = call i32 (i32, i64, i8*, i8*, i32, ...) @error(i32 1, i64 %112, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 176)
br label %114
114: ; preds = %111, %105
br label %32
115: ; preds = %32
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"\E6\E6\E6\E6\05%c\FA%c\00"
@errno = global i64 0
@.str.1 = [15 x i8] c"%s.%d: write()\00"
@.str.2 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kobolt/polaroid-320/refs/heads/master/comm.c\00"
@.str.3 = [14 x i8] c"%s.%d: read()\00"
@.str.4 = [47 x i8] c"%s.%d: Wrong picture data frame header: 0x%02X\00"
@EAGAIN = global i64 0
define void @comm_get_picture_data(i32 %0, i8 signext %1, i64 %2, i8* %3) {
%5 = alloca [2048 x i8]
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%7 = xor i8 %1, -1
%8 = call i32 @snprintf(i8* %6, i32 2048, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8 signext %1, i8 signext %7)
%9 = call i32 @write(i32 %0, i8* %6, i32 8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = load i64, i64* @errno
%13 = call i32 (i32, i64, i8*, i8*, i32, ...) @error(i32 1, i64 %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 120)
br label %14
14: ; preds = %11, %4
%15 = icmp sgt i64 %2, 0
br i1 %15, label %16, label %75
16: ; preds = %14, %73
%17 = phi i64 [ %67, %73 ], [ %2, %14 ]
%18 = phi i32 [ %66, %73 ], [ 0, %14 ]
%19 = call i32 @usleep(i32 10000)
%20 = call i32 @read(i32 %0, i8* %6, i32 5)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i64, i64* @errno
%24 = call i32 (i32, i64, i8*, i8*, i32, ...) @error(i32 1, i64 %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 129)
br label %25
25: ; preds = %22, %16
%26 = load i8, i8* %6
%27 = icmp eq i8 %26, 4
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = sext i8 %26 to i32
%30 = call i32 (i32, i64, i8*, i8*, i32, ...) @error(i32 0, i64 0, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 139, i32 %29)
br label %31
31: ; preds = %28, %25
%32 = icmp ult i64 %17, 2000
%33 = select i1 %32, i64 %17, i64 2000
%34 = trunc i64 %33 to i32
%35 = icmp eq i32 %34, 0
br i1 %35, label %65, label %36
36: ; preds = %31, %53
%37 = phi i64 [ %57, %53 ], [ %17, %31 ]
%38 = phi i32 [ %61, %53 ], [ %18, %31 ]
%39 = phi i32 [ %55, %53 ], [ %34, %31 ]
%40 = call i32 @read(i32 %0, i8* %6, i32 %39)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %53
42: ; preds = %36, %47
%43 = phi i32 [ %49, %47 ], [ %40, %36 ]
%44 = load i64, i64* @errno
%45 = load i64, i64* @EAGAIN
%46 = icmp eq i64 %44, %45
br i1 %46, label %47, label %51
47: ; preds = %42
%48 = call i32 @usleep(i32 1000)
%49 = call i32 @read(i32 %0, i8* %6, i32 %39)
%50 = icmp eq i32 %49, -1
br i1 %50, label %42, label %53
51: ; preds = %42
%52 = call i32 (i32, i64, i8*, i8*, i32, ...) @error(i32 1, i64 %44, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 154)
br label %53
53: ; preds = %47, %36, %51
%54 = phi i32 [ %43, %51 ], [ %40, %36 ], [ %49, %47 ]
%55 = sub nsw i32 %39, %54
%56 = sext i32 %54 to i64
%57 = sub nsw i64 %37, %56
%58 = sext i32 %38 to i64
%59 = getelementptr inbounds i8, i8* %3, i64 %58
%60 = call i32 @memcpy(i8* %59, i8* %6, i32 %54)
%61 = add nsw i32 %54, %38
%62 = call i32 @progress_bar(i64 %2, i64 %57)
%63 = call i32 @usleep(i32 1000)
%64 = icmp sgt i32 %55, 0
br i1 %64, label %36, label %65
65: ; preds = %53, %31
%66 = phi i32 [ %18, %31 ], [ %61, %53 ]
%67 = phi i64 [ %17, %31 ], [ %57, %53 ]
%68 = call i32 @read(i32 %0, i8* %6, i32 2)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %73
70: ; preds = %65
%71 = load i64, i64* @errno
%72 = call i32 (i32, i64, i8*, i8*, i32, ...) @error(i32 1, i64 %71, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.2, i64 0, i64 0), i32 176)
br label %73
73: ; preds = %70, %65
%74 = icmp sgt i64 %67, 0
br i1 %74, label %16, label %75
75: ; preds = %73, %14
ret void
}