#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 {
  int st_size;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int /*<<< orphan*/ free(char *);
int fstat(int, struct stat *);
char *malloc(int);
int open(char const *, int /*<<< orphan*/);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
char *read_file(const char *file_name) {
  int fd = open(file_name, O_RDONLY);
  do {
    if ((fd == -1)) {
      fprintf(stderr, "[ERROR in %s:%d]: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/master/"
              "src/config.c",
              16, (strerror(errno)));
      return (NULL);
    }
  } while (0);
  struct stat buf;
  int ret = fstat(fd, &buf);
  do {
    if ((ret == -1)) {
      fprintf(stderr, "[ERROR in %s:%d]: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/master/"
              "src/config.c",
              20, (strerror(errno)));
      return (NULL);
    }
  } while (0);
  char *p = malloc(buf.st_size + 1);
  do {
    if ((!p)) {
      fprintf(stderr, "[ERROR in %s:%d]: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/master/"
              "src/config.c",
              23, ("malloc"));
      return (NULL);
    }
  } while (0);
  if (read(fd, p, buf.st_size) == -1) {
    free(p);
    close(fd);
    do {
      if ((1)) {
        fprintf(stderr, "[ERROR in %s:%d]: %s\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/"
                "master/src/config.c",
                28, (strerror(errno)));
        return (NULL);
      }
    } while (0);
  }
  p[buf.st_size] = '\0';
  close(fd);
  return p;
}


x86 assembly (clang, -O0):
<read_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11f0 <read_file+0x70>
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    %rax,%r8
lea    0xe2e(%rip),%rsi
lea    0xe3d(%rip),%rdx
mov    $0x10,%ecx
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1336 <read_file+0x1b6>
jmp    11f5 <read_file+0x75>
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   10a0 <fstat@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1253 <read_file+0xd3>
mov    0x2dc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x30(%rbp),%edi
mov    %rax,%r8
lea    0xdcb(%rip),%rsi
lea    0xdda(%rip),%rdx
mov    $0x14,%ecx
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1336 <read_file+0x1b6>
jmp    1258 <read_file+0xd8>
mov    -0x18(%rbp),%edi
add    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12a7 <read_file+0x127>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
lea    0xd7e(%rip),%rsi
lea    0xd8d(%rip),%rdx
mov    $0x17,%ecx
lea    0xe0b(%rip),%r8
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1336 <read_file+0x1b6>
jmp    12ac <read_file+0x12c>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1050 <read@plt>
cmp    $0xffffffff,%eax
jne    131a <read_file+0x19a>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    0x2cfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%r8
lea    0xd04(%rip),%rsi
lea    0xd13(%rip),%rdx
mov    $0x1c,%ecx
call   1060 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1336 <read_file+0x1b6>
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_file>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
cmp    $0xffffffff,%eax
je     11ef <read_file+0x6f>
mov    %eax,%ebp
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   10a0 <fstat@plt>
cmp    $0xffffffff,%eax
je     1220 <read_file+0xa0>
movslq 0x8(%rsp),%r14
lea    0x1(%r14),%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     124e <read_file+0xce>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %rax,%rsi
mov    %r14d,%edx
call   1050 <read@plt>
cmp    $0xffffffff,%eax
je     1273 <read_file+0xf3>
movb   $0x0,(%rbx,%r14,1)
mov    %ebp,%edi
call   1040 <close@plt>
jmp    12b8 <read_file+0x138>
mov    0x2de2(%rip),%rax
mov    (%rax),%ebx
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xdf3(%rip),%rsi
lea    0xe02(%rip),%rdx
mov    %ebx,%edi
mov    $0x10,%ecx
jmp    12ae <read_file+0x12e>
mov    0x2db1(%rip),%rax
mov    (%rax),%ebx
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xdc2(%rip),%rsi
lea    0xdd1(%rip),%rdx
mov    %ebx,%edi
mov    $0x14,%ecx
jmp    12ae <read_file+0x12e>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
lea    0xda2(%rip),%rsi
lea    0xdb1(%rip),%rdx
lea    0xe34(%rip),%r8
mov    $0x17,%ecx
jmp    12b1 <read_file+0x131>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
call   1040 <close@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%ebx
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xd60(%rip),%rsi
lea    0xd6f(%rip),%rdx
mov    %ebx,%edi
mov    $0x1c,%ecx
mov    %rax,%r8
call   1060 <fprintf@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"[ERROR in %s:%d]: %s\0A\00"
@.str.1 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/master/src/config.c\00"
@errno = global i32 0
@.str.2 = [7 x i8] c"malloc\00"
define i8* @read_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.stat
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = load i32, i32* @O_RDONLY
%10 = call i32 @open(i8* %8, i32 %9)
store i32 %10, i32* %4
br label %11
11: ; preds = %1
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
%18 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 16, i8* %17)
store i8* null, i8** %2
br label %71
19: ; preds = %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = call i32 @fstat(i32 %21, %struct.stat* %5)
store i32 %22, i32* %6
br label %23
23: ; preds = %20
%24 = load i32, i32* %6
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = load i32, i32* @errno
%29 = call i8* @strerror(i32 %28)
%30 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 20, i8* %29)
store i8* null, i8** %2
br label %71
31: ; preds = %23
br label %32
32: ; preds = %31
%33 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%34 = load i32, i32* %33
%35 = add nsw i32 %34, 1
%36 = call i8* @malloc(i32 %35)
store i8* %36, i8** %7
br label %37
37: ; preds = %32
%38 = load i8*, i8** %7
%39 = icmp ne i8* %38, null
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %2
br label %71
43: ; preds = %37
br label %44
44: ; preds = %43
%45 = load i32, i32* %4
%46 = load i8*, i8** %7
%47 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%48 = load i32, i32* %47
%49 = call i32 @read(i32 %45, i8* %46, i32 %48)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %62
51: ; preds = %44
%52 = load i8*, i8** %7
%53 = call i32 @free(i8* %52)
%54 = load i32, i32* %4
%55 = call i32 @close(i32 %54)
br label %56
56: ; preds = %51
%57 = load i32, i32* @stderr
%58 = load i32, i32* @errno
%59 = call i8* @strerror(i32 %58)
%60 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 28, i8* %59)
store i8* null, i8** %2
br label %71
61: ; No predecessors!
br label %62
62: ; preds = %61, %44
%63 = load i8*, i8** %7
%64 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%65 = load i32, i32* %64
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %63, i64 %66
store i8 0, i8* %67
%68 = load i32, i32* %4
%69 = call i32 @close(i32 %68)
%70 = load i8*, i8** %7
store i8* %70, i8** %2
br label %71
71: ; preds = %62, %56, %40, %26, %14
%72 = load i8*, i8** %2
ret i8* %72
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"[ERROR in %s:%d]: %s\0A\00"
@.str.1 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/master/src/config.c\00"
@errno = global i32 0
@.str.2 = [7 x i8] c"malloc\00"
define noalias i8* @read_file(i8* nocapture %0) {
%2 = alloca %struct.stat
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* %0, i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = tail call i8* @strerror(i32 %8)
%10 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 16, i8* %9)
br label %45
11: ; preds = %1
%12 = bitcast %struct.stat* %2 to i8*
%13 = call i32 @fstat(i32 %4, %struct.stat* %2)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = load i32, i32* @errno
%18 = tail call i8* @strerror(i32 %17)
%19 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 20, i8* %18)
br label %43
20: ; preds = %11
%21 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
%24 = tail call i8* @malloc(i32 %23)
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %43
29: ; preds = %20
%30 = tail call i32 @read(i32 %4, i8* %24, i32 %22)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = tail call i32 @free(i8* %24)
%34 = tail call i32 @close(i32 %4)
%35 = load i32, i32* @stderr
%36 = load i32, i32* @errno
%37 = tail call i8* @strerror(i32 %36)
%38 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 28, i8* %37)
br label %43
39: ; preds = %29
%40 = sext i32 %22 to i64
%41 = getelementptr inbounds i8, i8* %24, i64 %40
store i8 0, i8* %41
%42 = tail call i32 @close(i32 %4)
br label %43
43: ; preds = %26, %32, %39, %15
%44 = phi i8* [ null, %15 ], [ null, %32 ], [ %24, %39 ], [ null, %26 ]
br label %45
45: ; preds = %43, %6
%46 = phi i8* [ null, %6 ], [ %44, %43 ]
ret i8* %46
}