#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*/ gen_generator(int /*<<< orphan*/, int /*<<< orphan*/,
                                 int /*<<< orphan*/);
int /*<<< orphan*/ gen_number(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ gen_prime(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ gen_safe_prime(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ get_rand_seed(int /*<<< orphan*/);
int /*<<< orphan*/ gmp_fprintf(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int /*<<< orphan*/ gmp_randclear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clears(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/ *);
int /*<<< orphan*/ mpz_inits(int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main() {
  mpz_t a;
  mpz_t b;
  mpz_inits(a, b, NULL);
  gmp_randstate_t r_state;
  get_rand_seed(r_state);
  gen_number(a, 10, r_state);
  gmp_fprintf(stderr, "Random number: %Zd\n", a);
  gen_prime(a, 10, r_state);
  gmp_fprintf(stderr, "Random prime: %Zd\n", a);
  gen_safe_prime(a, 10, r_state);
  gmp_fprintf(stderr, "Random safe prime: %Zd\n", a);
  gen_generator(b, a, r_state);
  gmp_fprintf(stderr, "Random gen for ^: %Zd\n", b);
  mpz_clears(a, b, NULL);
  gmp_randclear(r_state);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <mpz_inits@plt>
mov    -0x10(%rbp),%edi
call   1070 <get_rand_seed@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%edx
mov    $0xa,%esi
call   10a0 <gen_number@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe27(%rip),%rsi
call   10b0 <gmp_fprintf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%edx
mov    $0xa,%esi
call   1080 <gen_prime@plt>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe13(%rip),%rsi
call   10b0 <gmp_fprintf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%edx
mov    $0xa,%esi
call   1090 <gen_safe_prime@plt>
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xdfe(%rip),%rsi
call   10b0 <gmp_fprintf@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <gen_generator@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xdf0(%rip),%rsi
call   10b0 <gmp_fprintf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <mpz_clears@plt>
mov    -0x10(%rbp),%edi
call   1030 <gmp_randclear@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edx,%edx
call   1060 <mpz_inits@plt>
call   1070 <get_rand_seed@plt>
mov    $0xa,%esi
call   10a0 <gen_number@plt>
mov    0x2e32(%rip),%rbx
mov    (%rbx),%edi
lea    0xe49(%rip),%rsi
call   10b0 <gmp_fprintf@plt>
mov    $0xa,%esi
call   1080 <gen_prime@plt>
mov    (%rbx),%edi
lea    0xe45(%rip),%rsi
call   10b0 <gmp_fprintf@plt>
mov    $0xa,%esi
call   1090 <gen_safe_prime@plt>
mov    (%rbx),%edi
lea    0xe40(%rip),%rsi
call   10b0 <gmp_fprintf@plt>
call   1040 <gen_generator@plt>
mov    (%rbx),%edi
lea    0xe45(%rip),%rsi
call   10b0 <gmp_fprintf@plt>
xor    %edx,%edx
call   1050 <mpz_clears@plt>
call   1030 <gmp_randclear@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Random number: %Zd\0A\00"
@.str.1 = [19 x i8] c"Random prime: %Zd\0A\00"
@.str.2 = [24 x i8] c"Random safe prime: %Zd\0A\00"
@.str.3 = [23 x i8] c"Random gen for ^: %Zd\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* %2
%6 = load i32, i32* %3
%7 = call i32 @mpz_inits(i32 %5, i32 %6, i32* null)
%8 = load i32, i32* %4
%9 = call i32 @get_rand_seed(i32 %8)
%10 = load i32, i32* %2
%11 = load i32, i32* %4
%12 = call i32 @gen_number(i32 %10, i32 10, i32 %11)
%13 = load i32, i32* @stderr
%14 = load i32, i32* %2
%15 = call i32 @gmp_fprintf(i32 %13, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %2
%17 = load i32, i32* %4
%18 = call i32 @gen_prime(i32 %16, i32 10, i32 %17)
%19 = load i32, i32* @stderr
%20 = load i32, i32* %2
%21 = call i32 @gmp_fprintf(i32 %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %2
%23 = load i32, i32* %4
%24 = call i32 @gen_safe_prime(i32 %22, i32 10, i32 %23)
%25 = load i32, i32* @stderr
%26 = load i32, i32* %2
%27 = call i32 @gmp_fprintf(i32 %25, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = load i32, i32* %4
%31 = call i32 @gen_generator(i32 %28, i32 %29, i32 %30)
%32 = load i32, i32* @stderr
%33 = load i32, i32* %3
%34 = call i32 @gmp_fprintf(i32 %32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = call i32 @mpz_clears(i32 %35, i32 %36, i32* null)
%38 = load i32, i32* %4
%39 = call i32 @gmp_randclear(i32 %38)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Random number: %Zd\0A\00"
@.str.1 = [19 x i8] c"Random prime: %Zd\0A\00"
@.str.2 = [24 x i8] c"Random safe prime: %Zd\0A\00"
@.str.3 = [23 x i8] c"Random gen for ^: %Zd\0A\00"
define i32 @main() {
%1 = tail call i32 @mpz_inits(i32 undef, i32 undef, i32* null)
%2 = tail call i32 @get_rand_seed(i32 undef)
%3 = tail call i32 @gen_number(i32 undef, i32 10, i32 undef)
%4 = load i32, i32* @stderr
%5 = tail call i32 @gmp_fprintf(i32 %4, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 undef)
%6 = tail call i32 @gen_prime(i32 undef, i32 10, i32 undef)
%7 = load i32, i32* @stderr
%8 = tail call i32 @gmp_fprintf(i32 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 undef)
%9 = tail call i32 @gen_safe_prime(i32 undef, i32 10, i32 undef)
%10 = load i32, i32* @stderr
%11 = tail call i32 @gmp_fprintf(i32 %10, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 undef)
%12 = tail call i32 @gen_generator(i32 undef, i32 undef, i32 undef)
%13 = load i32, i32* @stderr
%14 = tail call i32 @gmp_fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 undef)
%15 = tail call i32 @mpz_clears(i32 undef, i32 undef, i32* null)
%16 = tail call i32 @gmp_randclear(i32 undef)
ret i32 0
}