#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*/ CONF;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
scalar_t__ BIO_R_NO_SUCH_FILE;
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new_file(char const *, char *);
int /*<<< orphan*/ CONF_F_DEF_LOAD;
int /*<<< orphan*/ CONF_R_NO_SUCH_FILE;
int /*<<< orphan*/ CONFerr(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ ERR_GET_REASON(int /*<<< orphan*/);
int /*<<< orphan*/ ERR_R_SYS_LIB;
int /*<<< orphan*/ ERR_peek_last_error();
int def_load_bio(int /*<<< orphan*/ *, int /*<<< orphan*/ *, long *);
int def_load(CONF *conf, const char *name, long *line) {
  int ret;
  BIO *in = NULL;
  in = BIO_new_file(name, "rb");
  if (in == NULL) {
    if (ERR_GET_REASON(ERR_peek_last_error()) == BIO_R_NO_SUCH_FILE)
      CONFerr(CONF_F_DEF_LOAD, CONF_R_NO_SUCH_FILE);
    else
      CONFerr(CONF_F_DEF_LOAD, ERR_R_SYS_LIB);
    return 0;
  }
  ret = def_load_bio(conf, in, line);
  BIO_free(in);
  return ret;
}


x86 assembly (clang, -O0):
<def_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1080 <BIO_new_file@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11f8 <def_load+0x98>
mov    $0x0,%al
call   1030 <ERR_peek_last_error@plt>
mov    %eax,%edi
call   1070 <ERR_GET_REASON@plt>
mov    0x2e38(%rip),%rcx
cmp    (%rcx),%rax
jne    11d5 <def_load+0x75>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
call   1040 <CONFerr@plt>
jmp    11ec <def_load+0x8c>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
mov    0x2deb(%rip),%rax
mov    (%rax),%esi
call   1040 <CONFerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    121b <def_load+0xbb>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <def_load_bio@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <BIO_free@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<def_load>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rax
mov    %rdi,%r15
lea    0xe89(%rip),%rsi
mov    %rax,%rdi
call   1080 <BIO_new_file@plt>
test   %rax,%rax
je     11a3 <def_load+0x43>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1050 <def_load_bio@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <BIO_free@plt>
mov    %ebp,%eax
jmp    11df <def_load+0x7f>
xor    %eax,%eax
call   1030 <ERR_peek_last_error@plt>
mov    %eax,%edi
call   1070 <ERR_GET_REASON@plt>
mov    0x2e30(%rip),%rcx
mov    0x2e09(%rip),%rdx
mov    (%rdx),%edi
cmp    (%rcx),%rax
jne    11cf <def_load+0x6f>
mov    0x2e0b(%rip),%rax
jmp    11d6 <def_load+0x76>
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
call   1040 <CONFerr@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@BIO_R_NO_SUCH_FILE = global i64 0
@CONF_F_DEF_LOAD = global i32 0
@CONF_R_NO_SUCH_FILE = global i32 0
@ERR_R_SYS_LIB = global i32 0
define i32 @def_load(i32* %0, i8* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca i32
%9 = alloca i32*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i64* %2, i64** %7
store i32* null, i32** %9
%10 = load i8*, i8** %6
%11 = call i32* @BIO_new_file(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %9
%12 = load i32*, i32** %9
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %28
14: ; preds = %3
%15 = call i32 (...) @ERR_peek_last_error()
%16 = call i64 @ERR_GET_REASON(i32 %15)
%17 = load i64, i64* @BIO_R_NO_SUCH_FILE
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i32, i32* @CONF_F_DEF_LOAD
%21 = load i32, i32* @CONF_R_NO_SUCH_FILE
%22 = call i32 @CONFerr(i32 %20, i32 %21)
br label %27
23: ; preds = %14
%24 = load i32, i32* @CONF_F_DEF_LOAD
%25 = load i32, i32* @ERR_R_SYS_LIB
%26 = call i32 @CONFerr(i32 %24, i32 %25)
br label %27
27: ; preds = %23, %19
store i32 0, i32* %4
br label %36
28: ; preds = %3
%29 = load i32*, i32** %5
%30 = load i32*, i32** %9
%31 = load i64*, i64** %7
%32 = call i32 @def_load_bio(i32* %29, i32* %30, i64* %31)
store i32 %32, i32* %8
%33 = load i32*, i32** %9
%34 = call i32 @BIO_free(i32* %33)
%35 = load i32, i32* %8
store i32 %35, i32* %4
br label %36
36: ; preds = %28, %27
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@BIO_R_NO_SUCH_FILE = global i64 0
@CONF_F_DEF_LOAD = global i32 0
@CONF_R_NO_SUCH_FILE = global i32 0
@ERR_R_SYS_LIB = global i32 0
define i32 @def_load(i32* %0, i8* %1, i64* %2) {
%4 = tail call i32* @BIO_new_file(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %18
6: ; preds = %3
%7 = tail call i32 (...) @ERR_peek_last_error()
%8 = tail call i64 @ERR_GET_REASON(i32 %7)
%9 = load i64, i64* @BIO_R_NO_SUCH_FILE
%10 = icmp eq i64 %8, %9
%11 = load i32, i32* @CONF_F_DEF_LOAD
br i1 %10, label %12, label %15
12: ; preds = %6
%13 = load i32, i32* @CONF_R_NO_SUCH_FILE
%14 = tail call i32 @CONFerr(i32 %11, i32 %13)
br label %21
15: ; preds = %6
%16 = load i32, i32* @ERR_R_SYS_LIB
%17 = tail call i32 @CONFerr(i32 %11, i32 %16)
br label %21
18: ; preds = %3
%19 = tail call i32 @def_load_bio(i32* %0, i32* %4, i64* %2)
%20 = tail call i32 @BIO_free(i32* %4)
br label %21
21: ; preds = %12, %15, %18
%22 = phi i32 [ %19, %18 ], [ 0, %15 ], [ 0, %12 ]
ret i32 %22
}