#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 RAND_MAX;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ rand();
int /*<<< orphan*/ scanf(char *, long *);
double sqrt(double);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(void) {
  double x, y, ratio, mean, standdev, sum, squaresum;
  long N = -1;
  float num_in;
  while (N < 0) {
    printf("Please enter a positive integer N:");
    scanf("%d", &N);
  }
  srand((unsigned)time(NULL));
  for (int j = 0; j < 10; j++) {
    num_in = 0;
    for (long i = 0; i < N; i++) {
      x = ((double)rand()) / RAND_MAX;
      y = ((double)rand()) / RAND_MAX;
      if ((x * x + y * y) <= 1) {
        num_in++;
      }
    }
    ratio = (num_in / N) * 4;
    printf("The number %d value is: %f \n", j + 1, ratio);
    sum += ratio;
    squaresum += (ratio * ratio);
  }
  mean = sum / 10;
  standdev = (squaresum / 10) - (mean * mean);
  if (standdev < 0) {
    standdev = sqrt(-1 * standdev);
  } else {
    standdev = sqrt(standdev);
  }
  printf("Mean: %f \n", mean);
  printf("Standard Deviation: %f \n \n", standdev);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0xffffffffffffffff,-0x48(%rbp)
ff
cmpq   $0x0,-0x48(%rbp)
jge    11a5 <main+0x45>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0x48(%rbp),%rsi
call   1060 <scanf@plt>
jmp    1177 <main+0x17>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x50(%rbp)
cmpl   $0xa,-0x50(%rbp)
jge    12e8 <main+0x188>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4c(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
cmp    -0x48(%rbp),%rax
jge    1272 <main+0x112>
mov    $0x0,%al
call   1080 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2df1(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2dd5(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdd0(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     125c <main+0xfc>
movss  0xdca(%rip),%xmm0
addss  -0x4c(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
jmp    1261 <main+0x101>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    11d6 <main+0x76>
movss  -0x4c(%rbp),%xmm0
cvtsi2ssq -0x48(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  0xd8f(%rip),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x50(%rbp),%esi
add    $0x1,%esi
movsd  -0x20(%rbp),%xmm0
lea    0xd9e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11bc <main+0x5c>
movsd  -0x38(%rbp),%xmm0
movsd  0xd0b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  0xcf5(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1367 <main+0x207>
movsd  0xcb5(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    1376 <main+0x216>
movsd  -0x30(%rbp),%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xce1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xcd9(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
movq   $0xffffffffffffffff,0x10(%rsp)
ff ff
lea    0xeb6(%rip),%r14
lea    0xed2(%rip),%rbp
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmpq   $0x0,0x10(%rsp)
js     1190 <main+0x30>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    0x2e26(%rip),%rbx
lea    0xe8d(%rip),%r14
xor    %r15d,%r15d
jmp    1236 <main+0xd6>
xchg   %ax,%ax
movss  %xmm0,0x4(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0x4(%rsp),%xmm1
divss  %xmm0,%xmm1
mulss  0xe24(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0x1,%r15d
mov    %r14,%rdi
mov    %r15d,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x18(%rsp),%xmm3
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm0
movapd 0x20(%rsp),%xmm4
addsd  %xmm0,%xmm4
cmp    $0xa,%r15d
je     12d4 <main+0x174>
mov    0x10(%rsp),%rax
test   %rax,%rax
movsd  %xmm3,0x18(%rsp)
movapd %xmm4,0x20(%rsp)
xorps  %xmm0,%xmm0
jle    11d0 <main+0x70>
movss  %xmm0,0x4(%rsp)
xor    %ebp,%ebp
jmp    1272 <main+0x112>
nopl   0x0(%rax)
add    $0x1,%rbp
mov    0x10(%rsp),%rax
cmp    %rax,%rbp
jge    11d6 <main+0x76>
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%rbx),%xmm0
mulsd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd48(%rip),%xmm0
ucomisd %xmm1,%xmm0
movss  0x4(%rsp),%xmm0
addss  0xd46(%rip),%xmm0
jb     1260 <main+0x100>
movss  %xmm0,0x4(%rsp)
jmp    1260 <main+0x100>
movsd  0xd2c(%rip),%xmm0
divsd  %xmm0,%xmm3
divsd  %xmm0,%xmm4
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
subsd  %xmm0,%xmm4
movapd 0xd28(%rip),%xmm1
xorpd  %xmm4,%xmm1
xorpd  %xmm2,%xmm2
movapd %xmm4,%xmm0
cmpltsd %xmm2,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm4,%xmm0
orpd   %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     1321 <main+0x1c1>
sqrtsd %xmm0,%xmm0
jmp    1332 <main+0x1d2>
movsd  %xmm3,0x18(%rsp)
call   1070 <sqrt@plt>
movsd  0x18(%rsp),%xmm3
movsd  %xmm0,0x8(%rsp)
lea    0xd34(%rip),%rdi
movapd %xmm3,%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xd2d(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Please enter a positive integer N:\00"
@.str.1 = [3 x i8] c"%d\00"
@RAND_MAX = global double 0.000000e+00
@.str.2 = [29 x i8] c"The number %d value is: %f \0A\00"
@.str.3 = [11 x i8] c"Mean: %f \0A\00"
@.str.4 = [27 x i8] c"Standard Deviation: %f \0A \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i64
%10 = alloca float
%11 = alloca i32
%12 = alloca i64
store i32 0, i32* %1
store i64 -1, i64* %9
br label %13
13: ; preds = %16, %0
%14 = load i64, i64* %9
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64* %9)
br label %13
19: ; preds = %13
%20 = call i64 @time(i32* null)
%21 = trunc i64 %20 to i32
%22 = call i32 @srand(i32 %21)
store i32 0, i32* %11
br label %23
23: ; preds = %72, %19
%24 = load i32, i32* %11
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %75
26: ; preds = %23
store float 0.000000e+00, float* %10
store i64 0, i64* %12
br label %27
27: ; preds = %51, %26
%28 = load i64, i64* %12
%29 = load i64, i64* %9
%30 = icmp slt i64 %28, %29
br i1 %30, label %31, label %54
31: ; preds = %27
%32 = call i64 (...) @rand()
%33 = sitofp i64 %32 to double
%34 = load double, double* @RAND_MAX
%35 = fdiv double %33, %34
store double %35, double* %2
%36 = call i64 (...) @rand()
%37 = sitofp i64 %36 to double
%38 = load double, double* @RAND_MAX
%39 = fdiv double %37, %38
store double %39, double* %3
%40 = load double, double* %2
%41 = load double, double* %2
%42 = load double, double* %3
%43 = load double, double* %3
%44 = fmul double %42, %43
%45 = call double @llvm.fmuladd.f64(double %40, double %41, double %44)
%46 = fcmp ole double %45, 1.000000e+00
br i1 %46, label %47, label %50
47: ; preds = %31
%48 = load float, float* %10
%49 = fadd float %48, 1.000000e+00
store float %49, float* %10
br label %50
50: ; preds = %47, %31
br label %51
51: ; preds = %50
%52 = load i64, i64* %12
%53 = add nsw i64 %52, 1
store i64 %53, i64* %12
br label %27
54: ; preds = %27
%55 = load float, float* %10
%56 = load i64, i64* %9
%57 = sitofp i64 %56 to float
%58 = fdiv float %55, %57
%59 = fmul float %58, 4.000000e+00
%60 = fpext float %59 to double
store double %60, double* %4
%61 = load i32, i32* %11
%62 = add nsw i32 %61, 1
%63 = load double, double* %4
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %62, double %63)
%65 = load double, double* %4
%66 = load double, double* %7
%67 = fadd double %66, %65
store double %67, double* %7
%68 = load double, double* %4
%69 = load double, double* %4
%70 = load double, double* %8
%71 = call double @llvm.fmuladd.f64(double %68, double %69, double %70)
store double %71, double* %8
br label %72
72: ; preds = %54
%73 = load i32, i32* %11
%74 = add nsw i32 %73, 1
store i32 %74, i32* %11
br label %23
75: ; preds = %23
%76 = load double, double* %7
%77 = fdiv double %76, 1.000000e+01
store double %77, double* %5
%78 = load double, double* %8
%79 = fdiv double %78, 1.000000e+01
%80 = load double, double* %5
%81 = load double, double* %5
%82 = fneg double %80
%83 = call double @llvm.fmuladd.f64(double %82, double %81, double %79)
store double %83, double* %6
%84 = load double, double* %6
%85 = fcmp olt double %84, 0.000000e+00
br i1 %85, label %86, label %90
86: ; preds = %75
%87 = load double, double* %6
%88 = fmul double -1.000000e+00, %87
%89 = call double @sqrt(double %88)
store double %89, double* %6
br label %93
90: ; preds = %75
%91 = load double, double* %6
%92 = call double @sqrt(double %91)
store double %92, double* %6
br label %93
93: ; preds = %90, %86
%94 = load double, double* %5
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %94)
%96 = load double, double* %6
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %96)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Please enter a positive integer N:\00"
@.str.1 = [3 x i8] c"%d\00"
@RAND_MAX = global double 0.000000e+00
@.str.2 = [29 x i8] c"The number %d value is: %f \0A\00"
@.str.3 = [11 x i8] c"Mean: %f \0A\00"
@.str.4 = [27 x i8] c"Standard Deviation: %f \0A \0A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 -1, i64* %1
br label %3
3: ; preds = %0, %3
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%6 = load i64, i64* %1
%7 = icmp slt i64 %6, 0
br i1 %7, label %3, label %8
8: ; preds = %3
%9 = call i64 @time(i32* null)
%10 = trunc i64 %9 to i32
%11 = call i32 @srand(i32 %10)
br label %12
12: ; preds = %8, %29
%13 = phi i32 [ 0, %8 ], [ %36, %29 ]
%14 = phi double [ undef, %8 ], [ %39, %29 ]
%15 = phi double [ undef, %8 ], [ %38, %29 ]
%16 = load i64, i64* %1
%17 = icmp sgt i64 %16, 0
br i1 %17, label %41, label %29
18: ; preds = %29
%19 = fdiv double %38, 1.000000e+01
%20 = fdiv double %39, 1.000000e+01
%21 = fneg double %19
%22 = call double @llvm.fmuladd.f64(double %21, double %19, double %20)
%23 = fcmp olt double %22, 0.000000e+00
%24 = fneg double %22
%25 = select i1 %23, double %24, double %22
%26 = call double @sqrt(double %25)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %19)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %26)
ret i32 0
29: ; preds = %41, %12
%30 = phi float [ 0.000000e+00, %12 ], [ %56, %41 ]
%31 = phi i64 [ %16, %12 ], [ %58, %41 ]
%32 = sitofp i64 %31 to float
%33 = fdiv float %30, %32
%34 = fmul float %33, 4.000000e+00
%35 = fpext float %34 to double
%36 = add nuw nsw i32 %13, 1
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %36, double %35)
%38 = fadd double %15, %35
%39 = call double @llvm.fmuladd.f64(double %35, double %35, double %14)
%40 = icmp eq i32 %36, 10
br i1 %40, label %18, label %12
41: ; preds = %12, %41
%42 = phi i64 [ %57, %41 ], [ 0, %12 ]
%43 = phi float [ %56, %41 ], [ 0.000000e+00, %12 ]
%44 = call i64 (...) @rand()
%45 = sitofp i64 %44 to double
%46 = load double, double* @RAND_MAX
%47 = fdiv double %45, %46
%48 = call i64 (...) @rand()
%49 = sitofp i64 %48 to double
%50 = load double, double* @RAND_MAX
%51 = fdiv double %49, %50
%52 = fmul double %51, %51
%53 = call double @llvm.fmuladd.f64(double %47, double %47, double %52)
%54 = fcmp ugt double %53, 1.000000e+00
%55 = fadd float %43, 1.000000e+00
%56 = select i1 %54, float %43, float %55
%57 = add nuw nsw i64 %42, 1
%58 = load i64, i64* %1
%59 = icmp slt i64 %57, %58
br i1 %59, label %41, label %29
}