#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_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_urandomm(int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/);
void gen_range(mpz_t rop, mpz_t min, mpz_t max, gmp_randstate_t r_state) {
  mpz_t tmax;
  mpz_init(tmax);
  mpz_sub(tmax, max, min);
  mpz_urandomm(rop, r_state, tmax);
  mpz_add(rop, rop, min);
  mpz_clear(tmax);
}


x86 assembly (clang, -O0):
<gen_range>:
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    -0x14(%rbp),%edi
call   1040 <mpz_init@plt>
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1030 <mpz_sub@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1070 <mpz_urandomm@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <mpz_add@plt>
mov    -0x14(%rbp),%edi
call   1060 <mpz_clear@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_range>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
call   1040 <mpz_init@plt>
mov    %r15d,%esi
mov    %ebx,%edx
call   1030 <mpz_sub@plt>
mov    %ebp,%edi
mov    %r14d,%esi
call   1070 <mpz_urandomm@plt>
mov    %ebp,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1050 <mpz_add@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <mpz_clear@plt>

LLVM IR (-O0):
define void @gen_range(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %9
%11 = call i32 @mpz_init(i32 %10)
%12 = load i32, i32* %9
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = call i32 @mpz_sub(i32 %12, i32 %13, i32 %14)
%16 = load i32, i32* %5
%17 = load i32, i32* %8
%18 = load i32, i32* %9
%19 = call i32 @mpz_urandomm(i32 %16, i32 %17, i32 %18)
%20 = load i32, i32* %5
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = call i32 @mpz_add(i32 %20, i32 %21, i32 %22)
%24 = load i32, i32* %9
%25 = call i32 @mpz_clear(i32 %24)
ret void
}

LLVM IR (-O2):
define void @gen_range(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @mpz_init(i32 undef)
%6 = tail call i32 @mpz_sub(i32 undef, i32 %2, i32 %1)
%7 = tail call i32 @mpz_urandomm(i32 %0, i32 %3, i32 undef)
%8 = tail call i32 @mpz_add(i32 %0, i32 %0, i32 %1)
%9 = tail call i32 @mpz_clear(i32 undef)
ret void
}