#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;

/* Variables and functions */
int /*<<< orphan*/ gmp_randinit_default(int /*<<< orphan*/);
int /*<<< orphan*/ gmp_randseed_ui(int /*<<< orphan*/, int /*<<< orphan*/);
int millerRabin(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_ui(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_urandomb(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void primeKeyGeneration(mpz_t p) {
  gmp_randstate_t state;
  gmp_randinit_default(state);
  gmp_randseed_ui(state, time(NULL));
  int isPrime = 0;
  while (isPrime == 0) {
    mpz_set_ui(p, 0);
    mpz_urandomb(p, state, 1024);
    isPrime = millerRabin(p);
  }
}


x86 assembly (clang, -O0):
<primeKeyGeneration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x8(%rbp),%edi
call   1080 <gmp_randinit_default@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%esi
call   1060 <gmp_randseed_ui@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11c7 <primeKeyGeneration+0x67>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1050 <mpz_set_ui@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x400,%edx
call   1030 <mpz_urandomb@plt>
mov    -0x4(%rbp),%edi
call   1070 <millerRabin@plt>
mov    %eax,-0xc(%rbp)
jmp    1193 <primeKeyGeneration+0x33>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primeKeyGeneration>:
push   %rbx
mov    %edi,%ebx
call   1080 <gmp_randinit_default@plt>
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%esi
call   1060 <gmp_randseed_ui@plt>
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <mpz_set_ui@plt>
mov    %ebx,%edi
mov    $0x400,%edx
call   1030 <mpz_urandomb@plt>
mov    %ebx,%edi
call   1070 <millerRabin@plt>
test   %eax,%eax
je     1180 <primeKeyGeneration+0x20>
pop    %rbx
ret

LLVM IR (-O0):
define void @primeKeyGeneration(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %3
%6 = call i32 @gmp_randinit_default(i32 %5)
%7 = load i32, i32* %3
%8 = call i32 @time(i32* null)
%9 = call i32 @gmp_randseed_ui(i32 %7, i32 %8)
store i32 0, i32* %4
br label %10
10: ; preds = %13, %1
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = load i32, i32* %2
%15 = call i32 @mpz_set_ui(i32 %14, i32 0)
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 @mpz_urandomb(i32 %16, i32 %17, i32 1024)
%19 = load i32, i32* %2
%20 = call i32 @millerRabin(i32 %19)
store i32 %20, i32* %4
br label %10
21: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @primeKeyGeneration(i32 %0) {
%2 = tail call i32 @gmp_randinit_default(i32 undef)
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @gmp_randseed_ui(i32 undef, i32 %3)
br label %5
5: ; preds = %1, %5
%6 = tail call i32 @mpz_set_ui(i32 %0, i32 0)
%7 = tail call i32 @mpz_urandomb(i32 %0, i32 undef, i32 1024)
%8 = tail call i32 @millerRabin(i32 %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %5, label %10
10: ; preds = %5
ret void
}