#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*/ mpz_add_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_cmp_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_powm(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_urandomb(int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/);
void generator_gd_compute(mpz_t rop, mpz_t pi, mpz_t lambda,
                          gmp_randstate_t rstate, mp_bitcnt_t bitcnt) {
  mpz_t t1;
  mpz_init(t1);
  mpz_urandomb(rop, rstate, bitcnt);
  do {
    mpz_add_ui(rop, rop, 2);
    mpz_powm(t1, rop, lambda, pi);
  } while (mpz_cmp_ui(t1, 1) != 0);
  mpz_clear(t1);
}


x86 assembly (clang, -O0):
<generator_gd_compute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1060 <mpz_urandomb@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    $0x2,%edx
call   1040 <mpz_add_ui@plt>
mov    -0x18(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
call   1030 <mpz_powm@plt>
mov    -0x18(%rbp),%edi
mov    $0x1,%esi
call   1070 <mpz_cmp_ui@plt>
cmp    $0x0,%rax
jne    118e <generator_gd_compute+0x2e>
mov    -0x18(%rbp),%edi
call   1080 <mpz_clear@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generator_gd_compute>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1050 <mpz_init@plt>
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
call   1060 <mpz_urandomb@plt>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %ebx,%esi
mov    $0x2,%edx
call   1040 <mpz_add_ui@plt>
mov    %ebx,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
call   1030 <mpz_powm@plt>
mov    $0x1,%esi
call   1070 <mpz_cmp_ui@plt>
test   %rax,%rax
jne    1190 <generator_gd_compute+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <mpz_clear@plt>

LLVM IR (-O0):
define void @generator_gd_compute(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* %11
%13 = call i32 @mpz_init(i32 %12)
%14 = load i32, i32* %6
%15 = load i32, i32* %9
%16 = load i32, i32* %10
%17 = call i32 @mpz_urandomb(i32 %14, i32 %15, i32 %16)
br label %18
18: ; preds = %27, %5
%19 = load i32, i32* %6
%20 = load i32, i32* %6
%21 = call i32 @mpz_add_ui(i32 %19, i32 %20, i32 2)
%22 = load i32, i32* %11
%23 = load i32, i32* %6
%24 = load i32, i32* %8
%25 = load i32, i32* %7
%26 = call i32 @mpz_powm(i32 %22, i32 %23, i32 %24, i32 %25)
br label %27
27: ; preds = %18
%28 = load i32, i32* %11
%29 = call i64 @mpz_cmp_ui(i32 %28, i32 1)
%30 = icmp ne i64 %29, 0
br i1 %30, label %18, label %31
31: ; preds = %27
%32 = load i32, i32* %11
%33 = call i32 @mpz_clear(i32 %32)
ret void
}

LLVM IR (-O2):
define void @generator_gd_compute(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @mpz_init(i32 undef)
%7 = tail call i32 @mpz_urandomb(i32 %0, i32 %3, i32 %4)
br label %8
8: ; preds = %8, %5
%9 = tail call i32 @mpz_add_ui(i32 %0, i32 %0, i32 2)
%10 = tail call i32 @mpz_powm(i32 undef, i32 %0, i32 %2, i32 %1)
%11 = tail call i64 @mpz_cmp_ui(i32 undef, i32 1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %8
13: ; preds = %8
%14 = tail call i32 @mpz_clear(i32 undef)
ret void
}