#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;
#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*/ X509error(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) {
        X509error(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    1242 <by_file_ctrl+0x102>
jmp    1175 <by_file_ctrl+0x35>
mov    -0x20(%rbp),%rax
mov    0x2e70(%rip),%rcx
cmp    (%rcx),%rax
jne    11d9 <by_file_ctrl+0x99>
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    11d4 <by_file_ctrl+0x94>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1050 <X509error@plt>
jmp    123d <by_file_ctrl+0xfd>
mov    -0x20(%rbp),%rax
mov    0x2e04(%rip),%rcx
cmp    (%rcx),%rax
jne    1217 <by_file_ctrl+0xd7>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2dec(%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    1238 <by_file_ctrl+0xf8>
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    123d <by_file_ctrl+0xfd>
jmp    1242 <by_file_ctrl+0x102>
mov    -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<by_file_ctrl>:
push   %rbx
cmp    $0x80,%esi
jne    1188 <by_file_ctrl+0x48>
mov    %rdi,%rbx
mov    0x2e9d(%rip),%rax
cmp    %rcx,(%rax)
jne    118c <by_file_ctrl+0x4c>
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    11ba <by_file_ctrl+0x7a>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
call   1050 <X509error@plt>
xor    %ecx,%ecx
jmp    11ba <by_file_ctrl+0x7a>
mov    0x2e55(%rip),%rax
cmp    %rcx,(%rax)
jne    11a8 <by_file_ctrl+0x68>
mov    %rbx,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
call   1060 <X509_load_cert_crl_file@plt>
jmp    11b5 <by_file_ctrl+0x75>
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_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 %51 [
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 %30
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 %29, label %26
26: ; preds = %17
%27 = load i32, i32* @X509_R_LOADING_DEFAULTS
%28 = call i32 @X509error(i32 %27)
br label %29
29: ; preds = %26, %17
br label %50
30: ; preds = %13
%31 = load i64, i64* %9
%32 = load i64, i64* @X509_FILETYPE_PEM
%33 = icmp eq i64 %31, %32
br i1 %33, label %34, label %41
34: ; preds = %30
%35 = load i32*, i32** %6
%36 = load i8*, i8** %8
%37 = load i64, i64* @X509_FILETYPE_PEM
%38 = call i32 @X509_load_cert_crl_file(i32* %35, i8* %36, i64 %37)
%39 = icmp ne i32 %38, 0
%40 = zext i1 %39 to i32
store i32 %40, i32* %11
br label %49
41: ; preds = %30
%42 = load i32*, i32** %6
%43 = load i8*, i8** %8
%44 = load i64, i64* %9
%45 = trunc i64 %44 to i32
%46 = call i32 @X509_load_cert_file(i32* %42, i8* %43, i32 %45)
%47 = icmp ne i32 %46, 0
%48 = zext i1 %47 to i32
store i32 %48, i32* %11
br label %49
49: ; preds = %41, %34
br label %50
50: ; preds = %49, %29
br label %51
51: ; preds = %5, %50
%52 = load i32, i32* %11
ret i32 %52
}

LLVM IR (-O2):
@X509_FILETYPE_DEFAULT = global i64 0
@X509_FILETYPE_PEM = global i64 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 %28
7: ; preds = %5
%8 = load i64, i64* @X509_FILETYPE_DEFAULT
%9 = icmp eq i64 %8, %3
br i1 %9, label %10, label %18
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 %28
15: ; preds = %10
%16 = load i32, i32* @X509_R_LOADING_DEFAULTS
%17 = tail call i32 @X509error(i32 %16)
br label %28
18: ; preds = %7
%19 = load i64, i64* @X509_FILETYPE_PEM
%20 = icmp eq i64 %19, %3
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = tail call i32 @X509_load_cert_crl_file(i32* %0, i8* %2, i64 %3)
%23 = icmp ne i32 %22, 0
br label %28
24: ; preds = %18
%25 = trunc i64 %3 to i32
%26 = tail call i32 @X509_load_cert_file(i32* %0, i8* %2, i32 %25)
%27 = icmp ne i32 %26, 0
br label %28
28: ; preds = %15, %10, %24, %21, %5
%29 = phi i1 [ true, %10 ], [ false, %15 ], [ %23, %21 ], [ %27, %24 ], [ false, %5 ]
%30 = zext i1 %29 to i32
ret i32 %30
}