#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_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 /*<<< orphan*/ X509_STORE_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *X509_STORE_new();
X509_STORE *ptls_openssl_create_default_certificate_store(void) {
  X509_STORE *store;
  X509_LOOKUP *lookup;
  if ((store = X509_STORE_new()) == NULL)
    goto Error;
  if ((lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file())) == NULL)
    goto Error;
  X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT);
  if ((lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir())) == NULL)
    goto Error;
  X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
  return store;
Error:
  if (store != NULL)
    X509_STORE_free(store);
  return NULL;
}


x86 assembly (clang, -O0):
<ptls_openssl_create_default_certificate_store>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1080 <X509_STORE_new@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1192 <ptls_openssl_create_default_certificate_store+0x22>
jmp    1225 <ptls_openssl_create_default_certificate_store+0xb5>
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)
cmp    $0x0,%rax
jne    11bf <ptls_openssl_create_default_certificate_store+0x4f>
jmp    1225 <ptls_openssl_create_default_certificate_store+0xb5>
mov    -0x18(%rbp),%rdi
mov    0x2e26(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1090 <X509_LOOKUP_load_file@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1060 <X509_LOOKUP_hash_dir@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1040 <X509_STORE_add_lookup@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1202 <ptls_openssl_create_default_certificate_store+0x92>
jmp    1225 <ptls_openssl_create_default_certificate_store+0xb5>
mov    -0x18(%rbp),%rdi
mov    0x2de3(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <X509_LOOKUP_add_dir@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1241 <ptls_openssl_create_default_certificate_store+0xd1>
cmpq   $0x0,-0x10(%rbp)
je     1239 <ptls_openssl_create_default_certificate_store+0xc9>
mov    -0x10(%rbp),%rdi
call   1070 <X509_STORE_free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptls_openssl_create_default_certificate_store>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <X509_STORE_new@plt>
test   %rax,%rax
je     11da <ptls_openssl_create_default_certificate_store+0x6a>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <X509_LOOKUP_file@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <X509_STORE_add_lookup@plt>
test   %rax,%rax
je     11d2 <ptls_openssl_create_default_certificate_store+0x62>
mov    0x2e50(%rip),%r14
mov    (%r14),%edx
mov    %rax,%rdi
xor    %esi,%esi
call   1090 <X509_LOOKUP_load_file@plt>
xor    %eax,%eax
call   1060 <X509_LOOKUP_hash_dir@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <X509_STORE_add_lookup@plt>
test   %rax,%rax
je     11d2 <ptls_openssl_create_default_certificate_store+0x62>
mov    (%r14),%edx
mov    %rax,%rdi
xor    %esi,%esi
call   1050 <X509_LOOKUP_add_dir@plt>
jmp    11dc <ptls_openssl_create_default_certificate_store+0x6c>
mov    %rbx,%rdi
call   1070 <X509_STORE_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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