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

/* Variables and functions */
int /*<<< orphan*/ BIO_NOCLOSE;
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_s_file();
int /*<<< orphan*/ BIO_set_fp(int /*<<< orphan*/ *, int /*<<< orphan*/,
                              int /*<<< orphan*/);
unsigned char BN_BITS;
unsigned char BN_BITS2;
int /*<<< orphan*/ BN_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_CTX_new();
scalar_t__ BN_cmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_mod(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int BN_mod_exp_mont(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int BN_mod_exp_mont_consttime(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                              int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                              int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int BN_mod_exp_recp(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *);
int BN_mod_exp_simple(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                      int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                      int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_new();
int BN_num_bits(int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_print(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_rand(int /*<<< orphan*/ *, unsigned char,
                           int /*<<< orphan*/, int);
int /*<<< orphan*/ CRYPTO_mem_leaks(int /*<<< orphan*/ *);
int /*<<< orphan*/ ERR_load_BN_strings();
int /*<<< orphan*/ ERR_load_crypto_strings();
int /*<<< orphan*/ ERR_print_errors(int /*<<< orphan*/ *);
int /*<<< orphan*/ ERR_remove_thread_state(int /*<<< orphan*/ *);
int /*<<< orphan*/ RAND_bytes(unsigned char *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  BN_CTX *ctx;
  BIO *out = NULL;
  int i, ret;
  unsigned char c;
  BIGNUM *r_mont, *r_mont_const, *r_recp, *r_simple, *a, *b, *m;
  ERR_load_BN_strings();
  ctx = BN_CTX_new();
  if (ctx == NULL)
    exit(1);
  r_mont = BN_new();
  r_mont_const = BN_new();
  r_recp = BN_new();
  r_simple = BN_new();
  a = BN_new();
  b = BN_new();
  m = BN_new();
  if ((r_mont == NULL) || (r_recp == NULL) || (a == NULL) || (b == NULL))
    goto err;
  out = BIO_new(BIO_s_file());
  if (out == NULL)
    exit(1);
  BIO_set_fp(out, stdout, BIO_NOCLOSE);
  for (i = 0; i < 200; i++) {
    RAND_bytes(&c, 1);
    c = (c % BN_BITS) - BN_BITS2;
    BN_rand(a, (BN_BITS * 2) + c, 0, 0);
    RAND_bytes(&c, 1);
    c = (c % BN_BITS) - BN_BITS2;
    BN_rand(b, (BN_BITS * 2) + c, 0, 0);
    RAND_bytes(&c, 1);
    c = (c % BN_BITS) - BN_BITS2;
    BN_rand(m, (BN_BITS * 2) + c, 0, 1);
    BN_mod(a, a, m, ctx);
    BN_mod(b, b, m, ctx);
    ret = BN_mod_exp_mont(r_mont, a, b, m, ctx, NULL);
    if (ret <= 0) {
      printf("BN_mod_exp_mont() problems\n");
      ERR_print_errors(out);
      exit(1);
    }
    ret = BN_mod_exp_recp(r_recp, a, b, m, ctx);
    if (ret <= 0) {
      printf("BN_mod_exp_recp() problems\n");
      ERR_print_errors(out);
      exit(1);
    }
    ret = BN_mod_exp_simple(r_simple, a, b, m, ctx);
    if (ret <= 0) {
      printf("BN_mod_exp_simple() problems\n");
      ERR_print_errors(out);
      exit(1);
    }
    ret = BN_mod_exp_mont_consttime(r_mont_const, a, b, m, ctx, NULL);
    if (ret <= 0) {
      printf("BN_mod_exp_mont_consttime() problems\n");
      ERR_print_errors(out);
      exit(1);
    }
    if (BN_cmp(r_simple, r_mont) == 0 && BN_cmp(r_simple, r_recp) == 0 &&
        BN_cmp(r_simple, r_mont_const) == 0) {
      printf(".");
      fflush(stdout);
    } else {
      if (BN_cmp(r_simple, r_mont) != 0)
        printf("\nsimple and mont results differ\n");
      if (BN_cmp(r_simple, r_mont_const) != 0)
        printf("\nsimple and mont const time results differ\n");
      if (BN_cmp(r_simple, r_recp) != 0)
        printf("\nsimple and recp results differ\n");
      printf("a (%3d) = ", BN_num_bits(a));
      BN_print(out, a);
      printf("\nb (%3d) = ", BN_num_bits(b));
      BN_print(out, b);
      printf("\nm (%3d) = ", BN_num_bits(m));
      BN_print(out, m);
      printf("\nsimple   =");
      BN_print(out, r_simple);
      printf("\nrecp     =");
      BN_print(out, r_recp);
      printf("\nmont     =");
      BN_print(out, r_mont);
      printf("\nmont_ct  =");
      BN_print(out, r_mont_const);
      printf("\n");
      exit(1);
    }
  }
  BN_free(r_mont);
  BN_free(r_mont_const);
  BN_free(r_recp);
  BN_free(r_simple);
  BN_free(a);
  BN_free(b);
  BN_free(m);
  BN_CTX_free(ctx);
  ERR_remove_thread_state(NULL);
  CRYPTO_mem_leaks(out);
  BIO_free(out);
  printf(" done\n");
  exit(0);
err:
  ERR_load_crypto_strings();
  ERR_print_errors(out);
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   10f0 <ERR_load_BN_strings@plt>
mov    $0x0,%al
call   10e0 <BN_CTX_new@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12e5 <main+0x45>
mov    $0x1,%edi
call   1190 <exit@plt>
mov    $0x0,%al
call   1070 <BN_new@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1070 <BN_new@plt>
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1070 <BN_new@plt>
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   1070 <BN_new@plt>
mov    %rax,-0x50(%rbp)
mov    $0x0,%al
call   1070 <BN_new@plt>
mov    %rax,-0x58(%rbp)
mov    $0x0,%al
call   1070 <BN_new@plt>
mov    %rax,-0x60(%rbp)
mov    $0x0,%al
call   1070 <BN_new@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     135e <main+0xbe>
cmpq   $0x0,-0x48(%rbp)
je     135e <main+0xbe>
cmpq   $0x0,-0x58(%rbp)
je     135e <main+0xbe>
cmpq   $0x0,-0x60(%rbp)
jne    1363 <main+0xc3>
jmp    185b <main+0x5bb>
mov    $0x0,%al
call   11b0 <BIO_s_file@plt>
mov    %eax,%edi
call   1120 <BIO_new@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    138a <main+0xea>
mov    $0x1,%edi
call   1190 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    0x2c33(%rip),%rax
mov    (%rax),%esi
mov    0x2c4a(%rip),%rax
mov    (%rax),%edx
call   1150 <BIO_set_fp@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0xc8,-0x24(%rbp)
jge    17e3 <main+0x543>
lea    -0x29(%rbp),%rdi
mov    $0x1,%esi
call   1090 <RAND_bytes@plt>
movzbl -0x29(%rbp),%eax
mov    0x2c0e(%rip),%rcx
movzbl (%rcx),%ecx
cltd
idiv   %ecx
mov    0x2bf1(%rip),%rax
movzbl (%rax),%eax
sub    %eax,%edx
mov    %dl,%al
mov    %al,-0x29(%rbp)
mov    -0x58(%rbp),%rdi
mov    0x2bec(%rip),%rax
movzbl (%rax),%eax
shl    $0x1,%eax
movzbl -0x29(%rbp),%ecx
add    %ecx,%eax
xor    %ecx,%ecx
movzbl %al,%esi
mov    %ecx,%edx
call   1030 <BN_rand@plt>
lea    -0x29(%rbp),%rdi
mov    $0x1,%esi
call   1090 <RAND_bytes@plt>
movzbl -0x29(%rbp),%eax
mov    0x2bbb(%rip),%rcx
movzbl (%rcx),%ecx
cltd
idiv   %ecx
mov    0x2b9e(%rip),%rax
movzbl (%rax),%eax
sub    %eax,%edx
mov    %dl,%al
mov    %al,-0x29(%rbp)
mov    -0x60(%rbp),%rdi
mov    0x2b99(%rip),%rax
movzbl (%rax),%eax
shl    $0x1,%eax
movzbl -0x29(%rbp),%ecx
add    %ecx,%eax
xor    %ecx,%ecx
movzbl %al,%esi
mov    %ecx,%edx
call   1030 <BN_rand@plt>
lea    -0x29(%rbp),%rdi
mov    $0x1,%esi
call   1090 <RAND_bytes@plt>
movzbl -0x29(%rbp),%eax
mov    0x2b68(%rip),%rcx
movzbl (%rcx),%ecx
cltd
idiv   %ecx
mov    0x2b4b(%rip),%rax
movzbl (%rax),%eax
sub    %eax,%edx
mov    %dl,%al
mov    %al,-0x29(%rbp)
mov    -0x68(%rbp),%rdi
mov    0x2b46(%rip),%rax
movzbl (%rax),%eax
shl    $0x1,%eax
movzbl -0x29(%rbp),%ecx
add    %ecx,%eax
xor    %edx,%edx
mov    $0x1,%ecx
movzbl %al,%esi
call   1030 <BN_rand@plt>
mov    -0x58(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1140 <BN_mod@plt>
mov    -0x60(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1140 <BN_mod@plt>
mov    -0x38(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x60(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    -0x18(%rbp),%r8
xor    %eax,%eax
mov    %eax,%r9d
call   11c0 <BN_mod_exp_mont@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jg     152b <main+0x28b>
lea    0xaef(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <ERR_print_errors@plt>
mov    $0x1,%edi
call   1190 <exit@plt>
mov    -0x48(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x60(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1040 <BN_mod_exp_recp@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jg     1572 <main+0x2d2>
lea    0xac4(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <ERR_print_errors@plt>
mov    $0x1,%edi
call   1190 <exit@plt>
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x60(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   10c0 <BN_mod_exp_simple@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jg     15b9 <main+0x319>
lea    0xa99(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <ERR_print_errors@plt>
mov    $0x1,%edi
call   1190 <exit@plt>
mov    -0x40(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x60(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    -0x18(%rbp),%r8
xor    %eax,%eax
mov    %eax,%r9d
call   1170 <BN_mod_exp_mont_consttime@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jg     1605 <main+0x365>
lea    0xa6b(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <ERR_print_errors@plt>
mov    $0x1,%edi
call   1190 <exit@plt>
mov    -0x50(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1160 <BN_cmp@plt>
cmp    $0x0,%rax
jne    166b <main+0x3cb>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1160 <BN_cmp@plt>
cmp    $0x0,%rax
jne    166b <main+0x3cb>
mov    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1160 <BN_cmp@plt>
cmp    $0x0,%rax
jne    166b <main+0x3cb>
lea    0xa2b(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    0x2969(%rip),%rax
mov    (%rax),%edi
call   1110 <fflush@plt>
jmp    17d0 <main+0x530>
mov    -0x50(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1160 <BN_cmp@plt>
cmp    $0x0,%rax
je     1690 <main+0x3f0>
lea    0x9f5(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1160 <BN_cmp@plt>
cmp    $0x0,%rax
je     16b5 <main+0x415>
lea    0x9f1(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1160 <BN_cmp@plt>
cmp    $0x0,%rax
je     16da <main+0x43a>
lea    0x9f8(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1080 <BN_num_bits@plt>
mov    %eax,%esi
lea    0xa00(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1100 <BN_print@plt>
mov    -0x60(%rbp),%rdi
call   1080 <BN_num_bits@plt>
mov    %eax,%esi
lea    0x9e5(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1100 <BN_print@plt>
mov    -0x68(%rbp),%rdi
call   1080 <BN_num_bits@plt>
mov    %eax,%esi
lea    0x9cb(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x68(%rbp),%rsi
call   1100 <BN_print@plt>
lea    0x9bc(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1100 <BN_print@plt>
lea    0x9ad(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1100 <BN_print@plt>
lea    0x99e(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1100 <BN_print@plt>
lea    0x98f(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1100 <BN_print@plt>
lea    0x985(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
mov    $0x1,%edi
call   1190 <exit@plt>
jmp    17d5 <main+0x535>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    13ac <main+0x10c>
mov    -0x38(%rbp),%rdi
call   10d0 <BN_free@plt>
mov    -0x40(%rbp),%rdi
call   10d0 <BN_free@plt>
mov    -0x48(%rbp),%rdi
call   10d0 <BN_free@plt>
mov    -0x50(%rbp),%rdi
call   10d0 <BN_free@plt>
mov    -0x58(%rbp),%rdi
call   10d0 <BN_free@plt>
mov    -0x60(%rbp),%rdi
call   10d0 <BN_free@plt>
mov    -0x68(%rbp),%rdi
call   10d0 <BN_free@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <BN_CTX_free@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <ERR_remove_thread_state@plt>
mov    -0x20(%rbp),%rdi
call   11a0 <CRYPTO_mem_leaks@plt>
mov    -0x20(%rbp),%rdi
call   1130 <BIO_free@plt>
lea    0x8f2(%rip),%rdi
mov    $0x0,%al
call   10a0 <printf@plt>
xor    %edi,%edi
call   1190 <exit@plt>
mov    $0x0,%al
call   1180 <ERR_load_crypto_strings@plt>
mov    -0x20(%rbp),%rdi
call   1060 <ERR_print_errors@plt>
mov    $0x1,%edi
call   1190 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
xor    %eax,%eax
call   1110 <ERR_load_BN_strings@plt>
xor    %eax,%eax
call   1100 <BN_CTX_new@plt>
test   %rax,%rax
je     135d <main+0x9d>
mov    %rax,%rbp
xor    %eax,%eax
call   1090 <BN_new@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1090 <BN_new@plt>
mov    %rax,0x18(%rsp)
xor    %eax,%eax
call   1090 <BN_new@plt>
mov    %rax,0x10(%rsp)
xor    %eax,%eax
call   1090 <BN_new@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1090 <BN_new@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1090 <BN_new@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1090 <BN_new@plt>
mov    %r13,0x20(%rsp)
test   %r13,%r13
je     1367 <main+0xa7>
cmpq   $0x0,0x10(%rsp)
je     1367 <main+0xa7>
test   %r15,%r15
je     1367 <main+0xa7>
test   %r14,%r14
je     1367 <main+0xa7>
mov    %rax,%r12
xor    %eax,%eax
call   11d0 <BIO_s_file@plt>
mov    %eax,%edi
call   1140 <BIO_new@plt>
test   %rax,%rax
jne    1375 <main+0xb5>
mov    $0x1,%edi
call   11b0 <exit@plt>
xor    %eax,%eax
call   11a0 <ERR_load_crypto_strings@plt>
xor    %edi,%edi
jmp    1755 <main+0x495>
mov    0x2c4c(%rip),%rcx
mov    (%rcx),%esi
mov    0x2c63(%rip),%rcx
mov    (%rcx),%edx
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
call   1170 <BIO_set_fp@plt>
mov    $0xc8,%eax
mov    %rbx,0x30(%rsp)
xchg   %ax,%ax
mov    %eax,0x2c(%rsp)
lea    0x7(%rsp),%r13
mov    %r13,%rdi
mov    $0x1,%esi
call   10b0 <RAND_bytes@plt>
mov    0x2c23(%rip),%rbx
movzbl (%rbx),%ecx
movzbl 0x7(%rsp),%eax
div    %cl
movzbl %ah,%eax
mov    0x2bff(%rip),%rdx
sub    (%rdx),%al
mov    %al,0x7(%rsp)
add    %cl,%cl
add    %al,%cl
movzbl %cl,%esi
mov    %r15,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <BN_rand@plt>
mov    %r13,%rdi
mov    $0x1,%esi
call   10b0 <RAND_bytes@plt>
movzbl (%rbx),%ecx
movzbl 0x7(%rsp),%eax
div    %cl
movzbl %ah,%eax
mov    0x2bc5(%rip),%rdx
sub    (%rdx),%al
mov    %al,0x7(%rsp)
add    %cl,%cl
add    %al,%cl
movzbl %cl,%esi
mov    %r14,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <BN_rand@plt>
mov    %r13,%rdi
mov    $0x1,%esi
call   10b0 <RAND_bytes@plt>
movzbl (%rbx),%ecx
movzbl 0x7(%rsp),%eax
div    %cl
movzbl %ah,%eax
mov    0x2b8b(%rip),%rdx
sub    (%rdx),%al
mov    %al,0x7(%rsp)
add    %cl,%cl
add    %al,%cl
movzbl %cl,%esi
mov    %r12,%rdi
xor    %edx,%edx
mov    $0x1,%ecx
call   1030 <BN_rand@plt>
mov    %r15,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbp,%rcx
call   1160 <BN_mod@plt>
mov    %r14,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %rbp,%rcx
call   1160 <BN_mod@plt>
mov    0x20(%rsp),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %rbp,%r8
xor    %r9d,%r9d
call   11e0 <BN_mod_exp_mont@plt>
test   %eax,%eax
jle    1729 <main+0x469>
mov    0x10(%rsp),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %rbp,%r8
call   1050 <BN_mod_exp_recp@plt>
test   %eax,%eax
jle    1732 <main+0x472>
mov    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %rbp,%r8
call   10e0 <BN_mod_exp_simple@plt>
test   %eax,%eax
jle    173b <main+0x47b>
mov    0x18(%rsp),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %rbp,%r8
xor    %r9d,%r9d
call   1190 <BN_mod_exp_mont_consttime@plt>
test   %eax,%eax
jle    1744 <main+0x484>
mov    %rbx,%rdi
mov    0x20(%rsp),%rsi
call   1180 <BN_cmp@plt>
test   %rax,%rax
jne    15e0 <main+0x320>
mov    %rbx,%rdi
mov    0x10(%rsp),%rsi
call   1180 <BN_cmp@plt>
test   %rax,%rax
jne    15e0 <main+0x320>
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
call   1180 <BN_cmp@plt>
test   %rax,%rax
jne    15e0 <main+0x320>
mov    $0x2e,%edi
call   1040 <putchar@plt>
mov    0x2a71(%rip),%rax
mov    (%rax),%edi
call   1130 <fflush@plt>
mov    0x2c(%rsp),%eax
add    $0xffffffff,%eax
jne    13a0 <main+0xe0>
mov    0x20(%rsp),%rdi
call   10f0 <BN_free@plt>
mov    0x18(%rsp),%rdi
call   10f0 <BN_free@plt>
mov    0x10(%rsp),%rdi
call   10f0 <BN_free@plt>
mov    %rbx,%rdi
call   10f0 <BN_free@plt>
mov    %r15,%rdi
call   10f0 <BN_free@plt>
mov    %r14,%rdi
call   10f0 <BN_free@plt>
mov    %r12,%rdi
call   10f0 <BN_free@plt>
mov    %rbp,%rdi
call   10d0 <BN_CTX_free@plt>
xor    %edi,%edi
call   1070 <ERR_remove_thread_state@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   11c0 <CRYPTO_mem_leaks@plt>
mov    %rbx,%rdi
call   1150 <BIO_free@plt>
lea    0xa7f(%rip),%rdi
call   1060 <puts@plt>
xor    %edi,%edi
call   11b0 <exit@plt>
mov    %rbx,%rdi
mov    0x20(%rsp),%rsi
call   1180 <BN_cmp@plt>
test   %rax,%rax
je     15fe <main+0x33e>
lea    0xaab(%rip),%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
call   1180 <BN_cmp@plt>
test   %rax,%rax
je     161c <main+0x35c>
lea    0xa62(%rip),%rdi
call   1060 <puts@plt>
mov    %r12,%rbp
mov    %rbx,%rdi
mov    0x10(%rsp),%rsi
call   1180 <BN_cmp@plt>
test   %rax,%rax
je     163d <main+0x37d>
lea    0xa21(%rip),%rdi
call   1060 <puts@plt>
mov    %r15,%rdi
call   10a0 <BN_num_bits@plt>
lea    0x9b4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    0x8(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1120 <BN_print@plt>
mov    %r14,%rdi
call   10a0 <BN_num_bits@plt>
lea    0x997(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1120 <BN_print@plt>
mov    %rbp,%rdi
call   10a0 <BN_num_bits@plt>
lea    0x980(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1120 <BN_print@plt>
lea    0x971(%rip),%rdi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1120 <BN_print@plt>
lea    0x964(%rip),%rdi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    %r12,%rdi
mov    0x10(%rsp),%rsi
call   1120 <BN_print@plt>
lea    0x955(%rip),%rdi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    %r12,%rdi
mov    0x20(%rsp),%rsi
call   1120 <BN_print@plt>
lea    0x946(%rip),%rdi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    %r12,%rdi
mov    0x18(%rsp),%rsi
call   1120 <BN_print@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0x1,%edi
call   11b0 <exit@plt>
lea    0x9f1(%rip),%rdi
jmp    174b <main+0x48b>
lea    0x9cd(%rip),%rdi
jmp    174b <main+0x48b>
lea    0x9a7(%rip),%rdi
jmp    174b <main+0x48b>
lea    0x979(%rip),%rdi
call   1060 <puts@plt>
mov    0x8(%rsp),%rdi
call   1080 <ERR_print_errors@plt>
mov    $0x1,%edi
call   11b0 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@BIO_NOCLOSE = global i32 0
@BN_BITS = global i8 0
@BN_BITS2 = global i8 0
@.str = [28 x i8] c"BN_mod_exp_mont() problems\0A\00"
@.str.1 = [28 x i8] c"BN_mod_exp_recp() problems\0A\00"
@.str.2 = [30 x i8] c"BN_mod_exp_simple() problems\0A\00"
@.str.3 = [38 x i8] c"BN_mod_exp_mont_consttime() problems\0A\00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [33 x i8] c"\0Asimple and mont results differ\0A\00"
@.str.6 = [44 x i8] c"\0Asimple and mont const time results differ\0A\00"
@.str.7 = [33 x i8] c"\0Asimple and recp results differ\0A\00"
@.str.8 = [11 x i8] c"a (%3d) = \00"
@.str.9 = [12 x i8] c"\0Ab (%3d) = \00"
@.str.10 = [12 x i8] c"\0Am (%3d) = \00"
@.str.11 = [12 x i8] c"\0Asimple =\00"
@.str.12 = [12 x i8] c"\0Arecp =\00"
@.str.13 = [12 x i8] c"\0Amont =\00"
@.str.14 = [12 x i8] c"\0Amont_ct =\00"
@.str.15 = [2 x i8] c"\0A\00"
@.str.16 = [7 x i8] c" done\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %7
%18 = call i32 (...) @ERR_load_BN_strings()
%19 = call i32* (...) @BN_CTX_new()
store i32* %19, i32** %6
%20 = load i32*, i32** %6
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %2
%25 = call i32* (...) @BN_new()
store i32* %25, i32** %11
%26 = call i32* (...) @BN_new()
store i32* %26, i32** %12
%27 = call i32* (...) @BN_new()
store i32* %27, i32** %13
%28 = call i32* (...) @BN_new()
store i32* %28, i32** %14
%29 = call i32* (...) @BN_new()
store i32* %29, i32** %15
%30 = call i32* (...) @BN_new()
store i32* %30, i32** %16
%31 = call i32* (...) @BN_new()
store i32* %31, i32** %17
%32 = load i32*, i32** %11
%33 = icmp eq i32* %32, null
br i1 %33, label %43, label %34
34: ; preds = %24
%35 = load i32*, i32** %13
%36 = icmp eq i32* %35, null
br i1 %36, label %43, label %37
37: ; preds = %34
%38 = load i32*, i32** %15
%39 = icmp eq i32* %38, null
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load i32*, i32** %16
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %44
43: ; preds = %40, %37, %34, %24
br label %287
44: ; preds = %40
%45 = call i32 (...) @BIO_s_file()
%46 = call i32* @BIO_new(i32 %45)
store i32* %46, i32** %7
%47 = load i32*, i32** %7
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %51
49: ; preds = %44
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %44
%52 = load i32*, i32** %7
%53 = load i32, i32* @stdout
%54 = load i32, i32* @BIO_NOCLOSE
%55 = call i32 @BIO_set_fp(i32* %52, i32 %53, i32 %54)
store i32 0, i32* %8
br label %56
56: ; preds = %260, %51
%57 = load i32, i32* %8
%58 = icmp slt i32 %57, 200
br i1 %58, label %59, label %263
59: ; preds = %56
%60 = call i32 @RAND_bytes(i8* %10, i32 1)
%61 = load i8, i8* %10
%62 = zext i8 %61 to i32
%63 = load i8, i8* @BN_BITS
%64 = zext i8 %63 to i32
%65 = srem i32 %62, %64
%66 = load i8, i8* @BN_BITS2
%67 = zext i8 %66 to i32
%68 = sub nsw i32 %65, %67
%69 = trunc i32 %68 to i8
store i8 %69, i8* %10
%70 = load i32*, i32** %15
%71 = load i8, i8* @BN_BITS
%72 = zext i8 %71 to i32
%73 = mul nsw i32 %72, 2
%74 = load i8, i8* %10
%75 = zext i8 %74 to i32
%76 = add nsw i32 %73, %75
%77 = trunc i32 %76 to i8
%78 = call i32 @BN_rand(i32* %70, i8 zeroext %77, i32 0, i32 0)
%79 = call i32 @RAND_bytes(i8* %10, i32 1)
%80 = load i8, i8* %10
%81 = zext i8 %80 to i32
%82 = load i8, i8* @BN_BITS
%83 = zext i8 %82 to i32
%84 = srem i32 %81, %83
%85 = load i8, i8* @BN_BITS2
%86 = zext i8 %85 to i32
%87 = sub nsw i32 %84, %86
%88 = trunc i32 %87 to i8
store i8 %88, i8* %10
%89 = load i32*, i32** %16
%90 = load i8, i8* @BN_BITS
%91 = zext i8 %90 to i32
%92 = mul nsw i32 %91, 2
%93 = load i8, i8* %10
%94 = zext i8 %93 to i32
%95 = add nsw i32 %92, %94
%96 = trunc i32 %95 to i8
%97 = call i32 @BN_rand(i32* %89, i8 zeroext %96, i32 0, i32 0)
%98 = call i32 @RAND_bytes(i8* %10, i32 1)
%99 = load i8, i8* %10
%100 = zext i8 %99 to i32
%101 = load i8, i8* @BN_BITS
%102 = zext i8 %101 to i32
%103 = srem i32 %100, %102
%104 = load i8, i8* @BN_BITS2
%105 = zext i8 %104 to i32
%106 = sub nsw i32 %103, %105
%107 = trunc i32 %106 to i8
store i8 %107, i8* %10
%108 = load i32*, i32** %17
%109 = load i8, i8* @BN_BITS
%110 = zext i8 %109 to i32
%111 = mul nsw i32 %110, 2
%112 = load i8, i8* %10
%113 = zext i8 %112 to i32
%114 = add nsw i32 %111, %113
%115 = trunc i32 %114 to i8
%116 = call i32 @BN_rand(i32* %108, i8 zeroext %115, i32 0, i32 1)
%117 = load i32*, i32** %15
%118 = load i32*, i32** %15
%119 = load i32*, i32** %17
%120 = load i32*, i32** %6
%121 = call i32 @BN_mod(i32* %117, i32* %118, i32* %119, i32* %120)
%122 = load i32*, i32** %16
%123 = load i32*, i32** %16
%124 = load i32*, i32** %17
%125 = load i32*, i32** %6
%126 = call i32 @BN_mod(i32* %122, i32* %123, i32* %124, i32* %125)
%127 = load i32*, i32** %11
%128 = load i32*, i32** %15
%129 = load i32*, i32** %16
%130 = load i32*, i32** %17
%131 = load i32*, i32** %6
%132 = call i32 @BN_mod_exp_mont(i32* %127, i32* %128, i32* %129, i32* %130, i32* %131, i32* null)
store i32 %132, i32* %9
%133 = load i32, i32* %9
%134 = icmp sle i32 %133, 0
br i1 %134, label %135, label %140
135: ; preds = %59
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%137 = load i32*, i32** %7
%138 = call i32 @ERR_print_errors(i32* %137)
%139 = call i32 @exit(i32 1)
unreachable
140: ; preds = %59
%141 = load i32*, i32** %13
%142 = load i32*, i32** %15
%143 = load i32*, i32** %16
%144 = load i32*, i32** %17
%145 = load i32*, i32** %6
%146 = call i32 @BN_mod_exp_recp(i32* %141, i32* %142, i32* %143, i32* %144, i32* %145)
store i32 %146, i32* %9
%147 = load i32, i32* %9
%148 = icmp sle i32 %147, 0
br i1 %148, label %149, label %154
149: ; preds = %140
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%151 = load i32*, i32** %7
%152 = call i32 @ERR_print_errors(i32* %151)
%153 = call i32 @exit(i32 1)
unreachable
154: ; preds = %140
%155 = load i32*, i32** %14
%156 = load i32*, i32** %15
%157 = load i32*, i32** %16
%158 = load i32*, i32** %17
%159 = load i32*, i32** %6
%160 = call i32 @BN_mod_exp_simple(i32* %155, i32* %156, i32* %157, i32* %158, i32* %159)
store i32 %160, i32* %9
%161 = load i32, i32* %9
%162 = icmp sle i32 %161, 0
br i1 %162, label %163, label %168
163: ; preds = %154
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%165 = load i32*, i32** %7
%166 = call i32 @ERR_print_errors(i32* %165)
%167 = call i32 @exit(i32 1)
unreachable
168: ; preds = %154
%169 = load i32*, i32** %12
%170 = load i32*, i32** %15
%171 = load i32*, i32** %16
%172 = load i32*, i32** %17
%173 = load i32*, i32** %6
%174 = call i32 @BN_mod_exp_mont_consttime(i32* %169, i32* %170, i32* %171, i32* %172, i32* %173, i32* null)
store i32 %174, i32* %9
%175 = load i32, i32* %9
%176 = icmp sle i32 %175, 0
br i1 %176, label %177, label %182
177: ; preds = %168
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%179 = load i32*, i32** %7
%180 = call i32 @ERR_print_errors(i32* %179)
%181 = call i32 @exit(i32 1)
unreachable
182: ; preds = %168
%183 = load i32*, i32** %14
%184 = load i32*, i32** %11
%185 = call i64 @BN_cmp(i32* %183, i32* %184)
%186 = icmp eq i64 %185, 0
br i1 %186, label %187, label %201
187: ; preds = %182
%188 = load i32*, i32** %14
%189 = load i32*, i32** %13
%190 = call i64 @BN_cmp(i32* %188, i32* %189)
%191 = icmp eq i64 %190, 0
br i1 %191, label %192, label %201
192: ; preds = %187
%193 = load i32*, i32** %14
%194 = load i32*, i32** %12
%195 = call i64 @BN_cmp(i32* %193, i32* %194)
%196 = icmp eq i64 %195, 0
br i1 %196, label %197, label %201
197: ; preds = %192
%198 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%199 = load i32, i32* @stdout
%200 = call i32 @fflush(i32 %199)
br label %259
201: ; preds = %192, %187, %182
%202 = load i32*, i32** %14
%203 = load i32*, i32** %11
%204 = call i64 @BN_cmp(i32* %202, i32* %203)
%205 = icmp ne i64 %204, 0
br i1 %205, label %206, label %208
206: ; preds = %201
%207 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
br label %208
208: ; preds = %206, %201
%209 = load i32*, i32** %14
%210 = load i32*, i32** %12
%211 = call i64 @BN_cmp(i32* %209, i32* %210)
%212 = icmp ne i64 %211, 0
br i1 %212, label %213, label %215
213: ; preds = %208
%214 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
br label %215
215: ; preds = %213, %208
%216 = load i32*, i32** %14
%217 = load i32*, i32** %13
%218 = call i64 @BN_cmp(i32* %216, i32* %217)
%219 = icmp ne i64 %218, 0
br i1 %219, label %220, label %222
220: ; preds = %215
%221 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
br label %222
222: ; preds = %220, %215
%223 = load i32*, i32** %15
%224 = call i32 @BN_num_bits(i32* %223)
%225 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %224)
%226 = load i32*, i32** %7
%227 = load i32*, i32** %15
%228 = call i32 @BN_print(i32* %226, i32* %227)
%229 = load i32*, i32** %16
%230 = call i32 @BN_num_bits(i32* %229)
%231 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %230)
%232 = load i32*, i32** %7
%233 = load i32*, i32** %16
%234 = call i32 @BN_print(i32* %232, i32* %233)
%235 = load i32*, i32** %17
%236 = call i32 @BN_num_bits(i32* %235)
%237 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i32 %236)
%238 = load i32*, i32** %7
%239 = load i32*, i32** %17
%240 = call i32 @BN_print(i32* %238, i32* %239)
%241 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%242 = load i32*, i32** %7
%243 = load i32*, i32** %14
%244 = call i32 @BN_print(i32* %242, i32* %243)
%245 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
%246 = load i32*, i32** %7
%247 = load i32*, i32** %13
%248 = call i32 @BN_print(i32* %246, i32* %247)
%249 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%250 = load i32*, i32** %7
%251 = load i32*, i32** %11
%252 = call i32 @BN_print(i32* %250, i32* %251)
%253 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%254 = load i32*, i32** %7
%255 = load i32*, i32** %12
%256 = call i32 @BN_print(i32* %254, i32* %255)
%257 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%258 = call i32 @exit(i32 1)
unreachable
259: ; preds = %197
br label %260
260: ; preds = %259
%261 = load i32, i32* %8
%262 = add nsw i32 %261, 1
store i32 %262, i32* %8
br label %56
263: ; preds = %56
%264 = load i32*, i32** %11
%265 = call i32 @BN_free(i32* %264)
%266 = load i32*, i32** %12
%267 = call i32 @BN_free(i32* %266)
%268 = load i32*, i32** %13
%269 = call i32 @BN_free(i32* %268)
%270 = load i32*, i32** %14
%271 = call i32 @BN_free(i32* %270)
%272 = load i32*, i32** %15
%273 = call i32 @BN_free(i32* %272)
%274 = load i32*, i32** %16
%275 = call i32 @BN_free(i32* %274)
%276 = load i32*, i32** %17
%277 = call i32 @BN_free(i32* %276)
%278 = load i32*, i32** %6
%279 = call i32 @BN_CTX_free(i32* %278)
%280 = call i32 @ERR_remove_thread_state(i32* null)
%281 = load i32*, i32** %7
%282 = call i32 @CRYPTO_mem_leaks(i32* %281)
%283 = load i32*, i32** %7
%284 = call i32 @BIO_free(i32* %283)
%285 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0))
%286 = call i32 @exit(i32 0)
unreachable
287: ; preds = %43
%288 = call i32 (...) @ERR_load_crypto_strings()
%289 = load i32*, i32** %7
%290 = call i32 @ERR_print_errors(i32* %289)
%291 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stdout = global i32 0
@BIO_NOCLOSE = global i32 0
@BN_BITS = global i8 0
@BN_BITS2 = global i8 0
@.str.8 = [11 x i8] c"a (%3d) = \00"
@.str.9 = [12 x i8] c"\0Ab (%3d) = \00"
@.str.10 = [12 x i8] c"\0Am (%3d) = \00"
@.str.11 = [12 x i8] c"\0Asimple =\00"
@.str.12 = [12 x i8] c"\0Arecp =\00"
@.str.13 = [12 x i8] c"\0Amont =\00"
@.str.14 = [12 x i8] c"\0Amont_ct =\00"
@str = [6 x i8] c" done\00"
@str.17 = [32 x i8] c"\0Asimple and recp results differ\00"
@str.18 = [43 x i8] c"\0Asimple and mont const time results differ\00"
@str.19 = [32 x i8] c"\0Asimple and mont results differ\00"
@str.20 = [37 x i8] c"BN_mod_exp_mont_consttime() problems\00"
@str.21 = [29 x i8] c"BN_mod_exp_simple() problems\00"
@str.22 = [27 x i8] c"BN_mod_exp_recp() problems\00"
@str.23 = [27 x i8] c"BN_mod_exp_mont() problems\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = tail call i32 (...) @ERR_load_BN_strings()
%5 = tail call i32* (...) @BN_CTX_new()
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = tail call i32* (...) @BN_new()
%11 = tail call i32* (...) @BN_new()
%12 = tail call i32* (...) @BN_new()
%13 = tail call i32* (...) @BN_new()
%14 = tail call i32* (...) @BN_new()
%15 = tail call i32* (...) @BN_new()
%16 = tail call i32* (...) @BN_new()
%17 = icmp eq i32* %10, null
%18 = icmp eq i32* %12, null
%19 = select i1 %17, i1 true, i1 %18
%20 = icmp eq i32* %14, null
%21 = select i1 %19, i1 true, i1 %20
%22 = icmp eq i32* %15, null
%23 = select i1 %21, i1 true, i1 %22
br i1 %23, label %156, label %24
24: ; preds = %9
%25 = tail call i32 (...) @BIO_s_file()
%26 = tail call i32* @BIO_new(i32 %25)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %24
%31 = load i32, i32* @stdout
%32 = load i32, i32* @BIO_NOCLOSE
%33 = tail call i32 @BIO_set_fp(i32* %26, i32 %31, i32 %32)
br label %34
34: ; preds = %30, %101
%35 = phi i32 [ 0, %30 ], [ %105, %101 ]
%36 = call i32 @RAND_bytes(i8* %3, i32 1)
%37 = load i8, i8* %3
%38 = load i8, i8* @BN_BITS
%39 = urem i8 %37, %38
%40 = load i8, i8* @BN_BITS2
%41 = sub i8 %39, %40
store i8 %41, i8* %3
%42 = shl i8 %38, 1
%43 = add i8 %41, %42
%44 = call i32 @BN_rand(i32* %14, i8 zeroext %43, i32 0, i32 0)
%45 = call i32 @RAND_bytes(i8* %3, i32 1)
%46 = load i8, i8* %3
%47 = load i8, i8* @BN_BITS
%48 = urem i8 %46, %47
%49 = load i8, i8* @BN_BITS2
%50 = sub i8 %48, %49
store i8 %50, i8* %3
%51 = shl i8 %47, 1
%52 = add i8 %50, %51
%53 = call i32 @BN_rand(i32* %15, i8 zeroext %52, i32 0, i32 0)
%54 = call i32 @RAND_bytes(i8* %3, i32 1)
%55 = load i8, i8* %3
%56 = load i8, i8* @BN_BITS
%57 = urem i8 %55, %56
%58 = load i8, i8* @BN_BITS2
%59 = sub i8 %57, %58
store i8 %59, i8* %3
%60 = shl i8 %56, 1
%61 = add i8 %59, %60
%62 = call i32 @BN_rand(i32* %16, i8 zeroext %61, i32 0, i32 1)
%63 = call i32 @BN_mod(i32* %14, i32* %14, i32* %16, i32* %5)
%64 = call i32 @BN_mod(i32* %15, i32* %15, i32* %16, i32* %5)
%65 = call i32 @BN_mod_exp_mont(i32* %10, i32* %14, i32* %15, i32* %16, i32* %5, i32* null)
%66 = icmp slt i32 %65, 1
br i1 %66, label %67, label %71
67: ; preds = %34
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.23, i64 0, i64 0))
%69 = call i32 @ERR_print_errors(i32* %26)
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %34
%72 = call i32 @BN_mod_exp_recp(i32* %12, i32* %14, i32* %15, i32* %16, i32* %5)
%73 = icmp slt i32 %72, 1
br i1 %73, label %74, label %78
74: ; preds = %71
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.22, i64 0, i64 0))
%76 = call i32 @ERR_print_errors(i32* %26)
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %71
%79 = call i32 @BN_mod_exp_simple(i32* %13, i32* %14, i32* %15, i32* %16, i32* %5)
%80 = icmp slt i32 %79, 1
br i1 %80, label %81, label %85
81: ; preds = %78
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.21, i64 0, i64 0))
%83 = call i32 @ERR_print_errors(i32* %26)
%84 = call i32 @exit(i32 1)
unreachable
85: ; preds = %78
%86 = call i32 @BN_mod_exp_mont_consttime(i32* %11, i32* %14, i32* %15, i32* %16, i32* %5, i32* null)
%87 = icmp slt i32 %86, 1
br i1 %87, label %88, label %92
88: ; preds = %85
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.20, i64 0, i64 0))
%90 = call i32 @ERR_print_errors(i32* %26)
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %85
%93 = call i64 @BN_cmp(i32* %13, i32* %10)
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %107
95: ; preds = %92
%96 = call i64 @BN_cmp(i32* %13, i32* %12)
%97 = icmp eq i64 %96, 0
br i1 %97, label %98, label %107
98: ; preds = %95
%99 = call i64 @BN_cmp(i32* %13, i32* %11)
%100 = icmp eq i64 %99, 0
br i1 %100, label %101, label %107
101: ; preds = %98
%102 = call i32 @putchar(i32 46)
%103 = load i32, i32* @stdout
%104 = call i32 @fflush(i32 %103)
%105 = add nuw nsw i32 %35, 1
%106 = icmp eq i32 %105, 200
br i1 %106, label %142, label %34
107: ; preds = %98, %95, %92
%108 = call i64 @BN_cmp(i32* %13, i32* %10)
%109 = icmp eq i64 %108, 0
br i1 %109, label %112, label %110
110: ; preds = %107
%111 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.19, i64 0, i64 0))
br label %112
112: ; preds = %110, %107
%113 = call i64 @BN_cmp(i32* %13, i32* %11)
%114 = icmp eq i64 %113, 0
br i1 %114, label %117, label %115
115: ; preds = %112
%116 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.18, i64 0, i64 0))
br label %117
117: ; preds = %115, %112
%118 = call i64 @BN_cmp(i32* %13, i32* %12)
%119 = icmp eq i64 %118, 0
br i1 %119, label %122, label %120
120: ; preds = %117
%121 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.17, i64 0, i64 0))
br label %122
122: ; preds = %120, %117
%123 = call i32 @BN_num_bits(i32* %14)
%124 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %123)
%125 = call i32 @BN_print(i32* %26, i32* %14)
%126 = call i32 @BN_num_bits(i32* %15)
%127 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %126)
%128 = call i32 @BN_print(i32* %26, i32* %15)
%129 = call i32 @BN_num_bits(i32* %16)
%130 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i32 %129)
%131 = call i32 @BN_print(i32* %26, i32* %16)
%132 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%133 = call i32 @BN_print(i32* %26, i32* %13)
%134 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
%135 = call i32 @BN_print(i32* %26, i32* %12)
%136 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%137 = call i32 @BN_print(i32* %26, i32* %10)
%138 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%139 = call i32 @BN_print(i32* %26, i32* %11)
%140 = call i32 @putchar(i32 10)
%141 = call i32 @exit(i32 1)
unreachable
142: ; preds = %101
%143 = call i32 @BN_free(i32* %10)
%144 = call i32 @BN_free(i32* %11)
%145 = call i32 @BN_free(i32* %12)
%146 = call i32 @BN_free(i32* %13)
%147 = call i32 @BN_free(i32* %14)
%148 = call i32 @BN_free(i32* %15)
%149 = call i32 @BN_free(i32* %16)
%150 = call i32 @BN_CTX_free(i32* %5)
%151 = call i32 @ERR_remove_thread_state(i32* null)
%152 = call i32 @CRYPTO_mem_leaks(i32* %26)
%153 = call i32 @BIO_free(i32* %26)
%154 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%155 = call i32 @exit(i32 0)
unreachable
156: ; preds = %9
%157 = tail call i32 (...) @ERR_load_crypto_strings()
%158 = tail call i32 @ERR_print_errors(i32* null)
%159 = tail call i32 @exit(i32 1)
unreachable
}