#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*/ BN_GENCB;
typedef int /*<<< orphan*/ BN_CTX;
typedef int /*<<< orphan*/ BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ BN_CTX_end(int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_CTX_get(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_CTX_new();
int /*<<< orphan*/ BN_CTX_start(int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_GENCB_call(int /*<<< orphan*/ *, int, int);
int BN_is_prime_fasttest_ex(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *,
                            int /*<<< orphan*/, int /*<<< orphan*/ *);
int BN_prime_checks_for_size(int);
int /*<<< orphan*/ BN_rshift1(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ bn_check_top(int /*<<< orphan*/ *);
int /*<<< orphan*/ probable_prime(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ probable_prime_dh(int /*<<< orphan*/ *, int,
                                     int /*<<< orphan*/ const *,
                                     int /*<<< orphan*/ const *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ probable_prime_dh_safe(int /*<<< orphan*/ *, int,
                                          int /*<<< orphan*/ const *,
                                          int /*<<< orphan*/ const *,
                                          int /*<<< orphan*/ *);
int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,
                         const BIGNUM *rem, BN_GENCB *cb) {
  BIGNUM *t;
  int found = 0;
  int i, j, c1 = 0;
  BN_CTX *ctx;
  int checks = BN_prime_checks_for_size(bits);
  ctx = BN_CTX_new();
  if (ctx == NULL)
    goto err;
  BN_CTX_start(ctx);
  t = BN_CTX_get(ctx);
  if (!t)
    goto err;
loop:
  if (add == NULL) {
    if (!probable_prime(ret, bits))
      goto err;
  } else {
    if (safe) {
      if (!probable_prime_dh_safe(ret, bits, add, rem, ctx))
        goto err;
    } else {
      if (!probable_prime_dh(ret, bits, add, rem, ctx))
        goto err;
    }
  }
  if (!BN_GENCB_call(cb, 0, c1++))
    goto err;
  if (!safe) {
    i = BN_is_prime_fasttest_ex(ret, checks, ctx, 0, cb);
    if (i == -1)
      goto err;
    if (i == 0)
      goto loop;
  } else {
    if (!BN_rshift1(t, ret))
      goto err;
    for (i = 0; i < checks; i++) {
      j = BN_is_prime_fasttest_ex(ret, 1, ctx, 0, cb);
      if (j == -1)
        goto err;
      if (j == 0)
        goto loop;
      j = BN_is_prime_fasttest_ex(t, 1, ctx, 0, cb);
      if (j == -1)
        goto err;
      if (j == 0)
        goto loop;
      if (!BN_GENCB_call(cb, 2, c1 - 1))
        goto err;
    }
  }
  found = 1;
err:
  if (ctx != NULL) {
    BN_CTX_end(ctx);
    BN_CTX_free(ctx);
  }
  bn_check_top(ret);
  return found;
}


x86 assembly (clang, -O0):
<BN_generate_prime_ex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0xc(%rbp),%edi
call   10f0 <BN_prime_checks_for_size@plt>
mov    %eax,-0x4c(%rbp)
mov    $0x0,%al
call   10c0 <BN_CTX_new@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1222 <BN_generate_prime_ex+0x52>
jmp    1427 <BN_generate_prime_ex+0x257>
mov    -0x48(%rbp),%rdi
call   1090 <BN_CTX_start@plt>
mov    -0x48(%rbp),%rdi
call   1030 <BN_CTX_get@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1248 <BN_generate_prime_ex+0x78>
jmp    1427 <BN_generate_prime_ex+0x257>
jmp    124d <BN_generate_prime_ex+0x7d>
cmpq   $0x0,-0x18(%rbp)
jne    1277 <BN_generate_prime_ex+0xa7>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <probable_prime@plt>
cmp    $0x0,%eax
jne    1272 <BN_generate_prime_ex+0xa2>
jmp    1427 <BN_generate_prime_ex+0x257>
jmp    12dc <BN_generate_prime_ex+0x10c>
cmpl   $0x0,-0x10(%rbp)
je     12ac <BN_generate_prime_ex+0xdc>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x48(%rbp),%r8
call   1050 <probable_prime_dh_safe@plt>
cmp    $0x0,%eax
jne    12a7 <BN_generate_prime_ex+0xd7>
jmp    1427 <BN_generate_prime_ex+0x257>
jmp    12d7 <BN_generate_prime_ex+0x107>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x48(%rbp),%r8
call   10e0 <probable_prime_dh@plt>
cmp    $0x0,%eax
jne    12d2 <BN_generate_prime_ex+0x102>
jmp    1427 <BN_generate_prime_ex+0x257>
jmp    12d7 <BN_generate_prime_ex+0x107>
jmp    12dc <BN_generate_prime_ex+0x10c>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
xor    %esi,%esi
call   10d0 <BN_GENCB_call@plt>
cmp    $0x0,%eax
jne    1300 <BN_generate_prime_ex+0x130>
jmp    1427 <BN_generate_prime_ex+0x257>
cmpl   $0x0,-0x10(%rbp)
jne    1346 <BN_generate_prime_ex+0x176>
mov    -0x8(%rbp),%rdi
mov    -0x4c(%rbp),%esi
mov    -0x48(%rbp),%rdx
mov    -0x28(%rbp),%r8
xor    %ecx,%ecx
call   10a0 <BN_is_prime_fasttest_ex@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xffffffff,-0x38(%rbp)
jne    1332 <BN_generate_prime_ex+0x162>
jmp    1427 <BN_generate_prime_ex+0x257>
cmpl   $0x0,-0x38(%rbp)
jne    1341 <BN_generate_prime_ex+0x171>
jmp    124d <BN_generate_prime_ex+0x7d>
jmp    1420 <BN_generate_prime_ex+0x250>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10b0 <BN_rshift1@plt>
cmp    $0x0,%eax
jne    1361 <BN_generate_prime_ex+0x191>
jmp    1427 <BN_generate_prime_ex+0x257>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    141b <BN_generate_prime_ex+0x24b>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    -0x28(%rbp),%r8
mov    $0x1,%esi
xor    %ecx,%ecx
call   10a0 <BN_is_prime_fasttest_ex@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    139e <BN_generate_prime_ex+0x1ce>
jmp    1427 <BN_generate_prime_ex+0x257>
cmpl   $0x0,-0x3c(%rbp)
jne    13ad <BN_generate_prime_ex+0x1dd>
jmp    124d <BN_generate_prime_ex+0x7d>
mov    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    -0x28(%rbp),%r8
mov    $0x1,%esi
xor    %ecx,%ecx
call   10a0 <BN_is_prime_fasttest_ex@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    13d7 <BN_generate_prime_ex+0x207>
jmp    1427 <BN_generate_prime_ex+0x257>
cmpl   $0x0,-0x3c(%rbp)
jne    13e6 <BN_generate_prime_ex+0x216>
jmp    124d <BN_generate_prime_ex+0x7d>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%edx
sub    $0x1,%edx
mov    $0x2,%esi
call   10d0 <BN_GENCB_call@plt>
cmp    $0x0,%eax
jne    1408 <BN_generate_prime_ex+0x238>
jmp    1427 <BN_generate_prime_ex+0x257>
jmp    140d <BN_generate_prime_ex+0x23d>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1368 <BN_generate_prime_ex+0x198>
jmp    1420 <BN_generate_prime_ex+0x250>
movl   $0x1,-0x34(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1444 <BN_generate_prime_ex+0x274>
mov    -0x48(%rbp),%rdi
call   1080 <BN_CTX_end@plt>
mov    -0x48(%rbp),%rdi
call   1060 <BN_CTX_free@plt>
mov    -0x8(%rbp),%rdi
call   1070 <bn_check_top@plt>
mov    -0x34(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BN_generate_prime_ex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%rbx
mov    %r8,%rbp
mov    %rcx,0x18(%rsp)
mov    %edx,0xc(%rsp)
mov    %rdi,%r14
mov    %esi,(%rsp)
mov    %esi,%edi
call   10f0 <BN_prime_checks_for_size@plt>
mov    %eax,0x8(%rsp)
xor    %r12d,%r12d
xor    %eax,%eax
call   10c0 <BN_CTX_new@plt>
test   %rax,%rax
je     13fe <BN_generate_prime_ex+0x22e>
mov    %rax,%r15
mov    %rax,%rdi
call   1090 <BN_CTX_start@plt>
mov    %r15,%rdi
call   1030 <BN_CTX_get@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
je     13de <BN_generate_prime_ex+0x20e>
xor    %r13d,%r13d
mov    %rbp,0x10(%rsp)
cmpq   $0x0,0x18(%rsp)
je     1290 <BN_generate_prime_ex+0xc0>
cmpl   $0x0,0xc(%rsp)
je     136f <BN_generate_prime_ex+0x19f>
mov    %r14,%rdi
mov    (%rsp),%esi
mov    0x18(%rsp),%rdx
mov    %rbp,%rcx
mov    %r15,%r8
call   1050 <probable_prime_dh_safe@plt>
xor    %r12d,%r12d
test   %eax,%eax
je     13ee <BN_generate_prime_ex+0x21e>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r13d,%edx
call   10d0 <BN_GENCB_call@plt>
test   %eax,%eax
je     13ee <BN_generate_prime_ex+0x21e>
lea    0x1(%r13),%ebp
jmp    12ca <BN_generate_prime_ex+0xfa>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    (%rsp),%esi
call   1040 <probable_prime@plt>
xor    %r12d,%r12d
test   %eax,%eax
je     13ee <BN_generate_prime_ex+0x21e>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r13d,%edx
call   10d0 <BN_GENCB_call@plt>
test   %eax,%eax
je     13ee <BN_generate_prime_ex+0x21e>
lea    0x1(%r13),%ebp
cmpl   $0x0,0xc(%rsp)
je     13a4 <BN_generate_prime_ex+0x1d4>
mov    0x20(%rsp),%rdi
mov    %r14,%rsi
call   10b0 <BN_rshift1@plt>
test   %eax,%eax
je     13de <BN_generate_prime_ex+0x20e>
mov    %ebp,0x4(%rsp)
mov    0x8(%rsp),%eax
mov    %eax,%ebp
test   %eax,%eax
jle    13e8 <BN_generate_prime_ex+0x218>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %r12d,%r12d
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
mov    %rbx,%r8
call   10a0 <BN_is_prime_fasttest_ex@plt>
cmp    $0xffffffff,%eax
je     13ee <BN_generate_prime_ex+0x21e>
test   %eax,%eax
je     13cd <BN_generate_prime_ex+0x1fd>
xor    %r12d,%r12d
mov    0x20(%rsp),%rdi
mov    $0x1,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
mov    %rbx,%r8
call   10a0 <BN_is_prime_fasttest_ex@plt>
cmp    $0xffffffff,%eax
je     13ee <BN_generate_prime_ex+0x21e>
test   %eax,%eax
je     13cd <BN_generate_prime_ex+0x1fd>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %r13d,%edx
call   10d0 <BN_GENCB_call@plt>
test   %eax,%eax
je     13ee <BN_generate_prime_ex+0x21e>
add    $0xffffffff,%ebp
jne    1300 <BN_generate_prime_ex+0x130>
jmp    13e8 <BN_generate_prime_ex+0x218>
mov    %r14,%rdi
mov    (%rsp),%esi
mov    0x18(%rsp),%rdx
mov    %rbp,%rcx
mov    %r15,%r8
call   10e0 <probable_prime_dh@plt>
xor    %r12d,%r12d
test   %eax,%eax
je     13ee <BN_generate_prime_ex+0x21e>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r13d,%edx
call   10d0 <BN_GENCB_call@plt>
test   %eax,%eax
je     13ee <BN_generate_prime_ex+0x21e>
add    $0x1,%r13d
mov    %r13d,%ebp
xor    %r12d,%r12d
mov    %r14,%rdi
mov    0x8(%rsp),%esi
mov    %r15,%rdx
xor    %ecx,%ecx
mov    %rbx,%r8
call   10a0 <BN_is_prime_fasttest_ex@plt>
mov    %ebp,%r13d
test   %eax,%eax
mov    0x10(%rsp),%rbp
je     123a <BN_generate_prime_ex+0x6a>
jmp    13e3 <BN_generate_prime_ex+0x213>
mov    0x4(%rsp),%eax
mov    %eax,%r13d
mov    0x10(%rsp),%rbp
jmp    123a <BN_generate_prime_ex+0x6a>
xor    %r12d,%r12d
jmp    13ee <BN_generate_prime_ex+0x21e>
cmp    $0xffffffff,%eax
je     13ee <BN_generate_prime_ex+0x21e>
mov    $0x1,%r12d
mov    %r15,%rdi
call   1080 <BN_CTX_end@plt>
mov    %r15,%rdi
call   1060 <BN_CTX_free@plt>
mov    %r14,%rdi
call   1070 <bn_check_top@plt>
mov    %r12d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @BN_generate_prime_ex(i32* %0, i32 %1, i32 %2, i32* %3, i32* %4, i32* %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i32
store i32* %0, i32** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32* %5, i32** %12
store i32 0, i32* %14
store i32 0, i32* %17
%20 = load i32, i32* %8
%21 = call i32 @BN_prime_checks_for_size(i32 %20)
store i32 %21, i32* %19
%22 = call i32* (...) @BN_CTX_new()
store i32* %22, i32** %18
%23 = load i32*, i32** %18
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %26
25: ; preds = %6
br label %141
26: ; preds = %6
%27 = load i32*, i32** %18
%28 = call i32 @BN_CTX_start(i32* %27)
%29 = load i32*, i32** %18
%30 = call i32* @BN_CTX_get(i32* %29)
store i32* %30, i32** %13
%31 = load i32*, i32** %13
%32 = icmp ne i32* %31, null
br i1 %32, label %34, label %33
33: ; preds = %26
br label %141
34: ; preds = %26
br label %35
35: ; preds = %127, %115, %91, %34
%36 = load i32*, i32** %10
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = load i32*, i32** %7
%40 = load i32, i32* %8
%41 = call i32 @probable_prime(i32* %39, i32 %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %38
br label %141
44: ; preds = %38
br label %69
45: ; preds = %35
%46 = load i32, i32* %9
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %58
48: ; preds = %45
%49 = load i32*, i32** %7
%50 = load i32, i32* %8
%51 = load i32*, i32** %10
%52 = load i32*, i32** %11
%53 = load i32*, i32** %18
%54 = call i32 @probable_prime_dh_safe(i32* %49, i32 %50, i32* %51, i32* %52, i32* %53)
%55 = icmp ne i32 %54, 0
br i1 %55, label %57, label %56
56: ; preds = %48
br label %141
57: ; preds = %48
br label %68
58: ; preds = %45
%59 = load i32*, i32** %7
%60 = load i32, i32* %8
%61 = load i32*, i32** %10
%62 = load i32*, i32** %11
%63 = load i32*, i32** %18
%64 = call i32 @probable_prime_dh(i32* %59, i32 %60, i32* %61, i32* %62, i32* %63)
%65 = icmp ne i32 %64, 0
br i1 %65, label %67, label %66
66: ; preds = %58
br label %141
67: ; preds = %58
br label %68
68: ; preds = %67, %57
br label %69
69: ; preds = %68, %44
%70 = load i32*, i32** %12
%71 = load i32, i32* %17
%72 = add nsw i32 %71, 1
store i32 %72, i32* %17
%73 = call i32 @BN_GENCB_call(i32* %70, i32 0, i32 %71)
%74 = icmp ne i32 %73, 0
br i1 %74, label %76, label %75
75: ; preds = %69
br label %141
76: ; preds = %69
%77 = load i32, i32* %9
%78 = icmp ne i32 %77, 0
br i1 %78, label %93, label %79
79: ; preds = %76
%80 = load i32*, i32** %7
%81 = load i32, i32* %19
%82 = load i32*, i32** %18
%83 = load i32*, i32** %12
%84 = call i32 @BN_is_prime_fasttest_ex(i32* %80, i32 %81, i32* %82, i32 0, i32* %83)
store i32 %84, i32* %15
%85 = load i32, i32* %15
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %88
87: ; preds = %79
br label %141
88: ; preds = %79
%89 = load i32, i32* %15
%90 = icmp eq i32 %89, 0
br i1 %90, label %91, label %92
91: ; preds = %88
br label %35
92: ; preds = %88
br label %140
93: ; preds = %76
%94 = load i32*, i32** %13
%95 = load i32*, i32** %7
%96 = call i32 @BN_rshift1(i32* %94, i32* %95)
%97 = icmp ne i32 %96, 0
br i1 %97, label %99, label %98
98: ; preds = %93
br label %141
99: ; preds = %93
store i32 0, i32* %15
br label %100
100: ; preds = %136, %99
%101 = load i32, i32* %15
%102 = load i32, i32* %19
%103 = icmp slt i32 %101, %102
br i1 %103, label %104, label %139
104: ; preds = %100
%105 = load i32*, i32** %7
%106 = load i32*, i32** %18
%107 = load i32*, i32** %12
%108 = call i32 @BN_is_prime_fasttest_ex(i32* %105, i32 1, i32* %106, i32 0, i32* %107)
store i32 %108, i32* %16
%109 = load i32, i32* %16
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %112
111: ; preds = %104
br label %141
112: ; preds = %104
%113 = load i32, i32* %16
%114 = icmp eq i32 %113, 0
br i1 %114, label %115, label %116
115: ; preds = %112
br label %35
116: ; preds = %112
%117 = load i32*, i32** %13
%118 = load i32*, i32** %18
%119 = load i32*, i32** %12
%120 = call i32 @BN_is_prime_fasttest_ex(i32* %117, i32 1, i32* %118, i32 0, i32* %119)
store i32 %120, i32* %16
%121 = load i32, i32* %16
%122 = icmp eq i32 %121, -1
br i1 %122, label %123, label %124
123: ; preds = %116
br label %141
124: ; preds = %116
%125 = load i32, i32* %16
%126 = icmp eq i32 %125, 0
br i1 %126, label %127, label %128
127: ; preds = %124
br label %35
128: ; preds = %124
%129 = load i32*, i32** %12
%130 = load i32, i32* %17
%131 = sub nsw i32 %130, 1
%132 = call i32 @BN_GENCB_call(i32* %129, i32 2, i32 %131)
%133 = icmp ne i32 %132, 0
br i1 %133, label %135, label %134
134: ; preds = %128
br label %141
135: ; preds = %128
br label %136
136: ; preds = %135
%137 = load i32, i32* %15
%138 = add nsw i32 %137, 1
store i32 %138, i32* %15
br label %100
139: ; preds = %100
br label %140
140: ; preds = %139, %92
store i32 1, i32* %14
br label %141
141: ; preds = %140, %134, %123, %111, %98, %87, %75, %66, %56, %43, %33, %25
%142 = load i32*, i32** %18
%143 = icmp ne i32* %142, null
br i1 %143, label %144, label %149
144: ; preds = %141
%145 = load i32*, i32** %18
%146 = call i32 @BN_CTX_end(i32* %145)
%147 = load i32*, i32** %18
%148 = call i32 @BN_CTX_free(i32* %147)
br label %149
149: ; preds = %144, %141
%150 = load i32*, i32** %7
%151 = call i32 @bn_check_top(i32* %150)
%152 = load i32, i32* %14
ret i32 %152
}

LLVM IR (-O2):
define i32 @BN_generate_prime_ex(i32* %0, i32 %1, i32 %2, i32* %3, i32* %4, i32* %5) {
%7 = tail call i32 @BN_prime_checks_for_size(i32 %1)
%8 = tail call i32* (...) @BN_CTX_new()
%9 = icmp eq i32* %8, null
br i1 %9, label %69, label %10
10: ; preds = %6
%11 = tail call i32 @BN_CTX_start(i32* %8)
%12 = tail call i32* @BN_CTX_get(i32* %8)
%13 = icmp eq i32* %12, null
br i1 %13, label %65, label %14
14: ; preds = %10
%15 = icmp eq i32* %3, null
%16 = icmp eq i32 %2, 0
%17 = icmp sgt i32 %7, 0
br label %18
18: ; preds = %46, %14
%19 = phi i32 [ 0, %14 ], [ %47, %46 ]
br i1 %15, label %20, label %23
20: ; preds = %18
%21 = tail call i32 @probable_prime(i32* %0, i32 %1)
%22 = icmp eq i32 %21, 0
br i1 %22, label %64, label %30
23: ; preds = %18
br i1 %16, label %27, label %24
24: ; preds = %23
%25 = tail call i32 @probable_prime_dh_safe(i32* %0, i32 %1, i32* %3, i32* %4, i32* %8)
%26 = icmp eq i32 %25, 0
br i1 %26, label %64, label %38
27: ; preds = %23
%28 = tail call i32 @probable_prime_dh(i32* %0, i32 %1, i32* %3, i32* %4, i32* %8)
%29 = icmp eq i32 %28, 0
br i1 %29, label %64, label %34
30: ; preds = %20
%31 = add nuw nsw i32 %19, 1
%32 = tail call i32 @BN_GENCB_call(i32* %5, i32 0, i32 %19)
%33 = icmp eq i32 %32, 0
br i1 %33, label %64, label %42
34: ; preds = %27
%35 = add nuw nsw i32 %19, 1
%36 = tail call i32 @BN_GENCB_call(i32* %5, i32 0, i32 %19)
%37 = icmp eq i32 %36, 0
br i1 %37, label %64, label %43
38: ; preds = %24
%39 = add nuw nsw i32 %19, 1
%40 = tail call i32 @BN_GENCB_call(i32* %5, i32 0, i32 %19)
%41 = icmp eq i32 %40, 0
br i1 %41, label %64, label %48
42: ; preds = %30
br i1 %16, label %43, label %48
43: ; preds = %34, %42
%44 = phi i32 [ %31, %42 ], [ %35, %34 ]
%45 = tail call i32 @BN_is_prime_fasttest_ex(i32* %0, i32 %7, i32* %8, i32 0, i32* %5)
switch i32 %45, label %65 [
i32 -1, label %64
i32 0, label %46
]
46: ; preds = %55, %58, %43
%47 = phi i32 [ %44, %43 ], [ %49, %58 ], [ %49, %55 ]
br label %18
48: ; preds = %38, %42
%49 = phi i32 [ %31, %42 ], [ %39, %38 ]
%50 = tail call i32 @BN_rshift1(i32* %12, i32* %0)
%51 = icmp eq i32 %50, 0
br i1 %51, label %64, label %52
52: ; preds = %48
br i1 %17, label %55, label %65
53: ; preds = %60
%54 = icmp eq i32 %63, %7
br i1 %54, label %65, label %55
55: ; preds = %52, %53
%56 = phi i32 [ %63, %53 ], [ 0, %52 ]
%57 = tail call i32 @BN_is_prime_fasttest_ex(i32* %0, i32 1, i32* %8, i32 0, i32* %5)
switch i32 %57, label %58 [
i32 -1, label %65
i32 0, label %46
]
58: ; preds = %55
%59 = tail call i32 @BN_is_prime_fasttest_ex(i32* %12, i32 1, i32* %8, i32 0, i32* %5)
switch i32 %59, label %60 [
i32 -1, label %65
i32 0, label %46
]
60: ; preds = %58
%61 = tail call i32 @BN_GENCB_call(i32* %5, i32 2, i32 %19)
%62 = icmp eq i32 %61, 0
%63 = add nuw nsw i32 %56, 1
br i1 %62, label %65, label %53
64: ; preds = %43, %48, %30, %27, %24, %20, %38, %34
br label %65
65: ; preds = %53, %60, %55, %58, %52, %43, %64, %10
%66 = phi i32 [ 0, %10 ], [ 0, %64 ], [ 1, %43 ], [ 1, %52 ], [ 1, %53 ], [ 0, %60 ], [ 0, %55 ], [ 0, %58 ]
%67 = tail call i32 @BN_CTX_end(i32* %8)
%68 = tail call i32 @BN_CTX_free(i32* %8)
br label %69
69: ; preds = %6, %65
%70 = phi i32 [ %66, %65 ], [ 0, %6 ]
%71 = tail call i32 @bn_check_top(i32* %0)
ret i32 %70
}