#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;

/* Variables and functions */
char *CONF_get1_default_config_file();
int CONF_modules_load(int /*<<< orphan*/ *, char const *, unsigned long);
int ERR_GET_REASON(int /*<<< orphan*/);
int /*<<< orphan*/ ERR_clear_error();
int /*<<< orphan*/ ERR_peek_last_error();
int /*<<< orphan*/ NCONF_free(int /*<<< orphan*/ *);
scalar_t__ NCONF_load(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *NCONF_new(int /*<<< orphan*/ *);
int /*<<< orphan*/ OPENSSL_free(char *);
int CONF_modules_load_file(const char *filename, const char *appname,
                           unsigned long flags) {
  char *file = NULL;
  CONF *conf = NULL;
  int ret = 0;
  conf = NCONF_new(NULL);
  if (conf == NULL)
    goto err;
  if (filename == NULL) {
    file = CONF_get1_default_config_file();
    if (!file)
      goto err;
  } else
    file = (char *)filename;
  if (NCONF_load(conf, file, NULL) <= 0) {
    if ((flags & 0x10) && (ERR_GET_REASON(ERR_peek_last_error()) == 114)) {
      ERR_clear_error();
      ret = 1;
    }
    goto err;
  }
  ret = CONF_modules_load(conf, appname, flags);
err:
  if (filename == NULL)
    OPENSSL_free(file);
  NCONF_free(conf);
  return ret;
}


x86 assembly (clang, -O0):
<CONF_modules_load_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <NCONF_new@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11d8 <CONF_modules_load_file+0x48>
jmp    1276 <CONF_modules_load_file+0xe6>
cmpq   $0x0,-0x8(%rbp)
jne    1203 <CONF_modules_load_file+0x73>
mov    $0x0,%al
call   1060 <CONF_get1_default_config_file@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11fe <CONF_modules_load_file+0x6e>
jmp    1276 <CONF_modules_load_file+0xe6>
jmp    120b <CONF_modules_load_file+0x7b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <NCONF_load@plt>
cmp    $0x0,%rax
jg     1262 <CONF_modules_load_file+0xd2>
mov    -0x18(%rbp),%rax
and    $0x10,%rax
cmp    $0x0,%rax
je     125d <CONF_modules_load_file+0xcd>
mov    $0x0,%al
call   1040 <ERR_peek_last_error@plt>
mov    %eax,%edi
call   10b0 <ERR_GET_REASON@plt>
cmp    $0x72,%eax
jne    125d <CONF_modules_load_file+0xcd>
mov    $0x0,%al
call   1070 <ERR_clear_error@plt>
movl   $0x1,-0x2c(%rbp)
jmp    1276 <CONF_modules_load_file+0xe6>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <CONF_modules_load@plt>
mov    %eax,-0x2c(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    128a <CONF_modules_load_file+0xfa>
mov    -0x20(%rbp),%rdi
call   1090 <OPENSSL_free@plt>
mov    -0x28(%rbp),%rdi
call   10a0 <NCONF_free@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CONF_modules_load_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%r15
xor    %r14d,%r14d
xor    %edi,%edi
call   1050 <NCONF_new@plt>
mov    %rax,%r12
mov    $0x0,%ebx
test   %rax,%rax
je     1221 <CONF_modules_load_file+0x91>
mov    %r15,%r14
test   %r15,%r15
jne    11d4 <CONF_modules_load_file+0x44>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <CONF_get1_default_config_file@plt>
mov    %rax,%r14
test   %rax,%rax
je     1228 <CONF_modules_load_file+0x98>
xor    %ebx,%ebx
mov    %r12,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1080 <NCONF_load@plt>
test   %rax,%rax
jle    11fa <CONF_modules_load_file+0x6a>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1030 <CONF_modules_load@plt>
mov    %eax,%ebx
jmp    1221 <CONF_modules_load_file+0x91>
test   $0x10,%r13b
je     1221 <CONF_modules_load_file+0x91>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <ERR_peek_last_error@plt>
mov    %eax,%edi
call   10b0 <ERR_GET_REASON@plt>
cmp    $0x72,%eax
jne    1221 <CONF_modules_load_file+0x91>
xor    %eax,%eax
call   1070 <ERR_clear_error@plt>
mov    $0x1,%ebx
test   %r15,%r15
jne    1233 <CONF_modules_load_file+0xa3>
jmp    122b <CONF_modules_load_file+0x9b>
xor    %r14d,%r14d
mov    %r14,%rdi
call   1090 <OPENSSL_free@plt>
mov    %r12,%rdi
call   10a0 <NCONF_free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @CONF_modules_load_file(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
store i8* null, i8** %7
store i32* null, i32** %8
store i32 0, i32* %9
%10 = call i32* @NCONF_new(i32* null)
store i32* %10, i32** %8
%11 = load i32*, i32** %8
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %14
13: ; preds = %3
br label %46
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = call i8* (...) @CONF_get1_default_config_file()
store i8* %18, i8** %7
%19 = load i8*, i8** %7
%20 = icmp ne i8* %19, null
br i1 %20, label %22, label %21
21: ; preds = %17
br label %46
22: ; preds = %17
br label %25
23: ; preds = %14
%24 = load i8*, i8** %4
store i8* %24, i8** %7
br label %25
25: ; preds = %23, %22
%26 = load i32*, i32** %8
%27 = load i8*, i8** %7
%28 = call i64 @NCONF_load(i32* %26, i8* %27, i32* null)
%29 = icmp sle i64 %28, 0
br i1 %29, label %30, label %41
30: ; preds = %25
%31 = load i64, i64* %6
%32 = and i64 %31, 16
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %30
%35 = call i32 (...) @ERR_peek_last_error()
%36 = call i32 @ERR_GET_REASON(i32 %35)
%37 = icmp eq i32 %36, 114
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 (...) @ERR_clear_error()
store i32 1, i32* %9
br label %40
40: ; preds = %38, %34, %30
br label %46
41: ; preds = %25
%42 = load i32*, i32** %8
%43 = load i8*, i8** %5
%44 = load i64, i64* %6
%45 = call i32 @CONF_modules_load(i32* %42, i8* %43, i64 %44)
store i32 %45, i32* %9
br label %46
46: ; preds = %41, %40, %21, %13
%47 = load i8*, i8** %4
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %52
49: ; preds = %46
%50 = load i8*, i8** %7
%51 = call i32 @OPENSSL_free(i8* %50)
br label %52
52: ; preds = %49, %46
%53 = load i32*, i32** %8
%54 = call i32 @NCONF_free(i32* %53)
%55 = load i32, i32* %9
ret i32 %55
}

LLVM IR (-O2):
define i32 @CONF_modules_load_file(i8* %0, i8* %1, i64 %2) {
%4 = tail call i32* @NCONF_new(i32* null)
%5 = icmp eq i32* %4, null
br i1 %5, label %26, label %6
6: ; preds = %3
%7 = icmp eq i8* %0, null
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = tail call i8* (...) @CONF_get1_default_config_file()
%10 = icmp eq i8* %9, null
br i1 %10, label %30, label %11
11: ; preds = %6, %8
%12 = phi i8* [ %9, %8 ], [ %0, %6 ]
%13 = tail call i64 @NCONF_load(i32* %4, i8* %12, i32* null)
%14 = icmp slt i64 %13, 1
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = and i64 %2, 16
%17 = icmp eq i64 %16, 0
br i1 %17, label %26, label %18
18: ; preds = %15
%19 = tail call i32 (...) @ERR_peek_last_error()
%20 = tail call i32 @ERR_GET_REASON(i32 %19)
%21 = icmp eq i32 %20, 114
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = tail call i32 (...) @ERR_clear_error()
br label %26
24: ; preds = %11
%25 = tail call i32 @CONF_modules_load(i32* %4, i8* %1, i64 %2)
br label %26
26: ; preds = %15, %18, %22, %3, %24
%27 = phi i8* [ null, %3 ], [ %12, %22 ], [ %12, %18 ], [ %12, %15 ], [ %12, %24 ]
%28 = phi i32 [ 0, %3 ], [ 1, %22 ], [ 0, %18 ], [ 0, %15 ], [ %25, %24 ]
%29 = icmp eq i8* %0, null
br i1 %29, label %30, label %34
30: ; preds = %8, %26
%31 = phi i32 [ %28, %26 ], [ 0, %8 ]
%32 = phi i8* [ %27, %26 ], [ null, %8 ]
%33 = tail call i32 @OPENSSL_free(i8* %32)
br label %34
34: ; preds = %30, %26
%35 = phi i32 [ %31, %30 ], [ %28, %26 ]
%36 = tail call i32 @NCONF_free(i32* %4)
ret i32 %35
}