#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*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_cmp_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_gcd(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_urandomm(int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/);
void mpz_random_in_mult_group(mpz_t rop, gmp_randstate_t rstate, mpz_t op) {
  mpz_t t1;
  mpz_init(t1);
  do {
    mpz_urandomm(rop, rstate, op);
    mpz_gcd(t1, rop, op);
  } while (mpz_cmp_ui(t1, 1) != 0);
  mpz_clear(t1);
}


x86 assembly (clang, -O0):
<mpz_random_in_mult_group>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <mpz_init@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1070 <mpz_urandomm@plt>
mov    -0x10(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1060 <mpz_gcd@plt>
mov    -0x10(%rbp),%edi
mov    $0x1,%esi
call   1040 <mpz_cmp_ui@plt>
cmp    $0x0,%rax
jne    1169 <mpz_random_in_mult_group+0x19>
mov    -0x10(%rbp),%edi
call   1050 <mpz_clear@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpz_random_in_mult_group>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
call   1030 <mpz_init@plt>
mov    %ebp,%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1070 <mpz_urandomm@plt>
mov    %ebp,%esi
mov    %ebx,%edx
call   1060 <mpz_gcd@plt>
mov    $0x1,%esi
call   1040 <mpz_cmp_ui@plt>
test   %rax,%rax
jne    1160 <mpz_random_in_mult_group+0x10>
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <mpz_clear@plt>

LLVM IR (-O0):
define void @mpz_random_in_mult_group(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %7
%9 = call i32 @mpz_init(i32 %8)
br label %10
10: ; preds = %19, %3
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = call i32 @mpz_urandomm(i32 %11, i32 %12, i32 %13)
%15 = load i32, i32* %7
%16 = load i32, i32* %4
%17 = load i32, i32* %6
%18 = call i32 @mpz_gcd(i32 %15, i32 %16, i32 %17)
br label %19
19: ; preds = %10
%20 = load i32, i32* %7
%21 = call i64 @mpz_cmp_ui(i32 %20, i32 1)
%22 = icmp ne i64 %21, 0
br i1 %22, label %10, label %23
23: ; preds = %19
%24 = load i32, i32* %7
%25 = call i32 @mpz_clear(i32 %24)
ret void
}

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