#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 list {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
struct list *list_from_file(int /*<<< orphan*/ *, int *);
struct list *list_from_filename(const char *s, int *haseol) {
  struct list *l;
  FILE *f;
  f = fopen(s, "r");
  if (!f)
    return NULL;
  l = list_from_file(f, haseol);
  fclose(f);
  return l;
}


x86 assembly (clang, -O0):
<list_from_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116c <list_from_filename+0x3c>
movq   $0x0,-0x8(%rbp)
jmp    118e <list_from_filename+0x5e>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <list_from_file@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_from_filename>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
lea    0xec2(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     1166 <list_from_filename+0x36>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <list_from_file@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rax
jmp    1168 <list_from_filename+0x38>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.list = type { i32 }
@.str = [2 x i8] c"r\00"
define %struct.list* @list_from_filename(i8* %0, i32* %1) {
%3 = alloca %struct.list*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca %struct.list*
%7 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %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 %struct.list* null, %struct.list** %3
br label %20
13: ; preds = %2
%14 = load i32*, i32** %7
%15 = load i32*, i32** %5
%16 = call %struct.list* @list_from_file(i32* %14, i32* %15)
store %struct.list* %16, %struct.list** %6
%17 = load i32*, i32** %7
%18 = call i32 @fclose(i32* %17)
%19 = load %struct.list*, %struct.list** %6
store %struct.list* %19, %struct.list** %3
br label %20
20: ; preds = %13, %12
%21 = load %struct.list*, %struct.list** %3
ret %struct.list* %21
}

LLVM IR (-O2):
%struct.list = type { i32 }
@.str = [2 x i8] c"r\00"
define %struct.list* @list_from_filename(i8* nocapture %0, i32* %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 %8, label %5
5: ; preds = %2
%6 = tail call %struct.list* @list_from_file(i32* %3, i32* %1)
%7 = tail call i32 @fclose(i32* %3)
br label %8
8: ; preds = %2, %5
%9 = phi %struct.list* [ %6, %5 ], [ null, %2 ]
ret %struct.list* %9
}