#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*/ uint32_t;
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_max_int(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_min_int(int /*<<< orphan*/, int /*<<< orphan*/);
bool mpz_fits(mpz_t z, uint32_t k) {
  mpz_t min, max;
  bool fits;
  mpz_init(min);
  mpz_init(max);
  mpz_set_min_int(min, k);
  mpz_set_max_int(max, k);
  fits = mpz_cmp(min, z) <= 0 && mpz_cmp(z, max) <= 0;
  mpz_clear(min);
  mpz_clear(max);
  return fits;
}


x86 assembly (clang, -O0):
<mpz_fits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <mpz_init@plt>
mov    -0x10(%rbp),%edi
call   1030 <mpz_init@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1070 <mpz_set_min_int@plt>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <mpz_set_max_int@plt>
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1050 <mpz_cmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x15(%rbp)
jg     11b6 <mpz_fits+0x66>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <mpz_cmp@plt>
cmp    $0x0,%rax
setle  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <mpz_clear@plt>
mov    -0x10(%rbp),%edi
call   1060 <mpz_clear@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpz_fits>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <mpz_init@plt>
call   1030 <mpz_init@plt>
mov    %ebp,%esi
call   1070 <mpz_set_min_int@plt>
mov    %ebp,%esi
call   1040 <mpz_set_max_int@plt>
mov    %ebx,%esi
call   1050 <mpz_cmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jg     118d <mpz_fits+0x3d>
mov    %ebx,%edi
call   1050 <mpz_cmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
setle  %bpl
call   1060 <mpz_clear@plt>
call   1060 <mpz_clear@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mpz_fits(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %5
%9 = call i32 @mpz_init(i32 %8)
%10 = load i32, i32* %6
%11 = call i32 @mpz_init(i32 %10)
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = call i32 @mpz_set_min_int(i32 %12, i32 %13)
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = call i32 @mpz_set_max_int(i32 %15, i32 %16)
%18 = load i32, i32* %5
%19 = load i32, i32* %3
%20 = call i64 @mpz_cmp(i32 %18, i32 %19)
%21 = icmp sle i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %2
%23 = load i32, i32* %3
%24 = load i32, i32* %6
%25 = call i64 @mpz_cmp(i32 %23, i32 %24)
%26 = icmp sle i64 %25, 0
br label %27
27: ; preds = %22, %2
%28 = phi i1 [ false, %2 ], [ %26, %22 ]
%29 = zext i1 %28 to i32
store i32 %29, i32* %7
%30 = load i32, i32* %5
%31 = call i32 @mpz_clear(i32 %30)
%32 = load i32, i32* %6
%33 = call i32 @mpz_clear(i32 %32)
%34 = load i32, i32* %7
ret i32 %34
}

LLVM IR (-O2):
define i32 @mpz_fits(i32 %0, i32 %1) {
%3 = tail call i32 @mpz_init(i32 undef)
%4 = tail call i32 @mpz_init(i32 undef)
%5 = tail call i32 @mpz_set_min_int(i32 undef, i32 %1)
%6 = tail call i32 @mpz_set_max_int(i32 undef, i32 %1)
%7 = tail call i64 @mpz_cmp(i32 undef, i32 %0)
%8 = icmp slt i64 %7, 1
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = tail call i64 @mpz_cmp(i32 %0, i32 undef)
%11 = icmp slt i64 %10, 1
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %9, %2
%14 = phi i32 [ 0, %2 ], [ %12, %9 ]
%15 = tail call i32 @mpz_clear(i32 undef)
%16 = tail call i32 @mpz_clear(i32 undef)
ret i32 %14
}