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

/* Variables and functions */
int /*<<< orphan*/ generator_gd_compute(int /*<<< orphan*/, int /*<<< orphan*/,
                                        int /*<<< orphan*/, int /*<<< orphan*/,
                                        int /*<<< orphan*/);
int /*<<< orphan*/ generator_gd_precompute(int /*<<< orphan*/,
                                           int /*<<< orphan*/,
                                           int /*<<< orphan*/,
                                           int /*<<< orphan*/,
                                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clears(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/ *);
scalar_t__ mpz_even_p(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_inits(int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ mpz_mod(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
scalar_t__ mpz_probab_prime_p(int /*<<< orphan*/, int);
void internal_fast_random_prime(mpz_t rop, gmp_randstate_t rstate,
                                mp_bitcnt_t bitcnt) {
  mpz_t c, pi, lambda, rho, nu;
  mpz_inits(c, pi, lambda, rho, nu, NULL);
  generator_gd_precompute(pi, nu, lambda, rho, bitcnt);
  generator_gd_compute(c, pi, lambda, rstate, bitcnt);
loop:
  mpz_add(rop, c, rho);
  if (mpz_even_p(rop))
    mpz_add(rop, rop, nu);
  if (mpz_probab_prime_p(rop, 25) == 0) {
    mpz_mul_ui(c, c, 2);
    mpz_mod(c, c, pi);
    goto loop;
  }
  mpz_clears(c, pi, lambda, rho, nu, NULL);
}


x86 assembly (clang, -O0):
<internal_fast_random_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%r9d
call   1070 <mpz_inits@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0xc(%rbp),%r8d
call   1050 <generator_gd_precompute@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
call   10b0 <generator_gd_compute@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1060 <mpz_add@plt>
mov    -0x4(%rbp),%edi
call   1080 <mpz_even_p@plt>
cmp    $0x0,%rax
je     1213 <internal_fast_random_prime+0x83>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1060 <mpz_add@plt>
mov    -0x4(%rbp),%edi
mov    $0x19,%esi
call   1030 <mpz_probab_prime_p@plt>
cmp    $0x0,%rax
jne    124d <internal_fast_random_prime+0xbd>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    $0x2,%edx
call   10a0 <mpz_mul_ui@plt>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1090 <mpz_mod@plt>
jmp    11e5 <internal_fast_random_prime+0x55>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%r9d
call   1040 <mpz_clears@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<internal_fast_random_prime>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%ebx
xor    %r9d,%r9d
call   1070 <mpz_inits@plt>
mov    %ebp,%r8d
call   1050 <generator_gd_precompute@plt>
mov    %r14d,%ecx
mov    %ebp,%r8d
call   10b0 <generator_gd_compute@plt>
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1060 <mpz_add@plt>
mov    %ebx,%edi
call   1080 <mpz_even_p@plt>
test   %rax,%rax
je     11dc <internal_fast_random_prime+0x4c>
mov    %ebx,%edi
mov    %ebx,%esi
call   1060 <mpz_add@plt>
mov    %ebx,%edi
mov    $0x19,%esi
call   1030 <mpz_probab_prime_p@plt>
test   %rax,%rax
jne    11fe <internal_fast_random_prime+0x6e>
mov    $0x2,%edx
call   10a0 <mpz_mul_ui@plt>
call   1090 <mpz_mod@plt>
jmp    11c0 <internal_fast_random_prime+0x30>
xor    %r9d,%r9d
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <mpz_clears@plt>

LLVM IR (-O0):
define void @internal_fast_random_prime(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = load i32, i32* %9
%15 = load i32, i32* %10
%16 = load i32, i32* %11
%17 = call i32 @mpz_inits(i32 %12, i32 %13, i32 %14, i32 %15, i32 %16, i32* null)
%18 = load i32, i32* %8
%19 = load i32, i32* %11
%20 = load i32, i32* %9
%21 = load i32, i32* %10
%22 = load i32, i32* %6
%23 = call i32 @generator_gd_precompute(i32 %18, i32 %19, i32 %20, i32 %21, i32 %22)
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = load i32, i32* %9
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = call i32 @generator_gd_compute(i32 %24, i32 %25, i32 %26, i32 %27, i32 %28)
br label %30
30: ; preds = %47, %3
%31 = load i32, i32* %4
%32 = load i32, i32* %7
%33 = load i32, i32* %10
%34 = call i32 @mpz_add(i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* %4
%36 = call i64 @mpz_even_p(i32 %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %30
%39 = load i32, i32* %4
%40 = load i32, i32* %4
%41 = load i32, i32* %11
%42 = call i32 @mpz_add(i32 %39, i32 %40, i32 %41)
br label %43
43: ; preds = %38, %30
%44 = load i32, i32* %4
%45 = call i64 @mpz_probab_prime_p(i32 %44, i32 25)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %55
47: ; preds = %43
%48 = load i32, i32* %7
%49 = load i32, i32* %7
%50 = call i32 @mpz_mul_ui(i32 %48, i32 %49, i32 2)
%51 = load i32, i32* %7
%52 = load i32, i32* %7
%53 = load i32, i32* %8
%54 = call i32 @mpz_mod(i32 %51, i32 %52, i32 %53)
br label %30
55: ; preds = %43
%56 = load i32, i32* %7
%57 = load i32, i32* %8
%58 = load i32, i32* %9
%59 = load i32, i32* %10
%60 = load i32, i32* %11
%61 = call i32 @mpz_clears(i32 %56, i32 %57, i32 %58, i32 %59, i32 %60, i32* null)
ret void
}

LLVM IR (-O2):
define void @internal_fast_random_prime(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @mpz_inits(i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32* null)
%5 = tail call i32 @generator_gd_precompute(i32 undef, i32 undef, i32 undef, i32 undef, i32 %2)
%6 = tail call i32 @generator_gd_compute(i32 undef, i32 undef, i32 undef, i32 %1, i32 %2)
br label %7
7: ; preds = %16, %3
%8 = tail call i32 @mpz_add(i32 %0, i32 undef, i32 undef)
%9 = tail call i64 @mpz_even_p(i32 %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 @mpz_add(i32 %0, i32 %0, i32 undef)
br label %13
13: ; preds = %11, %7
%14 = tail call i64 @mpz_probab_prime_p(i32 %0, i32 25)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = tail call i32 @mpz_mul_ui(i32 undef, i32 undef, i32 2)
%18 = tail call i32 @mpz_mod(i32 undef, i32 undef, i32 undef)
br label %7
19: ; preds = %13
%20 = tail call i32 @mpz_clears(i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32* null)
ret void
}