#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 */
struct stat {
  long st_size;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ bail(char *, ...);
scalar_t__ ceil(long);
int /*<<< orphan*/ close(int);
char *malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, long);
int stat(char *, struct stat *);
void readfiles(char **input_files, int bufsize, int num_input) {
  int i;
  int ret;
  char *buffer = malloc(bufsize * sizeof(char));
  if (NULL == buffer)
    bail("cannot allocate buffer (%d bytes)", bufsize);
  for (i = 0; i < num_input; i++) {
    int fd;
    int size;
    int count = 0;
    long int total_size = 0;
    struct stat st;
    fd = open(input_files[i], O_RDONLY);
    if (fd < 0)
      bail("cannot open 1 %s", input_files[i]);
    ret = stat(input_files[i], &st);
    if (ret < 0)
      bail("cannot stat %s", input_files[i]);
    printf("reading input file: %s size: %ld num_reads: %d\n", input_files[i],
           (long)st.st_size, (int)ceil((long)st.st_size / bufsize));
    while (total_size < (long)st.st_size) {
      memset(buffer, '\0', bufsize);
      if (st.st_size - total_size > bufsize)
        size = read(fd, buffer, bufsize);
      else
        size = read(fd, buffer, st.st_size - total_size);
      if (size < 0)
        bail("cannot read from %s", input_files[i]);
      total_size = total_size + size;
      count++;
      if (count % 1000 == 0)
        printf("reading operations: %d total_size: %ld st_size: %ld\n", count,
               total_size, (long)st.st_size);
    }
    printf("read : %ld bytes to %s with bufsize: %d\n", total_size,
           input_files[i], bufsize);
    close(fd);
  }
  return;
}


x86 assembly (clang, -O0):
<readfiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    11d2 <readfiles+0x42>
mov    -0xc(%rbp),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   10b0 <bail@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    13bb <readfiles+0x22b>
movl   $0x0,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2de1(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1235 <readfiles+0xa5>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   10b0 <bail@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x40(%rbp),%rsi
call   1080 <stat@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1271 <readfiles+0xe1>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   10b0 <bail@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
movslq -0xc(%rbp),%rcx
cqto
idiv   %rcx
mov    %rax,%rdi
call   1030 <ceil@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    %eax,%ecx
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
cmp    -0x40(%rbp),%rax
jge    1384 <readfiles+0x1f4>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x40(%rbp),%rax
sub    -0x38(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jle    12ff <readfiles+0x16f>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
movslq -0xc(%rbp),%rdx
call   1070 <read@plt>
mov    %eax,-0x28(%rbp)
jmp    1316 <readfiles+0x186>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x40(%rbp),%rdx
sub    -0x38(%rbp),%rdx
call   1070 <read@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    133a <readfiles+0x1aa>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   10b0 <bail@plt>
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    137f <readfiles+0x1ef>
mov    -0x2c(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
lea    0xd0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b6 <readfiles+0x126>
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0xc(%rbp),%ecx
lea    0xd1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d9 <readfiles+0x49>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readfiles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edx,%r14d
mov    %rdi,%rbx
mov    %esi,(%rsp)
mov    %esi,%edi
call   1090 <malloc@plt>
mov    %rax,0x28(%rsp)
test   %rax,%rax
je     11c2 <readfiles+0x32>
test   %r14d,%r14d
jg     11dc <readfiles+0x4c>
jmp    13b5 <readfiles+0x225>
lea    0xe37(%rip),%rdi
mov    (%rsp),%esi
xor    %eax,%eax
call   10b0 <bail@plt>
test   %r14d,%r14d
jle    13b5 <readfiles+0x225>
movslq (%rsp),%r15
mov    %r14d,%eax
mov    %rax,0x20(%rsp)
xor    %ebp,%ebp
mov    %rbx,0x8(%rsp)
mov    %r15,0x18(%rsp)
jmp    1242 <readfiles+0xb2>
cs nopw 0x0(%rax,%rax,1)
xor    %r12d,%r12d
mov    0x8(%rsp),%rbx
mov    0x10(%rsp),%rbp
mov    (%rbx,%rbp,8),%rdx
lea    0xea3(%rip),%rdi
mov    %r12,%rsi
mov    (%rsp),%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
call   1060 <close@plt>
add    $0x1,%rbp
cmp    0x20(%rsp),%rbp
mov    0x18(%rsp),%r15
je     13b5 <readfiles+0x225>
mov    (%rbx,%rbp,8),%rdi
mov    0x2d9b(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
jns    126e <readfiles+0xde>
mov    (%rbx,%rbp,8),%rsi
lea    0xdbb(%rip),%rdi
xor    %eax,%eax
call   10b0 <bail@plt>
mov    (%rbx,%rbp,8),%rdi
lea    0x30(%rsp),%rsi
call   1080 <stat@plt>
test   %eax,%eax
jns    1292 <readfiles+0x102>
mov    (%rbx,%rbp,8),%rsi
lea    0xda8(%rip),%rdi
xor    %eax,%eax
call   10b0 <bail@plt>
mov    (%rbx,%rbp,8),%r14
mov    0x30(%rsp),%r13
mov    %r13,%rax
or     %r15,%rax
shr    $0x20,%rax
je     12c0 <readfiles+0x130>
mov    %r13,%rax
cqto
idiv   %r15
mov    %rax,%rdi
jmp    12ca <readfiles+0x13a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13d,%eax
xor    %edx,%edx
divl   (%rsp)
mov    %eax,%edi
call   1030 <ceil@plt>
lea    0xd6c(%rip),%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
test   %r13,%r13
mov    %rbp,0x10(%rsp)
jle    1200 <readfiles+0x70>
mov    $0xffffffff,%ebx
mov    $0x1,%r14d
xor    %r12d,%r12d
jmp    1320 <readfiles+0x190>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xffffffff,%ebx
add    $0x1,%r14d
cmp    %r12,%r13
jle    1203 <readfiles+0x73>
mov    %r14d,%eax
imul   $0x10624dd3,%rax,%rax
shr    $0x26,%rax
imul   $0x3e8,%eax,%r15d
add    %ebx,%r15d
mov    0x28(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    (%rsp),%edx
call   1050 <memset@plt>
mov    %r13,%rdx
sub    %r12,%rdx
mov    0x18(%rsp),%rax
cmp    %rax,%rdx
cmovg  %rax,%rdx
mov    0x4(%rsp),%edi
mov    %rbp,%rsi
call   1070 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    138a <readfiles+0x1fa>
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xcef(%rip),%rdi
xor    %eax,%eax
call   10b0 <bail@plt>
movslq %ebp,%rax
add    %rax,%r12
test   %r15d,%r15d
jne    1310 <readfiles+0x180>
lea    0xce6(%rip),%rdi
mov    %r14d,%esi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1310 <readfiles+0x180>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [34 x i8] c"cannot allocate buffer (%d bytes)\00"
@O_RDONLY = global i32 0
@.str.1 = [17 x i8] c"cannot open 1 %s\00"
@.str.2 = [15 x i8] c"cannot stat %s\00"
@.str.3 = [48 x i8] c"reading input file: %s size: %ld num_reads: %d\0A\00"
@.str.4 = [20 x i8] c"cannot read from %s\00"
@.str.5 = [53 x i8] c"reading operations: %d total_size: %ld st_size: %ld\0A\00"
@.str.6 = [41 x i8] c"read : %ld bytes to %s with bufsize: %d\0A\00"
define void @readfiles(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca %struct.stat
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 1
%18 = trunc i64 %17 to i32
%19 = call i8* @malloc(i32 %18)
store i8* %19, i8** %9
%20 = load i8*, i8** %9
%21 = icmp eq i8* null, %20
br i1 %21, label %22, label %25
22: ; preds = %3
%23 = load i32, i32* %5
%24 = call i32 (i8*, ...) @bail(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %22, %3
store i32 0, i32* %7
br label %26
26: ; preds = %147, %25
%27 = load i32, i32* %7
%28 = load i32, i32* %6
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %150
30: ; preds = %26
store i32 0, i32* %12
store i64 0, i64* %13
%31 = load i8**, i8*** %4
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = load i32, i32* @O_RDONLY
%37 = call i32 @open(i8* %35, i32 %36)
store i32 %37, i32* %10
%38 = load i32, i32* %10
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %30
%41 = load i8**, i8*** %4
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %41, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 (i8*, ...) @bail(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %40, %30
%48 = load i8**, i8*** %4
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 @stat(i8* %52, %struct.stat* %14)
store i32 %53, i32* %8
%54 = load i32, i32* %8
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %63
56: ; preds = %47
%57 = load i8**, i8*** %4
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = call i32 (i8*, ...) @bail(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %61)
br label %63
63: ; preds = %56, %47
%64 = load i8**, i8*** %4
%65 = load i32, i32* %7
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8*, i8** %64, i64 %66
%68 = load i8*, i8** %67
%69 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%70 = load i64, i64* %69
%71 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%72 = load i64, i64* %71
%73 = load i32, i32* %5
%74 = sext i32 %73 to i64
%75 = sdiv i64 %72, %74
%76 = call i64 @ceil(i64 %75)
%77 = trunc i64 %76 to i32
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %68, i64 %70, i32 %77)
br label %79
79: ; preds = %135, %63
%80 = load i64, i64* %13
%81 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%82 = load i64, i64* %81
%83 = icmp slt i64 %80, %82
br i1 %83, label %84, label %136
84: ; preds = %79
%85 = load i8*, i8** %9
%86 = load i32, i32* %5
%87 = call i32 @memset(i8* %85, i8 signext 0, i32 %86)
%88 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%89 = load i64, i64* %88
%90 = load i64, i64* %13
%91 = sub nsw i64 %89, %90
%92 = load i32, i32* %5
%93 = sext i32 %92 to i64
%94 = icmp sgt i64 %91, %93
br i1 %94, label %95, label %101
95: ; preds = %84
%96 = load i32, i32* %10
%97 = load i8*, i8** %9
%98 = load i32, i32* %5
%99 = sext i32 %98 to i64
%100 = call i32 @read(i32 %96, i8* %97, i64 %99)
store i32 %100, i32* %11
br label %109
101: ; preds = %84
%102 = load i32, i32* %10
%103 = load i8*, i8** %9
%104 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%105 = load i64, i64* %104
%106 = load i64, i64* %13
%107 = sub nsw i64 %105, %106
%108 = call i32 @read(i32 %102, i8* %103, i64 %107)
store i32 %108, i32* %11
br label %109
109: ; preds = %101, %95
%110 = load i32, i32* %11
%111 = icmp slt i32 %110, 0
br i1 %111, label %112, label %119
112: ; preds = %109
%113 = load i8**, i8*** %4
%114 = load i32, i32* %7
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8*, i8** %113, i64 %115
%117 = load i8*, i8** %116
%118 = call i32 (i8*, ...) @bail(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %117)
br label %119
119: ; preds = %112, %109
%120 = load i64, i64* %13
%121 = load i32, i32* %11
%122 = sext i32 %121 to i64
%123 = add nsw i64 %120, %122
store i64 %123, i64* %13
%124 = load i32, i32* %12
%125 = add nsw i32 %124, 1
store i32 %125, i32* %12
%126 = load i32, i32* %12
%127 = srem i32 %126, 1000
%128 = icmp eq i32 %127, 0
br i1 %128, label %129, label %135
129: ; preds = %119
%130 = load i32, i32* %12
%131 = load i64, i64* %13
%132 = getelementptr inbounds %struct.stat, %struct.stat* %14, i32 0, i32 0
%133 = load i64, i64* %132
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), i32 %130, i64 %131, i64 %133)
br label %135
135: ; preds = %129, %119
br label %79
136: ; preds = %79
%137 = load i64, i64* %13
%138 = load i8**, i8*** %4
%139 = load i32, i32* %7
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8*, i8** %138, i64 %140
%142 = load i8*, i8** %141
%143 = load i32, i32* %5
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i64 %137, i8* %142, i32 %143)
%145 = load i32, i32* %10
%146 = call i32 @close(i32 %145)
br label %147
147: ; preds = %136
%148 = load i32, i32* %7
%149 = add nsw i32 %148, 1
store i32 %149, i32* %7
br label %26
150: ; preds = %26
ret void
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [34 x i8] c"cannot allocate buffer (%d bytes)\00"
@O_RDONLY = global i32 0
@.str.1 = [17 x i8] c"cannot open 1 %s\00"
@.str.2 = [15 x i8] c"cannot stat %s\00"
@.str.3 = [48 x i8] c"reading input file: %s size: %ld num_reads: %d\0A\00"
@.str.4 = [20 x i8] c"cannot read from %s\00"
@.str.5 = [53 x i8] c"reading operations: %d total_size: %ld st_size: %ld\0A\00"
@.str.6 = [41 x i8] c"read : %ld bytes to %s with bufsize: %d\0A\00"
define void @readfiles(i8** nocapture %0, i32 %1, i32 %2) {
%4 = alloca %struct.stat
%5 = sext i32 %1 to i64
%6 = tail call i8* @malloc(i32 %1)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 (i8*, ...) @bail(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %10
10: ; preds = %8, %3
%11 = icmp sgt i32 %2, 0
br i1 %11, label %12, label %70
12: ; preds = %10
%13 = bitcast %struct.stat* %4 to i8*
%14 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%15 = zext i32 %2 to i64
br label %16
16: ; preds = %12, %63
%17 = phi i64 [ 0, %12 ], [ %68, %63 ]
%18 = getelementptr inbounds i8*, i8** %0, i64 %17
%19 = load i8*, i8** %18
%20 = load i32, i32* @O_RDONLY
%21 = tail call i32 @open(i8* %19, i32 %20)
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = load i8*, i8** %18
%25 = tail call i32 (i8*, ...) @bail(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %23, %16
%27 = load i8*, i8** %18
%28 = call i32 @stat(i8* %27, %struct.stat* %4)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i8*, i8** %18
%32 = tail call i32 (i8*, ...) @bail(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %30, %26
%34 = load i8*, i8** %18
%35 = load i64, i64* %14
%36 = sdiv i64 %35, %5
%37 = tail call i64 @ceil(i64 %36)
%38 = trunc i64 %37 to i32
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %34, i64 %35, i32 %38)
%40 = icmp sgt i64 %35, 0
br i1 %40, label %41, label %63
41: ; preds = %33, %61
%42 = phi i64 [ %55, %61 ], [ 0, %33 ]
%43 = phi i32 [ %56, %61 ], [ 0, %33 ]
%44 = tail call i32 @memset(i8* %6, i8 signext 0, i32 %1)
%45 = sub nsw i64 %35, %42
%46 = icmp sgt i64 %45, %5
%47 = select i1 %46, i64 %5, i64 %45
%48 = tail call i32 @read(i32 %21, i8* %6, i64 %47)
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %41
%51 = load i8*, i8** %18
%52 = tail call i32 (i8*, ...) @bail(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %50, %41
%54 = sext i32 %48 to i64
%55 = add nsw i64 %42, %54
%56 = add nuw nsw i32 %43, 1
%57 = urem i32 %56, 1000
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %53
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0), i32 %56, i64 %55, i64 %35)
br label %61
61: ; preds = %59, %53
%62 = icmp sgt i64 %35, %55
br i1 %62, label %41, label %63
63: ; preds = %61, %33
%64 = phi i64 [ 0, %33 ], [ %55, %61 ]
%65 = load i8*, i8** %18
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i64 %64, i8* %65, i32 %1)
%67 = tail call i32 @close(i32 %21)
%68 = add nuw nsw i64 %17, 1
%69 = icmp eq i64 %68, %15
br i1 %69, label %70, label %16
70: ; preds = %63, %10
ret void
}