#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ modelload(int /*<<< orphan*/ *, struct model *);
int /*<<< orphan*/ printf(char *, char const *);
void collectmypdb(const char *name_i, struct model *pmodel_input) {
  FILE *fi;
  if (NULL != (fi = fopen(name_i, "r"))) {
    modelload(fi, pmodel_input);
    fclose(fi);
  } else {
    printf("problems with %s\n", name_i);
    exit(EXIT_FAILURE);
  }
  return;
}


x86 assembly (clang, -O0):
<collectmypdb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     119d <collectmypdb+0x4d>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <modelload@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11bb <collectmypdb+0x6b>
mov    -0x8(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<collectmypdb>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe9e(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1187 <collectmypdb+0x37>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <modelload@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
lea    0xe74(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.model = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"problems with %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @collectmypdb(i8* %0, %struct.model* %1) {
%3 = alloca i8*
%4 = alloca %struct.model*
%5 = alloca i32*
store i8* %0, i8** %3
store %struct.model* %1, %struct.model** %4
%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** %5
%8 = icmp ne i32* null, %7
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32*, i32** %5
%11 = load %struct.model*, %struct.model** %4
%12 = call i32 @modelload(i32* %10, %struct.model* %11)
%13 = load i32*, i32** %5
%14 = call i32 @fclose(i32* %13)
br label %20
15: ; preds = %2
%16 = load i8*, i8** %3
%17 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %9
ret void
}

LLVM IR (-O2):
%struct.model = type { i32 }
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"problems with %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @collectmypdb(i8* %0, %struct.model* %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 i32 @modelload(i32* %3, %struct.model* %1)
%7 = tail call i32 @fclose(i32* %3)
ret void
8: ; preds = %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
}