#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*/ mpf_t;

/* Variables and functions */
int /*<<< orphan*/ mpf_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_div_2exp(int /*<<< orphan*/, int /*<<< orphan*/,
                                unsigned int);
int /*<<< orphan*/ mpf_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set_prec(int /*<<< orphan*/, double);
int /*<<< orphan*/ mpf_set_ui(int /*<<< orphan*/, int);
void fp_epsilon(mpf_t eps, int prec) {
  static int cache_prec = -1;
  static mpf_t cache_eps;
  if (-1 == cache_prec) {
    mpf_init(cache_eps);
  }
  if (prec == cache_prec) {
    mpf_set(eps, cache_eps);
    return;
  }
  if (cache_prec < prec) {
    mpf_set_prec(cache_eps, 3.322 * prec + 50);
  }
  double mex = ((double)prec) * 3.321928095;
  unsigned int imax = (unsigned int)(mex + 1.0);
  mpf_t one;
  mpf_init(one);
  mpf_set_ui(one, 1);
  mpf_div_2exp(cache_eps, one, imax);
  mpf_set(eps, cache_eps);
  cache_prec = prec;
  mpf_clear(one);
}


x86 assembly (clang, -O0):
<fp_epsilon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0xffffffff,%eax
cmp    0x2ed7(%rip),%eax
jne    118a <fp_epsilon+0x2a>
mov    0x2ed3(%rip),%edi
call   1050 <mpf_init@plt>
mov    -0x8(%rbp),%eax
cmp    0x2ebd(%rip),%eax
jne    11ac <fp_epsilon+0x4c>
mov    -0x4(%rbp),%edi
mov    0x2eb6(%rip),%esi
call   1070 <mpf_set@plt>
jmp    1257 <fp_epsilon+0xf7>
mov    0x2e9e(%rip),%eax
cmp    -0x8(%rbp),%eax
jge    11e3 <fp_epsilon+0x83>
mov    0x2e97(%rip),%edi
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe32(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe2e(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <mpf_set_prec@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe20(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe12(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <mpf_init@plt>
mov    -0x18(%rbp),%edi
mov    $0x1,%esi
call   1080 <mpf_set_ui@plt>
mov    0x2e2b(%rip),%edi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <mpf_div_2exp@plt>
mov    -0x4(%rbp),%edi
mov    0x2e17(%rip),%esi
call   1070 <mpf_set@plt>
mov    -0x8(%rbp),%eax
mov    %eax,0x2e01(%rip)
mov    -0x18(%rbp),%edi
call   1060 <mpf_clear@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fp_epsilon>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%r14d
mov    0x2edd(%rip),%eax
cmp    $0xffffffff,%eax
je     118e <fp_epsilon+0x2e>
cmp    %ebx,%eax
jne    119f <fp_epsilon+0x3f>
mov    %r14d,%edi
xor    %esi,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <mpf_set@plt>
xor    %edi,%edi
call   1050 <mpf_init@plt>
mov    0x2eb5(%rip),%eax
cmp    %ebx,%eax
je     117c <fp_epsilon+0x1c>
cvtsi2sd %ebx,%xmm1
jge    11cc <fp_epsilon+0x6c>
movsd  0xe53(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xe4f(%rip),%xmm0
xor    %edi,%edi
movsd  %xmm1,0x8(%rsp)
call   1040 <mpf_set_prec@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0xe3c(%rip),%xmm1
addsd  0xe3c(%rip),%xmm1
cvttsd2si %xmm1,%rbp
call   1050 <mpf_init@plt>
mov    $0x1,%esi
call   1080 <mpf_set_ui@plt>
xor    %edi,%edi
mov    %ebp,%edx
call   1030 <mpf_div_2exp@plt>
mov    %r14d,%edi
xor    %esi,%esi
call   1070 <mpf_set@plt>
mov    %ebx,0x2e47(%rip)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <mpf_clear@plt>

LLVM IR (-O0):
@fp_epsilon.cache_prec = internal global i32 -1
@fp_epsilon.cache_eps = internal global i32 0
define void @fp_epsilon(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* @fp_epsilon.cache_prec
%9 = icmp eq i32 -1, %8
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @fp_epsilon.cache_eps
%12 = call i32 @mpf_init(i32 %11)
br label %13
13: ; preds = %10, %2
%14 = load i32, i32* %4
%15 = load i32, i32* @fp_epsilon.cache_prec
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i32, i32* %3
%19 = load i32, i32* @fp_epsilon.cache_eps
%20 = call i32 @mpf_set(i32 %18, i32 %19)
br label %52
21: ; preds = %13
%22 = load i32, i32* @fp_epsilon.cache_prec
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i32, i32* @fp_epsilon.cache_eps
%27 = load i32, i32* %4
%28 = sitofp i32 %27 to double
%29 = call double @llvm.fmuladd.f64(double 3.322000e+00, double %28, double 5.000000e+01)
%30 = call i32 @mpf_set_prec(i32 %26, double %29)
br label %31
31: ; preds = %25, %21
%32 = load i32, i32* %4
%33 = sitofp i32 %32 to double
%34 = fmul double %33, 0x400A934F097D8237
store double %34, double* %5
%35 = load double, double* %5
%36 = fadd double %35, 1.000000e+00
%37 = fptoui double %36 to i32
store i32 %37, i32* %6
%38 = load i32, i32* %7
%39 = call i32 @mpf_init(i32 %38)
%40 = load i32, i32* %7
%41 = call i32 @mpf_set_ui(i32 %40, i32 1)
%42 = load i32, i32* @fp_epsilon.cache_eps
%43 = load i32, i32* %7
%44 = load i32, i32* %6
%45 = call i32 @mpf_div_2exp(i32 %42, i32 %43, i32 %44)
%46 = load i32, i32* %3
%47 = load i32, i32* @fp_epsilon.cache_eps
%48 = call i32 @mpf_set(i32 %46, i32 %47)
%49 = load i32, i32* %4
store i32 %49, i32* @fp_epsilon.cache_prec
%50 = load i32, i32* %7
%51 = call i32 @mpf_clear(i32 %50)
br label %52
52: ; preds = %31, %17
ret void
}

LLVM IR (-O2):
@fp_epsilon.cache_prec = internal unnamed_addr global i32 -1
define void @fp_epsilon(i32 %0, i32 %1) {
%3 = load i32, i32* @fp_epsilon.cache_prec
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @mpf_init(i32 0)
%7 = load i32, i32* @fp_epsilon.cache_prec
br label %8
8: ; preds = %5, %2
%9 = phi i32 [ %7, %5 ], [ %3, %2 ]
%10 = icmp eq i32 %9, %1
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @mpf_set(i32 %0, i32 0)
br label %28
13: ; preds = %8
%14 = icmp slt i32 %9, %1
%15 = sitofp i32 %1 to double
br i1 %14, label %16, label %19
16: ; preds = %13
%17 = tail call double @llvm.fmuladd.f64(double %15, double 3.322000e+00, double 5.000000e+01)
%18 = tail call i32 @mpf_set_prec(i32 0, double %17)
br label %19
19: ; preds = %13, %16
%20 = fmul double %15, 0x400A934F097D8237
%21 = fadd double %20, 1.000000e+00
%22 = fptoui double %21 to i32
%23 = tail call i32 @mpf_init(i32 undef)
%24 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%25 = tail call i32 @mpf_div_2exp(i32 0, i32 undef, i32 %22)
%26 = tail call i32 @mpf_set(i32 %0, i32 0)
store i32 %1, i32* @fp_epsilon.cache_prec
%27 = tail call i32 @mpf_clear(i32 undef)
br label %28
28: ; preds = %19, %11
ret void
}