#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*/ internal_naive_random_prime(int /*<<< orphan*/,
                                               int /*<<< orphan*/,
                                               int /*<<< orphan*/);
int /*<<< orphan*/ mpz_divexact_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
scalar_t__ mpz_probab_prime_p(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_sub_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
void internal_fast_random_safe_prime(mpz_t rop1, mpz_t rop2,
                                     gmp_randstate_t rstate,
                                     mp_bitcnt_t bitcnt) {
  do {
    internal_naive_random_prime(rop1, rstate, bitcnt);
    mpz_sub_ui(rop2, rop1, 1);
    mpz_divexact_ui(rop2, rop2, 2);
  } while (mpz_probab_prime_p(rop2, 25) == 0);
}


x86 assembly (clang, -O0):
<internal_fast_random_safe_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <internal_naive_random_prime@plt>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
call   1060 <mpz_sub_ui@plt>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x2,%edx
call   1040 <mpz_divexact_ui@plt>
mov    -0x8(%rbp),%edi
mov    $0x19,%esi
call   1030 <mpz_probab_prime_p@plt>
cmp    $0x0,%rax
je     1154 <internal_fast_random_safe_prime+0x14>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<internal_fast_random_safe_prime>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r15d,%esi
mov    %r14d,%edx
call   1050 <internal_naive_random_prime@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    $0x1,%edx
call   1060 <mpz_sub_ui@plt>
mov    %ebx,%edi
mov    %ebx,%esi
mov    $0x2,%edx
call   1040 <mpz_divexact_ui@plt>
mov    %ebx,%edi
mov    $0x19,%esi
call   1030 <mpz_probab_prime_p@plt>
test   %rax,%rax
je     1160 <internal_fast_random_safe_prime+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @internal_fast_random_safe_prime(i32 %0, i32 %1, i32 %2, i32 %3) {
br label %5
5: ; preds = %5, %4
%6 = tail call i32 @internal_naive_random_prime(i32 %0, i32 %2, i32 %3)
%7 = tail call i32 @mpz_sub_ui(i32 %1, i32 %0, i32 1)
%8 = tail call i32 @mpz_divexact_ui(i32 %1, i32 %1, i32 2)
%9 = tail call i64 @mpz_probab_prime_p(i32 %1, i32 25)
%10 = icmp eq i64 %9, 0
br i1 %10, label %5, label %11
11: ; preds = %5
ret void
}