#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(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_read_filename(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ BIO_s_file();
int /*<<< orphan*/ *PEM_read_bio_X509(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
scalar_t__ test_int_gt(char *, int, char *, char *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ test_ptr(char *, int, char *, int /*<<< orphan*/ *);
X509 *load_cert_pem(const char *file) {
  X509 *cert = NULL;
  BIO *bio = NULL;
  if (!test_ptr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/jens-maus/amissl/refs/heads/"
                "master/openssl/test/verify_extra_test.c",
                28, "bio = BIO_new(BIO_s_file())", bio = BIO_new(BIO_s_file())))
    return NULL;
  if (test_int_gt("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/jens-maus/amissl/refs/"
                  "heads/master/openssl/test/verify_extra_test.c",
                  30, "BIO_read_filename(bio, file)", "0",
                  BIO_read_filename(bio, file), 0))
    (void)test_ptr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/jens-maus/amissl/refs/"
                   "heads/master/openssl/test/verify_extra_test.c",
                   31, "cert = PEM_read_bio_X509(bio, NULL, NULL, NULL)",
                   cert = PEM_read_bio_X509(bio, NULL, NULL, NULL));
  BIO_free(bio);
  return cert;
}


x86 assembly (clang, -O0):
<load_cert_pem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1090 <BIO_s_file@plt>
mov    %eax,%edi
call   1050 <BIO_new@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xe58(%rip),%rdi
mov    $0x1c,%esi
lea    0xeea(%rip),%rdx
call   1040 <test_ptr@plt>
cmp    $0x0,%eax
jne    11cf <load_cert_pem+0x5f>
movq   $0x0,-0x8(%rbp)
jmp    124e <load_cert_pem+0xde>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <BIO_read_filename@plt>
mov    %eax,%r8d
lea    0xe1a(%rip),%rdi
mov    $0x1e,%esi
lea    0xec8(%rip),%rdx
lea    0xede(%rip),%rcx
xor    %r9d,%r9d
call   1030 <test_int_gt@plt>
cmp    $0x0,%rax
je     123d <load_cert_pem+0xcd>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1080 <PEM_read_bio_X509@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xdd4(%rip),%rdi
mov    $0x1f,%esi
lea    0xea1(%rip),%rdx
call   1040 <test_ptr@plt>
mov    -0x20(%rbp),%rdi
call   1060 <BIO_free@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_cert_pem>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %r14d,%r14d
xor    %eax,%eax
call   1090 <BIO_s_file@plt>
mov    %eax,%edi
call   1050 <BIO_new@plt>
mov    %rax,%rbx
lea    0xe6d(%rip),%rdi
lea    0xf04(%rip),%rdx
mov    $0x1c,%esi
mov    %rax,%rcx
call   1040 <test_ptr@plt>
test   %eax,%eax
je     1217 <load_cert_pem+0xa7>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <BIO_read_filename@plt>
lea    0xe43(%rip),%rdi
lea    0xef6(%rip),%rdx
lea    0xf0c(%rip),%rcx
xor    %r14d,%r14d
mov    $0x1e,%esi
mov    %eax,%r8d
xor    %r9d,%r9d
call   1030 <test_int_gt@plt>
test   %rax,%rax
je     120f <load_cert_pem+0x9f>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1080 <PEM_read_bio_X509@plt>
mov    %rax,%r14
lea    0xe05(%rip),%rdi
lea    0xed7(%rip),%rdx
mov    $0x1f,%esi
mov    %rax,%rcx
call   1040 <test_ptr@plt>
mov    %rbx,%rdi
call   1060 <BIO_free@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jens-maus/amissl/refs/heads/master/openssl/test/verify_extra_test.c\00"
@.str.1 = [28 x i8] c"bio = BIO_new(BIO_s_file())\00"
@.str.2 = [29 x i8] c"BIO_read_filename(bio, file)\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [48 x i8] c"cert = PEM_read_bio_X509(bio, NULL, NULL, NULL)\00"
define i32* @load_cert_pem(i8* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
store i8* %0, i8** %3
store i32* null, i32** %4
store i32* null, i32** %5
%6 = call i32 (...) @BIO_s_file()
%7 = call i32* @BIO_new(i32 %6)
store i32* %7, i32** %5
%8 = call i32 @test_ptr(i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 28, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %1
store i32* null, i32** %2
br label %25
11: ; preds = %1
%12 = load i32*, i32** %5
%13 = load i8*, i8** %3
%14 = call i32 @BIO_read_filename(i32* %12, i8* %13)
%15 = call i64 @test_int_gt(i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 30, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %14, i32 0)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = load i32*, i32** %5
%19 = call i32* @PEM_read_bio_X509(i32* %18, i32* null, i32* null, i32* null)
store i32* %19, i32** %4
%20 = call i32 @test_ptr(i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 31, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i32* %19)
br label %21
21: ; preds = %17, %11
%22 = load i32*, i32** %5
%23 = call i32 @BIO_free(i32* %22)
%24 = load i32*, i32** %4
store i32* %24, i32** %2
br label %25
25: ; preds = %21, %10
%26 = load i32*, i32** %2
ret i32* %26
}

LLVM IR (-O2):
@.str = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jens-maus/amissl/refs/heads/master/openssl/test/verify_extra_test.c\00"
@.str.1 = [28 x i8] c"bio = BIO_new(BIO_s_file())\00"
@.str.2 = [29 x i8] c"BIO_read_filename(bio, file)\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [48 x i8] c"cert = PEM_read_bio_X509(bio, NULL, NULL, NULL)\00"
define i32* @load_cert_pem(i8* %0) {
%2 = tail call i32 (...) @BIO_s_file()
%3 = tail call i32* @BIO_new(i32 %2)
%4 = tail call i32 @test_ptr(i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 28, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %1
%7 = tail call i32 @BIO_read_filename(i32* %3, i8* %0)
%8 = tail call i64 @test_int_gt(i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 30, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %7, i32 0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = tail call i32* @PEM_read_bio_X509(i32* %3, i32* null, i32* null, i32* null)
%12 = tail call i32 @test_ptr(i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 31, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i32* %11)
br label %13
13: ; preds = %10, %6
%14 = phi i32* [ %11, %10 ], [ null, %6 ]
%15 = tail call i32 @BIO_free(i32* %3)
br label %16
16: ; preds = %1, %13
%17 = phi i32* [ %14, %13 ], [ null, %1 ]
ret i32* %17
}