#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 */
double fabs(double);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ scanf(char *, double *);
int main() {
  double sum = 0, eps, d, pi;
  int i = 1, k = 1;
  scanf("%lf", &eps);
  do {
    d = 1.0 / (i * k);
    sum += d;
    k = -k;
    i += 2;
  } while (fabs(d) >= eps / 4.0);
  pi = 4 * sum;
  printf("%lf", pi);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
lea    0xed4(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xe98(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
xor    %eax,%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x20(%rbp),%xmm0
movaps 0xe73(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe5a(%rip),%xmm2
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jae    1155 <main+0x35>
movsd  0xe44(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf08(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
movsd  (%rsp),%xmm1
mulsd  0xec3(%rip),%xmm1
mov    $0x1,%eax
xorpd  %xmm0,%xmm0
movsd  0xeba(%rip),%xmm2
movapd 0xeca(%rip),%xmm3
mov    $0x1,%ecx
nopl   0x0(%rax,%rax,1)
mov    %ecx,%edx
imul   %eax,%edx
xorps  %xmm4,%xmm4
cvtsi2sd %edx,%xmm4
movapd %xmm2,%xmm5
divsd  %xmm4,%xmm5
addsd  %xmm5,%xmm0
neg    %ecx
add    $0x2,%eax
andpd  %xmm3,%xmm5
ucomisd %xmm1,%xmm5
jae    1160 <main+0x40>
mulsd  0xe81(%rip),%xmm0
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store i32 1, i32* %6
store i32 1, i32* %7
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %3)
br label %9
9: ; preds = %22, %0
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = mul nsw i32 %10, %11
%13 = sitofp i32 %12 to double
%14 = fdiv double 1.000000e+00, %13
store double %14, double* %4
%15 = load double, double* %4
%16 = load double, double* %2
%17 = fadd double %16, %15
store double %17, double* %2
%18 = load i32, i32* %7
%19 = sub nsw i32 0, %18
store i32 %19, i32* %7
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 2
store i32 %21, i32* %6
br label %22
22: ; preds = %9
%23 = load double, double* %4
%24 = call double @llvm.fabs.f64(double %23)
%25 = load double, double* %3
%26 = fdiv double %25, 4.000000e+00
%27 = fcmp oge double %24, %26
br i1 %27, label %9, label %28
28: ; preds = %22
%29 = load double, double* %2
%30 = fmul double 4.000000e+00, %29
store double %30, double* %5
%31 = load double, double* %5
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%4 = load double, double* %1
%5 = fmul double %4, 2.500000e-01
br label %6
6: ; preds = %6, %0
%7 = phi double [ 0.000000e+00, %0 ], [ %13, %6 ]
%8 = phi i32 [ 1, %0 ], [ %15, %6 ]
%9 = phi i32 [ 1, %0 ], [ %14, %6 ]
%10 = mul nsw i32 %9, %8
%11 = sitofp i32 %10 to double
%12 = fdiv double 1.000000e+00, %11
%13 = fadd double %7, %12
%14 = sub nsw i32 0, %9
%15 = add nuw nsw i32 %8, 2
%16 = call double @llvm.fabs.f64(double %12)
%17 = fcmp ult double %16, %5
br i1 %17, label %18, label %6
18: ; preds = %6
%19 = fmul double %13, 4.000000e+00
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %19)
ret i32 0
}