#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 circle_pi(int);
double leibniz_pi(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int i;
  printf("Approximations for pi\n"
         "Iterations      Circle Method   Leibniz Method\n"
         "----------------------------------------------\n");
  for (i = 1; i <= 1000000; i *= 10) {
    double pi_circle = circle_pi(i), pi_leibniz = leibniz_pi(i);
    printf("%10i%20.12f%16.12f\n", i, pi_circle, pi_leibniz);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jg     11a2 <main+0x72>
mov    -0x8(%rbp),%edi
call   1050 <circle_pi@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <leibniz_pi@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xee6(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1060 <circle_pi@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%edi
call   1030 <leibniz_pi@plt>
movaps %xmm0,%xmm1
lea    0xe8b(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1060 <circle_pi@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%edi
call   1030 <leibniz_pi@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
mov    $0xa,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0x64,%edi
call   1060 <circle_pi@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x64,%edi
call   1030 <leibniz_pi@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
mov    $0x64,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0x3e8,%edi
call   1060 <circle_pi@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x3e8,%edi
call   1030 <leibniz_pi@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
mov    $0x3e8,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0x2710,%edi
call   1060 <circle_pi@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2710,%edi
call   1030 <leibniz_pi@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
mov    $0x2710,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0x186a0,%edi
call   1060 <circle_pi@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x186a0,%edi
call   1030 <leibniz_pi@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
mov    $0x186a0,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0xf4240,%edi
call   1060 <circle_pi@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xf4240,%edi
call   1030 <leibniz_pi@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
mov    $0xf4240,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [117 x i8] c"Approximations for pi\0AIterations Circle Method Leibniz Method\0A----------------------------------------------\0A\00"
@.str.1 = [20 x i8] c"%10i%20.12f%16.12f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([117 x i8], [117 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %6
6: ; preds = %18, %0
%7 = load i32, i32* %2
%8 = icmp sle i32 %7, 1000000
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = load i32, i32* %2
%11 = call double @circle_pi(i32 %10)
store double %11, double* %3
%12 = load i32, i32* %2
%13 = call double @leibniz_pi(i32 %12)
store double %13, double* %4
%14 = load i32, i32* %2
%15 = load double, double* %3
%16 = load double, double* %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %14, double %15, double %16)
br label %18
18: ; preds = %9
%19 = load i32, i32* %2
%20 = mul nsw i32 %19, 10
store i32 %20, i32* %2
br label %6
21: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"%10i%20.12f%16.12f\0A\00"
@str = [116 x i8] c"Approximations for pi\0AIterations Circle Method Leibniz Method\0A----------------------------------------------\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([116 x i8], [116 x i8]* @str, i64 0, i64 0))
%2 = tail call double @circle_pi(i32 1)
%3 = tail call double @leibniz_pi(i32 1)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 1, double %2, double %3)
%5 = tail call double @circle_pi(i32 10)
%6 = tail call double @leibniz_pi(i32 10)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 10, double %5, double %6)
%8 = tail call double @circle_pi(i32 100)
%9 = tail call double @leibniz_pi(i32 100)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 100, double %8, double %9)
%11 = tail call double @circle_pi(i32 1000)
%12 = tail call double @leibniz_pi(i32 1000)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 1000, double %11, double %12)
%14 = tail call double @circle_pi(i32 10000)
%15 = tail call double @leibniz_pi(i32 10000)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 10000, double %14, double %15)
%17 = tail call double @circle_pi(i32 100000)
%18 = tail call double @leibniz_pi(i32 100000)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 100000, double %17, double %18)
%20 = tail call double @circle_pi(i32 1000000)
%21 = tail call double @leibniz_pi(i32 1000000)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 1000000, double %20, double %21)
ret i32 0
}