#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*/ mpz_t;
typedef int /*<<< orphan*/ gmp_randstate_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ gmp_randclear(int /*<<< orphan*/);
int /*<<< orphan*/ gmp_randinit_default(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
scalar_t__ mpz_legendre(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mod(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_nextprime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_out_str(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_powm(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_str(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ mpz_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_urandomm(int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/);
int /*<<< orphan*/ number_theory_exp_modp(int /*<<< orphan*/,
                                          int /*<<< orphan*/,
                                          int /*<<< orphan*/,
                                          int /*<<< orphan*/);
int /*<<< orphan*/ number_theory_exp_modp_ui(int /*<<< orphan*/,
                                             int /*<<< orphan*/, int,
                                             int /*<<< orphan*/);
int /*<<< orphan*/ number_theory_inverse(int /*<<< orphan*/, int /*<<< orphan*/,
                                         int /*<<< orphan*/);
scalar_t__ number_theory_legendre(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ number_theory_squareroot_modp(int /*<<< orphan*/,
                                                 int /*<<< orphan*/,
                                                 int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ random_seeding(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
bool test_number_theory(FILE *out) {
  fprintf(out, "\n--- Test number theory ---\n");
  gmp_randstate_t rstate;
  gmp_randinit_default(rstate);
  random_seeding(rstate);
  mpz_t top;
  mpz_init(top);
  mpz_set_str(top, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 16);
  mpz_t i1;
  mpz_init(i1);
  mpz_t i2;
  mpz_init(i2);
  mpz_t i3;
  mpz_init(i3);
  mpz_t r1;
  mpz_init(r1);
  mpz_t r2;
  mpz_init(r2);
  mpz_t t1;
  mpz_init(t1);
  mpz_t t2;
  mpz_init(t2);
  bool exp_mod = true, sqrt_mod = true, mul_inv = true, legendre = true;
  int i;
  for (i = 0; i < 500; i++) {
    mpz_urandomm(i1, rstate, top);
    mpz_urandomm(i2, rstate, i1);
    mpz_urandomm(i3, rstate, i1);
    mpz_powm(r1, i2, i3, i1);
    number_theory_exp_modp(r2, i2, i3, i1);
    if (mpz_cmp(r1, r2) != 0) {
      exp_mod = false;
      break;
    }
  }
  if (exp_mod)
    fprintf(out, "Modular explonentiation:      Ok\n");
  else
    fprintf(out, "Modular explonentiation:      Failed!\n");
  for (i = 0; i < 500; i++) {
    mpz_urandomm(i2, rstate, top);
    mpz_nextprime(i1, i2);
    mpz_urandomm(i2, rstate, i1);
    number_theory_exp_modp_ui(i3, i2, 2, i1);
    number_theory_squareroot_modp(r1, i3, i1);
    mpz_sub(r2, i1, r1);
    if (mpz_cmp(i2, r1) != 0 && mpz_cmp(i2, r2) != 0) {
      sqrt_mod = false;
      break;
    }
  }
  if (sqrt_mod)
    fprintf(out, "Squaring modulo prime:        Ok\n");
  else
    fprintf(out, "Squaring modulo prime:        Failed!\n");
  mpz_set_ui(r1, 1);
  for (i = 0; i < 500; i++) {
    mpz_urandomm(i2, rstate, top);
    mpz_nextprime(i1, i2);
    mpz_urandomm(i2, rstate, i1);
    number_theory_inverse(t1, i2, i1);
    mpz_mul(t2, t1, i2);
    mpz_mod(r2, t2, i1);
    if (mpz_cmp(r1, r2) != 0) {
      mul_inv = false;
      break;
    }
  }
  if (mul_inv)
    fprintf(out, "Extended euclidean algorithm: Ok\n");
  else
    fprintf(out, "Extended euclidean algorithm: Failed!\n");
  for (i = 0; i < 500; i++) {
    mpz_urandomm(i2, rstate, top);
    mpz_nextprime(i1, i2);
    mpz_urandomm(i2, rstate, i1);
    if (mpz_legendre(i2, i1) != number_theory_legendre(i2, i1)) {
      printf("\np:");
      mpz_out_str(stdout, 10, i1);
      printf("\na:");
      mpz_out_str(stdout, 10, i2);
      printf("\n");
      legendre = false;
      break;
    }
  }
  if (legendre)
    fprintf(out, "Legendre symbol test:         Ok\n");
  else
    fprintf(out, "Legendre symbol test:         Failed!\n");
  if (exp_mod && sqrt_mod && mul_inv && legendre)
    fprintf(out, "Number theory tests successfully completed %i times.\n", 500);
  else
    fprintf(out, "Number theory tests failed!\n");
  gmp_randclear(rstate);
  mpz_clear(r1);
  mpz_clear(r2);
  mpz_clear(i1);
  mpz_clear(i2);
  mpz_clear(i3);
  mpz_clear(t1);
  mpz_clear(t2);
  return exp_mod && sqrt_mod && mul_inv && legendre;
}


x86 assembly (clang, -O0):
<test_number_theory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xd79(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0xc(%rbp),%edi
call   1170 <gmp_randinit_default@plt>
mov    -0xc(%rbp),%edi
call   1180 <random_seeding@plt>
mov    -0x10(%rbp),%edi
call   10b0 <mpz_init@plt>
mov    -0x10(%rbp),%edi
lea    0xd6d(%rip),%rsi
mov    $0x10,%edx
call   1100 <mpz_set_str@plt>
mov    -0x14(%rbp),%edi
call   10b0 <mpz_init@plt>
mov    -0x18(%rbp),%edi
call   10b0 <mpz_init@plt>
mov    -0x1c(%rbp),%edi
call   10b0 <mpz_init@plt>
mov    -0x20(%rbp),%edi
call   10b0 <mpz_init@plt>
mov    -0x24(%rbp),%edi
call   10b0 <mpz_init@plt>
mov    -0x28(%rbp),%edi
call   10b0 <mpz_init@plt>
mov    -0x2c(%rbp),%edi
call   10b0 <mpz_init@plt>
movl   $0x1,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
movl   $0x1,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0x1f4,-0x40(%rbp)
jge    13a2 <test_number_theory+0x132>
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1190 <mpz_urandomm@plt>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1190 <mpz_urandomm@plt>
mov    -0x1c(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1190 <mpz_urandomm@plt>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <mpz_powm@plt>
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1120 <number_theory_exp_modp@plt>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1130 <mpz_cmp@plt>
cmp    $0x0,%rax
je     138f <test_number_theory+0x11f>
movl   $0x0,-0x30(%rbp)
jmp    13a2 <test_number_theory+0x132>
jmp    1394 <test_number_theory+0x124>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1315 <test_number_theory+0xa5>
cmpl   $0x0,-0x30(%rbp)
je     13c3 <test_number_theory+0x153>
mov    -0x8(%rbp),%rdi
lea    0xc87(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    13d5 <test_number_theory+0x165>
mov    -0x8(%rbp),%rdi
lea    0xc92(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x1f4,-0x40(%rbp)
jge    1488 <test_number_theory+0x218>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1190 <mpz_urandomm@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   10f0 <mpz_nextprime@plt>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1190 <mpz_urandomm@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%ecx
mov    $0x2,%edx
call   10a0 <number_theory_exp_modp_ui@plt>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1110 <number_theory_squareroot_modp@plt>
mov    -0x24(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1060 <mpz_sub@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1130 <mpz_cmp@plt>
cmp    $0x0,%rax
je     1475 <test_number_theory+0x205>
mov    -0x18(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1130 <mpz_cmp@plt>
cmp    $0x0,%rax
je     1475 <test_number_theory+0x205>
movl   $0x0,-0x34(%rbp)
jmp    1488 <test_number_theory+0x218>
jmp    147a <test_number_theory+0x20a>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    13dc <test_number_theory+0x16c>
cmpl   $0x0,-0x34(%rbp)
je     14a9 <test_number_theory+0x239>
mov    -0x8(%rbp),%rdi
lea    0xbea(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    14bb <test_number_theory+0x24b>
mov    -0x8(%rbp),%rdi
lea    0xbf5(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x20(%rbp),%edi
mov    $0x1,%esi
call   1140 <mpz_set_ui@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x1f4,-0x40(%rbp)
jge    1561 <test_number_theory+0x2f1>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1190 <mpz_urandomm@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   10f0 <mpz_nextprime@plt>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1190 <mpz_urandomm@plt>
mov    -0x28(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <number_theory_inverse@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10d0 <mpz_mul@plt>
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1150 <mpz_mod@plt>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1130 <mpz_cmp@plt>
cmp    $0x0,%rax
je     154e <test_number_theory+0x2de>
movl   $0x0,-0x38(%rbp)
jmp    1561 <test_number_theory+0x2f1>
jmp    1553 <test_number_theory+0x2e3>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    14cf <test_number_theory+0x25f>
cmpl   $0x0,-0x38(%rbp)
je     1582 <test_number_theory+0x312>
mov    -0x8(%rbp),%rdi
lea    0xb5a(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    1594 <test_number_theory+0x324>
mov    -0x8(%rbp),%rdi
lea    0xb65(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x1f4,-0x40(%rbp)
jge    1668 <test_number_theory+0x3f8>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1190 <mpz_urandomm@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   10f0 <mpz_nextprime@plt>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1190 <mpz_urandomm@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1080 <mpz_legendre@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1070 <number_theory_legendre@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
je     1655 <test_number_theory+0x3e5>
lea    0xb19(%rip),%rdi
call   1090 <printf@plt>
mov    0x29d4(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    $0xa,%esi
call   10e0 <mpz_out_str@plt>
lea    0xafb(%rip),%rdi
call   1090 <printf@plt>
mov    0x29b2(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
mov    $0xa,%esi
call   10e0 <mpz_out_str@plt>
lea    0xb24(%rip),%rdi
call   1090 <printf@plt>
movl   $0x0,-0x3c(%rbp)
jmp    1668 <test_number_theory+0x3f8>
jmp    165a <test_number_theory+0x3ea>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    159b <test_number_theory+0x32b>
cmpl   $0x0,-0x3c(%rbp)
je     1689 <test_number_theory+0x419>
mov    -0x8(%rbp),%rdi
lea    0xaa4(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    169b <test_number_theory+0x42b>
mov    -0x8(%rbp),%rdi
lea    0xaaf(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
cmpl   $0x0,-0x30(%rbp)
je     16df <test_number_theory+0x46f>
cmpl   $0x0,-0x34(%rbp)
je     16df <test_number_theory+0x46f>
cmpl   $0x0,-0x38(%rbp)
je     16df <test_number_theory+0x46f>
cmpl   $0x0,-0x3c(%rbp)
je     16df <test_number_theory+0x46f>
mov    -0x8(%rbp),%rdi
lea    0xa9c(%rip),%rsi
mov    $0x1f4,%edx
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    16f1 <test_number_theory+0x481>
mov    -0x8(%rbp),%rdi
lea    0xab6(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0xc(%rbp),%edi
call   1050 <gmp_randclear@plt>
mov    -0x20(%rbp),%edi
call   1160 <mpz_clear@plt>
mov    -0x24(%rbp),%edi
call   1160 <mpz_clear@plt>
mov    -0x14(%rbp),%edi
call   1160 <mpz_clear@plt>
mov    -0x18(%rbp),%edi
call   1160 <mpz_clear@plt>
mov    -0x1c(%rbp),%edi
call   1160 <mpz_clear@plt>
mov    -0x28(%rbp),%edi
call   1160 <mpz_clear@plt>
mov    -0x2c(%rbp),%edi
call   1160 <mpz_clear@plt>
xor    %eax,%eax
cmpl   $0x0,-0x30(%rbp)
mov    %al,-0x49(%rbp)
je     1768 <test_number_theory+0x4f8>
xor    %eax,%eax
cmpl   $0x0,-0x34(%rbp)
mov    %al,-0x49(%rbp)
je     1768 <test_number_theory+0x4f8>
xor    %eax,%eax
cmpl   $0x0,-0x38(%rbp)
mov    %al,-0x49(%rbp)
je     1768 <test_number_theory+0x4f8>
cmpl   $0x0,-0x3c(%rbp)
setne  %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_number_theory>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xd5b(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1180 <fwrite@plt>
call   1190 <gmp_randinit_default@plt>
call   11a0 <random_seeding@plt>
call   10c0 <mpz_init@plt>
lea    0xd50(%rip),%rsi
mov    $0x10,%edx
call   1110 <mpz_set_str@plt>
call   10c0 <mpz_init@plt>
call   10c0 <mpz_init@plt>
call   10c0 <mpz_init@plt>
call   10c0 <mpz_init@plt>
call   10c0 <mpz_init@plt>
call   10c0 <mpz_init@plt>
call   10c0 <mpz_init@plt>
xor    %ebx,%ebx
mov    $0x1,%bpl
nop
call   11b0 <mpz_urandomm@plt>
call   11b0 <mpz_urandomm@plt>
call   11b0 <mpz_urandomm@plt>
call   1040 <mpz_powm@plt>
call   1130 <number_theory_exp_modp@plt>
call   1140 <mpz_cmp@plt>
test   %rax,%rax
jne    1347 <test_number_theory+0xb7>
cmp    $0x1f3,%ebx
lea    0x1(%rbx),%eax
setb   %bpl
mov    %eax,%ebx
cmp    $0x1f4,%eax
jne    1300 <test_number_theory+0x70>
lea    0xcfe(%rip),%rdi
mov    $0x21,%esi
jmp    1353 <test_number_theory+0xc3>
lea    0xd12(%rip),%rdi
mov    $0x26,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1180 <fwrite@plt>
xor    %ebx,%ebx
mov    $0x1,%r15b
jmp    1386 <test_number_theory+0xf6>
nopw   0x0(%rax,%rax,1)
cmp    $0x1f3,%ebx
lea    0x1(%rbx),%eax
setb   %r15b
mov    %eax,%ebx
cmp    $0x1f4,%eax
je     13cb <test_number_theory+0x13b>
call   11b0 <mpz_urandomm@plt>
call   1100 <mpz_nextprime@plt>
call   11b0 <mpz_urandomm@plt>
mov    $0x2,%edx
call   10b0 <number_theory_exp_modp_ui@plt>
call   1120 <number_theory_squareroot_modp@plt>
call   1070 <mpz_sub@plt>
call   1140 <mpz_cmp@plt>
test   %rax,%rax
je     1370 <test_number_theory+0xe0>
call   1140 <mpz_cmp@plt>
test   %rax,%rax
je     1370 <test_number_theory+0xe0>
lea    0xce5(%rip),%rdi
mov    $0x26,%esi
jmp    13d7 <test_number_theory+0x147>
lea    0xcb5(%rip),%rdi
mov    $0x21,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1180 <fwrite@plt>
mov    $0x1,%esi
call   1150 <mpz_set_ui@plt>
xor    %ebx,%ebx
mov    $0x1,%r13b
mov    %r14,(%rsp)
nopw   0x0(%rax,%rax,1)
call   11b0 <mpz_urandomm@plt>
call   1100 <mpz_nextprime@plt>
call   11b0 <mpz_urandomm@plt>
call   1050 <number_theory_inverse@plt>
call   10e0 <mpz_mul@plt>
call   1160 <mpz_mod@plt>
call   1140 <mpz_cmp@plt>
test   %rax,%rax
jne    144c <test_number_theory+0x1bc>
cmp    $0x1f3,%ebx
lea    0x1(%rbx),%eax
setb   %r13b
mov    %eax,%ebx
cmp    $0x1f4,%eax
jne    1400 <test_number_theory+0x170>
lea    0xc8b(%rip),%rdi
mov    $0x21,%esi
jmp    1458 <test_number_theory+0x1c8>
lea    0xc9f(%rip),%rdi
mov    $0x26,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1180 <fwrite@plt>
xor    %eax,%eax
mov    $0x1,%r12b
nopw   0x0(%rax,%rax,1)
mov    %eax,%r14d
call   11b0 <mpz_urandomm@plt>
call   1100 <mpz_nextprime@plt>
call   11b0 <mpz_urandomm@plt>
call   1090 <mpz_legendre@plt>
mov    %rax,%rbx
call   1080 <number_theory_legendre@plt>
cmp    %rax,%rbx
jne    150a <test_number_theory+0x27a>
lea    0x1(%r14),%eax
cmp    $0x1f3,%r14d
setb   %r12b
cmp    $0x1f4,%eax
jne    1470 <test_number_theory+0x1e0>
cmp    $0x1f3,%r14d
setae  %r12b
lea    0xc65(%rip),%rdi
mov    $0x21,%esi
mov    $0x1,%edx
mov    (%rsp),%rcx
call   1180 <fwrite@plt>
or     %r15b,%bpl
or     %r13b,%bpl
test   $0x1,%bpl
jne    1574 <test_number_theory+0x2e4>
cmp    $0x1f3,%r14d
jb     1574 <test_number_theory+0x2e4>
lea    0xc77(%rip),%rsi
xor    %ebp,%ebp
mov    (%rsp),%rdi
mov    $0x1f4,%edx
xor    %eax,%eax
call   10d0 <fprintf@plt>
jmp    1591 <test_number_theory+0x301>
lea    0xc08(%rip),%rdi
call   10a0 <printf@plt>
mov    0x2ac3(%rip),%rbx
mov    (%rbx),%edi
mov    $0xa,%esi
call   10f0 <mpz_out_str@plt>
lea    0xbed(%rip),%rdi
call   10a0 <printf@plt>
mov    (%rbx),%edi
mov    $0xa,%esi
call   10f0 <mpz_out_str@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    $0x1,%r12b
lea    0xbed(%rip),%rdi
mov    $0x26,%esi
mov    $0x1,%edx
mov    (%rsp),%rbx
mov    %rbx,%rcx
call   1180 <fwrite@plt>
or     %r15b,%bpl
or     %r13b,%bpl
jmp    1578 <test_number_theory+0x2e8>
mov    (%rsp),%rbx
lea    0xc21(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1180 <fwrite@plt>
call   1060 <gmp_randclear@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
call   1170 <mpz_clear@plt>
not    %bpl
and    %r12b,%bpl
movzbl %bpl,%eax
and    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"\0A--- Test number theory ---\0A\00"
@.str.1 = [33 x i8] c"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\00"
@.str.2 = [34 x i8] c"Modular explonentiation: Ok\0A\00"
@.str.3 = [39 x i8] c"Modular explonentiation: Failed!\0A\00"
@.str.4 = [34 x i8] c"Squaring modulo prime: Ok\0A\00"
@.str.5 = [39 x i8] c"Squaring modulo prime: Failed!\0A\00"
@.str.6 = [34 x i8] c"Extended euclidean algorithm: Ok\0A\00"
@.str.7 = [39 x i8] c"Extended euclidean algorithm: Failed!\0A\00"
@.str.8 = [4 x i8] c"\0Ap:\00"
@stdout = global i32 0
@.str.9 = [4 x i8] c"\0Aa:\00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [34 x i8] c"Legendre symbol test: Ok\0A\00"
@.str.12 = [39 x i8] c"Legendre symbol test: Failed!\0A\00"
@.str.13 = [54 x i8] c"Number theory tests successfully completed %i times.\0A\00"
@.str.14 = [29 x i8] c"Number theory tests failed!\0A\00"
define i32 @test_number_theory(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%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
store i32* %0, i32** %2
%17 = load i32*, i32** %2
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* %3
%20 = call i32 @gmp_randinit_default(i32 %19)
%21 = load i32, i32* %3
%22 = call i32 @random_seeding(i32 %21)
%23 = load i32, i32* %4
%24 = call i32 @mpz_init(i32 %23)
%25 = load i32, i32* %4
%26 = call i32 @mpz_set_str(i32 %25, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 16)
%27 = load i32, i32* %5
%28 = call i32 @mpz_init(i32 %27)
%29 = load i32, i32* %6
%30 = call i32 @mpz_init(i32 %29)
%31 = load i32, i32* %7
%32 = call i32 @mpz_init(i32 %31)
%33 = load i32, i32* %8
%34 = call i32 @mpz_init(i32 %33)
%35 = load i32, i32* %9
%36 = call i32 @mpz_init(i32 %35)
%37 = load i32, i32* %10
%38 = call i32 @mpz_init(i32 %37)
%39 = load i32, i32* %11
%40 = call i32 @mpz_init(i32 %39)
store i32 1, i32* %12
store i32 1, i32* %13
store i32 1, i32* %14
store i32 1, i32* %15
store i32 0, i32* %16
br label %41
41: ; preds = %73, %1
%42 = load i32, i32* %16
%43 = icmp slt i32 %42, 500
br i1 %43, label %44, label %76
44: ; preds = %41
%45 = load i32, i32* %5
%46 = load i32, i32* %3
%47 = load i32, i32* %4
%48 = call i32 @mpz_urandomm(i32 %45, i32 %46, i32 %47)
%49 = load i32, i32* %6
%50 = load i32, i32* %3
%51 = load i32, i32* %5
%52 = call i32 @mpz_urandomm(i32 %49, i32 %50, i32 %51)
%53 = load i32, i32* %7
%54 = load i32, i32* %3
%55 = load i32, i32* %5
%56 = call i32 @mpz_urandomm(i32 %53, i32 %54, i32 %55)
%57 = load i32, i32* %8
%58 = load i32, i32* %6
%59 = load i32, i32* %7
%60 = load i32, i32* %5
%61 = call i32 @mpz_powm(i32 %57, i32 %58, i32 %59, i32 %60)
%62 = load i32, i32* %9
%63 = load i32, i32* %6
%64 = load i32, i32* %7
%65 = load i32, i32* %5
%66 = call i32 @number_theory_exp_modp(i32 %62, i32 %63, i32 %64, i32 %65)
%67 = load i32, i32* %8
%68 = load i32, i32* %9
%69 = call i64 @mpz_cmp(i32 %67, i32 %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %44
store i32 0, i32* %12
br label %76
72: ; preds = %44
br label %73
73: ; preds = %72
%74 = load i32, i32* %16
%75 = add nsw i32 %74, 1
store i32 %75, i32* %16
br label %41
76: ; preds = %71, %41
%77 = load i32, i32* %12
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %76
%80 = load i32*, i32** %2
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %85
82: ; preds = %76
%83 = load i32*, i32** %2
%84 = call i32 (i32*, i8*, ...) @fprintf(i32* %83, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
br label %85
85: ; preds = %82, %79
store i32 0, i32* %16
br label %86
86: ; preds = %124, %85
%87 = load i32, i32* %16
%88 = icmp slt i32 %87, 500
br i1 %88, label %89, label %127
89: ; preds = %86
%90 = load i32, i32* %6
%91 = load i32, i32* %3
%92 = load i32, i32* %4
%93 = call i32 @mpz_urandomm(i32 %90, i32 %91, i32 %92)
%94 = load i32, i32* %5
%95 = load i32, i32* %6
%96 = call i32 @mpz_nextprime(i32 %94, i32 %95)
%97 = load i32, i32* %6
%98 = load i32, i32* %3
%99 = load i32, i32* %5
%100 = call i32 @mpz_urandomm(i32 %97, i32 %98, i32 %99)
%101 = load i32, i32* %7
%102 = load i32, i32* %6
%103 = load i32, i32* %5
%104 = call i32 @number_theory_exp_modp_ui(i32 %101, i32 %102, i32 2, i32 %103)
%105 = load i32, i32* %8
%106 = load i32, i32* %7
%107 = load i32, i32* %5
%108 = call i32 @number_theory_squareroot_modp(i32 %105, i32 %106, i32 %107)
%109 = load i32, i32* %9
%110 = load i32, i32* %5
%111 = load i32, i32* %8
%112 = call i32 @mpz_sub(i32 %109, i32 %110, i32 %111)
%113 = load i32, i32* %6
%114 = load i32, i32* %8
%115 = call i64 @mpz_cmp(i32 %113, i32 %114)
%116 = icmp ne i64 %115, 0
br i1 %116, label %117, label %123
117: ; preds = %89
%118 = load i32, i32* %6
%119 = load i32, i32* %9
%120 = call i64 @mpz_cmp(i32 %118, i32 %119)
%121 = icmp ne i64 %120, 0
br i1 %121, label %122, label %123
122: ; preds = %117
store i32 0, i32* %13
br label %127
123: ; preds = %117, %89
br label %124
124: ; preds = %123
%125 = load i32, i32* %16
%126 = add nsw i32 %125, 1
store i32 %126, i32* %16
br label %86
127: ; preds = %122, %86
%128 = load i32, i32* %13
%129 = icmp ne i32 %128, 0
br i1 %129, label %130, label %133
130: ; preds = %127
%131 = load i32*, i32** %2
%132 = call i32 (i32*, i8*, ...) @fprintf(i32* %131, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %136
133: ; preds = %127
%134 = load i32*, i32** %2
%135 = call i32 (i32*, i8*, ...) @fprintf(i32* %134, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
br label %136
136: ; preds = %133, %130
%137 = load i32, i32* %8
%138 = call i32 @mpz_set_ui(i32 %137, i32 1)
store i32 0, i32* %16
br label %139
139: ; preds = %172, %136
%140 = load i32, i32* %16
%141 = icmp slt i32 %140, 500
br i1 %141, label %142, label %175
142: ; preds = %139
%143 = load i32, i32* %6
%144 = load i32, i32* %3
%145 = load i32, i32* %4
%146 = call i32 @mpz_urandomm(i32 %143, i32 %144, i32 %145)
%147 = load i32, i32* %5
%148 = load i32, i32* %6
%149 = call i32 @mpz_nextprime(i32 %147, i32 %148)
%150 = load i32, i32* %6
%151 = load i32, i32* %3
%152 = load i32, i32* %5
%153 = call i32 @mpz_urandomm(i32 %150, i32 %151, i32 %152)
%154 = load i32, i32* %10
%155 = load i32, i32* %6
%156 = load i32, i32* %5
%157 = call i32 @number_theory_inverse(i32 %154, i32 %155, i32 %156)
%158 = load i32, i32* %11
%159 = load i32, i32* %10
%160 = load i32, i32* %6
%161 = call i32 @mpz_mul(i32 %158, i32 %159, i32 %160)
%162 = load i32, i32* %9
%163 = load i32, i32* %11
%164 = load i32, i32* %5
%165 = call i32 @mpz_mod(i32 %162, i32 %163, i32 %164)
%166 = load i32, i32* %8
%167 = load i32, i32* %9
%168 = call i64 @mpz_cmp(i32 %166, i32 %167)
%169 = icmp ne i64 %168, 0
br i1 %169, label %170, label %171
170: ; preds = %142
store i32 0, i32* %14
br label %175
171: ; preds = %142
br label %172
172: ; preds = %171
%173 = load i32, i32* %16
%174 = add nsw i32 %173, 1
store i32 %174, i32* %16
br label %139
175: ; preds = %170, %139
%176 = load i32, i32* %14
%177 = icmp ne i32 %176, 0
br i1 %177, label %178, label %181
178: ; preds = %175
%179 = load i32*, i32** %2
%180 = call i32 (i32*, i8*, ...) @fprintf(i32* %179, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %184
181: ; preds = %175
%182 = load i32*, i32** %2
%183 = call i32 (i32*, i8*, ...) @fprintf(i32* %182, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
br label %184
184: ; preds = %181, %178
store i32 0, i32* %16
br label %185
185: ; preds = %218, %184
%186 = load i32, i32* %16
%187 = icmp slt i32 %186, 500
br i1 %187, label %188, label %221
188: ; preds = %185
%189 = load i32, i32* %6
%190 = load i32, i32* %3
%191 = load i32, i32* %4
%192 = call i32 @mpz_urandomm(i32 %189, i32 %190, i32 %191)
%193 = load i32, i32* %5
%194 = load i32, i32* %6
%195 = call i32 @mpz_nextprime(i32 %193, i32 %194)
%196 = load i32, i32* %6
%197 = load i32, i32* %3
%198 = load i32, i32* %5
%199 = call i32 @mpz_urandomm(i32 %196, i32 %197, i32 %198)
%200 = load i32, i32* %6
%201 = load i32, i32* %5
%202 = call i64 @mpz_legendre(i32 %200, i32 %201)
%203 = load i32, i32* %6
%204 = load i32, i32* %5
%205 = call i64 @number_theory_legendre(i32 %203, i32 %204)
%206 = icmp ne i64 %202, %205
br i1 %206, label %207, label %217
207: ; preds = %188
%208 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%209 = load i32, i32* @stdout
%210 = load i32, i32* %5
%211 = call i32 @mpz_out_str(i32 %209, i32 10, i32 %210)
%212 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%213 = load i32, i32* @stdout
%214 = load i32, i32* %6
%215 = call i32 @mpz_out_str(i32 %213, i32 10, i32 %214)
%216 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %15
br label %221
217: ; preds = %188
br label %218
218: ; preds = %217
%219 = load i32, i32* %16
%220 = add nsw i32 %219, 1
store i32 %220, i32* %16
br label %185
221: ; preds = %207, %185
%222 = load i32, i32* %15
%223 = icmp ne i32 %222, 0
br i1 %223, label %224, label %227
224: ; preds = %221
%225 = load i32*, i32** %2
%226 = call i32 (i32*, i8*, ...) @fprintf(i32* %225, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0))
br label %230
227: ; preds = %221
%228 = load i32*, i32** %2
%229 = call i32 (i32*, i8*, ...) @fprintf(i32* %228, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0))
br label %230
230: ; preds = %227, %224
%231 = load i32, i32* %12
%232 = icmp ne i32 %231, 0
br i1 %232, label %233, label %245
233: ; preds = %230
%234 = load i32, i32* %13
%235 = icmp ne i32 %234, 0
br i1 %235, label %236, label %245
236: ; preds = %233
%237 = load i32, i32* %14
%238 = icmp ne i32 %237, 0
br i1 %238, label %239, label %245
239: ; preds = %236
%240 = load i32, i32* %15
%241 = icmp ne i32 %240, 0
br i1 %241, label %242, label %245
242: ; preds = %239
%243 = load i32*, i32** %2
%244 = call i32 (i32*, i8*, ...) @fprintf(i32* %243, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.13, i64 0, i64 0), i32 500)
br label %248
245: ; preds = %239, %236, %233, %230
%246 = load i32*, i32** %2
%247 = call i32 (i32*, i8*, ...) @fprintf(i32* %246, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.14, i64 0, i64 0))
br label %248
248: ; preds = %245, %242
%249 = load i32, i32* %3
%250 = call i32 @gmp_randclear(i32 %249)
%251 = load i32, i32* %8
%252 = call i32 @mpz_clear(i32 %251)
%253 = load i32, i32* %9
%254 = call i32 @mpz_clear(i32 %253)
%255 = load i32, i32* %5
%256 = call i32 @mpz_clear(i32 %255)
%257 = load i32, i32* %6
%258 = call i32 @mpz_clear(i32 %257)
%259 = load i32, i32* %7
%260 = call i32 @mpz_clear(i32 %259)
%261 = load i32, i32* %10
%262 = call i32 @mpz_clear(i32 %261)
%263 = load i32, i32* %11
%264 = call i32 @mpz_clear(i32 %263)
%265 = load i32, i32* %12
%266 = icmp ne i32 %265, 0
br i1 %266, label %267, label %276
267: ; preds = %248
%268 = load i32, i32* %13
%269 = icmp ne i32 %268, 0
br i1 %269, label %270, label %276
270: ; preds = %267
%271 = load i32, i32* %14
%272 = icmp ne i32 %271, 0
br i1 %272, label %273, label %276
273: ; preds = %270
%274 = load i32, i32* %15
%275 = icmp ne i32 %274, 0
br label %276
276: ; preds = %273, %270, %267, %248
%277 = phi i1 [ false, %270 ], [ false, %267 ], [ false, %248 ], [ %275, %273 ]
%278 = zext i1 %277 to i32
ret i32 %278
}

LLVM IR (-O2):
@.str = [29 x i8] c"\0A--- Test number theory ---\0A\00"
@.str.1 = [33 x i8] c"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\00"
@.str.2 = [34 x i8] c"Modular explonentiation: Ok\0A\00"
@.str.3 = [39 x i8] c"Modular explonentiation: Failed!\0A\00"
@.str.4 = [34 x i8] c"Squaring modulo prime: Ok\0A\00"
@.str.5 = [39 x i8] c"Squaring modulo prime: Failed!\0A\00"
@.str.6 = [34 x i8] c"Extended euclidean algorithm: Ok\0A\00"
@.str.7 = [39 x i8] c"Extended euclidean algorithm: Failed!\0A\00"
@.str.8 = [4 x i8] c"\0Ap:\00"
@stdout = global i32 0
@.str.9 = [4 x i8] c"\0Aa:\00"
@.str.11 = [34 x i8] c"Legendre symbol test: Ok\0A\00"
@.str.12 = [39 x i8] c"Legendre symbol test: Failed!\0A\00"
@.str.13 = [54 x i8] c"Number theory tests successfully completed %i times.\0A\00"
@.str.14 = [29 x i8] c"Number theory tests failed!\0A\00"
define i32 @test_number_theory(i32* nocapture %0) {
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 28, i64 1, i32* %0)
%3 = tail call i32 @gmp_randinit_default(i32 undef)
%4 = tail call i32 @random_seeding(i32 undef)
%5 = tail call i32 @mpz_init(i32 undef)
%6 = tail call i32 @mpz_set_str(i32 undef, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 16)
%7 = tail call i32 @mpz_init(i32 undef)
%8 = tail call i32 @mpz_init(i32 undef)
%9 = tail call i32 @mpz_init(i32 undef)
%10 = tail call i32 @mpz_init(i32 undef)
%11 = tail call i32 @mpz_init(i32 undef)
%12 = tail call i32 @mpz_init(i32 undef)
%13 = tail call i32 @mpz_init(i32 undef)
br label %18
14: ; preds = %18
%15 = add nuw nsw i32 %20, 1
%16 = icmp ult i32 %20, 499
%17 = icmp eq i32 %15, 500
br i1 %17, label %28, label %18
18: ; preds = %1, %14
%19 = phi i1 [ true, %1 ], [ %16, %14 ]
%20 = phi i32 [ 0, %1 ], [ %15, %14 ]
%21 = tail call i32 @mpz_urandomm(i32 undef, i32 undef, i32 undef)
%22 = tail call i32 @mpz_urandomm(i32 undef, i32 undef, i32 undef)
%23 = tail call i32 @mpz_urandomm(i32 undef, i32 undef, i32 undef)
%24 = tail call i32 @mpz_powm(i32 undef, i32 undef, i32 undef, i32 undef)
%25 = tail call i32 @number_theory_exp_modp(i32 undef, i32 undef, i32 undef, i32 undef)
%26 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%27 = icmp eq i64 %26, 0
br i1 %27, label %14, label %30
28: ; preds = %14
%29 = tail call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i64 33, i64 1, i32* %0)
br label %32
30: ; preds = %18
%31 = tail call i64 @fwrite(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i64 38, i64 1, i32* %0)
br label %32
32: ; preds = %30, %28
%33 = phi i1 [ %19, %30 ], [ %16, %28 ]
br label %34
34: ; preds = %32, %48
%35 = phi i1 [ true, %32 ], [ %50, %48 ]
%36 = phi i32 [ 0, %32 ], [ %49, %48 ]
%37 = tail call i32 @mpz_urandomm(i32 undef, i32 undef, i32 undef)
%38 = tail call i32 @mpz_nextprime(i32 undef, i32 undef)
%39 = tail call i32 @mpz_urandomm(i32 undef, i32 undef, i32 undef)
%40 = tail call i32 @number_theory_exp_modp_ui(i32 undef, i32 undef, i32 2, i32 undef)
%41 = tail call i32 @number_theory_squareroot_modp(i32 undef, i32 undef, i32 undef)
%42 = tail call i32 @mpz_sub(i32 undef, i32 undef, i32 undef)
%43 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%44 = icmp eq i64 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %34
%46 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %54
48: ; preds = %34, %45
%49 = add nuw nsw i32 %36, 1
%50 = icmp ult i32 %36, 499
%51 = icmp eq i32 %49, 500
br i1 %51, label %52, label %34
52: ; preds = %48
%53 = tail call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i64 33, i64 1, i32* %0)
br label %56
54: ; preds = %45
%55 = tail call i64 @fwrite(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i64 38, i64 1, i32* %0)
br label %56
56: ; preds = %54, %52
%57 = phi i1 [ %35, %54 ], [ %50, %52 ]
%58 = tail call i32 @mpz_set_ui(i32 undef, i32 1)
br label %63
59: ; preds = %63
%60 = add nuw nsw i32 %65, 1
%61 = icmp ult i32 %65, 499
%62 = icmp eq i32 %60, 500
br i1 %62, label %74, label %63
63: ; preds = %56, %59
%64 = phi i1 [ true, %56 ], [ %61, %59 ]
%65 = phi i32 [ 0, %56 ], [ %60, %59 ]
%66 = tail call i32 @mpz_urandomm(i32 undef, i32 undef, i32 undef)
%67 = tail call i32 @mpz_nextprime(i32 undef, i32 undef)
%68 = tail call i32 @mpz_urandomm(i32 undef, i32 undef, i32 undef)
%69 = tail call i32 @number_theory_inverse(i32 undef, i32 undef, i32 undef)
%70 = tail call i32 @mpz_mul(i32 undef, i32 undef, i32 undef)
%71 = tail call i32 @mpz_mod(i32 undef, i32 undef, i32 undef)
%72 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%73 = icmp eq i64 %72, 0
br i1 %73, label %59, label %76
74: ; preds = %59
%75 = tail call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i64 33, i64 1, i32* %0)
br label %78
76: ; preds = %63
%77 = tail call i64 @fwrite(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i64 38, i64 1, i32* %0)
br label %78
78: ; preds = %76, %74
%79 = phi i1 [ %64, %76 ], [ %61, %74 ]
br label %84
80: ; preds = %84
%81 = add nuw nsw i32 %86, 1
%82 = icmp ult i32 %86, 499
%83 = icmp eq i32 %81, 500
br i1 %83, label %105, label %84
84: ; preds = %78, %80
%85 = phi i1 [ true, %78 ], [ %82, %80 ]
%86 = phi i32 [ 0, %78 ], [ %81, %80 ]
%87 = tail call i32 @mpz_urandomm(i32 undef, i32 undef, i32 undef)
%88 = tail call i32 @mpz_nextprime(i32 undef, i32 undef)
%89 = tail call i32 @mpz_urandomm(i32 undef, i32 undef, i32 undef)
%90 = tail call i64 @mpz_legendre(i32 undef, i32 undef)
%91 = tail call i64 @number_theory_legendre(i32 undef, i32 undef)
%92 = icmp eq i64 %90, %91
br i1 %92, label %80, label %93
93: ; preds = %84
%94 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%95 = load i32, i32* @stdout
%96 = tail call i32 @mpz_out_str(i32 %95, i32 10, i32 undef)
%97 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%98 = load i32, i32* @stdout
%99 = tail call i32 @mpz_out_str(i32 %98, i32 10, i32 undef)
%100 = tail call i32 @putchar(i32 10)
%101 = xor i1 %85, true
%102 = tail call i64 @fwrite(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i64 38, i64 1, i32* %0)
%103 = select i1 %33, i1 true, i1 %57
%104 = select i1 %103, i1 true, i1 %79
br label %113
105: ; preds = %80
%106 = xor i1 %82, true
%107 = tail call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i64 33, i64 1, i32* %0)
%108 = select i1 %33, i1 true, i1 %57
%109 = select i1 %108, i1 true, i1 %79
%110 = select i1 %109, i1 true, i1 %82
br i1 %110, label %113, label %111
111: ; preds = %105
%112 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.13, i64 0, i64 0), i32 500)
br label %117
113: ; preds = %93, %105
%114 = phi i1 [ %104, %93 ], [ %109, %105 ]
%115 = phi i1 [ %101, %93 ], [ %106, %105 ]
%116 = tail call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.14, i64 0, i64 0), i64 28, i64 1, i32* %0)
br label %117
117: ; preds = %113, %111
%118 = phi i1 [ %114, %113 ], [ false, %111 ]
%119 = phi i1 [ %115, %113 ], [ %106, %111 ]
%120 = tail call i32 @gmp_randclear(i32 undef)
%121 = tail call i32 @mpz_clear(i32 undef)
%122 = tail call i32 @mpz_clear(i32 undef)
%123 = tail call i32 @mpz_clear(i32 undef)
%124 = tail call i32 @mpz_clear(i32 undef)
%125 = tail call i32 @mpz_clear(i32 undef)
%126 = tail call i32 @mpz_clear(i32 undef)
%127 = tail call i32 @mpz_clear(i32 undef)
%128 = xor i1 %118, true
%129 = select i1 %128, i1 %119, i1 false
%130 = zext i1 %129 to i32
ret i32 %130
}