#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 */
scalar_t__ Getenv(int /*<<< orphan*/);
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_get_default_cert_file_env();
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;
  char *file;
  switch (cmd) {
  case X509_L_FILE_LOAD:
    if (argl == X509_FILETYPE_DEFAULT) {
      file = (char *)Getenv(X509_get_default_cert_file_env());
      if (file)
        ok = (X509_load_cert_crl_file(ctx, file, X509_FILETYPE_PEM) != 0);
      else
        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    12b2 <by_file_ctrl+0x152>
jmp    1195 <by_file_ctrl+0x35>
mov    -0x20(%rbp),%rax
mov    0x2e50(%rip),%rcx
cmp    (%rcx),%rax
jne    1249 <by_file_ctrl+0xe9>
mov    $0x0,%al
call   1080 <X509_get_default_cert_file_env@plt>
mov    %eax,%edi
call   1060 <Getenv@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11f0 <by_file_ctrl+0x90>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    0x2e13(%rip),%rax
mov    (%rax),%rdx
call   1070 <X509_load_cert_crl_file@plt>
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
jmp    1223 <by_file_ctrl+0xc3>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1040 <X509_get_default_cert_file@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rsi
mov    0x2ddb(%rip),%rax
mov    (%rax),%rdx
call   1070 <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    1244 <by_file_ctrl+0xe4>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
mov    0x2d8b(%rip),%rax
mov    (%rax),%esi
call   1050 <X509err@plt>
jmp    12ad <by_file_ctrl+0x14d>
mov    -0x20(%rbp),%rax
mov    0x2d94(%rip),%rcx
cmp    (%rcx),%rax
jne    1287 <by_file_ctrl+0x127>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2d7c(%rip),%rax
mov    (%rax),%rdx
call   1070 <X509_load_cert_crl_file@plt>
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x2c(%rbp)
jmp    12a8 <by_file_ctrl+0x148>
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    12ad <by_file_ctrl+0x14d>
jmp    12b2 <by_file_ctrl+0x152>
mov    -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<by_file_ctrl>:
push   %rbx
cmp    $0x80,%esi
jne    11c4 <by_file_ctrl+0x64>
mov    %rdi,%rbx
mov    0x2e7d(%rip),%rax
cmp    %rcx,(%rax)
jne    11c8 <by_file_ctrl+0x68>
xor    %eax,%eax
call   1080 <X509_get_default_cert_file_env@plt>
mov    %eax,%edi
call   1060 <Getenv@plt>
test   %rax,%rax
jne    1192 <by_file_ctrl+0x32>
xor    %eax,%eax
call   1040 <X509_get_default_cert_file@plt>
mov    0x2e4f(%rip),%rcx
mov    (%rcx),%rdx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1070 <X509_load_cert_crl_file@plt>
mov    $0x1,%cl
test   %eax,%eax
jne    11f6 <by_file_ctrl+0x96>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
call   1050 <X509err@plt>
xor    %ecx,%ecx
jmp    11f6 <by_file_ctrl+0x96>
mov    0x2e19(%rip),%rax
cmp    %rcx,(%rax)
jne    11e4 <by_file_ctrl+0x84>
mov    %rbx,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
call   1070 <X509_load_cert_crl_file@plt>
jmp    11f1 <by_file_ctrl+0x91>
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
%12 = alloca i8*
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
%13 = load i32, i32* %7
switch i32 %13, label %67 [
i32 128, label %14
]
14: ; preds = %5
%15 = load i64, i64* %9
%16 = load i64, i64* @X509_FILETYPE_DEFAULT
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %46
18: ; preds = %14
%19 = call i32 (...) @X509_get_default_cert_file_env()
%20 = call i64 @Getenv(i32 %19)
%21 = inttoptr i64 %20 to i8*
store i8* %21, i8** %12
%22 = load i8*, i8** %12
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %31
24: ; preds = %18
%25 = load i32*, i32** %6
%26 = load i8*, i8** %12
%27 = load i64, i64* @X509_FILETYPE_PEM
%28 = call i32 @X509_load_cert_crl_file(i32* %25, i8* %26, i64 %27)
%29 = icmp ne i32 %28, 0
%30 = zext i1 %29 to i32
store i32 %30, i32* %11
br label %38
31: ; preds = %18
%32 = load i32*, i32** %6
%33 = call i8* (...) @X509_get_default_cert_file()
%34 = load i64, i64* @X509_FILETYPE_PEM
%35 = call i32 @X509_load_cert_crl_file(i32* %32, i8* %33, i64 %34)
%36 = icmp ne i32 %35, 0
%37 = zext i1 %36 to i32
store i32 %37, i32* %11
br label %38
38: ; preds = %31, %24
%39 = load i32, i32* %11
%40 = icmp ne i32 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %38
%42 = load i32, i32* @X509_F_BY_FILE_CTRL
%43 = load i32, i32* @X509_R_LOADING_DEFAULTS
%44 = call i32 @X509err(i32 %42, i32 %43)
br label %45
45: ; preds = %41, %38
br label %66
46: ; preds = %14
%47 = load i64, i64* %9
%48 = load i64, i64* @X509_FILETYPE_PEM
%49 = icmp eq i64 %47, %48
br i1 %49, label %50, label %57
50: ; preds = %46
%51 = load i32*, i32** %6
%52 = load i8*, i8** %8
%53 = load i64, i64* @X509_FILETYPE_PEM
%54 = call i32 @X509_load_cert_crl_file(i32* %51, i8* %52, i64 %53)
%55 = icmp ne i32 %54, 0
%56 = zext i1 %55 to i32
store i32 %56, i32* %11
br label %65
57: ; preds = %46
%58 = load i32*, i32** %6
%59 = load i8*, i8** %8
%60 = load i64, i64* %9
%61 = trunc i64 %60 to i32
%62 = call i32 @X509_load_cert_file(i32* %58, i8* %59, i32 %61)
%63 = icmp ne i32 %62, 0
%64 = zext i1 %63 to i32
store i32 %64, i32* %11
br label %65
65: ; preds = %57, %50
br label %66
66: ; preds = %65, %45
br label %67
67: ; preds = %5, %66
%68 = load i32, i32* %11
ret i32 %68
}

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 %39
7: ; preds = %5
%8 = load i64, i64* @X509_FILETYPE_DEFAULT
%9 = icmp eq i64 %8, %3
br i1 %9, label %10, label %29
10: ; preds = %7
%11 = tail call i32 (...) @X509_get_default_cert_file_env()
%12 = tail call i64 @Getenv(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = inttoptr i64 %12 to i8*
%16 = load i64, i64* @X509_FILETYPE_PEM
%17 = tail call i32 @X509_load_cert_crl_file(i32* %0, i8* %15, i64 %16)
br label %22
18: ; preds = %10
%19 = tail call i8* (...) @X509_get_default_cert_file()
%20 = load i64, i64* @X509_FILETYPE_PEM
%21 = tail call i32 @X509_load_cert_crl_file(i32* %0, i8* %19, i64 %20)
br label %22
22: ; preds = %18, %14
%23 = phi i32 [ %17, %14 ], [ %21, %18 ]
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %39
25: ; preds = %22
%26 = load i32, i32* @X509_F_BY_FILE_CTRL
%27 = load i32, i32* @X509_R_LOADING_DEFAULTS
%28 = tail call i32 @X509err(i32 %26, i32 %27)
br label %39
29: ; preds = %7
%30 = load i64, i64* @X509_FILETYPE_PEM
%31 = icmp eq i64 %30, %3
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = tail call i32 @X509_load_cert_crl_file(i32* %0, i8* %2, i64 %3)
%34 = icmp ne i32 %33, 0
br label %39
35: ; preds = %29
%36 = trunc i64 %3 to i32
%37 = tail call i32 @X509_load_cert_file(i32* %0, i8* %2, i32 %36)
%38 = icmp ne i32 %37, 0
br label %39
39: ; preds = %25, %22, %35, %32, %5
%40 = phi i1 [ true, %22 ], [ false, %25 ], [ %34, %32 ], [ %38, %35 ], [ false, %5 ]
%41 = zext i1 %40 to i32
ret i32 %41
}