#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 */

/* Variables and functions */
int /*<<< orphan*/ CRYPTO_MEM_CHECK_ON;
int /*<<< orphan*/ CRYPTO_mem_ctrl(int /*<<< orphan*/);
scalar_t__ CRYPTO_mem_leaks_fp(int /*<<< orphan*/);
int /*<<< orphan*/ CRYPTO_set_mem_debug(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ test_509_dup_cert(char *);
int main(int argc, char **argv) {
  CRYPTO_set_mem_debug(1);
  CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
  if (argc != 2) {
    fprintf(stderr, "usage: x509_dup_cert_test cert.pem\n");
    return 1;
  }
  if (!test_509_dup_cert(argv[1])) {
    fprintf(stderr, "Test X509 duplicate cert failed\n");
    return 1;
  }
  if (CRYPTO_mem_leaks_fp(stderr) <= 0)
    return 1;
  printf("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
call   1080 <CRYPTO_set_mem_debug@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
call   1060 <CRYPTO_mem_ctrl@plt>
cmpl   $0x2,-0x8(%rbp)
je     11b9 <main+0x59>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1227 <main+0xc7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <test_509_dup_cert@plt>
cmp    $0x0,%eax
jne    11f0 <main+0x90>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1227 <main+0xc7>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1030 <CRYPTO_mem_leaks_fp@plt>
cmp    $0x0,%rax
jg     1214 <main+0xb4>
movl   $0x1,-0x4(%rbp)
jmp    1227 <main+0xc7>
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r14d
mov    $0x1,%edi
call   1080 <CRYPTO_set_mem_debug@plt>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1060 <CRYPTO_mem_ctrl@plt>
cmp    $0x2,%ebp
jne    11bd <main+0x5d>
mov    0x8(%rbx),%rdi
call   1070 <test_509_dup_cert@plt>
mov    0x2e3c(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     11cf <main+0x6f>
call   1040 <CRYPTO_mem_leaks_fp@plt>
test   %rax,%rax
jle    11db <main+0x7b>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
jmp    11db <main+0x7b>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
jmp    11d6 <main+0x76>
lea    0xe4e(%rip),%rsi
call   1050 <fprintf@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@CRYPTO_MEM_CHECK_ON = global i32 0
@stderr = global i32 0
@.str = [36 x i8] c"usage: x509_dup_cert_test cert.pem\0A\00"
@.str.1 = [33 x i8] c"Test X509 duplicate cert failed\0A\00"
@.str.2 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 @CRYPTO_set_mem_debug(i32 1)
%7 = load i32, i32* @CRYPTO_MEM_CHECK_ON
%8 = call i32 @CRYPTO_mem_ctrl(i32 %7)
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %30
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @test_509_dup_cert(i8* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %30
23: ; preds = %14
%24 = load i32, i32* @stderr
%25 = call i64 @CRYPTO_mem_leaks_fp(i32 %24)
%26 = icmp sle i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 1, i32* %3
br label %30
28: ; preds = %23
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %30
30: ; preds = %28, %27, %20, %11
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@CRYPTO_MEM_CHECK_ON = global i32 0
@stderr = global i32 0
@.str = [36 x i8] c"usage: x509_dup_cert_test cert.pem\0A\00"
@.str.1 = [33 x i8] c"Test X509 duplicate cert failed\0A\00"
@str = [5 x i8] c"PASS\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @CRYPTO_set_mem_debug(i32 1)
%4 = load i32, i32* @CRYPTO_MEM_CHECK_ON
%5 = tail call i32 @CRYPTO_mem_ctrl(i32 %4)
%6 = icmp eq i32 %0, 2
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %23
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @test_509_dup_cert(i8* %12)
%14 = icmp eq i32 %13, 0
%15 = load i32, i32* @stderr
br i1 %14, label %16, label %18
16: ; preds = %10
%17 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %23
18: ; preds = %10
%19 = tail call i64 @CRYPTO_mem_leaks_fp(i32 %15)
%20 = icmp slt i64 %19, 1
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %23
23: ; preds = %18, %21, %16, %7
%24 = phi i32 [ 1, %7 ], [ 0, %21 ], [ 1, %16 ], [ 1, %18 ]
ret i32 %24
}