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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, double);
int sqrt(int);
void ramd(int times) {
  double n, pi, term, mult, tmp;
  pi = 1103;
  term = 0;
  mult = 1;
  tmp = 0;
  for (n = 1; n < times; n++) {
    tmp = ((4 * n) * (4 * n - 1) * (4 * n - 2) * (4 * n - 3)) /
          (n * n * n * n * 396 * 396 * 396 * 396);
    mult *= tmp;
    term = mult * (1103 + 26390 * n);
    pi += term;
  }
  pi *= (2 * sqrt(2)) / 9801;
  pi = 1 / pi;
  printf("%16g\n", pi);
}


x86 assembly (clang, -O0):
<ramd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  0xed5(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xea3(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x4(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1293 <ramd+0x173>
movsd  0xea2(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe90(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe9c(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe6f(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe73(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe4e(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe4a(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xe16(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe0a(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdfe(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdf2(%rip),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xdbc(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xda8(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xd7c(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1162 <ramd+0x42>
mov    $0x2,%edi
call   1040 <sqrt@plt>
shl    $0x1,%eax
mov    $0x2649,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xd42(%rip),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xd6c(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ramd>:
push   %rax
cmp    $0x2,%edi
jl     121f <ramd+0xff>
cvtsi2sd %edi,%xmm0
movsd  0xec9(%rip),%xmm10
movsd  0xec8(%rip),%xmm14
movsd  0xec7(%rip),%xmm8
movsd  0xec6(%rip),%xmm9
movsd  0xec5(%rip),%xmm11
movsd  0xec4(%rip),%xmm12
movapd 0xed3(%rip),%xmm13
movapd 0xedb(%rip),%xmm3
movsd  0xeb2(%rip),%xmm15
movapd %xmm14,%xmm2
movapd %xmm10,%xmm4
movapd %xmm14,%xmm7
nopl   (%rax)
movapd %xmm7,%xmm1
mulsd  %xmm8,%xmm1
movapd %xmm7,%xmm5
mulsd  %xmm7,%xmm5
mulsd  %xmm7,%xmm5
mulsd  %xmm7,%xmm5
movapd %xmm7,%xmm6
unpcklpd %xmm5,%xmm6
movapd %xmm1,%xmm5
addsd  %xmm9,%xmm5
mulpd  %xmm13,%xmm6
shufpd $0x2,%xmm3,%xmm5
mulpd  %xmm6,%xmm5
movapd %xmm1,%xmm6
addsd  %xmm11,%xmm6
shufpd $0x2,%xmm3,%xmm6
mulpd  %xmm5,%xmm6
addsd  %xmm12,%xmm1
shufpd $0x2,%xmm3,%xmm1
mulpd  %xmm6,%xmm1
movapd %xmm1,%xmm5
unpckhpd %xmm1,%xmm5
divsd  %xmm5,%xmm1
mulsd  %xmm1,%xmm2
movapd %xmm7,%xmm1
mulsd  %xmm15,%xmm1
addsd  %xmm10,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm1,%xmm4
addsd  %xmm14,%xmm7
ucomisd %xmm7,%xmm0
ja     1190 <ramd+0x70>
jmp    1227 <ramd+0x107>
movsd  0xdd9(%rip),%xmm4
movsd  %xmm4,(%rsp)
mov    $0x2,%edi
call   1040 <sqrt@plt>
mov    %eax,%ecx
add    %eax,%ecx
movslq %ecx,%rcx
imul   $0xffffffffd5f92819,%rcx,%rcx
shr    $0x20,%rcx
lea    (%rcx,%rax,2),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xd,%eax
add    %ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  (%rsp),%xmm1
movsd  0xd9f(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xdec(%rip),%rdi
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%16g\0A\00"
define void @ramd(i32 %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %2
store double 1.103000e+03, double* %4
store double 0.000000e+00, double* %5
store double 1.000000e+00, double* %6
store double 0.000000e+00, double* %7
store double 1.000000e+00, double* %3
br label %8
8: ; preds = %47, %1
%9 = load double, double* %3
%10 = load i32, i32* %2
%11 = sitofp i32 %10 to double
%12 = fcmp olt double %9, %11
br i1 %12, label %13, label %50
13: ; preds = %8
%14 = load double, double* %3
%15 = fmul double 4.000000e+00, %14
%16 = load double, double* %3
%17 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %16, double -1.000000e+00)
%18 = fmul double %15, %17
%19 = load double, double* %3
%20 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %19, double -2.000000e+00)
%21 = fmul double %18, %20
%22 = load double, double* %3
%23 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %22, double -3.000000e+00)
%24 = fmul double %21, %23
%25 = load double, double* %3
%26 = load double, double* %3
%27 = fmul double %25, %26
%28 = load double, double* %3
%29 = fmul double %27, %28
%30 = load double, double* %3
%31 = fmul double %29, %30
%32 = fmul double %31, 3.960000e+02
%33 = fmul double %32, 3.960000e+02
%34 = fmul double %33, 3.960000e+02
%35 = fmul double %34, 3.960000e+02
%36 = fdiv double %24, %35
store double %36, double* %7
%37 = load double, double* %7
%38 = load double, double* %6
%39 = fmul double %38, %37
store double %39, double* %6
%40 = load double, double* %6
%41 = load double, double* %3
%42 = call double @llvm.fmuladd.f64(double 2.639000e+04, double %41, double 1.103000e+03)
%43 = fmul double %40, %42
store double %43, double* %5
%44 = load double, double* %5
%45 = load double, double* %4
%46 = fadd double %45, %44
store double %46, double* %4
br label %47
47: ; preds = %13
%48 = load double, double* %3
%49 = fadd double %48, 1.000000e+00
store double %49, double* %3
br label %8
50: ; preds = %8
%51 = call i32 @sqrt(i32 2)
%52 = mul nsw i32 2, %51
%53 = sdiv i32 %52, 9801
%54 = sitofp i32 %53 to double
%55 = load double, double* %4
%56 = fmul double %55, %54
store double %56, double* %4
%57 = load double, double* %4
%58 = fdiv double 1.000000e+00, %57
store double %58, double* %4
%59 = load double, double* %4
%60 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %59)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%16g\0A\00"
define void @ramd(i32 %0) {
%2 = sitofp i32 %0 to double
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %32
4: ; preds = %1, %4
%5 = phi double [ %26, %4 ], [ 1.000000e+00, %1 ]
%6 = phi double [ %29, %4 ], [ 1.103000e+03, %1 ]
%7 = phi double [ %30, %4 ], [ 1.000000e+00, %1 ]
%8 = tail call double @llvm.fmuladd.f64(double %7, double 4.000000e+00, double -1.000000e+00)
%9 = tail call double @llvm.fmuladd.f64(double %7, double 4.000000e+00, double -2.000000e+00)
%10 = tail call double @llvm.fmuladd.f64(double %7, double 4.000000e+00, double -3.000000e+00)
%11 = fmul double %7, %7
%12 = fmul double %7, %11
%13 = fmul double %7, %12
%14 = insertelement <2 x double> poison, double %7, i64 0
%15 = insertelement <2 x double> %14, double %13, i64 1
%16 = fmul <2 x double> %15, <double 4.000000e+00, double 3.960000e+02>
%17 = insertelement <2 x double> <double poison, double 3.960000e+02>, double %8, i64 0
%18 = fmul <2 x double> %16, %17
%19 = insertelement <2 x double> <double poison, double 3.960000e+02>, double %9, i64 0
%20 = fmul <2 x double> %19, %18
%21 = insertelement <2 x double> <double poison, double 3.960000e+02>, double %10, i64 0
%22 = fmul <2 x double> %21, %20
%23 = extractelement <2 x double> %22, i64 0
%24 = extractelement <2 x double> %22, i64 1
%25 = fdiv double %23, %24
%26 = fmul double %5, %25
%27 = tail call double @llvm.fmuladd.f64(double %7, double 2.639000e+04, double 1.103000e+03)
%28 = fmul double %27, %26
%29 = fadd double %6, %28
%30 = fadd double %7, 1.000000e+00
%31 = fcmp olt double %30, %2
br i1 %31, label %4, label %32
32: ; preds = %4, %1
%33 = phi double [ 1.103000e+03, %1 ], [ %29, %4 ]
%34 = tail call i32 @sqrt(i32 2)
%35 = shl nsw i32 %34, 1
%36 = sdiv i32 %35, 9801
%37 = sitofp i32 %36 to double
%38 = fmul double %33, %37
%39 = fdiv double 1.000000e+00, %38
%40 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %39)
ret void
}