#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_CTX;
typedef int /*<<< orphan*/ X509_STORE;
typedef int /*<<< orphan*/ X509_LOOKUP;

/* Variables and functions */
int /*<<< orphan*/ X509_FILETYPE_PEM;
int /*<<< orphan*/ X509_LOOKUP_file();
int /*<<< orphan*/ X509_STORE_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *X509_STORE_add_lookup(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/);
int /*<<< orphan*/ X509_STORE_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *X509_STORE_new();
scalar_t__ X509_load_cert_file(int /*<<< orphan*/ *, char const *,
                               int /*<<< orphan*/);
char *test_get_argument(int);
scalar_t__ test_ptr(char *, int, char *, int /*<<< orphan*/ *);
scalar_t__ test_true(char *, int, char *, int);
int test_509_dup_cert(int n) {
  int ret = 0;
  X509_STORE_CTX *sctx = NULL;
  X509_STORE *store = NULL;
  X509_LOOKUP *lookup = NULL;
  const char *cert_f = test_get_argument(n);
  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/x509_dup_cert_test.c",
          24, "store = X509_STORE_new()", store = X509_STORE_new()) &&
      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/x509_dup_cert_test.c",
          25, "lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file())",
          lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file())) &&
      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/x509_dup_cert_test.c",
          26, "X509_load_cert_file(lookup, cert_f, X509_FILETYPE_PEM)",
          (X509_load_cert_file(lookup, cert_f, X509_FILETYPE_PEM)) != 0) &&
      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/x509_dup_cert_test.c",
          27, "X509_load_cert_file(lookup, cert_f, X509_FILETYPE_PEM)",
          (X509_load_cert_file(lookup, cert_f, X509_FILETYPE_PEM)) != 0))
    ret = 1;
  X509_STORE_CTX_free(sctx);
  X509_STORE_free(store);
  return ret;
}


x86 assembly (clang, -O0):
<test_509_dup_cert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x4(%rbp),%edi
call   1080 <test_get_argument@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   10b0 <X509_STORE_new@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xe25(%rip),%rdi
mov    $0x18,%esi
lea    0xecf(%rip),%rdx
call   1060 <test_ptr@plt>
cmp    $0x0,%rax
je     12c8 <test_509_dup_cert+0x138>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1030 <X509_LOOKUP_file@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1050 <X509_STORE_add_lookup@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xde2(%rip),%rdi
mov    $0x19,%esi
lea    0xea5(%rip),%rdx
call   1060 <test_ptr@plt>
cmp    $0x0,%rax
je     12c8 <test_509_dup_cert+0x138>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    0x2da8(%rip),%rax
mov    (%rax),%edx
call   10a0 <X509_load_cert_file@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xd9e(%rip),%rdi
mov    $0x1a,%esi
lea    0xe9b(%rip),%rdx
call   1040 <test_true@plt>
cmp    $0x0,%rax
je     12c8 <test_509_dup_cert+0x138>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    0x2d64(%rip),%rax
mov    (%rax),%edx
call   10a0 <X509_load_cert_file@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xd5a(%rip),%rdi
mov    $0x1b,%esi
lea    0xe57(%rip),%rdx
call   1040 <test_true@plt>
cmp    $0x0,%rax
je     12c8 <test_509_dup_cert+0x138>
movl   $0x1,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <X509_STORE_CTX_free@plt>
mov    -0x18(%rbp),%rdi
call   1090 <X509_STORE_free@plt>
mov    -0x8(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_509_dup_cert>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
call   1080 <test_get_argument@plt>
mov    %rax,%r14
xor    %ebp,%ebp
xor    %eax,%eax
call   10b0 <X509_STORE_new@plt>
mov    %rax,%rbx
lea    0xe4d(%rip),%rdi
lea    0xefc(%rip),%rdx
mov    $0x18,%esi
mov    %rax,%rcx
call   1060 <test_ptr@plt>
test   %rax,%rax
je     1279 <test_509_dup_cert+0xe9>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <X509_LOOKUP_file@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <X509_STORE_add_lookup@plt>
mov    %rax,%r15
lea    0xe13(%rip),%rdi
lea    0xedb(%rip),%rdx
mov    $0x19,%esi
mov    %rax,%rcx
call   1060 <test_ptr@plt>
test   %rax,%rax
je     1279 <test_509_dup_cert+0xe9>
mov    0x2de3(%rip),%r12
mov    (%r12),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   10a0 <X509_load_cert_file@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xdd5(%rip),%rdi
lea    0xed7(%rip),%rdx
mov    $0x1a,%esi
call   1040 <test_true@plt>
test   %rax,%rax
je     1279 <test_509_dup_cert+0xe9>
mov    (%r12),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   10a0 <X509_load_cert_file@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xda1(%rip),%rdi
lea    0xea3(%rip),%rdx
mov    $0x1b,%esi
call   1040 <test_true@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
xor    %edi,%edi
call   1070 <X509_STORE_CTX_free@plt>
mov    %rbx,%rdi
call   1090 <X509_STORE_free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [182 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/x509_dup_cert_test.c\00"
@.str.1 = [25 x i8] c"store = X509_STORE_new()\00"
@.str.2 = [58 x i8] c"lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file())\00"
@.str.3 = [55 x i8] c"X509_load_cert_file(lookup, cert_f, X509_FILETYPE_PEM)\00"
@X509_FILETYPE_PEM = global i32 0
define i32 @test_509_dup_cert(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
store i32 %0, i32* %2
store i32 0, i32* %3
store i32* null, i32** %4
store i32* null, i32** %5
store i32* null, i32** %6
%8 = load i32, i32* %2
%9 = call i8* @test_get_argument(i32 %8)
store i8* %9, i8** %7
%10 = call i32* (...) @X509_STORE_new()
store i32* %10, i32** %5
%11 = call i64 @test_ptr(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 24, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %38
13: ; preds = %1
%14 = load i32*, i32** %5
%15 = call i32 (...) @X509_LOOKUP_file()
%16 = call i32* @X509_STORE_add_lookup(i32* %14, i32 %15)
store i32* %16, i32** %6
%17 = call i64 @test_ptr(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 25, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), i32* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %38
19: ; preds = %13
%20 = load i32*, i32** %6
%21 = load i8*, i8** %7
%22 = load i32, i32* @X509_FILETYPE_PEM
%23 = call i64 @X509_load_cert_file(i32* %20, i8* %21, i32 %22)
%24 = icmp ne i64 %23, 0
%25 = zext i1 %24 to i32
%26 = call i64 @test_true(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %19
%29 = load i32*, i32** %6
%30 = load i8*, i8** %7
%31 = load i32, i32* @X509_FILETYPE_PEM
%32 = call i64 @X509_load_cert_file(i32* %29, i8* %30, i32 %31)
%33 = icmp ne i64 %32, 0
%34 = zext i1 %33 to i32
%35 = call i64 @test_true(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 27, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %28
store i32 1, i32* %3
br label %38
38: ; preds = %37, %28, %19, %13, %1
%39 = load i32*, i32** %4
%40 = call i32 @X509_STORE_CTX_free(i32* %39)
%41 = load i32*, i32** %5
%42 = call i32 @X509_STORE_free(i32* %41)
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [182 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/x509_dup_cert_test.c\00"
@.str.1 = [25 x i8] c"store = X509_STORE_new()\00"
@.str.2 = [58 x i8] c"lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file())\00"
@.str.3 = [55 x i8] c"X509_load_cert_file(lookup, cert_f, X509_FILETYPE_PEM)\00"
@X509_FILETYPE_PEM = global i32 0
define i32 @test_509_dup_cert(i32 %0) {
%2 = tail call i8* @test_get_argument(i32 %0)
%3 = tail call i32* (...) @X509_STORE_new()
%4 = tail call i64 @test_ptr(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 24, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %26, label %6
6: ; preds = %1
%7 = tail call i32 (...) @X509_LOOKUP_file()
%8 = tail call i32* @X509_STORE_add_lookup(i32* %3, i32 %7)
%9 = tail call i64 @test_ptr(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 25, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %26, label %11
11: ; preds = %6
%12 = load i32, i32* @X509_FILETYPE_PEM
%13 = tail call i64 @X509_load_cert_file(i32* %8, i8* %2, i32 %12)
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call i64 @test_true(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %26, label %18
18: ; preds = %11
%19 = load i32, i32* @X509_FILETYPE_PEM
%20 = tail call i64 @X509_load_cert_file(i32* %8, i8* %2, i32 %19)
%21 = icmp ne i64 %20, 0
%22 = zext i1 %21 to i32
%23 = tail call i64 @test_true(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 27, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = icmp ne i64 %23, 0
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %18, %11, %6, %1
%27 = phi i32 [ 0, %11 ], [ 0, %6 ], [ 0, %1 ], [ %25, %18 ]
%28 = tail call i32 @X509_STORE_CTX_free(i32* null)
%29 = tail call i32 @X509_STORE_free(i32* %3)
ret i32 %27
}