#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 M_PI;
int /*<<< orphan*/ mpf_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_div_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_mul_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_out_str(int /*<<< orphan*/, int, int /*<<< orphan*/,
                               int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set_d(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_set_prec(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_sqrt_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_ui_div(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
void ramanujanNW(int times) {
  mpf_t pi, term, mult, tmp, rpi;
  mpf_init(pi);
  mpf_init(term);
  mpf_init(mult);
  mpf_init(tmp);
  mpf_set_prec(pi, 16384);
  mpf_set_prec(term, 16384);
  mpf_set_prec(mult, 16384);
  mpf_set_prec(tmp, 16384);
  mpf_set_ui(mult, 1);
  double n;
  mpf_set_ui(pi, 1103);
  for (n = 1; n < times; n++) {
    mpf_set_d(tmp, ((4 * n) * (4 * n - 1) * (4 * n - 2) * (4 * n - 3)));
    mpf_div_ui(tmp, tmp, (n * n * 396 * 396));
    mpf_div_ui(tmp, tmp, (n * n * 396 * 396));
    mpf_mul(mult, mult, tmp);
    mpf_mul_ui(term, mult, (1103 + 26390 * n));
    mpf_add(pi, pi, term);
    printf("%d\n", (int)n);
  }
  mpf_sqrt_ui(tmp, 2);
  mpf_mul_ui(tmp, tmp, 2);
  mpf_div_ui(tmp, tmp, 9801);
  mpf_mul(pi, pi, tmp);
  mpf_ui_div(pi, 1, pi);
  mpf_out_str(stdout, 10, 0, pi);
  printf("\n");
  mpf_set_d(tmp, M_PI);
  mpf_sub(tmp, pi, tmp);
  printf("delta=\n");
  mpf_out_str(stdout, 10, 0, tmp);
  printf("\n");
}


x86 assembly (clang, -O0):
<ramanujanNW>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <mpf_init@plt>
mov    -0xc(%rbp),%edi
call   1070 <mpf_init@plt>
mov    -0x10(%rbp),%edi
call   1070 <mpf_init@plt>
mov    -0x14(%rbp),%edi
call   1070 <mpf_init@plt>
mov    -0x8(%rbp),%edi
mov    $0x4000,%esi
call   1060 <mpf_set_prec@plt>
mov    -0xc(%rbp),%edi
mov    $0x4000,%esi
call   1060 <mpf_set_prec@plt>
mov    -0x10(%rbp),%edi
mov    $0x4000,%esi
call   1060 <mpf_set_prec@plt>
mov    -0x14(%rbp),%edi
mov    $0x4000,%esi
call   1060 <mpf_set_prec@plt>
mov    -0x10(%rbp),%edi
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
mov    -0x8(%rbp),%edi
mov    $0x44f,%esi
call   10a0 <mpf_set_ui@plt>
movsd  0xdaf(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x4(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    13ba <ramanujanNW+0x1ea>
mov    -0x14(%rbp),%edi
movsd  0xdab(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xd99(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xda5(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xd78(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd7c(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xd57(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd53(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
call   1090 <mpf_set_d@plt>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xd1a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd0e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
call   1080 <mpf_div_ui@plt>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xce9(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xcdd(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
call   1080 <mpf_div_ui@plt>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   10e0 <mpf_mul@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
movsd  -0x20(%rbp),%xmm0
movsd  0xc9f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xc9b(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
call   10b0 <mpf_mul_ui@plt>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <mpf_add@plt>
cvttsd2si -0x20(%rbp),%esi
lea    0xca4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  0xc55(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1256 <ramanujanNW+0x86>
mov    -0x14(%rbp),%edi
mov    $0x2,%esi
call   10f0 <mpf_sqrt_ui@plt>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x2,%edx
call   10b0 <mpf_mul_ui@plt>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x2649,%edx
call   1080 <mpf_div_ui@plt>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
call   10e0 <mpf_mul@plt>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    $0x1,%esi
call   1030 <mpf_ui_div@plt>
mov    0x2bcc(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%ecx
mov    $0xa,%esi
xor    %edx,%edx
call   10d0 <mpf_out_str@plt>
lea    0xc26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2bb3(%rip),%rax
mov    (%rax),%esi
call   1090 <mpf_set_d@plt>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
call   10c0 <mpf_sub@plt>
lea    0xbf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2b79(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%ecx
mov    $0xa,%esi
xor    %edx,%edx
call   10d0 <mpf_out_str@plt>
lea    0xbd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ramanujanNW>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
call   1090 <mpf_init@plt>
call   1090 <mpf_init@plt>
call   1090 <mpf_init@plt>
call   1090 <mpf_init@plt>
mov    $0x4000,%esi
call   1080 <mpf_set_prec@plt>
mov    $0x4000,%esi
call   1080 <mpf_set_prec@plt>
mov    $0x4000,%esi
call   1080 <mpf_set_prec@plt>
mov    $0x4000,%esi
call   1080 <mpf_set_prec@plt>
mov    $0x1,%esi
call   10c0 <mpf_set_ui@plt>
mov    $0x44f,%esi
call   10c0 <mpf_set_ui@plt>
cmp    $0x2,%ebx
jl     134a <ramanujanNW+0x15a>
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xd9d(%rip),%xmm0
lea    0xdd6(%rip),%rbx
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xd84(%rip),%xmm0
movapd %xmm0,%xmm1
addsd  0xd80(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm0,%xmm2
addsd  0xd78(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xd74(%rip),%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%esi
call   10b0 <mpf_set_d@plt>
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm0
movsd  0xd5d(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ebp
mov    %ebp,%edx
call   10a0 <mpf_div_ui@plt>
mov    %ebp,%edx
call   10a0 <mpf_div_ui@plt>
call   1100 <mpf_mul@plt>
movsd  0x8(%rsp),%xmm0
mulsd  0xd38(%rip),%xmm0
addsd  0xd38(%rip),%xmm0
cvttsd2si %xmm0,%edx
call   10d0 <mpf_mul_ui@plt>
call   1070 <mpf_add@plt>
cvttsd2si 0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xcd4(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
ucomisd 0x8(%rsp),%xmm0
movsd  0x8(%rsp),%xmm0
ja     1270 <ramanujanNW+0x80>
mov    $0x2,%esi
call   1110 <mpf_sqrt_ui@plt>
mov    $0x2,%edx
call   10d0 <mpf_mul_ui@plt>
mov    $0x2649,%edx
call   10a0 <mpf_div_ui@plt>
call   1100 <mpf_mul@plt>
mov    $0x1,%esi
call   1050 <mpf_ui_div@plt>
mov    0x2c5a(%rip),%rbx
mov    (%rbx),%edi
mov    $0xa,%esi
xor    %edx,%edx
call   10f0 <mpf_out_str@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2c4b(%rip),%rax
mov    (%rax),%esi
call   10b0 <mpf_set_d@plt>
call   10e0 <mpf_sub@plt>
lea    0xc94(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%edi
mov    $0xa,%esi
xor    %edx,%edx
call   10f0 <mpf_out_str@plt>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@M_PI = global i32 0
@.str.2 = [8 x i8] c"delta=\0A\00"
define void @ramanujanNW(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store i32 %0, i32* %2
%9 = load i32, i32* %3
%10 = call i32 @mpf_init(i32 %9)
%11 = load i32, i32* %4
%12 = call i32 @mpf_init(i32 %11)
%13 = load i32, i32* %5
%14 = call i32 @mpf_init(i32 %13)
%15 = load i32, i32* %6
%16 = call i32 @mpf_init(i32 %15)
%17 = load i32, i32* %3
%18 = call i32 @mpf_set_prec(i32 %17, i32 16384)
%19 = load i32, i32* %4
%20 = call i32 @mpf_set_prec(i32 %19, i32 16384)
%21 = load i32, i32* %5
%22 = call i32 @mpf_set_prec(i32 %21, i32 16384)
%23 = load i32, i32* %6
%24 = call i32 @mpf_set_prec(i32 %23, i32 16384)
%25 = load i32, i32* %5
%26 = call i32 @mpf_set_ui(i32 %25, i32 1)
%27 = load i32, i32* %3
%28 = call i32 @mpf_set_ui(i32 %27, i32 1103)
store double 1.000000e+00, double* %8
br label %29
29: ; preds = %84, %1
%30 = load double, double* %8
%31 = load i32, i32* %2
%32 = sitofp i32 %31 to double
%33 = fcmp olt double %30, %32
br i1 %33, label %34, label %87
34: ; preds = %29
%35 = load i32, i32* %6
%36 = load double, double* %8
%37 = fmul double 4.000000e+00, %36
%38 = load double, double* %8
%39 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %38, double -1.000000e+00)
%40 = fmul double %37, %39
%41 = load double, double* %8
%42 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %41, double -2.000000e+00)
%43 = fmul double %40, %42
%44 = load double, double* %8
%45 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %44, double -3.000000e+00)
%46 = fmul double %43, %45
%47 = fptosi double %46 to i32
%48 = call i32 @mpf_set_d(i32 %35, i32 %47)
%49 = load i32, i32* %6
%50 = load i32, i32* %6
%51 = load double, double* %8
%52 = load double, double* %8
%53 = fmul double %51, %52
%54 = fmul double %53, 3.960000e+02
%55 = fmul double %54, 3.960000e+02
%56 = fptosi double %55 to i32
%57 = call i32 @mpf_div_ui(i32 %49, i32 %50, i32 %56)
%58 = load i32, i32* %6
%59 = load i32, i32* %6
%60 = load double, double* %8
%61 = load double, double* %8
%62 = fmul double %60, %61
%63 = fmul double %62, 3.960000e+02
%64 = fmul double %63, 3.960000e+02
%65 = fptosi double %64 to i32
%66 = call i32 @mpf_div_ui(i32 %58, i32 %59, i32 %65)
%67 = load i32, i32* %5
%68 = load i32, i32* %5
%69 = load i32, i32* %6
%70 = call i32 @mpf_mul(i32 %67, i32 %68, i32 %69)
%71 = load i32, i32* %4
%72 = load i32, i32* %5
%73 = load double, double* %8
%74 = call double @llvm.fmuladd.f64(double 2.639000e+04, double %73, double 1.103000e+03)
%75 = fptosi double %74 to i32
%76 = call i32 @mpf_mul_ui(i32 %71, i32 %72, i32 %75)
%77 = load i32, i32* %3
%78 = load i32, i32* %3
%79 = load i32, i32* %4
%80 = call i32 @mpf_add(i32 %77, i32 %78, i32 %79)
%81 = load double, double* %8
%82 = fptosi double %81 to i32
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %34
%85 = load double, double* %8
%86 = fadd double %85, 1.000000e+00
store double %86, double* %8
br label %29
87: ; preds = %29
%88 = load i32, i32* %6
%89 = call i32 @mpf_sqrt_ui(i32 %88, i32 2)
%90 = load i32, i32* %6
%91 = load i32, i32* %6
%92 = call i32 @mpf_mul_ui(i32 %90, i32 %91, i32 2)
%93 = load i32, i32* %6
%94 = load i32, i32* %6
%95 = call i32 @mpf_div_ui(i32 %93, i32 %94, i32 9801)
%96 = load i32, i32* %3
%97 = load i32, i32* %3
%98 = load i32, i32* %6
%99 = call i32 @mpf_mul(i32 %96, i32 %97, i32 %98)
%100 = load i32, i32* %3
%101 = load i32, i32* %3
%102 = call i32 @mpf_ui_div(i32 %100, i32 1, i32 %101)
%103 = load i32, i32* @stdout
%104 = load i32, i32* %3
%105 = call i32 @mpf_out_str(i32 %103, i32 10, i32 0, i32 %104)
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%107 = load i32, i32* %6
%108 = load i32, i32* @M_PI
%109 = call i32 @mpf_set_d(i32 %107, i32 %108)
%110 = load i32, i32* %6
%111 = load i32, i32* %3
%112 = load i32, i32* %6
%113 = call i32 @mpf_sub(i32 %110, i32 %111, i32 %112)
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%115 = load i32, i32* @stdout
%116 = load i32, i32* %6
%117 = call i32 @mpf_out_str(i32 %115, i32 10, i32 0, i32 %116)
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@stdout = global i32 0
@M_PI = global i32 0
@str = [7 x i8] c"delta=\00"
define void @ramanujanNW(i32 %0) {
%2 = tail call i32 @mpf_init(i32 undef)
%3 = tail call i32 @mpf_init(i32 undef)
%4 = tail call i32 @mpf_init(i32 undef)
%5 = tail call i32 @mpf_init(i32 undef)
%6 = tail call i32 @mpf_set_prec(i32 undef, i32 16384)
%7 = tail call i32 @mpf_set_prec(i32 undef, i32 16384)
%8 = tail call i32 @mpf_set_prec(i32 undef, i32 16384)
%9 = tail call i32 @mpf_set_prec(i32 undef, i32 16384)
%10 = tail call i32 @mpf_set_ui(i32 undef, i32 1)
%11 = tail call i32 @mpf_set_ui(i32 undef, i32 1103)
%12 = sitofp i32 %0 to double
%13 = icmp sgt i32 %0, 1
br i1 %13, label %14, label %40
14: ; preds = %1, %14
%15 = phi double [ %38, %14 ], [ 1.000000e+00, %1 ]
%16 = fmul double %15, 4.000000e+00
%17 = tail call double @llvm.fmuladd.f64(double %15, double 4.000000e+00, double -1.000000e+00)
%18 = fmul double %16, %17
%19 = tail call double @llvm.fmuladd.f64(double %15, double 4.000000e+00, double -2.000000e+00)
%20 = fmul double %19, %18
%21 = tail call double @llvm.fmuladd.f64(double %15, double 4.000000e+00, double -3.000000e+00)
%22 = fmul double %21, %20
%23 = fptosi double %22 to i32
%24 = tail call i32 @mpf_set_d(i32 undef, i32 %23)
%25 = fmul double %15, %15
%26 = fmul double %25, 3.960000e+02
%27 = fmul double %26, 3.960000e+02
%28 = fptosi double %27 to i32
%29 = tail call i32 @mpf_div_ui(i32 undef, i32 undef, i32 %28)
%30 = tail call i32 @mpf_div_ui(i32 undef, i32 undef, i32 %28)
%31 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%32 = tail call double @llvm.fmuladd.f64(double %15, double 2.639000e+04, double 1.103000e+03)
%33 = fptosi double %32 to i32
%34 = tail call i32 @mpf_mul_ui(i32 undef, i32 undef, i32 %33)
%35 = tail call i32 @mpf_add(i32 undef, i32 undef, i32 undef)
%36 = fptosi double %15 to i32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = fadd double %15, 1.000000e+00
%39 = fcmp olt double %38, %12
br i1 %39, label %14, label %40
40: ; preds = %14, %1
%41 = tail call i32 @mpf_sqrt_ui(i32 undef, i32 2)
%42 = tail call i32 @mpf_mul_ui(i32 undef, i32 undef, i32 2)
%43 = tail call i32 @mpf_div_ui(i32 undef, i32 undef, i32 9801)
%44 = tail call i32 @mpf_mul(i32 undef, i32 undef, i32 undef)
%45 = tail call i32 @mpf_ui_div(i32 undef, i32 1, i32 undef)
%46 = load i32, i32* @stdout
%47 = tail call i32 @mpf_out_str(i32 %46, i32 10, i32 0, i32 undef)
%48 = tail call i32 @putchar(i32 10)
%49 = load i32, i32* @M_PI
%50 = tail call i32 @mpf_set_d(i32 undef, i32 %49)
%51 = tail call i32 @mpf_sub(i32 undef, i32 undef, i32 undef)
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%53 = load i32, i32* @stdout
%54 = tail call i32 @mpf_out_str(i32 %53, i32 10, i32 0, i32 undef)
%55 = tail call i32 @putchar(i32 10)
ret void
}