#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*/ ERR_clear_error();
int /*<<< orphan*/ X509_FILETYPE_DEFAULT;
int /*<<< orphan*/ X509_LOOKUP_add_dir(int /*<<< orphan*/ *,
                                       int /*<<< orphan*/ *,
                                       int /*<<< orphan*/);
int /*<<< orphan*/ X509_LOOKUP_file();
int /*<<< orphan*/ X509_LOOKUP_hash_dir();
int /*<<< orphan*/ X509_LOOKUP_load_file(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ *,
                                         int /*<<< orphan*/);
int /*<<< orphan*/ *X509_STORE_add_lookup(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/);
int X509_STORE_set_default_paths(X509_STORE *ctx) {
  X509_LOOKUP *lookup;
  lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file());
  if (lookup == NULL)
    return (0);
  X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT);
  lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir());
  if (lookup == NULL)
    return (0);
  X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
  ERR_clear_error();
  return (1);
}


x86 assembly (clang, -O0):
<X509_STORE_set_default_paths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <X509_LOOKUP_file@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1040 <X509_STORE_add_lookup@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a1 <X509_STORE_set_default_paths+0x41>
movl   $0x0,-0x4(%rbp)
jmp    1210 <X509_STORE_set_default_paths+0xb0>
mov    -0x18(%rbp),%rdi
mov    0x2e44(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1080 <X509_LOOKUP_load_file@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1070 <X509_LOOKUP_hash_dir@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1040 <X509_STORE_add_lookup@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ec <X509_STORE_set_default_paths+0x8c>
movl   $0x0,-0x4(%rbp)
jmp    1210 <X509_STORE_set_default_paths+0xb0>
mov    -0x18(%rbp),%rdi
mov    0x2df9(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <X509_LOOKUP_add_dir@plt>
mov    $0x0,%al
call   1060 <ERR_clear_error@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X509_STORE_set_default_paths>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <X509_LOOKUP_file@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <X509_STORE_add_lookup@plt>
test   %rax,%rax
je     11c5 <X509_STORE_set_default_paths+0x65>
mov    0x2e69(%rip),%r15
mov    (%r15),%edx
xor    %ebx,%ebx
mov    %rax,%rdi
xor    %esi,%esi
call   1080 <X509_LOOKUP_load_file@plt>
xor    %eax,%eax
call   1070 <X509_LOOKUP_hash_dir@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <X509_STORE_add_lookup@plt>
test   %rax,%rax
je     11c5 <X509_STORE_set_default_paths+0x65>
mov    (%r15),%edx
mov    %rax,%rdi
xor    %esi,%esi
call   1050 <X509_LOOKUP_add_dir@plt>
xor    %eax,%eax
call   1060 <ERR_clear_error@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@X509_FILETYPE_DEFAULT = global i32 0
define i32 @X509_STORE_set_default_paths(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
store i32* %0, i32** %3
%5 = load i32*, i32** %3
%6 = call i32 (...) @X509_LOOKUP_file()
%7 = call i32* @X509_STORE_add_lookup(i32* %5, i32 %6)
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %26
11: ; preds = %1
%12 = load i32*, i32** %4
%13 = load i32, i32* @X509_FILETYPE_DEFAULT
%14 = call i32 @X509_LOOKUP_load_file(i32* %12, i32* null, i32 %13)
%15 = load i32*, i32** %3
%16 = call i32 (...) @X509_LOOKUP_hash_dir()
%17 = call i32* @X509_STORE_add_lookup(i32* %15, i32 %16)
store i32* %17, i32** %4
%18 = load i32*, i32** %4
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %21
20: ; preds = %11
store i32 0, i32* %2
br label %26
21: ; preds = %11
%22 = load i32*, i32** %4
%23 = load i32, i32* @X509_FILETYPE_DEFAULT
%24 = call i32 @X509_LOOKUP_add_dir(i32* %22, i32* null, i32 %23)
%25 = call i32 (...) @ERR_clear_error()
store i32 1, i32* %2
br label %26
26: ; preds = %21, %20, %10
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@X509_FILETYPE_DEFAULT = global i32 0
define i32 @X509_STORE_set_default_paths(i32* %0) {
%2 = tail call i32 (...) @X509_LOOKUP_file()
%3 = tail call i32* @X509_STORE_add_lookup(i32* %0, i32 %2)
%4 = icmp eq i32* %3, null
br i1 %4, label %15, label %5
5: ; preds = %1
%6 = load i32, i32* @X509_FILETYPE_DEFAULT
%7 = tail call i32 @X509_LOOKUP_load_file(i32* %3, i32* null, i32 %6)
%8 = tail call i32 (...) @X509_LOOKUP_hash_dir()
%9 = tail call i32* @X509_STORE_add_lookup(i32* %0, i32 %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %15, label %11
11: ; preds = %5
%12 = load i32, i32* @X509_FILETYPE_DEFAULT
%13 = tail call i32 @X509_LOOKUP_add_dir(i32* %9, i32* null, i32 %12)
%14 = tail call i32 (...) @ERR_clear_error()
br label %15
15: ; preds = %5, %1, %11
%16 = phi i32 [ 1, %11 ], [ 0, %1 ], [ 0, %5 ]
ret i32 %16
}