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

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
struct model *obj_load_from_file(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ warn(char *, char const *, int /*<<< orphan*/);
struct model *obj_load(const char *filename) {
  FILE *f;
  struct model *m;
  f = fopen(filename, "r");
  if (!f) {
    warn("%s:%s\n", filename, strerror(errno));
    return 0;
  }
  m = obj_load_from_file(f, filename);
  fclose(f);
  return m;
}


x86 assembly (clang, -O0):
<obj_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b0 <obj_load+0x60>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xe64(%rip),%rdi
call   1030 <warn@plt>
movq   $0x0,-0x8(%rbp)
jmp    11d2 <obj_load+0x82>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <obj_load_from_file@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%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):
<obj_load>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1186 <obj_load+0x36>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <obj_load_from_file@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rax
jmp    11a7 <obj_load+0x57>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe67(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <warn@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.model = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"%s:%s\0A\00"
@errno = global i32 0
define %struct.model* @obj_load(i8* %0) {
%2 = alloca %struct.model*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.model*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %15, label %10
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = call i32 @warn(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %13)
store %struct.model* null, %struct.model** %2
br label %22
15: ; preds = %1
%16 = load i32*, i32** %4
%17 = load i8*, i8** %3
%18 = call %struct.model* @obj_load_from_file(i32* %16, i8* %17)
store %struct.model* %18, %struct.model** %5
%19 = load i32*, i32** %4
%20 = call i32 @fclose(i32* %19)
%21 = load %struct.model*, %struct.model** %5
store %struct.model* %21, %struct.model** %2
br label %22
22: ; preds = %15, %10
%23 = load %struct.model*, %struct.model** %2
ret %struct.model* %23
}

LLVM IR (-O2):
%struct.model = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"%s:%s\0A\00"
@errno = global i32 0
define %struct.model* @obj_load(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = load i32, i32* @errno
%6 = tail call i32 @strerror(i32 %5)
%7 = tail call i32 @warn(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %6)
br label %11
8: ; preds = %1
%9 = tail call %struct.model* @obj_load_from_file(i32* %2, i8* %0)
%10 = tail call i32 @fclose(i32* %2)
br label %11
11: ; preds = %8, %4
%12 = phi %struct.model* [ %9, %8 ], [ null, %4 ]
ret %struct.model* %12
}