#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 *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
scalar_t__ fread(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
char *malloc(size_t);
int /*<<< orphan*/ stderr;
char *read_ignore_list(const char *filename, size_t *len) {
  char *buf;
  FILE *infile;
  infile = fopen(filename, "r");
  if (!infile)
    return NULL;
  fseek(infile, 0, SEEK_END);
  *len = ftell(infile);
  fseek(infile, 0, SEEK_SET);
  buf = malloc(*len + 1);
  if (buf == NULL)
    return NULL;
  if (fread(buf, 1, *len, infile) == 0)
    fprintf(stderr, "Error with reading buf from %s\n", filename);
  fclose(infile);
  return buf;
}


x86 assembly (clang, -O0):
<read_ignore_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11ac <read_ignore_list+0x3c>
movq   $0x0,-0x8(%rbp)
jmp    1260 <read_ignore_list+0xf0>
mov    -0x28(%rbp),%rdi
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x28(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
mov    0x2df2(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1213 <read_ignore_list+0xa3>
movq   $0x0,-0x8(%rbp)
jmp    1260 <read_ignore_list+0xf0>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
cmp    $0x0,%rax
jne    124f <read_ignore_list+0xdf>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdb8(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_ignore_list>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe7b(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1216 <read_ignore_list+0xa6>
mov    %rax,%rbx
mov    0x2e4b(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %rbx,%rdi
call   1060 <ftell@plt>
mov    %rax,(%r15)
mov    0x2e15(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    (%r15),%r12
lea    0x1(%r12),%rdi
call   1070 <malloc@plt>
test   %rax,%rax
je     1216 <read_ignore_list+0xa6>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    %rbx,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jne    120c <read_ignore_list+0x9c>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
lea    0xdfe(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    1219 <read_ignore_list+0xa9>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str.1 = [32 x i8] c"Error with reading buf from %s\0A\00"
define i8* @read_ignore_list(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i8*
%7 = alloca i32*
store i8* %0, i8** %4
store i64* %1, i64** %5
%8 = load i8*, i8** %4
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 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 %13, label %12
12: ; preds = %2
store i8* null, i8** %3
br label %45
13: ; preds = %2
%14 = load i32*, i32** %7
%15 = load i32, i32* @SEEK_END
%16 = call i32 @fseek(i32* %14, i32 0, i32 %15)
%17 = load i32*, i32** %7
%18 = call i64 @ftell(i32* %17)
%19 = load i64*, i64** %5
store i64 %18, i64* %19
%20 = load i32*, i32** %7
%21 = load i32, i32* @SEEK_SET
%22 = call i32 @fseek(i32* %20, i32 0, i32 %21)
%23 = load i64*, i64** %5
%24 = load i64, i64* %23
%25 = add i64 %24, 1
%26 = call i8* @malloc(i64 %25)
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %30
29: ; preds = %13
store i8* null, i8** %3
br label %45
30: ; preds = %13
%31 = load i8*, i8** %6
%32 = load i64*, i64** %5
%33 = load i64, i64* %32
%34 = load i32*, i32** %7
%35 = call i64 @fread(i8* %31, i32 1, i64 %33, i32* %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %30
%38 = load i32, i32* @stderr
%39 = load i8*, i8** %4
%40 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %37, %30
%42 = load i32*, i32** %7
%43 = call i32 @fclose(i32* %42)
%44 = load i8*, i8** %6
store i8* %44, i8** %3
br label %45
45: ; preds = %41, %29, %12
%46 = load i8*, i8** %3
ret i8* %46
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str.1 = [32 x i8] c"Error with reading buf from %s\0A\00"
define noalias i8* @read_ignore_list(i8* %0, i64* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %23, label %5
5: ; preds = %2
%6 = load i32, i32* @SEEK_END
%7 = tail call i32 @fseek(i32* %3, i32 0, i32 %6)
%8 = tail call i64 @ftell(i32* %3)
store i64 %8, i64* %1
%9 = load i32, i32* @SEEK_SET
%10 = tail call i32 @fseek(i32* %3, i32 0, i32 %9)
%11 = load i64, i64* %1
%12 = add i64 %11, 1
%13 = tail call i8* @malloc(i64 %12)
%14 = icmp eq i8* %13, null
br i1 %14, label %23, label %15
15: ; preds = %5
%16 = tail call i64 @fread(i8* %13, i32 1, i64 %11, i32* %3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %21
21: ; preds = %18, %15
%22 = tail call i32 @fclose(i32* %3)
br label %23
23: ; preds = %5, %2, %21
%24 = phi i8* [ %13, %21 ], [ null, %2 ], [ null, %5 ]
ret i8* %24
}