#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;

/* Variables and functions */
int /*<<< orphan*/ X509_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *X509_new();
scalar_t__ X509_set_version(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ test_ptr(char *, int, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ test_true(char *, int, char *, int);
X509 *make_cert(void) {
  X509 *crt = NULL;
  if (!test_ptr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/"
                "refs/heads/master/Src/OSF/OpenSSL-111/test/v3nametest.c",
                257, "crt = X509_new()", crt = X509_new()))
    return NULL;
  if (!test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/v3nametest.c",
          259, "X509_set_version(crt, 2)", (X509_set_version(crt, 2)) != 0)) {
    X509_free(crt);
    return NULL;
  }
  return crt;
}


x86 assembly (clang, -O0):
<make_cert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1070 <X509_new@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xe8b(%rip),%rdi
mov    $0x101,%esi
lea    0xf2d(%rip),%rdx
call   1050 <test_ptr@plt>
cmp    $0x0,%eax
jne    119c <make_cert+0x4c>
movq   $0x0,-0x8(%rbp)
jmp    11f5 <make_cert+0xa5>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1040 <X509_set_version@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xe43(%rip),%rdi
mov    $0x103,%esi
lea    0xef6(%rip),%rdx
call   1030 <test_true@plt>
cmp    $0x0,%eax
jne    11ed <make_cert+0x9d>
mov    -0x10(%rbp),%rdi
call   1060 <X509_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11f5 <make_cert+0xa5>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_cert>:
push   %rbx
xor    %eax,%eax
call   1070 <X509_new@plt>
mov    %rax,%rbx
lea    0xe9e(%rip),%rdi
lea    0xf45(%rip),%rdx
mov    $0x101,%esi
mov    %rax,%rcx
call   1050 <test_ptr@plt>
test   %eax,%eax
je     11b3 <make_cert+0x63>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <X509_set_version@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xe6a(%rip),%rdi
lea    0xf22(%rip),%rdx
mov    $0x103,%esi
call   1030 <test_true@plt>
test   %eax,%eax
jne    11b5 <make_cert+0x65>
mov    %rbx,%rdi
call   1060 <X509_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [174 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/master/Src/OSF/OpenSSL-111/test/v3nametest.c\00"
@.str.1 = [17 x i8] c"crt = X509_new()\00"
@.str.2 = [25 x i8] c"X509_set_version(crt, 2)\00"
define i32* @make_cert() {
%1 = alloca i32*
%2 = alloca i32*
store i32* null, i32** %2
%3 = call i32* (...) @X509_new()
store i32* %3, i32** %2
%4 = call i32 @test_ptr(i8* getelementptr inbounds ([174 x i8], [174 x i8]* @.str, i64 0, i64 0), i32 257, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%5 = icmp ne i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %0
store i32* null, i32** %1
br label %19
7: ; preds = %0
%8 = load i32*, i32** %2
%9 = call i64 @X509_set_version(i32* %8, i32 2)
%10 = icmp ne i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @test_true(i8* getelementptr inbounds ([174 x i8], [174 x i8]* @.str, i64 0, i64 0), i32 259, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %7
%15 = load i32*, i32** %2
%16 = call i32 @X509_free(i32* %15)
store i32* null, i32** %1
br label %19
17: ; preds = %7
%18 = load i32*, i32** %2
store i32* %18, i32** %1
br label %19
19: ; preds = %17, %14, %6
%20 = load i32*, i32** %1
ret i32* %20
}

LLVM IR (-O2):
@.str = [174 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/master/Src/OSF/OpenSSL-111/test/v3nametest.c\00"
@.str.1 = [17 x i8] c"crt = X509_new()\00"
@.str.2 = [25 x i8] c"X509_set_version(crt, 2)\00"
define i32* @make_cert() {
%1 = tail call i32* (...) @X509_new()
%2 = tail call i32 @test_ptr(i8* getelementptr inbounds ([174 x i8], [174 x i8]* @.str, i64 0, i64 0), i32 257, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%3 = icmp eq i32 %2, 0
br i1 %3, label %12, label %4
4: ; preds = %0
%5 = tail call i64 @X509_set_version(i32* %1, i32 2)
%6 = icmp ne i64 %5, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @test_true(i8* getelementptr inbounds ([174 x i8], [174 x i8]* @.str, i64 0, i64 0), i32 259, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = tail call i32 @X509_free(i32* %1)
br label %12
12: ; preds = %4, %0, %10
%13 = phi i32* [ null, %10 ], [ null, %0 ], [ %1, %4 ]
ret i32* %13
}