#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*/ X509_LOOKUP;

/* Variables and functions */
long X509_FILETYPE_DEFAULT;
long X509_FILETYPE_PEM;
int /*<<< orphan*/ X509_F_BY_FILE_CTRL;
#define X509_L_FILE_LOAD 128
int /*<<< orphan*/ X509_R_LOADING_DEFAULTS;
char const *X509_get_default_cert_file();
int /*<<< orphan*/ X509_load_cert_crl_file(int /*<<< orphan*/ *, char const *,
                                           long);
int /*<<< orphan*/ X509_load_cert_file(int /*<<< orphan*/ *, char const *, int);
int /*<<< orphan*/ X509err(int /*<<< orphan*/, int /*<<< orphan*/);
int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
                 char **ret) {
  int ok = 0;
  switch (cmd) {
  case X509_L_FILE_LOAD:
    if (argl == X509_FILETYPE_DEFAULT) {
      ok = (X509_load_cert_crl_file(ctx, X509_get_default_cert_file(),
                                    X509_FILETYPE_PEM) != 0);
      if (!ok) {
        X509err(X509_F_BY_FILE_CTRL, X509_R_LOADING_DEFAULTS);
      }
    } else {
      if (argl == X509_FILETYPE_PEM)
        ok = (X509_load_cert_crl_file(ctx, argp, X509_FILETYPE_PEM) != 0);
      else
        ok = (X509_load_cert_file(ctx, argp, (int)argl) != 0);
    }
    break;
  }
  return (ok);
}


x86 assembly (clang, -O0):
<by_file_ctrl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x80,%eax
jne    124b <by_file_ctrl+0x10b>
jmp    1175 <by_file_ctrl+0x35>
mov    -0x20(%rbp),%rax
mov    0x2e70(%rip),%rcx
cmp    (%rcx),%rax
jne    11e2 <by_file_ctrl+0xa2>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1040 <X509_get_default_cert_file@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
mov    0x2e42(%rip),%rax
mov    (%rax),%rdx
call   1060 <X509_load_cert_crl_file@plt>
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11dd <by_file_ctrl+0x9d>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    0x2df2(%rip),%rax
mov    (%rax),%esi
call   1050 <X509err@plt>
jmp    1246 <by_file_ctrl+0x106>
mov    -0x20(%rbp),%rax
mov    0x2dfb(%rip),%rcx
cmp    (%rcx),%rax
jne    1220 <by_file_ctrl+0xe0>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2de3(%rip),%rax
mov    (%rax),%rdx
call   1060 <X509_load_cert_crl_file@plt>
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
jmp    1241 <by_file_ctrl+0x101>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    %eax,%edx
call   1030 <X509_load_cert_file@plt>
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
jmp    1246 <by_file_ctrl+0x106>
jmp    124b <by_file_ctrl+0x10b>
mov    -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<by_file_ctrl>:
push   %rbx
cmp    $0x80,%esi
jne    1191 <by_file_ctrl+0x51>
mov    %rdi,%rbx
mov    0x2e9d(%rip),%rax
cmp    %rcx,(%rax)
jne    1195 <by_file_ctrl+0x55>
xor    %eax,%eax
call   1040 <X509_get_default_cert_file@plt>
mov    0x2e82(%rip),%rcx
mov    (%rcx),%rdx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <X509_load_cert_crl_file@plt>
mov    $0x1,%cl
test   %eax,%eax
jne    11c3 <by_file_ctrl+0x83>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
call   1050 <X509err@plt>
xor    %ecx,%ecx
jmp    11c3 <by_file_ctrl+0x83>
mov    0x2e4c(%rip),%rax
cmp    %rcx,(%rax)
jne    11b1 <by_file_ctrl+0x71>
mov    %rbx,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
call   1060 <X509_load_cert_crl_file@plt>
jmp    11be <by_file_ctrl+0x7e>
mov    %rbx,%rdi
mov    %rdx,%rsi
mov    %ecx,%edx
call   1030 <X509_load_cert_file@plt>
test   %eax,%eax
setne  %cl
movzbl %cl,%eax
pop    %rbx
ret

LLVM IR (-O0):
@X509_FILETYPE_DEFAULT = global i64 0
@X509_FILETYPE_PEM = global i64 0
@X509_F_BY_FILE_CTRL = global i32 0
@X509_R_LOADING_DEFAULTS = global i32 0
define i32 @by_file_ctrl(i32* %0, i32 %1, i8* %2, i64 %3, i8** %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8**
%11 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i8** %4, i8*** %10
store i32 0, i32* %11
%12 = load i32, i32* %7
switch i32 %12, label %52 [
i32 128, label %13
]
13: ; preds = %5
%14 = load i64, i64* %9
%15 = load i64, i64* @X509_FILETYPE_DEFAULT
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %31
17: ; preds = %13
%18 = load i32*, i32** %6
%19 = call i8* (...) @X509_get_default_cert_file()
%20 = load i64, i64* @X509_FILETYPE_PEM
%21 = call i32 @X509_load_cert_crl_file(i32* %18, i8* %19, i64 %20)
%22 = icmp ne i32 %21, 0
%23 = zext i1 %22 to i32
store i32 %23, i32* %11
%24 = load i32, i32* %11
%25 = icmp ne i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %17
%27 = load i32, i32* @X509_F_BY_FILE_CTRL
%28 = load i32, i32* @X509_R_LOADING_DEFAULTS
%29 = call i32 @X509err(i32 %27, i32 %28)
br label %30
30: ; preds = %26, %17
br label %51
31: ; preds = %13
%32 = load i64, i64* %9
%33 = load i64, i64* @X509_FILETYPE_PEM
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %42
35: ; preds = %31
%36 = load i32*, i32** %6
%37 = load i8*, i8** %8
%38 = load i64, i64* @X509_FILETYPE_PEM
%39 = call i32 @X509_load_cert_crl_file(i32* %36, i8* %37, i64 %38)
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i32
store i32 %41, i32* %11
br label %50
42: ; preds = %31
%43 = load i32*, i32** %6
%44 = load i8*, i8** %8
%45 = load i64, i64* %9
%46 = trunc i64 %45 to i32
%47 = call i32 @X509_load_cert_file(i32* %43, i8* %44, i32 %46)
%48 = icmp ne i32 %47, 0
%49 = zext i1 %48 to i32
store i32 %49, i32* %11
br label %50
50: ; preds = %42, %35
br label %51
51: ; preds = %50, %30
br label %52
52: ; preds = %5, %51
%53 = load i32, i32* %11
ret i32 %53
}

LLVM IR (-O2):
@X509_FILETYPE_DEFAULT = global i64 0
@X509_FILETYPE_PEM = global i64 0
@X509_F_BY_FILE_CTRL = global i32 0
@X509_R_LOADING_DEFAULTS = global i32 0
define i32 @by_file_ctrl(i32* %0, i32 %1, i8* %2, i64 %3, i8** nocapture readnone %4) {
%6 = icmp eq i32 %1, 128
br i1 %6, label %7, label %29
7: ; preds = %5
%8 = load i64, i64* @X509_FILETYPE_DEFAULT
%9 = icmp eq i64 %8, %3
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = tail call i8* (...) @X509_get_default_cert_file()
%12 = load i64, i64* @X509_FILETYPE_PEM
%13 = tail call i32 @X509_load_cert_crl_file(i32* %0, i8* %11, i64 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %29
15: ; preds = %10
%16 = load i32, i32* @X509_F_BY_FILE_CTRL
%17 = load i32, i32* @X509_R_LOADING_DEFAULTS
%18 = tail call i32 @X509err(i32 %16, i32 %17)
br label %29
19: ; preds = %7
%20 = load i64, i64* @X509_FILETYPE_PEM
%21 = icmp eq i64 %20, %3
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = tail call i32 @X509_load_cert_crl_file(i32* %0, i8* %2, i64 %3)
%24 = icmp ne i32 %23, 0
br label %29
25: ; preds = %19
%26 = trunc i64 %3 to i32
%27 = tail call i32 @X509_load_cert_file(i32* %0, i8* %2, i32 %26)
%28 = icmp ne i32 %27, 0
br label %29
29: ; preds = %15, %10, %25, %22, %5
%30 = phi i1 [ true, %10 ], [ false, %15 ], [ %24, %22 ], [ %28, %25 ], [ false, %5 ]
%31 = zext i1 %30 to i32
ret i32 %31
}