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

/* Variables and functions */
int /*<<< orphan*/ BIO_NOCLOSE;
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new_fp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ CRYPTO_cleanup_all_ex_data();
int /*<<< orphan*/ CRYPTO_mem_leaks(int /*<<< orphan*/ *);
int /*<<< orphan*/ ERR_free_strings();
int /*<<< orphan*/ ERR_load_crypto_strings();
int /*<<< orphan*/ ERR_print_errors(int /*<<< orphan*/ *);
int /*<<< orphan*/ ERR_remove_thread_state(int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ test_builtin(int /*<<< orphan*/ *);
int main(void) {
  int ret = 1;
  BIO *out;
  out = BIO_new_fp(stdout, BIO_NOCLOSE);
  ERR_load_crypto_strings();
  if (!test_builtin(out))
    goto err;
  ret = 0;
err:
  if (ret)
    BIO_printf(out, "\nECDSA test failed\n");
  else
    BIO_printf(out, "\nECDSA test passed\n");
  if (ret)
    ERR_print_errors(out);
  CRYPTO_cleanup_all_ex_data();
  ERR_remove_thread_state(NULL);
  ERR_free_strings();
  CRYPTO_mem_leaks(out);
  if (out != NULL)
    BIO_free(out);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_new_fp@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   10b0 <ERR_load_crypto_strings@plt>
mov    -0x10(%rbp),%rdi
call   1080 <test_builtin@plt>
cmp    $0x0,%eax
jne    11ef <main+0x4f>
jmp    11f6 <main+0x56>
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1215 <main+0x75>
mov    -0x10(%rbp),%rdi
lea    0xdf5(%rip),%rsi
call   1070 <BIO_printf@plt>
jmp    1225 <main+0x85>
mov    -0x10(%rbp),%rdi
lea    0xdf4(%rip),%rsi
call   1070 <BIO_printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1238 <main+0x98>
mov    -0x10(%rbp),%rdi
call   1050 <ERR_print_errors@plt>
mov    $0x0,%al
call   1060 <CRYPTO_cleanup_all_ex_data@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <ERR_remove_thread_state@plt>
mov    $0x0,%al
call   1090 <ERR_free_strings@plt>
mov    -0x10(%rbp),%rdi
call   10c0 <CRYPTO_mem_leaks@plt>
cmpq   $0x0,-0x10(%rbp)
je     126c <main+0xcc>
mov    -0x10(%rbp),%rdi
call   10a0 <BIO_free@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_new_fp@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   10b0 <ERR_load_crypto_strings@plt>
mov    %rbx,%rdi
call   1080 <test_builtin@plt>
mov    %eax,%ebp
test   %eax,%eax
je     11e3 <main+0x43>
lea    0xe3b(%rip),%rsi
mov    %rbx,%rdi
call   1070 <BIO_printf@plt>
jmp    11fa <main+0x5a>
lea    0xe16(%rip),%rsi
mov    %rbx,%rdi
call   1070 <BIO_printf@plt>
mov    %rbx,%rdi
call   1050 <ERR_print_errors@plt>
xor    %eax,%eax
call   1060 <CRYPTO_cleanup_all_ex_data@plt>
xor    %edi,%edi
call   1040 <ERR_remove_thread_state@plt>
xor    %eax,%eax
call   1090 <ERR_free_strings@plt>
mov    %rbx,%rdi
call   10c0 <CRYPTO_mem_leaks@plt>
test   %rbx,%rbx
je     1224 <main+0x84>
mov    %rbx,%rdi
call   10a0 <BIO_free@plt>
xor    %eax,%eax
test   %ebp,%ebp
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@BIO_NOCLOSE = global i32 0
@.str = [20 x i8] c"\0AECDSA test failed\0A\00"
@.str.1 = [20 x i8] c"\0AECDSA test passed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
store i32 1, i32* %2
%4 = load i32, i32* @stdout
%5 = load i32, i32* @BIO_NOCLOSE
%6 = call i32* @BIO_new_fp(i32 %4, i32 %5)
store i32* %6, i32** %3
%7 = call i32 (...) @ERR_load_crypto_strings()
%8 = load i32*, i32** %3
%9 = call i32 @test_builtin(i32* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %0
br label %13
12: ; preds = %0
store i32 0, i32* %2
br label %13
13: ; preds = %12, %11
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32*, i32** %3
%18 = call i32 @BIO_printf(i32* %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %22
19: ; preds = %13
%20 = load i32*, i32** %3
%21 = call i32 @BIO_printf(i32* %20, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %19, %16
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32*, i32** %3
%27 = call i32 @ERR_print_errors(i32* %26)
br label %28
28: ; preds = %25, %22
%29 = call i32 (...) @CRYPTO_cleanup_all_ex_data()
%30 = call i32 @ERR_remove_thread_state(i32* null)
%31 = call i32 (...) @ERR_free_strings()
%32 = load i32*, i32** %3
%33 = call i32 @CRYPTO_mem_leaks(i32* %32)
%34 = load i32*, i32** %3
%35 = icmp ne i32* %34, null
br i1 %35, label %36, label %39
36: ; preds = %28
%37 = load i32*, i32** %3
%38 = call i32 @BIO_free(i32* %37)
br label %39
39: ; preds = %36, %28
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@stdout = global i32 0
@BIO_NOCLOSE = global i32 0
@.str = [20 x i8] c"\0AECDSA test failed\0A\00"
@.str.1 = [20 x i8] c"\0AECDSA test passed\0A\00"
define i32 @main() {
%1 = load i32, i32* @stdout
%2 = load i32, i32* @BIO_NOCLOSE
%3 = tail call i32* @BIO_new_fp(i32 %1, i32 %2)
%4 = tail call i32 (...) @ERR_load_crypto_strings()
%5 = tail call i32 @test_builtin(i32* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = tail call i32 @BIO_printf(i32* %3, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %12
9: ; preds = %0
%10 = tail call i32 @BIO_printf(i32* %3, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @ERR_print_errors(i32* %3)
br label %12
12: ; preds = %7, %9
%13 = tail call i32 (...) @CRYPTO_cleanup_all_ex_data()
%14 = tail call i32 @ERR_remove_thread_state(i32* null)
%15 = tail call i32 (...) @ERR_free_strings()
%16 = tail call i32 @CRYPTO_mem_leaks(i32* %3)
%17 = icmp eq i32* %3, null
br i1 %17, label %20, label %18
18: ; preds = %12
%19 = tail call i32 @BIO_free(i32* %3)
br label %20
20: ; preds = %18, %12
%21 = zext i1 %6 to i32
ret i32 %21
}