#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_STORE;
typedef int /*<<< orphan*/ X509_LOOKUP;

/* Variables and functions */
int /*<<< orphan*/ X509_FILETYPE_PEM;
int X509_LOOKUP_add_dir(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ X509_LOOKUP_file();
int /*<<< orphan*/ X509_LOOKUP_hash_dir();
int X509_LOOKUP_load_file(int /*<<< orphan*/ *, char const *,
                          int /*<<< orphan*/);
int /*<<< orphan*/ *X509_STORE_add_lookup(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/);
int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
                              const char *path) {
  X509_LOOKUP *lookup;
  if (file != NULL) {
    lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file());
    if (lookup == NULL)
      return (0);
    if (X509_LOOKUP_load_file(lookup, file, X509_FILETYPE_PEM) != 1)
      return (0);
  }
  if (path != NULL) {
    lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir());
    if (lookup == NULL)
      return (0);
    if (X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) != 1)
      return (0);
  }
  if ((path == NULL) && (file == NULL))
    return (0);
  return (1);
}


x86 assembly (clang, -O0):
<X509_STORE_load_locations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11d4 <X509_STORE_load_locations+0x84>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1030 <X509_LOOKUP_file@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1040 <X509_STORE_add_lookup@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a4 <X509_STORE_load_locations+0x54>
movl   $0x0,-0x4(%rbp)
jmp    126d <X509_STORE_load_locations+0x11d>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e3d(%rip),%rax
mov    (%rax),%edx
call   1070 <X509_LOOKUP_load_file@plt>
cmp    $0x1,%eax
je     11cf <X509_STORE_load_locations+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    126d <X509_STORE_load_locations+0x11d>
jmp    11d4 <X509_STORE_load_locations+0x84>
cmpq   $0x0,-0x20(%rbp)
je     1244 <X509_STORE_load_locations+0xf4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1060 <X509_LOOKUP_hash_dir@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1040 <X509_STORE_add_lookup@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1214 <X509_STORE_load_locations+0xc4>
movl   $0x0,-0x4(%rbp)
jmp    126d <X509_STORE_load_locations+0x11d>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2dcd(%rip),%rax
mov    (%rax),%edx
call   1050 <X509_LOOKUP_add_dir@plt>
cmp    $0x1,%eax
je     123f <X509_STORE_load_locations+0xef>
movl   $0x0,-0x4(%rbp)
jmp    126d <X509_STORE_load_locations+0x11d>
jmp    1244 <X509_STORE_load_locations+0xf4>
cmpq   $0x0,-0x20(%rbp)
jne    1266 <X509_STORE_load_locations+0x116>
cmpq   $0x0,-0x18(%rbp)
jne    1266 <X509_STORE_load_locations+0x116>
movl   $0x0,-0x4(%rbp)
jmp    126d <X509_STORE_load_locations+0x11d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X509_STORE_load_locations>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
test   %rsi,%rsi
je     1196 <X509_STORE_load_locations+0x46>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <X509_LOOKUP_file@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <X509_STORE_add_lookup@plt>
test   %rax,%rax
je     11d5 <X509_STORE_load_locations+0x85>
mov    0x2e6c(%rip),%rcx
mov    (%rcx),%edx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1070 <X509_LOOKUP_load_file@plt>
cmp    $0x1,%eax
jne    11d5 <X509_STORE_load_locations+0x85>
test   %r14,%r14
je     11cc <X509_STORE_load_locations+0x7c>
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <X509_LOOKUP_hash_dir@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <X509_STORE_add_lookup@plt>
test   %rax,%rax
je     11d5 <X509_STORE_load_locations+0x85>
mov    0x2e36(%rip),%rcx
mov    (%rcx),%edx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <X509_LOOKUP_add_dir@plt>
cmp    $0x1,%eax
jne    11d5 <X509_STORE_load_locations+0x85>
xor    %ebp,%ebp
or     %r14,%rbx
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@X509_FILETYPE_PEM = global i32 0
define i32 @X509_STORE_load_locations(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %26
11: ; preds = %3
%12 = load i32*, i32** %5
%13 = call i32 (...) @X509_LOOKUP_file()
%14 = call i32* @X509_STORE_add_lookup(i32* %12, i32 %13)
store i32* %14, i32** %8
%15 = load i32*, i32** %8
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %18
17: ; preds = %11
store i32 0, i32* %4
br label %52
18: ; preds = %11
%19 = load i32*, i32** %8
%20 = load i8*, i8** %6
%21 = load i32, i32* @X509_FILETYPE_PEM
%22 = call i32 @X509_LOOKUP_load_file(i32* %19, i8* %20, i32 %21)
%23 = icmp ne i32 %22, 1
br i1 %23, label %24, label %25
24: ; preds = %18
store i32 0, i32* %4
br label %52
25: ; preds = %18
br label %26
26: ; preds = %25, %3
%27 = load i8*, i8** %7
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %44
29: ; preds = %26
%30 = load i32*, i32** %5
%31 = call i32 (...) @X509_LOOKUP_hash_dir()
%32 = call i32* @X509_STORE_add_lookup(i32* %30, i32 %31)
store i32* %32, i32** %8
%33 = load i32*, i32** %8
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %36
35: ; preds = %29
store i32 0, i32* %4
br label %52
36: ; preds = %29
%37 = load i32*, i32** %8
%38 = load i8*, i8** %7
%39 = load i32, i32* @X509_FILETYPE_PEM
%40 = call i32 @X509_LOOKUP_add_dir(i32* %37, i8* %38, i32 %39)
%41 = icmp ne i32 %40, 1
br i1 %41, label %42, label %43
42: ; preds = %36
store i32 0, i32* %4
br label %52
43: ; preds = %36
br label %44
44: ; preds = %43, %26
%45 = load i8*, i8** %7
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = load i8*, i8** %6
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %51
50: ; preds = %47
store i32 0, i32* %4
br label %52
51: ; preds = %47, %44
store i32 1, i32* %4
br label %52
52: ; preds = %51, %50, %42, %35, %24, %17
%53 = load i32, i32* %4
ret i32 %53
}

LLVM IR (-O2):
@X509_FILETYPE_PEM = global i32 0
define i32 @X509_STORE_load_locations(i32* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %13, label %5
5: ; preds = %3
%6 = tail call i32 (...) @X509_LOOKUP_file()
%7 = tail call i32* @X509_STORE_add_lookup(i32* %0, i32 %6)
%8 = icmp eq i32* %7, null
br i1 %8, label %27, label %9
9: ; preds = %5
%10 = load i32, i32* @X509_FILETYPE_PEM
%11 = tail call i32 @X509_LOOKUP_load_file(i32* %7, i8* %1, i32 %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %27
13: ; preds = %9, %3
%14 = icmp eq i8* %2, null
br i1 %14, label %23, label %15
15: ; preds = %13
%16 = tail call i32 (...) @X509_LOOKUP_hash_dir()
%17 = tail call i32* @X509_STORE_add_lookup(i32* %0, i32 %16)
%18 = icmp eq i32* %17, null
br i1 %18, label %27, label %19
19: ; preds = %15
%20 = load i32, i32* @X509_FILETYPE_PEM
%21 = tail call i32 @X509_LOOKUP_add_dir(i32* %17, i8* %2, i32 %20)
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %27
23: ; preds = %19, %13
%24 = and i1 %4, %14
%25 = xor i1 %24, true
%26 = zext i1 %25 to i32
br label %27
27: ; preds = %23, %19, %15, %9, %5
%28 = phi i32 [ 0, %5 ], [ 0, %9 ], [ 0, %15 ], [ 0, %19 ], [ %26, %23 ]
ret i32 %28
}