#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 estimate_pi(int);
scalar_t__ pow(int, int);
int /*<<< orphan*/ printf(char *, int, double);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int i, N;
  srand(time(NULL));
  for (i = 1; i < 9; i++) {
    N = (int)pow(10, i);
    printf("No. of points: %d, Pi: %f\n", N, estimate_pi(N));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x9,-0x8(%rbp)
jge    11bb <main+0x6b>
mov    -0x8(%rbp),%esi
mov    $0xa,%edi
call   1060 <pow@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <estimate_pi@plt>
mov    -0x10(%rbp),%esi
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1176 <main+0x26>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0xa,%edi
mov    $0x1,%esi
call   1060 <pow@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1070 <estimate_pi@plt>
lea    0xe7e(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0xa,%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1070 <estimate_pi@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0xa,%edi
mov    $0x3,%esi
call   1060 <pow@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1070 <estimate_pi@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0xa,%edi
mov    $0x4,%esi
call   1060 <pow@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1070 <estimate_pi@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0xa,%edi
mov    $0x5,%esi
call   1060 <pow@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1070 <estimate_pi@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0xa,%edi
mov    $0x6,%esi
call   1060 <pow@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1070 <estimate_pi@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0xa,%edi
mov    $0x7,%esi
call   1060 <pow@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1070 <estimate_pi@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    $0xa,%edi
mov    $0x8,%esi
call   1060 <pow@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1070 <estimate_pi@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [27 x i8] c"No. of points: %d, Pi: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
store i32 1, i32* %2
br label %6
6: ; preds = %17, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 9
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = load i32, i32* %2
%11 = call i64 @pow(i32 10, i32 %10)
%12 = trunc i64 %11 to i32
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = load i32, i32* %3
%15 = call double @estimate_pi(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %13, double %15)
br label %17
17: ; preds = %9
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %6
20: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"No. of points: %d, Pi: %f\0A\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i64 @pow(i32 10, i32 1)
%4 = trunc i64 %3 to i32
%5 = tail call double @estimate_pi(i32 %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %4, double %5)
%7 = tail call i64 @pow(i32 10, i32 2)
%8 = trunc i64 %7 to i32
%9 = tail call double @estimate_pi(i32 %8)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %8, double %9)
%11 = tail call i64 @pow(i32 10, i32 3)
%12 = trunc i64 %11 to i32
%13 = tail call double @estimate_pi(i32 %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %12, double %13)
%15 = tail call i64 @pow(i32 10, i32 4)
%16 = trunc i64 %15 to i32
%17 = tail call double @estimate_pi(i32 %16)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %16, double %17)
%19 = tail call i64 @pow(i32 10, i32 5)
%20 = trunc i64 %19 to i32
%21 = tail call double @estimate_pi(i32 %20)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %20, double %21)
%23 = tail call i64 @pow(i32 10, i32 6)
%24 = trunc i64 %23 to i32
%25 = tail call double @estimate_pi(i32 %24)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %24, double %25)
%27 = tail call i64 @pow(i32 10, i32 7)
%28 = trunc i64 %27 to i32
%29 = tail call double @estimate_pi(i32 %28)
%30 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %28, double %29)
%31 = tail call i64 @pow(i32 10, i32 8)
%32 = trunc i64 %31 to i32
%33 = tail call double @estimate_pi(i32 %32)
%34 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %32, double %33)
ret i32 0
}