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

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new_file(char const *, char *);
int /*<<< orphan*/ *PEM_read_bio_X509_AUX(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
X509 *TS_CONF_load_cert(const char *file) {
  BIO *cert = NULL;
  X509 *x = NULL;
  if ((cert = BIO_new_file(file, "r")) == NULL)
    goto end;
  x = PEM_read_bio_X509_AUX(cert, NULL, NULL, NULL);
end:
  if (x == NULL)
    fprintf(stderr, "unable to load certificate: %s\n", file);
  BIO_free(cert);
  return x;
}


x86 assembly (clang, -O0):
<TS_CONF_load_cert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1060 <BIO_new_file@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    117f <TS_CONF_load_cert+0x3f>
jmp    1196 <TS_CONF_load_cert+0x56>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1040 <PEM_read_bio_X509_AUX@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ba <TS_CONF_load_cert+0x7a>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe4d(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <BIO_free@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TS_CONF_load_cert>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xeb1(%rip),%rsi
call   1060 <BIO_new_file@plt>
mov    %rax,%r15
test   %rax,%rax
je     1172 <TS_CONF_load_cert+0x32>
mov    %r15,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <PEM_read_bio_X509_AUX@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    118c <TS_CONF_load_cert+0x4c>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
xor    %ebx,%ebx
mov    %r15,%rdi
call   1050 <BIO_free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [32 x i8] c"unable to load certificate: %s\0A\00"
define i32* @TS_CONF_load_cert(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
store i8* %0, i8** %2
store i32* null, i32** %3
store i32* null, i32** %4
%5 = load i8*, i8** %2
%6 = call i32* @BIO_new_file(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %3
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
br label %12
9: ; preds = %1
%10 = load i32*, i32** %3
%11 = call i32* @PEM_read_bio_X509_AUX(i32* %10, i32* null, i32* null, i32* null)
store i32* %11, i32** %4
br label %12
12: ; preds = %9, %8
%13 = load i32*, i32** %4
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %2
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %15, %12
%20 = load i32*, i32** %3
%21 = call i32 @BIO_free(i32* %20)
%22 = load i32*, i32** %4
ret i32* %22
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [32 x i8] c"unable to load certificate: %s\0A\00"
define i32* @TS_CONF_load_cert(i8* %0) {
%2 = tail call i32* @BIO_new_file(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32* @PEM_read_bio_X509_AUX(i32* %2, i32* null, i32* null, i32* null)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %1, %4
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %10
10: ; preds = %7, %4
%11 = phi i32* [ null, %7 ], [ %5, %4 ]
%12 = tail call i32 @BIO_free(i32* %2)
ret i32* %11
}