#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;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
size_t fread(char *, int, long, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
char *malloc(long);
int /*<<< orphan*/ panic(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ perror(char const *);
char *slurp(const char *fname, long *size) {
  size_t ok_read;
  char *buf = NULL;
  FILE *fd = fopen(fname, "rb");
  if (fd) {
    if (fseek(fd, 0, SEEK_END) != 0) {
      perror(fname);
      panic(NULL,
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/bjarneh/organice/refs/heads/master/src/"
            "utilz/handy.c",
            85);
    }
    (*size) = ftell(fd);
    if (fseek(fd, 0, SEEK_SET) != 0) {
      perror(fname);
      panic(NULL,
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/bjarneh/organice/refs/heads/master/src/"
            "utilz/handy.c",
            90);
    }
    buf = malloc((*size));
    if (buf != NULL) {
      ok_read = fread(buf, 1, (*size), fd);
      if (ok_read != (*size)) {
        perror(fname);
        panic(NULL,
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/bjarneh/organice/refs/heads/master/"
              "src/utilz/handy.c",
              99);
      }
    } else {
      perror(fname);
      panic(NULL,
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/bjarneh/organice/refs/heads/master/src/"
            "utilz/handy.c",
            103);
    }
  } else {
    perror(fname);
    panic(NULL,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/bjarneh/organice/refs/heads/master/src/"
          "utilz/handy.c",
          107);
  }
  fclose(fd);
  return buf;
}


x86 assembly (clang, -O0):
<slurp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12d1 <slurp+0x151>
mov    -0x28(%rbp),%rdi
mov    0x2e26(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
cmp    $0x0,%rax
je     11f3 <slurp+0x73>
mov    -0x8(%rbp),%rdi
call   10a0 <perror@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe1a(%rip),%rsi
mov    $0x55,%edx
call   1050 <panic@plt>
mov    -0x28(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
mov    0x2dc7(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
cmp    $0x0,%rax
je     1242 <slurp+0xc2>
mov    -0x8(%rbp),%rdi
call   10a0 <perror@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdcb(%rip),%rsi
mov    $0x5a,%edx
call   1050 <panic@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12ae <slurp+0x12e>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
je     12a9 <slurp+0x129>
mov    -0x8(%rbp),%rdi
call   10a0 <perror@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd64(%rip),%rsi
mov    $0x63,%edx
call   1050 <panic@plt>
jmp    12cc <slurp+0x14c>
mov    -0x8(%rbp),%rdi
call   10a0 <perror@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd41(%rip),%rsi
mov    $0x67,%edx
call   1050 <panic@plt>
jmp    12ef <slurp+0x16f>
mov    -0x8(%rbp),%rdi
call   10a0 <perror@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd1e(%rip),%rsi
mov    $0x6b,%edx
call   1050 <panic@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slurp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe6b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
je     121c <slurp+0x9c>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
test   %rax,%rax
jne    1225 <slurp+0xa5>
mov    %r12,%rdi
call   1060 <ftell@plt>
mov    %rax,(%r15)
mov    0x2e0c(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
test   %rax,%rax
jne    1245 <slurp+0xc5>
mov    (%r15),%rbp
mov    %rbp,%rdi
call   1070 <malloc@plt>
test   %rax,%rax
je     1265 <slurp+0xe5>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    %r12,%rcx
call   1030 <fread@plt>
cmp    (%r15),%rax
jne    126e <slurp+0xee>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x6b,%ebp
xor    %ebx,%ebx
jmp    1273 <slurp+0xf3>
mov    %r14,%rdi
call   10a0 <perror@plt>
lea    0xdcf(%rip),%rsi
xor    %edi,%edi
mov    $0x55,%edx
call   1050 <panic@plt>
jmp    11ba <slurp+0x3a>
mov    %r14,%rdi
call   10a0 <perror@plt>
lea    0xdaf(%rip),%rsi
xor    %edi,%edi
mov    $0x5a,%edx
call   1050 <panic@plt>
jmp    11dd <slurp+0x5d>
mov    $0x67,%ebp
xor    %ebx,%ebx
jmp    1273 <slurp+0xf3>
mov    $0x63,%ebp
mov    %r14,%rdi
call   10a0 <perror@plt>
lea    0xd81(%rip),%rsi
xor    %edi,%edi
mov    %ebp,%edx
call   1050 <panic@plt>
jmp    1208 <slurp+0x88>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@.str.1 = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bjarneh/organice/refs/heads/master/src/utilz/handy.c\00"
@SEEK_SET = global i32 0
define i8* @slurp(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32*
store i8* %0, i8** %3
store i64* %1, i64** %4
store i8* null, i8** %6
%8 = load i8*, i8** %3
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %59
12: ; preds = %2
%13 = load i32*, i32** %7
%14 = load i32, i32* @SEEK_END
%15 = call i64 @fseek(i32* %13, i32 0, i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = call i32 @perror(i8* %18)
%20 = call i32 @panic(i32* null, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 85)
br label %21
21: ; preds = %17, %12
%22 = load i32*, i32** %7
%23 = call i64 @ftell(i32* %22)
%24 = load i64*, i64** %4
store i64 %23, i64* %24
%25 = load i32*, i32** %7
%26 = load i32, i32* @SEEK_SET
%27 = call i64 @fseek(i32* %25, i32 0, i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %21
%30 = load i8*, i8** %3
%31 = call i32 @perror(i8* %30)
%32 = call i32 @panic(i32* null, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 90)
br label %33
33: ; preds = %29, %21
%34 = load i64*, i64** %4
%35 = load i64, i64* %34
%36 = call i8* @malloc(i64 %35)
store i8* %36, i8** %6
%37 = load i8*, i8** %6
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %54
39: ; preds = %33
%40 = load i8*, i8** %6
%41 = load i64*, i64** %4
%42 = load i64, i64* %41
%43 = load i32*, i32** %7
%44 = call i64 @fread(i8* %40, i32 1, i64 %42, i32* %43)
store i64 %44, i64* %5
%45 = load i64, i64* %5
%46 = load i64*, i64** %4
%47 = load i64, i64* %46
%48 = icmp ne i64 %45, %47
br i1 %48, label %49, label %53
49: ; preds = %39
%50 = load i8*, i8** %3
%51 = call i32 @perror(i8* %50)
%52 = call i32 @panic(i32* null, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 99)
br label %53
53: ; preds = %49, %39
br label %58
54: ; preds = %33
%55 = load i8*, i8** %3
%56 = call i32 @perror(i8* %55)
%57 = call i32 @panic(i32* null, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 103)
br label %58
58: ; preds = %54, %53
br label %63
59: ; preds = %2
%60 = load i8*, i8** %3
%61 = call i32 @perror(i8* %60)
%62 = call i32 @panic(i32* null, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 107)
br label %63
63: ; preds = %59, %58
%64 = load i32*, i32** %7
%65 = call i32 @fclose(i32* %64)
%66 = load i8*, i8** %6
ret i8* %66
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@.str.1 = [143 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bjarneh/organice/refs/heads/master/src/utilz/handy.c\00"
@SEEK_SET = global i32 0
define noalias i8* @slurp(i8* nocapture %0, i64* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %28, label %5
5: ; preds = %2
%6 = load i32, i32* @SEEK_END
%7 = tail call i64 @fseek(i32* %3, i32 0, i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = tail call i32 @perror(i8* %0)
%11 = tail call i32 @panic(i32* null, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 85)
br label %12
12: ; preds = %9, %5
%13 = tail call i64 @ftell(i32* %3)
store i64 %13, i64* %1
%14 = load i32, i32* @SEEK_SET
%15 = tail call i64 @fseek(i32* %3, i32 0, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = tail call i32 @perror(i8* %0)
%19 = tail call i32 @panic(i32* null, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 90)
br label %20
20: ; preds = %17, %12
%21 = load i64, i64* %1
%22 = tail call i8* @malloc(i64 %21)
%23 = icmp eq i8* %22, null
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = tail call i64 @fread(i8* %22, i32 1, i64 %21, i32* %3)
%26 = load i64, i64* %1
%27 = icmp eq i64 %25, %26
br i1 %27, label %33, label %28
28: ; preds = %2, %20, %24
%29 = phi i32 [ 99, %24 ], [ 103, %20 ], [ 107, %2 ]
%30 = phi i8* [ %22, %24 ], [ null, %20 ], [ null, %2 ]
%31 = tail call i32 @perror(i8* %0)
%32 = tail call i32 @panic(i32* null, i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %33
33: ; preds = %28, %24
%34 = phi i8* [ %22, %24 ], [ %30, %28 ]
%35 = tail call i32 @fclose(i32* %3)
ret i8* %34
}