#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*/ getchar();
double monteCarloPi(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  printf("Monte Carlo estimnation of pi:\n");
  printf("n = %7d: pi ~ %f\n", 1, monteCarloPi(1));
  printf("n = %7d: pi ~ %f\n", 10, monteCarloPi(10));
  printf("n = %7d: pi ~ %f\n", 100, monteCarloPi(100));
  printf("n = %7d: pi ~ %f\n", 1000, monteCarloPi(1000));
  printf("n = %7d: pi ~ %f\n", 10000, monteCarloPi(10000));
  printf("n = %7d: pi ~ %f\n", 100000, monteCarloPi(100000));
  printf("n = %7d: pi ~ %f\n", 1000000, monteCarloPi(1000000));
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1030 <monteCarloPi@plt>
lea    0xe9d(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <monteCarloPi@plt>
lea    0xe80(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x64,%edi
call   1030 <monteCarloPi@plt>
lea    0xe63(%rip),%rdi
mov    $0x64,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x3e8,%edi
call   1030 <monteCarloPi@plt>
lea    0xe46(%rip),%rdi
mov    $0x3e8,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x2710,%edi
call   1030 <monteCarloPi@plt>
lea    0xe29(%rip),%rdi
mov    $0x2710,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x186a0,%edi
call   1030 <monteCarloPi@plt>
lea    0xe0c(%rip),%rdi
mov    $0x186a0,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xf4240,%edi
call   1030 <monteCarloPi@plt>
lea    0xdef(%rip),%rdi
mov    $0xf4240,%esi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1040 <monteCarloPi@plt>
lea    0xe74(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <monteCarloPi@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x64,%edi
call   1040 <monteCarloPi@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x3e8,%edi
call   1040 <monteCarloPi@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x2710,%edi
call   1040 <monteCarloPi@plt>
mov    %rbx,%rdi
mov    $0x2710,%esi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x186a0,%edi
call   1040 <monteCarloPi@plt>
mov    %rbx,%rdi
mov    $0x186a0,%esi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xf4240,%edi
call   1040 <monteCarloPi@plt>
mov    %rbx,%rdi
mov    $0xf4240,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Monte Carlo estimnation of pi:\0A\00"
@.str.1 = [18 x i8] c"n = %7d: pi ~ %f\0A\00"
define i32 @main() {
%1 = call i32 @time(i32* null)
%2 = call i32 @srand(i32 %1)
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = call double @monteCarloPi(i32 1)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 1, double %4)
%6 = call double @monteCarloPi(i32 10)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 10, double %6)
%8 = call double @monteCarloPi(i32 100)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 100, double %8)
%10 = call double @monteCarloPi(i32 1000)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 1000, double %10)
%12 = call double @monteCarloPi(i32 10000)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 10000, double %12)
%14 = call double @monteCarloPi(i32 100000)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 100000, double %14)
%16 = call double @monteCarloPi(i32 1000000)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 1000000, double %16)
%18 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"n = %7d: pi ~ %f\0A\00"
@str = [31 x i8] c"Monte Carlo estimnation of pi:\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%4 = tail call double @monteCarloPi(i32 1)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 1, double %4)
%6 = tail call double @monteCarloPi(i32 10)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 10, double %6)
%8 = tail call double @monteCarloPi(i32 100)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 100, double %8)
%10 = tail call double @monteCarloPi(i32 1000)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 1000, double %10)
%12 = tail call double @monteCarloPi(i32 10000)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 10000, double %12)
%14 = tail call double @monteCarloPi(i32 100000)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 100000, double %14)
%16 = tail call double @monteCarloPi(i32 1000000)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 1000000, double %16)
%18 = tail call i32 (...) @getchar()
ret i32 0
}