#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*/ M_PI;
int fabs(double);
int /*<<< orphan*/ printf(char *, double, int /*<<< orphan*/);
int main() {
  double pi = 0, sign = 4, member = sign;
  int denominator = 1;
  do {
    pi += member;
    denominator += 2;
    sign = -sign;
    member = sign / denominator;
  } while (fabs(member) > 1e-6);
  printf("pi (aproximate) = %10.8lf \t pi = %10.8lf\n", pi, M_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)
movsd  0xec1(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe51(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1155 <main+0x35>
movsd  -0x10(%rbp),%xmm0
mov    0x2e1b(%rip),%rax
mov    (%rax),%esi
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movsd  0xed3(%rip),%xmm1
xorpd  %xmm0,%xmm0
mov    $0x3,%ebx
movapd %xmm1,%xmm2
nopw   0x0(%rax,%rax,1)
xorpd  0xec8(%rip),%xmm1
movapd %xmm1,0x20(%rsp)
addsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
call   1040 <fabs@plt>
movapd 0x10(%rsp),%xmm2
movapd 0x20(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
add    $0x2,%ebx
test   %eax,%eax
jg     1140 <main+0x20>
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"pi (aproximate) = %10.8lf \09 pi = %10.8lf\0A\00"
@M_PI = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 4.000000e+00, double* %3
%6 = load double, double* %3
store double %6, double* %4
store i32 1, i32* %5
br label %7
7: ; preds = %19, %0
%8 = load double, double* %4
%9 = load double, double* %2
%10 = fadd double %9, %8
store double %10, double* %2
%11 = load i32, i32* %5
%12 = add nsw i32 %11, 2
store i32 %12, i32* %5
%13 = load double, double* %3
%14 = fneg double %13
store double %14, double* %3
%15 = load double, double* %3
%16 = load i32, i32* %5
%17 = sitofp i32 %16 to double
%18 = fdiv double %15, %17
store double %18, double* %4
br label %19
19: ; preds = %7
%20 = load double, double* %4
%21 = call i32 @fabs(double %20)
%22 = sitofp i32 %21 to double
%23 = fcmp ogt double %22, 0x3EB0C6F7A0B5ED8D
br i1 %23, label %7, label %24
24: ; preds = %19
%25 = load double, double* %2
%26 = load i32, i32* @M_PI
%27 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), double %25, i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"pi (aproximate) = %10.8lf \09 pi = %10.8lf\0A\00"
@M_PI = global i32 0
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi double [ 0.000000e+00, %0 ], [ %6, %1 ]
%3 = phi double [ 4.000000e+00, %0 ], [ %8, %1 ]
%4 = phi double [ 4.000000e+00, %0 ], [ %10, %1 ]
%5 = phi i32 [ 1, %0 ], [ %7, %1 ]
%6 = fadd double %2, %4
%7 = add nuw nsw i32 %5, 2
%8 = fneg double %3
%9 = sitofp i32 %7 to double
%10 = fdiv double %8, %9
%11 = tail call i32 @fabs(double %10)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %1, label %13
13: ; preds = %1
%14 = load i32, i32* @M_PI
%15 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), double %6, i32 %14)
ret i32 0
}