// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/./mini-gmp/mini-gmp.c
// Function: mpz_probab_prime_p
int
mpz_probab_prime_p (const mpz_t n, int reps)
{
  mpz_t nm1;
  mpz_t q;
  mpz_t y;
  mp_bitcnt_t k;
  int is_prime;
  int j;

  /* Note that we use the absolute value of n only, for compatibility
     with the real GMP. */
  if (mpz_even_p (n))
    return (mpz_cmpabs_ui (n, 2) == 0) ? 2 : 0;

  /* Above test excludes n == 0 */
  assert (n->_mp_size != 0);

  if (mpz_cmpabs_ui (n, 64) < 0)
    return (GMP_PRIME_MASK >> (n->_mp_d[0] >> 1)) & 2;

  if (mpz_gcd_ui (NULL, n, GMP_PRIME_PRODUCT) != 1)
    return 0;

  /* All prime factors are >= 31. */
  if (mpz_cmpabs_ui (n, 31*31) < 0)
    return 2;

  /* Use Miller-Rabin, with a deterministic sequence of bases, a[j] =
     j^2 + j + 41 using Euler's polynomial. We potentially stop early,
     if a[j] >= n - 1. Since n >= 31*31, this can happen only if reps >
     30 (a[30] == 971 > 31*31 == 961). */

  mpz_init (nm1);
  mpz_init (q);
  mpz_init (y);

  /* Find q and k, where q is odd and n = 1 + 2**k * q.  */
  nm1->_mp_size = mpz_abs_sub_ui (nm1, n, 1);
  k = mpz_scan1 (nm1, 0);
  mpz_tdiv_q_2exp (q, nm1, k);

  for (j = 0, is_prime = 1; is_prime & (j < reps); j++)
    {
      mpz_set_ui (y, (unsigned long) j*j+j+41);
      if (mpz_cmp (y, nm1) >= 0)
	{
	  /* Don't try any further bases. This "early" break does not affect
	     the result for any reasonable reps value (<=5000 was tested) */
	  assert (j >= 30);
	  break;
	}
      is_prime = gmp_millerrabin (n, nm1, y, q, k);
    }
  mpz_clear (nm1);
  mpz_clear (q);
  mpz_clear (y);

  return is_prime;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x4(%rdi)
sete %al
movq 0x8(%rdi), %rcx
movq (%rcx), %r15
testb $0x1, %r15b
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x5d68
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x29a4
xorl %r12d, %r12d
testl %eax, %eax
sete %r12b
addl %r12d, %r12d
jmp 0x5f67
movl %esi, %r14d
pushq $0x40
popq %rsi
movq %rbx, %rdi
callq 0x29a4
testl %eax, %eax
js 0x5f1b
xorl %r12d, %r12d
movl $0xc0cfd797, %edx       # imm = 0xC0CFD797
xorl %edi, %edi
movq %rbx, %rsi
callq 0x3f23
cmpq $0x1, %rax
jne 0x5f67
movl $0x3c1, %esi            # imm = 0x3C1
movq %rbx, %rdi
callq 0x29a4
testl %eax, %eax
js 0x5f37
movl %r14d, -0x30(%rbp)
pushq $0x1
popq %r14
leaq -0x50(%rbp), %r15
movq %r14, (%r15)
pushq $0x8
popq %r12
movq %r12, %rdi
callq *0x92cd(%rip)           # 0xf098
movq %rax, 0x8(%r15)
leaq -0x70(%rbp), %r13
movq %r14, (%r13)
movq %r12, %rdi
callq *0x92b8(%rip)           # 0xf098
movq %rax, 0x8(%r13)
leaq -0x60(%rbp), %r13
movq %r14, (%r13)
movq %r12, %rdi
callq *0x92a3(%rip)           # 0xf098
movq %rax, 0x8(%r13)
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2b25
movl %eax, 0x4(%r15)
xorl %r14d, %r14d
movq %r15, %rdi
xorl %esi, %esi
callq 0x5fb7
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
movq %rax, -0x38(%rbp)
movq %rax, %rdx
callq 0x38a6
movslq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
pushq $0x1
popq %rax
movl %eax, %r12d
testl %r12d, %r12d
je 0x5f43
cmpq -0x30(%rbp), %r14
jge 0x5f43
leaq 0x1(%r14), %r15
movq %r15, %rax
imulq %r14, %rax
addq $0x29, %rax
movq -0x58(%rbp), %rcx
movq %rax, (%rcx)
movl $0x1, -0x5c(%rbp)
movq %r13, %rdi
leaq -0x50(%rbp), %rsi
callq 0x2963
testl %eax, %eax
jns 0x5f3d
cmpq $0x0, -0x38(%rbp)
je 0x5f79
movq %r13, %rdi
movq %r13, %rsi
leaq -0x70(%rbp), %rdx
movq %rbx, %rcx
callq 0x4cac
movq %r13, %rdi
pushq $0x1
popq %rsi
callq 0x292a
movq %r15, %r14
pushq $0x1
popq %rcx
movl %ecx, %r12d
testl %eax, %eax
je 0x5e39
movq %r13, %rdi
leaq -0x50(%rbp), %rsi
callq 0x2963
movq %r15, %r14
pushq $0x1
popq %rcx
movl %ecx, %r12d
testl %eax, %eax
je 0x5e39
movq -0x38(%rbp), %r14
xorl %r12d, %r12d
decq %r14
je 0x5f0b
movq %r13, %rdi
movq %r13, %rsi
pushq $0x2
popq %rdx
movq %rbx, %rcx
callq 0x553a
movq %r13, %rdi
leaq -0x50(%rbp), %rsi
callq 0x2963
testl %eax, %eax
je 0x5f13
movq %r13, %rdi
pushq $0x1
popq %rsi
callq 0x292a
testl %eax, %eax
jg 0x5ed3
movq %r15, %r14
jmp 0x5e39
movq %r15, %r14
jmp 0x5e33
shrl %r15d
movl $0xc0cfd797, %r12d      # imm = 0xC0CFD797
addq $0x899bf45, %r12        # imm = 0x899BF45
movl %r15d, %ecx
shrq %cl, %r12
andl $0x2, %r12d
jmp 0x5f67
pushq $0x2
popq %r12
jmp 0x5f67
cmpq $0x1d, %r14
jbe 0x5f98
movq -0x48(%rbp), %rdi
xorl %esi, %esi
callq *0x9159(%rip)           # 0xf0a8
movq -0x68(%rbp), %rdi
xorl %esi, %esi
callq *0x914d(%rip)           # 0xf0a8
movq -0x58(%rbp), %rdi
xorl %esi, %esi
callq *0x9141(%rip)           # 0xf0a8
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x468f(%rip), %rdi      # 0xa60f
leaq 0x30dd(%rip), %rsi      # 0x9064
leaq 0x4687(%rip), %rcx      # 0xa615
movl $0xd1a, %edx            # imm = 0xD1A
callq 0x1090
leaq 0x36ef(%rip), %rdi      # 0x968e
leaq 0x30be(%rip), %rsi      # 0x9064
leaq 0x36af(%rip), %rcx      # 0x965c
movl $0xd68, %edx            # imm = 0xD68
callq 0x1090