#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;
typedef double mp_bitcnt_t;

/* Variables and functions */
int /*<<< orphan*/ fp_exp(int /*<<< orphan*/, int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ fp_harmonic(int /*<<< orphan*/, unsigned int, unsigned int);
int /*<<< orphan*/ fp_log2(int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ mpf_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_clear(int /*<<< orphan*/);
scalar_t__ mpf_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpf_div(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_div_ui(int /*<<< orphan*/, int /*<<< orphan*/,
                              unsigned int);
int /*<<< orphan*/ mpf_init2(int /*<<< orphan*/, double);
int /*<<< orphan*/ mpf_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_mul_2exp(int /*<<< orphan*/, int /*<<< orphan*/,
                                unsigned int);
int /*<<< orphan*/ mpf_mul_ui(int /*<<< orphan*/, int /*<<< orphan*/,
                              unsigned int);
int /*<<< orphan*/ mpf_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
void fp_euler_mascheroni_limit(mpf_t gam, unsigned int n, unsigned int prec) {
  mp_bitcnt_t bits = ((double)prec) * 3.322 + 50;
  mpf_t maxterm;
  mpf_init2(maxterm, bits);
  mpf_set_ui(maxterm, 1);
  mpf_t z_n, twon, term, tmp, fact;
  mpf_init2(z_n, bits);
  mpf_init2(twon, bits);
  mpf_init2(term, bits);
  mpf_init2(tmp, bits);
  mpf_init2(fact, bits);
  mpf_set_ui(twon, 1);
  mpf_mul_2exp(twon, twon, n);
  mpf_mul(z_n, twon, twon);
  mpf_set_ui(fact, 1);
  mpf_div_ui(fact, fact, 2);
  mpf_set(gam, twon);
  unsigned int k = 2;
  while (1) {
    fp_harmonic(tmp, k, prec);
    mpf_mul(term, z_n, tmp);
    mpf_mul(term, term, fact);
    mpf_add(gam, gam, term);
    if (mpf_cmp(term, maxterm) < 0)
      break;
    k++;
    mpf_mul(z_n, z_n, twon);
    mpf_div_ui(fact, fact, k);
  }
  fp_exp(tmp, twon, prec);
  mpf_div(gam, gam, tmp);
  fp_log2(tmp, prec);
  mpf_mul_ui(tmp, tmp, n);
  mpf_sub(gam, gam, tmp);
  mpf_clear(z_n);
  mpf_clear(twon);
  mpf_clear(term);
  mpf_clear(tmp);
  mpf_clear(fact);
  mpf_clear(maxterm);
}


x86 assembly (clang, -O0):
<fp_euler_mascheroni_limit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xdef(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdeb(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1110 <mpf_init2@plt>
mov    -0x1c(%rbp),%edi
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
mov    -0x20(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1110 <mpf_init2@plt>
mov    -0x24(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1110 <mpf_init2@plt>
mov    -0x28(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1110 <mpf_init2@plt>
mov    -0x2c(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1110 <mpf_init2@plt>
mov    -0x30(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
call   1110 <mpf_init2@plt>
mov    -0x24(%rbp),%edi
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
mov    -0x24(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <mpf_mul_2exp@plt>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
call   10d0 <mpf_mul@plt>
mov    -0x30(%rbp),%edi
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
mov    -0x30(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    $0x2,%edx
call   1090 <mpf_div_ui@plt>
mov    -0x4(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1080 <mpf_set@plt>
movl   $0x2,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0xc(%rbp),%edx
call   10f0 <fp_harmonic@plt>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   10d0 <mpf_mul@plt>
mov    -0x28(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x30(%rbp),%edx
call   10d0 <mpf_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1060 <mpf_add@plt>
mov    -0x28(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1040 <mpf_cmp@plt>
cmp    $0x0,%rax
jge    132b <fp_euler_mascheroni_limit+0x13b>
jmp    1355 <fp_euler_mascheroni_limit+0x165>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   10d0 <mpf_mul@plt>
mov    -0x30(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1090 <mpf_div_ui@plt>
jmp    12d9 <fp_euler_mascheroni_limit+0xe9>
mov    -0x2c(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <fp_exp@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   10e0 <mpf_div@plt>
mov    -0x2c(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1100 <fp_log2@plt>
mov    -0x2c(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x8(%rbp),%edx
call   10b0 <mpf_mul_ui@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   10c0 <mpf_sub@plt>
mov    -0x20(%rbp),%edi
call   1070 <mpf_clear@plt>
mov    -0x24(%rbp),%edi
call   1070 <mpf_clear@plt>
mov    -0x28(%rbp),%edi
call   1070 <mpf_clear@plt>
mov    -0x2c(%rbp),%edi
call   1070 <mpf_clear@plt>
mov    -0x30(%rbp),%edi
call   1070 <mpf_clear@plt>
mov    -0x1c(%rbp),%edi
call   1070 <mpf_clear@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fp_euler_mascheroni_limit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%r14d
mov    %edi,%ebx
mov    %edx,%eax
cvtsi2sd %rax,%xmm0
mulsd  0xdf2(%rip),%xmm0
addsd  0xdf2(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   1110 <mpf_init2@plt>
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
movsd  (%rsp),%xmm0
call   1110 <mpf_init2@plt>
movsd  (%rsp),%xmm0
call   1110 <mpf_init2@plt>
movsd  (%rsp),%xmm0
call   1110 <mpf_init2@plt>
movsd  (%rsp),%xmm0
call   1110 <mpf_init2@plt>
movsd  (%rsp),%xmm0
call   1110 <mpf_init2@plt>
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
mov    %r14d,%edx
call   1050 <mpf_mul_2exp@plt>
call   10d0 <mpf_mul@plt>
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
mov    $0x2,%edx
call   1090 <mpf_div_ui@plt>
mov    %ebx,%edi
call   1080 <mpf_set@plt>
mov    $0x3,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x1(%rbp),%esi
mov    %r15d,%edx
call   10f0 <fp_harmonic@plt>
call   10d0 <mpf_mul@plt>
call   10d0 <mpf_mul@plt>
mov    %ebx,%edi
mov    %ebx,%esi
call   1060 <mpf_add@plt>
call   1040 <mpf_cmp@plt>
test   %rax,%rax
js     12d9 <fp_euler_mascheroni_limit+0xe9>
call   10d0 <mpf_mul@plt>
mov    %ebp,%edx
call   1090 <mpf_div_ui@plt>
add    $0x1,%ebp
jmp    12a0 <fp_euler_mascheroni_limit+0xb0>
mov    %r15d,%edx
call   1030 <fp_exp@plt>
mov    %ebx,%edi
mov    %ebx,%esi
call   10e0 <mpf_div@plt>
mov    %r15d,%esi
call   1100 <fp_log2@plt>
mov    %r14d,%edx
call   10b0 <mpf_mul_ui@plt>
mov    %ebx,%edi
mov    %ebx,%esi
call   10c0 <mpf_sub@plt>
call   1070 <mpf_clear@plt>
call   1070 <mpf_clear@plt>
call   1070 <mpf_clear@plt>
call   1070 <mpf_clear@plt>
call   1070 <mpf_clear@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <mpf_clear@plt>

LLVM IR (-O0):
define void @fp_euler_mascheroni_limit(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%15 = load i32, i32* %6
%16 = uitofp i32 %15 to double
%17 = call double @llvm.fmuladd.f64(double %16, double 3.322000e+00, double 5.000000e+01)
store double %17, double* %7
%18 = load i32, i32* %8
%19 = load double, double* %7
%20 = call i32 @mpf_init2(i32 %18, double %19)
%21 = load i32, i32* %8
%22 = call i32 @mpf_set_ui(i32 %21, i32 1)
%23 = load i32, i32* %9
%24 = load double, double* %7
%25 = call i32 @mpf_init2(i32 %23, double %24)
%26 = load i32, i32* %10
%27 = load double, double* %7
%28 = call i32 @mpf_init2(i32 %26, double %27)
%29 = load i32, i32* %11
%30 = load double, double* %7
%31 = call i32 @mpf_init2(i32 %29, double %30)
%32 = load i32, i32* %12
%33 = load double, double* %7
%34 = call i32 @mpf_init2(i32 %32, double %33)
%35 = load i32, i32* %13
%36 = load double, double* %7
%37 = call i32 @mpf_init2(i32 %35, double %36)
%38 = load i32, i32* %10
%39 = call i32 @mpf_set_ui(i32 %38, i32 1)
%40 = load i32, i32* %10
%41 = load i32, i32* %10
%42 = load i32, i32* %5
%43 = call i32 @mpf_mul_2exp(i32 %40, i32 %41, i32 %42)
%44 = load i32, i32* %9
%45 = load i32, i32* %10
%46 = load i32, i32* %10
%47 = call i32 @mpf_mul(i32 %44, i32 %45, i32 %46)
%48 = load i32, i32* %13
%49 = call i32 @mpf_set_ui(i32 %48, i32 1)
%50 = load i32, i32* %13
%51 = load i32, i32* %13
%52 = call i32 @mpf_div_ui(i32 %50, i32 %51, i32 2)
%53 = load i32, i32* %4
%54 = load i32, i32* %10
%55 = call i32 @mpf_set(i32 %53, i32 %54)
store i32 2, i32* %14
br label %56
56: ; preds = %3, %78
%57 = load i32, i32* %12
%58 = load i32, i32* %14
%59 = load i32, i32* %6
%60 = call i32 @fp_harmonic(i32 %57, i32 %58, i32 %59)
%61 = load i32, i32* %11
%62 = load i32, i32* %9
%63 = load i32, i32* %12
%64 = call i32 @mpf_mul(i32 %61, i32 %62, i32 %63)
%65 = load i32, i32* %11
%66 = load i32, i32* %11
%67 = load i32, i32* %13
%68 = call i32 @mpf_mul(i32 %65, i32 %66, i32 %67)
%69 = load i32, i32* %4
%70 = load i32, i32* %4
%71 = load i32, i32* %11
%72 = call i32 @mpf_add(i32 %69, i32 %70, i32 %71)
%73 = load i32, i32* %11
%74 = load i32, i32* %8
%75 = call i64 @mpf_cmp(i32 %73, i32 %74)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %56
br label %89
78: ; preds = %56
%79 = load i32, i32* %14
%80 = add i32 %79, 1
store i32 %80, i32* %14
%81 = load i32, i32* %9
%82 = load i32, i32* %9
%83 = load i32, i32* %10
%84 = call i32 @mpf_mul(i32 %81, i32 %82, i32 %83)
%85 = load i32, i32* %13
%86 = load i32, i32* %13
%87 = load i32, i32* %14
%88 = call i32 @mpf_div_ui(i32 %85, i32 %86, i32 %87)
br label %56
89: ; preds = %77
%90 = load i32, i32* %12
%91 = load i32, i32* %10
%92 = load i32, i32* %6
%93 = call i32 @fp_exp(i32 %90, i32 %91, i32 %92)
%94 = load i32, i32* %4
%95 = load i32, i32* %4
%96 = load i32, i32* %12
%97 = call i32 @mpf_div(i32 %94, i32 %95, i32 %96)
%98 = load i32, i32* %12
%99 = load i32, i32* %6
%100 = call i32 @fp_log2(i32 %98, i32 %99)
%101 = load i32, i32* %12
%102 = load i32, i32* %12
%103 = load i32, i32* %5
%104 = call i32 @mpf_mul_ui(i32 %101, i32 %102, i32 %103)
%105 = load i32, i32* %4
%106 = load i32, i32* %4
%107 = load i32, i32* %12
%108 = call i32 @mpf_sub(i32 %105, i32 %106, i32 %107)
%109 = load i32, i32* %9
%110 = call i32 @mpf_clear(i32 %109)
%111 = load i32, i32* %10
%112 = call i32 @mpf_clear(i32 %111)
%113 = load i32, i32* %11
%114 = call i32 @mpf_clear(i32 %113)
%115 = load i32, i32* %12
%116 = call i32 @mpf_clear(i32 %115)
%117 = load i32, i32* %13
%118 = call i32 @mpf_clear(i32 %117)
%119 = load i32, i32* %8
%120 = call i32 @mpf_clear(i32 %119)
ret void
}

LLVM IR (-O2):
define void @fp_euler_mascheroni_limit(i32 %0, i32 %1, i32 %2) {
%4 = uitofp i32 %2 to double
%5 = tail call double @llvm.fmuladd.f64(double %4, double 3.322000e+00, double 5.000000e+01)
%6 = tail call i32 @mpf_init2(i32 undef, double %5)
%7 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%8 = tail call i32 @mpf_init2(i32 undef, double %5)
%9 = tail call i32 @mpf_init2(i32 undef, double %5)
%10 = tail call i32 @mpf_init2(i32 undef, double %5)
%11 = tail call i32 @mpf_init2(i32 undef, double %5)
%12 = tail call i32 @mpf_init2(i32 undef, double %5)
%13 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%14 = tail call i32 @mpf_mul_2exp(i32 undef, i32 undef, i32 %1)
%15 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%16 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%17 = tail call i32 @mpf_div_ui(i32 undef, i32 undef, i32 2)
%18 = tail call i32 @mpf_set(i32 %0, i32 undef)
br label %19
19: ; preds = %27, %3
%20 = phi i32 [ 2, %3 ], [ %28, %27 ]
%21 = tail call i32 @fp_harmonic(i32 undef, i32 %20, i32 %2)
%22 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%23 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%24 = tail call i32 @mpf_add(i32 %0, i32 %0, i32 undef)
%25 = tail call i64 @mpf_cmp(i32 undef, i32 undef)
%26 = icmp slt i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %19
%28 = add i32 %20, 1
%29 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%30 = tail call i32 @mpf_div_ui(i32 undef, i32 undef, i32 %28)
br label %19
31: ; preds = %19
%32 = tail call i32 @fp_exp(i32 undef, i32 undef, i32 %2)
%33 = tail call i32 @mpf_div(i32 %0, i32 %0, i32 undef)
%34 = tail call i32 @fp_log2(i32 undef, i32 %2)
%35 = tail call i32 @mpf_mul_ui(i32 undef, i32 undef, i32 %1)
%36 = tail call i32 @mpf_sub(i32 %0, i32 %0, i32 undef)
%37 = tail call i32 @mpf_clear(i32 undef)
%38 = tail call i32 @mpf_clear(i32 undef)
%39 = tail call i32 @mpf_clear(i32 undef)
%40 = tail call i32 @mpf_clear(i32 undef)
%41 = tail call i32 @mpf_clear(i32 undef)
%42 = tail call i32 @mpf_clear(i32 undef)
ret void
}