#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*/ fp_e_pi(int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ mpf_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_add_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_clear(int /*<<< orphan*/);
scalar_t__ mpf_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpf_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_mul_2exp(int /*<<< orphan*/, int /*<<< orphan*/,
                                unsigned int);
int /*<<< orphan*/ mpf_pow_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_sub_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_ui_div(int /*<<< orphan*/, int, int /*<<< orphan*/);
void fp_ess(mpf_t ess_plus, mpf_t ess_minus, unsigned int k,
            unsigned int prec) {
  mpf_t e_pi, en, enp, epip, eppos, epneg, term, oterm, acc;
  mpf_init(e_pi);
  mpf_init(en);
  mpf_init(enp);
  mpf_init(epip);
  mpf_init(eppos);
  mpf_init(epneg);
  mpf_init(term);
  mpf_init(oterm);
  mpf_init(acc);
  fp_e_pi(e_pi, prec);
  mpf_set_ui(ess_plus, 0);
  mpf_set_ui(ess_minus, 0);
  double mex = ((double)prec) * 3.321928095;
  unsigned int imax = (unsigned int)(mex + 1.0);
  mpf_t maxterm, one;
  mpf_init(maxterm);
  mpf_init(one);
  mpf_set_ui(one, 1);
  mpf_mul_2exp(maxterm, one, imax);
  int n;
  for (n = 1; n < 1000000000; n++) {
    mpf_set_ui(en, n);
    mpf_pow_ui(enp, en, k);
    mpf_pow_ui(epip, e_pi, 2 * n);
    mpf_add_ui(eppos, epip, 1);
    mpf_sub_ui(epneg, epip, 1);
    mpf_mul(term, enp, eppos);
    mpf_ui_div(oterm, 1, term);
    mpf_add(acc, ess_plus, oterm);
    mpf_set(ess_plus, acc);
    mpf_mul(term, enp, epneg);
    mpf_ui_div(oterm, 1, term);
    mpf_add(acc, ess_minus, oterm);
    mpf_set(ess_minus, acc);
    if (mpf_cmp(term, maxterm) > 0)
      break;
  }
  mpf_clear(e_pi);
  mpf_clear(en);
  mpf_clear(enp);
  mpf_clear(epip);
  mpf_clear(eppos);
  mpf_clear(epneg);
  mpf_clear(term);
  mpf_clear(oterm);
  mpf_clear(acc);
  mpf_clear(one);
  mpf_clear(maxterm);
}


x86 assembly (clang, -O0):
<fp_ess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x14(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x18(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x1c(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x20(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x24(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x28(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x2c(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x30(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x34(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
call   10c0 <fp_e_pi@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
mov    %esi,-0x54(%rbp)
call   10b0 <mpf_set_ui@plt>
mov    -0x54(%rbp),%esi
mov    -0x8(%rbp),%edi
call   10b0 <mpf_set_ui@plt>
mov    -0x10(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xda1(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xd93(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,-0x44(%rbp)
mov    -0x48(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x4c(%rbp),%edi
call   1080 <mpf_init@plt>
mov    -0x4c(%rbp),%edi
mov    $0x1,%esi
call   10b0 <mpf_set_ui@plt>
mov    -0x48(%rbp),%edi
mov    -0x4c(%rbp),%esi
mov    -0x44(%rbp),%edx
call   1040 <mpf_mul_2exp@plt>
movl   $0x1,-0x50(%rbp)
cmpl   $0x3b9aca00,-0x50(%rbp)
jge    13a5 <fp_ess+0x1d5>
mov    -0x18(%rbp),%edi
mov    -0x50(%rbp),%esi
call   10b0 <mpf_set_ui@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0xc(%rbp),%edx
call   10d0 <mpf_pow_ui@plt>
mov    -0x20(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x50(%rbp),%edx
shl    $0x1,%edx
call   10d0 <mpf_pow_ui@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    $0x1,%edx
call   10f0 <mpf_add_ui@plt>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    $0x1,%edx
call   1060 <mpf_sub_ui@plt>
mov    -0x2c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
call   10e0 <mpf_mul@plt>
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%edx
mov    $0x1,%esi
call   1050 <mpf_ui_div@plt>
mov    -0x34(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x30(%rbp),%edx
call   1070 <mpf_add@plt>
mov    -0x4(%rbp),%edi
mov    -0x34(%rbp),%esi
call   10a0 <mpf_set@plt>
mov    -0x2c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%edx
call   10e0 <mpf_mul@plt>
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%edx
mov    $0x1,%esi
call   1050 <mpf_ui_div@plt>
mov    -0x34(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x30(%rbp),%edx
call   1070 <mpf_add@plt>
mov    -0x8(%rbp),%edi
mov    -0x34(%rbp),%esi
call   10a0 <mpf_set@plt>
mov    -0x2c(%rbp),%edi
mov    -0x48(%rbp),%esi
call   1030 <mpf_cmp@plt>
cmp    $0x0,%rax
jle    1392 <fp_ess+0x1c2>
jmp    13a5 <fp_ess+0x1d5>
jmp    1397 <fp_ess+0x1c7>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    12b3 <fp_ess+0xe3>
mov    -0x14(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x18(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x1c(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x20(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x24(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x28(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x2c(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x30(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x34(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x4c(%rbp),%edi
call   1090 <mpf_clear@plt>
mov    -0x48(%rbp),%edi
call   1090 <mpf_clear@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fp_ess>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%r12d
call   1080 <mpf_init@plt>
call   1080 <mpf_init@plt>
call   1080 <mpf_init@plt>
call   1080 <mpf_init@plt>
call   1080 <mpf_init@plt>
call   1080 <mpf_init@plt>
call   1080 <mpf_init@plt>
call   1080 <mpf_init@plt>
call   1080 <mpf_init@plt>
mov    %ebx,%esi
call   10c0 <fp_e_pi@plt>
mov    %r12d,%edi
xor    %esi,%esi
call   10b0 <mpf_set_ui@plt>
mov    %r15d,%edi
xor    %esi,%esi
call   10b0 <mpf_set_ui@plt>
mov    %ebx,%eax
cvtsi2sd %rax,%xmm0
mulsd  0xdc6(%rip),%xmm0
addsd  0xdc6(%rip),%xmm0
cvttsd2si %xmm0,%rbx
call   1080 <mpf_init@plt>
call   1080 <mpf_init@plt>
mov    $0x1,%ebp
mov    $0x1,%esi
call   10b0 <mpf_set_ui@plt>
mov    %ebx,%edx
call   1040 <mpf_mul_2exp@plt>
mov    $0x2,%ebx
nopl   0x0(%rax)
mov    %ebp,%esi
call   10b0 <mpf_set_ui@plt>
mov    %r14d,%edx
call   10d0 <mpf_pow_ui@plt>
mov    %ebx,%edx
call   10d0 <mpf_pow_ui@plt>
mov    $0x1,%edx
call   10f0 <mpf_add_ui@plt>
mov    $0x1,%edx
call   1060 <mpf_sub_ui@plt>
call   10e0 <mpf_mul@plt>
mov    $0x1,%esi
call   1050 <mpf_ui_div@plt>
mov    %r12d,%esi
call   1070 <mpf_add@plt>
mov    %r12d,%edi
call   10a0 <mpf_set@plt>
call   10e0 <mpf_mul@plt>
mov    $0x1,%esi
call   1050 <mpf_ui_div@plt>
mov    %r15d,%esi
call   1070 <mpf_add@plt>
mov    %r15d,%edi
call   10a0 <mpf_set@plt>
call   1030 <mpf_cmp@plt>
test   %rax,%rax
jg     12f6 <fp_ess+0x126>
add    $0x1,%ebp
lea    0x2(%rbx),%eax
cmp    $0x773593fe,%ebx
mov    %eax,%ebx
jne    1270 <fp_ess+0xa0>
call   1090 <mpf_clear@plt>
call   1090 <mpf_clear@plt>
call   1090 <mpf_clear@plt>
call   1090 <mpf_clear@plt>
call   1090 <mpf_clear@plt>
call   1090 <mpf_clear@plt>
call   1090 <mpf_clear@plt>
call   1090 <mpf_clear@plt>
call   1090 <mpf_clear@plt>
call   1090 <mpf_clear@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <mpf_clear@plt>

LLVM IR (-O0):
define void @fp_ess(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%23 = load i32, i32* %9
%24 = call i32 @mpf_init(i32 %23)
%25 = load i32, i32* %10
%26 = call i32 @mpf_init(i32 %25)
%27 = load i32, i32* %11
%28 = call i32 @mpf_init(i32 %27)
%29 = load i32, i32* %12
%30 = call i32 @mpf_init(i32 %29)
%31 = load i32, i32* %13
%32 = call i32 @mpf_init(i32 %31)
%33 = load i32, i32* %14
%34 = call i32 @mpf_init(i32 %33)
%35 = load i32, i32* %15
%36 = call i32 @mpf_init(i32 %35)
%37 = load i32, i32* %16
%38 = call i32 @mpf_init(i32 %37)
%39 = load i32, i32* %17
%40 = call i32 @mpf_init(i32 %39)
%41 = load i32, i32* %9
%42 = load i32, i32* %8
%43 = call i32 @fp_e_pi(i32 %41, i32 %42)
%44 = load i32, i32* %5
%45 = call i32 @mpf_set_ui(i32 %44, i32 0)
%46 = load i32, i32* %6
%47 = call i32 @mpf_set_ui(i32 %46, i32 0)
%48 = load i32, i32* %8
%49 = uitofp i32 %48 to double
%50 = fmul double %49, 0x400A934F097D8237
store double %50, double* %18
%51 = load double, double* %18
%52 = fadd double %51, 1.000000e+00
%53 = fptoui double %52 to i32
store i32 %53, i32* %19
%54 = load i32, i32* %20
%55 = call i32 @mpf_init(i32 %54)
%56 = load i32, i32* %21
%57 = call i32 @mpf_init(i32 %56)
%58 = load i32, i32* %21
%59 = call i32 @mpf_set_ui(i32 %58, i32 1)
%60 = load i32, i32* %20
%61 = load i32, i32* %21
%62 = load i32, i32* %19
%63 = call i32 @mpf_mul_2exp(i32 %60, i32 %61, i32 %62)
store i32 1, i32* %22
br label %64
64: ; preds = %120, %4
%65 = load i32, i32* %22
%66 = icmp slt i32 %65, 1000000000
br i1 %66, label %67, label %123
67: ; preds = %64
%68 = load i32, i32* %10
%69 = load i32, i32* %22
%70 = call i32 @mpf_set_ui(i32 %68, i32 %69)
%71 = load i32, i32* %11
%72 = load i32, i32* %10
%73 = load i32, i32* %7
%74 = call i32 @mpf_pow_ui(i32 %71, i32 %72, i32 %73)
%75 = load i32, i32* %12
%76 = load i32, i32* %9
%77 = load i32, i32* %22
%78 = mul nsw i32 2, %77
%79 = call i32 @mpf_pow_ui(i32 %75, i32 %76, i32 %78)
%80 = load i32, i32* %13
%81 = load i32, i32* %12
%82 = call i32 @mpf_add_ui(i32 %80, i32 %81, i32 1)
%83 = load i32, i32* %14
%84 = load i32, i32* %12
%85 = call i32 @mpf_sub_ui(i32 %83, i32 %84, i32 1)
%86 = load i32, i32* %15
%87 = load i32, i32* %11
%88 = load i32, i32* %13
%89 = call i32 @mpf_mul(i32 %86, i32 %87, i32 %88)
%90 = load i32, i32* %16
%91 = load i32, i32* %15
%92 = call i32 @mpf_ui_div(i32 %90, i32 1, i32 %91)
%93 = load i32, i32* %17
%94 = load i32, i32* %5
%95 = load i32, i32* %16
%96 = call i32 @mpf_add(i32 %93, i32 %94, i32 %95)
%97 = load i32, i32* %5
%98 = load i32, i32* %17
%99 = call i32 @mpf_set(i32 %97, i32 %98)
%100 = load i32, i32* %15
%101 = load i32, i32* %11
%102 = load i32, i32* %14
%103 = call i32 @mpf_mul(i32 %100, i32 %101, i32 %102)
%104 = load i32, i32* %16
%105 = load i32, i32* %15
%106 = call i32 @mpf_ui_div(i32 %104, i32 1, i32 %105)
%107 = load i32, i32* %17
%108 = load i32, i32* %6
%109 = load i32, i32* %16
%110 = call i32 @mpf_add(i32 %107, i32 %108, i32 %109)
%111 = load i32, i32* %6
%112 = load i32, i32* %17
%113 = call i32 @mpf_set(i32 %111, i32 %112)
%114 = load i32, i32* %15
%115 = load i32, i32* %20
%116 = call i64 @mpf_cmp(i32 %114, i32 %115)
%117 = icmp sgt i64 %116, 0
br i1 %117, label %118, label %119
118: ; preds = %67
br label %123
119: ; preds = %67
br label %120
120: ; preds = %119
%121 = load i32, i32* %22
%122 = add nsw i32 %121, 1
store i32 %122, i32* %22
br label %64
123: ; preds = %118, %64
%124 = load i32, i32* %9
%125 = call i32 @mpf_clear(i32 %124)
%126 = load i32, i32* %10
%127 = call i32 @mpf_clear(i32 %126)
%128 = load i32, i32* %11
%129 = call i32 @mpf_clear(i32 %128)
%130 = load i32, i32* %12
%131 = call i32 @mpf_clear(i32 %130)
%132 = load i32, i32* %13
%133 = call i32 @mpf_clear(i32 %132)
%134 = load i32, i32* %14
%135 = call i32 @mpf_clear(i32 %134)
%136 = load i32, i32* %15
%137 = call i32 @mpf_clear(i32 %136)
%138 = load i32, i32* %16
%139 = call i32 @mpf_clear(i32 %138)
%140 = load i32, i32* %17
%141 = call i32 @mpf_clear(i32 %140)
%142 = load i32, i32* %21
%143 = call i32 @mpf_clear(i32 %142)
%144 = load i32, i32* %20
%145 = call i32 @mpf_clear(i32 %144)
ret void
}

LLVM IR (-O2):
define void @fp_ess(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @mpf_init(i32 undef)
%6 = tail call i32 @mpf_init(i32 undef)
%7 = tail call i32 @mpf_init(i32 undef)
%8 = tail call i32 @mpf_init(i32 undef)
%9 = tail call i32 @mpf_init(i32 undef)
%10 = tail call i32 @mpf_init(i32 undef)
%11 = tail call i32 @mpf_init(i32 undef)
%12 = tail call i32 @mpf_init(i32 undef)
%13 = tail call i32 @mpf_init(i32 undef)
%14 = tail call i32 @fp_e_pi(i32 undef, i32 %3)
%15 = tail call i32 @mpf_set_ui(i32 %0, i32 0)
%16 = tail call i32 @mpf_set_ui(i32 %1, i32 0)
%17 = uitofp i32 %3 to double
%18 = fmul double %17, 0x400A934F097D8237
%19 = fadd double %18, 1.000000e+00
%20 = fptoui double %19 to i32
%21 = tail call i32 @mpf_init(i32 undef)
%22 = tail call i32 @mpf_init(i32 undef)
%23 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%24 = tail call i32 @mpf_mul_2exp(i32 undef, i32 undef, i32 %20)
br label %25
25: ; preds = %25, %4
%26 = phi i32 [ 1, %4 ], [ %43, %25 ]
%27 = tail call i32 @mpf_set_ui(i32 undef, i32 %26)
%28 = tail call i32 @mpf_pow_ui(i32 undef, i32 undef, i32 %2)
%29 = shl nuw nsw i32 %26, 1
%30 = tail call i32 @mpf_pow_ui(i32 undef, i32 undef, i32 %29)
%31 = tail call i32 @mpf_add_ui(i32 undef, i32 undef, i32 1)
%32 = tail call i32 @mpf_sub_ui(i32 undef, i32 undef, i32 1)
%33 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%34 = tail call i32 @mpf_ui_div(i32 undef, i32 1, i32 undef)
%35 = tail call i32 @mpf_add(i32 undef, i32 %0, i32 undef)
%36 = tail call i32 @mpf_set(i32 %0, i32 undef)
%37 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%38 = tail call i32 @mpf_ui_div(i32 undef, i32 1, i32 undef)
%39 = tail call i32 @mpf_add(i32 undef, i32 %1, i32 undef)
%40 = tail call i32 @mpf_set(i32 %1, i32 undef)
%41 = tail call i64 @mpf_cmp(i32 undef, i32 undef)
%42 = icmp sgt i64 %41, 0
%43 = add nuw nsw i32 %26, 1
%44 = icmp eq i32 %43, 1000000000
%45 = select i1 %42, i1 true, i1 %44
br i1 %45, label %46, label %25
46: ; preds = %25
%47 = tail call i32 @mpf_clear(i32 undef)
%48 = tail call i32 @mpf_clear(i32 undef)
%49 = tail call i32 @mpf_clear(i32 undef)
%50 = tail call i32 @mpf_clear(i32 undef)
%51 = tail call i32 @mpf_clear(i32 undef)
%52 = tail call i32 @mpf_clear(i32 undef)
%53 = tail call i32 @mpf_clear(i32 undef)
%54 = tail call i32 @mpf_clear(i32 undef)
%55 = tail call i32 @mpf_clear(i32 undef)
%56 = tail call i32 @mpf_clear(i32 undef)
%57 = tail call i32 @mpf_clear(i32 undef)
ret void
}