#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
void *calloc(size_t, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
size_t fread(void *, int, size_t, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printerr(char *, int, int /*<<< orphan*/, char *,
                            char const *);
char *load_txt(const char *name) {
  FILE *fp = 0;
  void *p = 0;
  size_t n = 0;
  if ((fp = fopen(name, "rb"))) {
    if (fseek(fp, 0, SEEK_END) == 0) {
      if ((n = (size_t)ftell(fp))) {
        if (fseek(fp, 0, SEEK_SET) == 0) {
          if ((p = calloc(n + 1, 1))) {
            if (fread(p, 1, n, fp) == n) {
            } else
              printerr("/scratch/repos/new/home/jordi_armengol_estape/"
                       "c-scraper/outputs/2022-01-22/02-19-57/repos/rlk/"
                       "scmtiff/refs/heads/master/finish.c",
                       46, 0, "Failure to read %s", name);
          } else
            printerr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/rlk/scmtiff/refs/heads/"
                     "master/finish.c",
                     48, 0, "Failure to allocate %s", name);
        } else
          printerr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/rlk/scmtiff/refs/heads/"
                   "master/finish.c",
                   50, 0, "Failed to seek %s", name);
      } else
        printerr(
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/rlk/scmtiff/refs/heads/master/finish.c",
            52, 0, "Failed to tell %s", name);
    } else
      printerr(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/rlk/scmtiff/refs/heads/master/finish.c",
          54, 0, "Failed to seek %s", name);
  } else
    printerr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/rlk/scmtiff/refs/heads/master/finish.c",
             56, 0, "Failed to open %s", name);
  fclose(fp);
  return (char *)p;
}


x86 assembly (clang, -O0):
<load_txt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     12f9 <load_txt+0x189>
mov    -0x10(%rbp),%rdi
mov    0x2e2b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
cmp    $0x0,%rax
jne    12d6 <load_txt+0x166>
mov    -0x10(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     12b3 <load_txt+0x143>
mov    -0x10(%rbp),%rdi
mov    0x2de6(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
cmp    $0x0,%rax
jne    1290 <load_txt+0x120>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     126d <load_txt+0xfd>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
cmp    -0x20(%rbp),%rax
jne    124a <load_txt+0xda>
jmp    1268 <load_txt+0xf8>
mov    -0x8(%rbp),%r8
lea    0xdae(%rip),%rdi
mov    $0x2e,%esi
xor    %edx,%edx
lea    0xe21(%rip),%rcx
call   1050 <printerr@plt>
jmp    128b <load_txt+0x11b>
mov    -0x8(%rbp),%r8
lea    0xd8b(%rip),%rdi
mov    $0x30,%esi
xor    %edx,%edx
lea    0xe11(%rip),%rcx
call   1050 <printerr@plt>
jmp    12ae <load_txt+0x13e>
mov    -0x8(%rbp),%r8
lea    0xd68(%rip),%rdi
mov    $0x32,%esi
xor    %edx,%edx
lea    0xe05(%rip),%rcx
call   1050 <printerr@plt>
jmp    12d1 <load_txt+0x161>
mov    -0x8(%rbp),%r8
lea    0xd45(%rip),%rdi
mov    $0x34,%esi
xor    %edx,%edx
lea    0xdf4(%rip),%rcx
call   1050 <printerr@plt>
jmp    12f4 <load_txt+0x184>
mov    -0x8(%rbp),%r8
lea    0xd22(%rip),%rdi
mov    $0x36,%esi
xor    %edx,%edx
lea    0xdbf(%rip),%rcx
call   1050 <printerr@plt>
jmp    1317 <load_txt+0x1a7>
mov    -0x8(%rbp),%r8
lea    0xcff(%rip),%rdi
mov    $0x38,%esi
xor    %edx,%edx
lea    0xdc0(%rip),%rcx
call   1050 <printerr@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_txt>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe7e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11bf <load_txt+0x4f>
mov    0x2e52(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
test   %rax,%rax
je     11f6 <load_txt+0x86>
lea    0xe55(%rip),%rdi
lea    0xef9(%rip),%rcx
xor    %r15d,%r15d
mov    $0x36,%esi
jmp    11d5 <load_txt+0x65>
lea    0xe3d(%rip),%rdi
lea    0xf05(%rip),%rcx
xor    %r15d,%r15d
mov    $0x38,%esi
xor    %edx,%edx
mov    %r14,%r8
call   1050 <printerr@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   1070 <ftell@plt>
test   %rax,%rax
je     1236 <load_txt+0xc6>
mov    %rax,%r12
mov    0x2dcb(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
test   %rax,%rax
je     124e <load_txt+0xde>
lea    0xdde(%rip),%rdi
lea    0xe82(%rip),%rcx
xor    %r15d,%r15d
mov    $0x32,%esi
jmp    11d5 <load_txt+0x65>
lea    0xdc6(%rip),%rdi
lea    0xe7c(%rip),%rcx
xor    %r15d,%r15d
mov    $0x34,%esi
jmp    11d5 <load_txt+0x65>
lea    0x1(%r12),%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
test   %rax,%rax
je     1299 <load_txt+0x129>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    %r12,%rax
je     11df <load_txt+0x6f>
lea    0xd7b(%rip),%rdi
lea    0xdf5(%rip),%rcx
mov    $0x2e,%esi
jmp    11d5 <load_txt+0x65>
lea    0xd63(%rip),%rdi
lea    0xdf0(%rip),%rcx
xor    %r15d,%r15d
mov    $0x30,%esi
jmp    11d5 <load_txt+0x65>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [129 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/rlk/scmtiff/refs/heads/master/finish.c\00"
@.str.2 = [19 x i8] c"Failure to read %s\00"
@.str.3 = [23 x i8] c"Failure to allocate %s\00"
@.str.4 = [18 x i8] c"Failed to seek %s\00"
@.str.5 = [18 x i8] c"Failed to tell %s\00"
@.str.6 = [18 x i8] c"Failed to open %s\00"
define i8* @load_txt(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %2
store i32* null, i32** %3
store i8* null, i8** %4
store i64 0, i64* %5
%6 = load i8*, i8** %2
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %3
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %56
9: ; preds = %1
%10 = load i32*, i32** %3
%11 = load i32, i32* @SEEK_END
%12 = call i64 @fseek(i32* %10, i32 0, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %52
14: ; preds = %9
%15 = load i32*, i32** %3
%16 = call i64 @ftell(i32* %15)
store i64 %16, i64* %5
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %48
18: ; preds = %14
%19 = load i32*, i32** %3
%20 = load i32, i32* @SEEK_SET
%21 = call i64 @fseek(i32* %19, i32 0, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %44
23: ; preds = %18
%24 = load i64, i64* %5
%25 = add i64 %24, 1
%26 = call i8* @calloc(i64 %25, i32 1)
store i8* %26, i8** %4
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %40
28: ; preds = %23
%29 = load i8*, i8** %4
%30 = load i64, i64* %5
%31 = load i32*, i32** %3
%32 = call i64 @fread(i8* %29, i32 1, i64 %30, i32* %31)
%33 = load i64, i64* %5
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %36
35: ; preds = %28
br label %39
36: ; preds = %28
%37 = load i8*, i8** %2
%38 = call i32 @printerr(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i32 46, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %36, %35
br label %43
40: ; preds = %23
%41 = load i8*, i8** %2
%42 = call i32 @printerr(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i32 48, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %40, %39
br label %47
44: ; preds = %18
%45 = load i8*, i8** %2
%46 = call i32 @printerr(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i32 50, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %44, %43
br label %51
48: ; preds = %14
%49 = load i8*, i8** %2
%50 = call i32 @printerr(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i32 52, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %48, %47
br label %55
52: ; preds = %9
%53 = load i8*, i8** %2
%54 = call i32 @printerr(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i32 54, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %53)
br label %55
55: ; preds = %52, %51
br label %59
56: ; preds = %1
%57 = load i8*, i8** %2
%58 = call i32 @printerr(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i32 56, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %57)
br label %59
59: ; preds = %56, %55
%60 = load i32*, i32** %3
%61 = call i32 @fclose(i32* %60)
%62 = load i8*, i8** %4
ret i8* %62
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [129 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/rlk/scmtiff/refs/heads/master/finish.c\00"
@.str.2 = [19 x i8] c"Failure to read %s\00"
@.str.3 = [23 x i8] c"Failure to allocate %s\00"
@.str.4 = [18 x i8] c"Failed to seek %s\00"
@.str.5 = [18 x i8] c"Failed to tell %s\00"
@.str.6 = [18 x i8] c"Failed to open %s\00"
define i8* @load_txt(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %32, label %4
4: ; preds = %1
%5 = load i32, i32* @SEEK_END
%6 = tail call i64 @fseek(i32* %2, i32 0, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %30
8: ; preds = %4
%9 = tail call i64 @ftell(i32* %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %28, label %11
11: ; preds = %8
%12 = load i32, i32* @SEEK_SET
%13 = tail call i64 @fseek(i32* %2, i32 0, i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = add i64 %9, 1
%17 = tail call i8* @calloc(i64 %16, i32 1)
%18 = icmp eq i8* %17, null
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = tail call i64 @fread(i8* %17, i32 1, i64 %9, i32* %2)
%21 = icmp eq i64 %20, %9
br i1 %21, label %34, label %22
22: ; preds = %19
%23 = tail call i32 @printerr(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i32 46, i32 0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %34
24: ; preds = %15
%25 = tail call i32 @printerr(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i32 48, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %34
26: ; preds = %11
%27 = tail call i32 @printerr(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i32 50, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %34
28: ; preds = %8
%29 = tail call i32 @printerr(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i32 52, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br label %34
30: ; preds = %4
%31 = tail call i32 @printerr(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i32 54, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %34
32: ; preds = %1
%33 = tail call i32 @printerr(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.1, i64 0, i64 0), i32 56, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %0)
br label %34
34: ; preds = %30, %26, %22, %19, %24, %28, %32
%35 = phi i8* [ %17, %19 ], [ %17, %22 ], [ null, %24 ], [ null, %26 ], [ null, %28 ], [ null, %30 ], [ null, %32 ]
%36 = tail call i32 @fclose(i32* %2)
ret i8* %35
}