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

/* Variables and functions */
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
scalar_t__ BN_generate_prime_ex(int /*<<< orphan*/ *, int, int /*<<< orphan*/,
                                int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_new();
int /*<<< orphan*/ BN_num_bits(int /*<<< orphan*/ *);
int /*<<< orphan*/ test_false(char *, int, char *, int);
int /*<<< orphan*/ test_int_eq(char *, int, char *, char *, int /*<<< orphan*/,
                               int);
int /*<<< orphan*/ test_ptr(char *, int, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ test_true(char *, int, char *, int);
int test_smallprime(int kBits) {
  BIGNUM *r;
  int st = 0;
  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/bntest.c",
                2176, "r = BN_new()", r = BN_new()))
    goto err;
  if (kBits <= 1) {
    if (!test_false(
            "/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/bntest.c",
            2180, "BN_generate_prime_ex(r, kBits, 0, NULL, NULL, NULL)",
            (BN_generate_prime_ex(r, kBits, 0, NULL, NULL, NULL)) != 0))
      goto err;
  } else {
    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/bntest.c",
            2184, "BN_generate_prime_ex(r, kBits, 0, NULL, NULL, NULL)",
            (BN_generate_prime_ex(r, kBits, 0, NULL, NULL, NULL)) != 0) ||
        !test_int_eq(
            "/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/bntest.c",
            2186, "BN_num_bits(r)", "kBits", BN_num_bits(r), kBits))
      goto err;
  }
  st = 1;
err:
  BN_free(r);
  return st;
}


x86 assembly (clang, -O0):
<test_smallprime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1050 <BN_new@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xe59(%rip),%rdi
mov    $0x880,%esi
lea    0xef7(%rip),%rdx
call   1080 <test_ptr@plt>
cmp    $0x0,%eax
jne    11c6 <test_smallprime+0x46>
jmp    12af <test_smallprime+0x12f>
cmpl   $0x1,-0x4(%rbp)
jg     1220 <test_smallprime+0xa0>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
xor    %edx,%edx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rcx
mov    %r9,%r8
call   1070 <BN_generate_prime_ex@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xe04(%rip),%rdi
mov    $0x884,%esi
lea    0xeaf(%rip),%rdx
call   1030 <test_false@plt>
cmp    $0x0,%eax
jne    121b <test_smallprime+0x9b>
jmp    12af <test_smallprime+0x12f>
jmp    12a8 <test_smallprime+0x128>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
xor    %edx,%edx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rcx
mov    %r9,%r8
call   1070 <BN_generate_prime_ex@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xdb4(%rip),%rdi
mov    $0x888,%esi
lea    0xe5f(%rip),%rdx
call   1040 <test_true@plt>
cmp    $0x0,%eax
je     129e <test_smallprime+0x11e>
mov    -0x10(%rbp),%rdi
call   1060 <BN_num_bits@plt>
mov    %eax,%r8d
mov    -0x4(%rbp),%r9d
lea    0xd83(%rip),%rdi
mov    $0x88a,%esi
lea    0xe62(%rip),%rdx
lea    0xe6a(%rip),%rcx
call   1090 <test_int_eq@plt>
cmp    $0x0,%eax
jne    12a3 <test_smallprime+0x123>
jmp    12af <test_smallprime+0x12f>
jmp    12a8 <test_smallprime+0x128>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   10a0 <BN_free@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_smallprime>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <BN_new@plt>
mov    %rax,%rbx
lea    0xe66(%rip),%rdi
lea    0xf09(%rip),%rdx
mov    $0x880,%esi
mov    %rax,%rcx
call   1080 <test_ptr@plt>
test   %eax,%eax
je     123d <test_smallprime+0xbd>
xor    %r14d,%r14d
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1070 <BN_generate_prime_ex@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xe24(%rip),%rdi
lea    0xed4(%rip),%rdx
cmp    $0x1,%ebp
jg     11f8 <test_smallprime+0x78>
mov    $0x884,%esi
call   1030 <test_false@plt>
test   %eax,%eax
jne    1237 <test_smallprime+0xb7>
jmp    123d <test_smallprime+0xbd>
mov    $0x888,%esi
call   1040 <test_true@plt>
test   %eax,%eax
je     123d <test_smallprime+0xbd>
mov    %rbx,%rdi
call   1060 <BN_num_bits@plt>
lea    0xdeb(%rip),%rdi
lea    0xecf(%rip),%rdx
lea    0xed7(%rip),%rcx
mov    $0x88a,%esi
mov    %eax,%r8d
mov    %ebp,%r9d
call   1090 <test_int_eq@plt>
test   %eax,%eax
je     123d <test_smallprime+0xbd>
mov    $0x1,%r14d
mov    %rbx,%rdi
call   10a0 <BN_free@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [170 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/bntest.c\00"
@.str.1 = [13 x i8] c"r = BN_new()\00"
@.str.2 = [52 x i8] c"BN_generate_prime_ex(r, kBits, 0, NULL, NULL, NULL)\00"
@.str.3 = [15 x i8] c"BN_num_bits(r)\00"
@.str.4 = [6 x i8] c"kBits\00"
define i32 @test_smallprime(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %4
%5 = call i32* (...) @BN_new()
store i32* %5, i32** %3
%6 = call i32 @test_ptr(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2176, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %1
br label %39
9: ; preds = %1
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 1
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i32*, i32** %3
%14 = load i32, i32* %2
%15 = call i64 @BN_generate_prime_ex(i32* %13, i32 %14, i32 0, i32* null, i32* null, i32* null)
%16 = icmp ne i64 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @test_false(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2180, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %12
br label %39
21: ; preds = %12
br label %38
22: ; preds = %9
%23 = load i32*, i32** %3
%24 = load i32, i32* %2
%25 = call i64 @BN_generate_prime_ex(i32* %23, i32 %24, i32 0, i32* null, i32* null, i32* null)
%26 = icmp ne i64 %25, 0
%27 = zext i1 %26 to i32
%28 = call i32 @test_true(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2184, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %22
%31 = load i32*, i32** %3
%32 = call i32 @BN_num_bits(i32* %31)
%33 = load i32, i32* %2
%34 = call i32 @test_int_eq(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2186, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %32, i32 %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %30, %22
br label %39
37: ; preds = %30
br label %38
38: ; preds = %37, %21
store i32 1, i32* %4
br label %39
39: ; preds = %38, %36, %20, %8
%40 = load i32*, i32** %3
%41 = call i32 @BN_free(i32* %40)
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
@.str = [170 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/bntest.c\00"
@.str.1 = [13 x i8] c"r = BN_new()\00"
@.str.2 = [52 x i8] c"BN_generate_prime_ex(r, kBits, 0, NULL, NULL, NULL)\00"
@.str.3 = [15 x i8] c"BN_num_bits(r)\00"
@.str.4 = [6 x i8] c"kBits\00"
define i32 @test_smallprime(i32 %0) {
%2 = tail call i32* (...) @BN_new()
%3 = tail call i32 @test_ptr(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2176, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %1
%6 = icmp slt i32 %0, 2
%7 = tail call i64 @BN_generate_prime_ex(i32* %2, i32 %0, i32 0, i32* null, i32* null, i32* null)
%8 = icmp ne i64 %7, 0
%9 = zext i1 %8 to i32
br i1 %6, label %10, label %13
10: ; preds = %5
%11 = tail call i32 @test_false(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2180, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%12 = icmp eq i32 %11, 0
br i1 %12, label %21, label %20
13: ; preds = %5
%14 = tail call i32 @test_true(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2184, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%15 = icmp eq i32 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %13
%17 = tail call i32 @BN_num_bits(i32* %2)
%18 = tail call i32 @test_int_eq(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2186, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %17, i32 %0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %16, %10
br label %21
21: ; preds = %13, %16, %10, %1, %20
%22 = phi i32 [ 1, %20 ], [ 0, %10 ], [ 0, %16 ], [ 0, %13 ], [ 0, %1 ]
%23 = tail call i32 @BN_free(i32* %2)
ret i32 %22
}