#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_ctrl(int /*<<< orphan*/ *, int /*<<< orphan*/, char const *,
                     int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_LOOKUP_mem();
int /*<<< orphan*/ X509_L_FILE_LOAD;
int /*<<< orphan*/ *X509_STORE_add_lookup(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/);
int X509_STORE_load_mem(X509_STORE *ctx, const char *str) {
  X509_LOOKUP *lookup;
  if (!str)
    return 1;
  lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_mem());
  if (lookup == NULL)
    return 0;
  if (X509_LOOKUP_ctrl(lookup, X509_L_FILE_LOAD, str, X509_FILETYPE_PEM,
                       NULL) != 1)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<X509_STORE_load_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1157 <X509_STORE_load_mem+0x27>
movl   $0x1,-0x4(%rbp)
jmp    11cc <X509_STORE_load_mem+0x9c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <X509_LOOKUP_mem@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1030 <X509_STORE_add_lookup@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118c <X509_STORE_load_mem+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    11cc <X509_STORE_load_mem+0x9c>
mov    -0x20(%rbp),%rdi
mov    0x2e49(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
mov    0x2e4c(%rip),%rax
mov    (%rax),%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <X509_LOOKUP_ctrl@plt>
cmp    $0x1,%eax
je     11c5 <X509_STORE_load_mem+0x95>
movl   $0x0,-0x4(%rbp)
jmp    11cc <X509_STORE_load_mem+0x9c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X509_STORE_load_mem>:
push   %rbp
push   %r14
push   %rbx
test   %rsi,%rsi
je     1182 <X509_STORE_load_mem+0x52>
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <X509_LOOKUP_mem@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <X509_STORE_add_lookup@plt>
test   %rax,%rax
je     1187 <X509_STORE_load_mem+0x57>
mov    0x2e82(%rip),%rcx
mov    (%rcx),%esi
mov    0x2e89(%rip),%rcx
mov    (%rcx),%ecx
mov    %rax,%rdi
mov    %r14,%rdx
xor    %r8d,%r8d
call   1040 <X509_LOOKUP_ctrl@plt>
xor    %ebp,%ebp
cmp    $0x1,%eax
sete   %bpl
jmp    1187 <X509_STORE_load_mem+0x57>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@X509_L_FILE_LOAD = global i32 0
@X509_FILETYPE_PEM = global i32 0
define i32 @X509_STORE_load_mem(i32* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %14, label %4
4: ; preds = %2
%5 = tail call i32 (...) @X509_LOOKUP_mem()
%6 = tail call i32* @X509_STORE_add_lookup(i32* %0, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %14, label %8
8: ; preds = %4
%9 = load i32, i32* @X509_L_FILE_LOAD
%10 = load i32, i32* @X509_FILETYPE_PEM
%11 = tail call i32 @X509_LOOKUP_ctrl(i32* %6, i32 %9, i8* %1, i32 %10, i32* null)
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %8, %4, %2
%15 = phi i32 [ 1, %2 ], [ 0, %4 ], [ %13, %8 ]
ret i32 %15
}