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

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t fread(char *, int, size_t, int /*<<< orphan*/ *);
char *malloc(size_t);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
char *realloc(char *, size_t);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
char *read_file(char const *filename) {
  FILE *fp = fopen(filename, "r");
  if (fp) {
    size_t size = 4096;
    char buf[size];
    size_t n = size;
    size_t i = 0;
    size_t read;
    char *s = malloc(n);
    while (!feof(fp) && !ferror(fp)) {
      read = fread(buf, 1, size, fp);
      if (i + read > n) {
        n += size;
        if (!(s = realloc(s, n)))
          do {
            do {
              fprintf(stderr, "error: ");
              fprintf(stderr, "%s:%d out of memory",
                      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/samsonjs/lake/refs/"
                      "heads/master/src/repl.c",
                      116);
              fprintf(stderr, "\n");
            } while (0);
            exit(1);
          } while (0);
      }
      memcpy(s + i, buf, read);
      i += read;
    }
    s[i] = '\0';
    if (ferror(fp)) {
      do {
        fprintf(stderr, "error: ");
        fprintf(stderr, "failed to read file %s: %s", filename,
                strerror(errno));
        fprintf(stderr, "\n");
      } while (0);
      return NULL;
    }
    fclose(fp);
    return s;
  } else {
    do {
      fprintf(stderr, "error: ");
      fprintf(stderr, "cannot open file %s: %s", filename, strerror(errno));
      fprintf(stderr, "\n");
    } while (0);
    return NULL;
  }
}


x86 assembly (clang, -O0):
<read_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1419 <read_file+0x269>
movq   $0x1000,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   1090 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x61(%rbp)
jne    1258 <read_file+0xa8>
mov    -0x18(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    1268 <read_file+0xb8>
jmp    1350 <read_file+0x1a0>
mov    -0x60(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
add    -0x48(%rbp),%rax
cmp    -0x38(%rbp),%rax
jbe    132a <read_file+0x17a>
mov    -0x20(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   10a0 <realloc@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    1325 <read_file+0x175>
jmp    12c0 <read_file+0x110>
jmp    12c5 <read_file+0x115>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    0xd2d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
lea    0xd1e(%rip),%rsi
lea    0xd2b(%rip),%rdx
mov    $0x74,%ecx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    131b <read_file+0x16b>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    132a <read_file+0x17a>
mov    -0x60(%rbp),%rsi
mov    -0x50(%rbp),%rdi
add    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rdx
call   1080 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    122a <read_file+0x7a>
mov    -0x50(%rbp),%rax
mov    -0x40(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     13f5 <read_file+0x245>
jmp    1374 <read_file+0x1c4>
mov    0x2c65(%rip),%rax
mov    (%rax),%edi
lea    0xc7e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rdx
mov    %rax,%rcx
lea    0xce7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c14(%rip),%rax
mov    (%rax),%edi
lea    0xcce(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    13e1 <read_file+0x231>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    140d <read_file+0x25d>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
jmp    1494 <read_file+0x2e4>
jmp    141e <read_file+0x26e>
mov    0x2bbb(%rip),%rax
mov    (%rax),%edi
lea    0xbd4(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2ba4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    0x2b85(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rdx
mov    %rax,%rcx
lea    0xc52(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2b64(%rip),%rax
mov    (%rax),%edi
lea    0xc1e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_file>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r12
lea    0xe35(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1213 <read_file+0x63>
mov    %rax,%rbx
mov    %r12,-0x38(%rbp)
mov    %rsp,-0x30(%rbp)
mov    %rsp,%r15
add    $0xfffffffffffff000,%r15
mov    %r15,%rsp
mov    $0x1000,%r12d
mov    $0x1000,%edi
call   1090 <malloc@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     126c <read_file+0xbc>
xor    %ecx,%ecx
jmp    1352 <read_file+0x1a2>
mov    0x2dc6(%rip),%r14
mov    (%r14),%edi
lea    0xdde(%rip),%rsi
xor    %r13d,%r13d
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r14),%r15d
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xe7a(%rip),%rsi
mov    %r15d,%edi
mov    %r12,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r14),%edi
lea    0xe43(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    13c8 <read_file+0x218>
xor    %r14d,%r14d
mov    %rbx,-0x48(%rbp)
mov    %r15,-0x40(%rbp)
jmp    12b6 <read_file+0x106>
nopl   0x0(%rax)
mov    %r13,%rax
mov    %rax,%r13
add    %rax,%r14
mov    %r14,%rdi
mov    -0x40(%rbp),%rsi
mov    %r15,%rdx
mov    %rsi,%r15
call   1080 <memcpy@plt>
mov    -0x48(%rbp),%rbx
mov    %rbx,%rdi
call   1070 <feof@plt>
mov    -0x50(%rbp),%rcx
mov    %rcx,%r14
test   %eax,%eax
jne    1352 <read_file+0x1a2>
mov    %rbx,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    134f <read_file+0x19f>
mov    $0x1000,%edx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %rax,%r15
add    %r14,%rax
mov    %rax,-0x50(%rbp)
cmp    %r12,%rax
jbe    1280 <read_file+0xd0>
add    $0x1000,%r12
mov    %r13,%rdi
mov    %r12,%rsi
call   10a0 <realloc@plt>
test   %rax,%rax
jne    1283 <read_file+0xd3>
mov    0x2cd7(%rip),%rbx
mov    (%rbx),%edi
lea    0xcf0(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xce8(%rip),%rsi
lea    0xcf5(%rip),%rdx
mov    $0x74,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd65(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    %r14,%rcx
movb   $0x0,0x0(%r13,%rcx,1)
mov    %rbx,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
je     13bc <read_file+0x20c>
mov    0x2c74(%rip),%r14
mov    (%r14),%edi
lea    0xc8c(%rip),%rsi
xor    %r13d,%r13d
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r14),%r15d
mov    0x2c4e(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd0d(%rip),%rsi
mov    %r15d,%edi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r14),%edi
lea    0xcf0(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    13c4 <read_file+0x214>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rsp
mov    %r13,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [8 x i8] c"error: \00"
@.str.2 = [20 x i8] c"%s:%d out of memory\00"
@.str.3 = [133 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/samsonjs/lake/refs/heads/master/src/repl.c\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [27 x i8] c"failed to read file %s: %s\00"
@errno = global i32 0
@.str.6 = [24 x i8] c"cannot open file %s: %s\00"
define i8* @read_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i32
store i8* %0, i8** %3
%13 = load i8*, i8** %3
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %4
%15 = load i32*, i32** %4
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %102
17: ; preds = %1
store i64 4096, i64* %5
%18 = load i64, i64* %5
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %6
%20 = alloca i8, i64 %18
store i64 %18, i64* %7
%21 = load i64, i64* %5
store i64 %21, i64* %8
store i64 0, i64* %9
%22 = load i64, i64* %8
%23 = call i8* @malloc(i64 %22)
store i8* %23, i8** %11
br label %24
24: ; preds = %67, %17
%25 = load i32*, i32** %4
%26 = call i32 @feof(i32* %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %24
%29 = load i32*, i32** %4
%30 = call i64 @ferror(i32* %29)
%31 = icmp ne i64 %30, 0
%32 = xor i1 %31, true
br label %33
33: ; preds = %28, %24
%34 = phi i1 [ false, %24 ], [ %32, %28 ]
br i1 %34, label %35, label %76
35: ; preds = %33
%36 = load i64, i64* %5
%37 = load i32*, i32** %4
%38 = call i64 @fread(i8* %20, i32 1, i64 %36, i32* %37)
store i64 %38, i64* %10
%39 = load i64, i64* %9
%40 = load i64, i64* %10
%41 = add i64 %39, %40
%42 = load i64, i64* %8
%43 = icmp ugt i64 %41, %42
br i1 %43, label %44, label %67
44: ; preds = %35
%45 = load i64, i64* %5
%46 = load i64, i64* %8
%47 = add i64 %46, %45
store i64 %47, i64* %8
%48 = load i8*, i8** %11
%49 = load i64, i64* %8
%50 = call i8* @realloc(i8* %48, i64 %49)
store i8* %50, i8** %11
%51 = icmp ne i8* %50, null
br i1 %51, label %66, label %52
52: ; preds = %44
br label %53
53: ; preds = %52
br label %54
54: ; preds = %53
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str.3, i64 0, i64 0), i32 116)
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %61
61: ; preds = %54
br label %62
62: ; preds = %61
%63 = call i32 @exit(i32 1)
unreachable
64: ; No predecessors!
br label %65
65: ; preds = %64
br label %66
66: ; preds = %65, %44
br label %67
67: ; preds = %66, %35
%68 = load i8*, i8** %11
%69 = load i64, i64* %9
%70 = getelementptr inbounds i8, i8* %68, i64 %69
%71 = load i64, i64* %10
%72 = call i32 @memcpy(i8* %70, i8* %20, i64 %71)
%73 = load i64, i64* %10
%74 = load i64, i64* %9
%75 = add i64 %74, %73
store i64 %75, i64* %9
br label %24
76: ; preds = %33
%77 = load i8*, i8** %11
%78 = load i64, i64* %9
%79 = getelementptr inbounds i8, i8* %77, i64 %78
store i8 0, i8* %79
%80 = load i32*, i32** %4
%81 = call i64 @ferror(i32* %80)
%82 = icmp ne i64 %81, 0
br i1 %82, label %83, label %96
83: ; preds = %76
br label %84
84: ; preds = %83
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%87 = load i32, i32* @stderr
%88 = load i8*, i8** %3
%89 = load i32, i32* @errno
%90 = call i8* @strerror(i32 %89)
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %88, i8* %90)
%92 = load i32, i32* @stderr
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %94
94: ; preds = %84
br label %95
95: ; preds = %94
store i8* null, i8** %2
store i32 1, i32* %12
br label %100
96: ; preds = %76
%97 = load i32*, i32** %4
%98 = call i32 @fclose(i32* %97)
%99 = load i8*, i8** %11
store i8* %99, i8** %2
store i32 1, i32* %12
br label %100
100: ; preds = %96, %95
%101 = load i8*, i8** %6
br label %114
102: ; preds = %1
br label %103
103: ; preds = %102
%104 = load i32, i32* @stderr
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%106 = load i32, i32* @stderr
%107 = load i8*, i8** %3
%108 = load i32, i32* @errno
%109 = call i8* @strerror(i32 %108)
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %107, i8* %109)
%111 = load i32, i32* @stderr
%112 = call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %113
113: ; preds = %103
store i8* null, i8** %2
br label %114
114: ; preds = %113, %100
%115 = load i8*, i8** %2
ret i8* %115
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [8 x i8] c"error: \00"
@.str.2 = [20 x i8] c"%s:%d out of memory\00"
@.str.3 = [133 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/samsonjs/lake/refs/heads/master/src/repl.c\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [27 x i8] c"failed to read file %s: %s\00"
@errno = global i32 0
@.str.6 = [24 x i8] c"cannot open file %s: %s\00"
define i8* @read_file(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %59, label %4
4: ; preds = %1
%5 = tail call i8* @llvm.stacksave()
%6 = alloca [4096 x i8]
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%8 = tail call dereferenceable_or_null(4096) i8* @malloc(i64 4096)
%9 = call i32 @feof(i32* %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %40
11: ; preds = %4, %33
%12 = phi i8* [ %35, %33 ], [ %8, %4 ]
%13 = phi i64 [ %19, %33 ], [ 0, %4 ]
%14 = phi i64 [ %34, %33 ], [ 4096, %4 ]
%15 = call i64 @ferror(i32* %2)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %40
17: ; preds = %11
%18 = call i64 @fread(i8* %7, i32 1, i64 4096, i32* %2)
%19 = add i64 %18, %13
%20 = icmp ugt i64 %19, %14
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = add i64 %14, 4096
%23 = call i8* @realloc(i8* %12, i64 %22)
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %33
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([133 x i8], [133 x i8]* @.str.3, i64 0, i64 0), i32 116)
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %21, %17
%34 = phi i64 [ %22, %21 ], [ %14, %17 ]
%35 = phi i8* [ %23, %21 ], [ %12, %17 ]
%36 = getelementptr inbounds i8, i8* %35, i64 %13
%37 = call i32 @memcpy(i8* %36, i8* %7, i64 %18)
%38 = call i32 @feof(i32* %2)
%39 = icmp eq i32 %38, 0
br i1 %39, label %11, label %40
40: ; preds = %11, %33, %4
%41 = phi i64 [ 0, %4 ], [ %19, %33 ], [ %13, %11 ]
%42 = phi i8* [ %8, %4 ], [ %35, %33 ], [ %12, %11 ]
%43 = getelementptr inbounds i8, i8* %42, i64 %41
store i8 0, i8* %43
%44 = call i64 @ferror(i32* %2)
%45 = icmp eq i64 %44, 0
br i1 %45, label %55, label %46
46: ; preds = %40
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%49 = load i32, i32* @stderr
%50 = load i32, i32* @errno
%51 = call i8* @strerror(i32 %50)
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %0, i8* %51)
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %57
55: ; preds = %40
%56 = call i32 @fclose(i32* %2)
br label %57
57: ; preds = %55, %46
%58 = phi i8* [ null, %46 ], [ %42, %55 ]
br label %68
59: ; preds = %1
%60 = load i32, i32* @stderr
%61 = tail call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%62 = load i32, i32* @stderr
%63 = load i32, i32* @errno
%64 = tail call i8* @strerror(i32 %63)
%65 = tail call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %0, i8* %64)
%66 = load i32, i32* @stderr
%67 = tail call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %68
68: ; preds = %59, %57
%69 = phi i8* [ %58, %57 ], [ null, %59 ]
ret i8* %69
}