#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*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
double sqrt(double);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(void) {
  double x, y, ratio, mean, standdev, sum, squaresum;
  int 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 (int i = 0; i < N; i++) {
      x = ((double)(rand() % 10001)) / 10000;
      y = ((double)(rand() % 10001)) / 10000;
      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 - (sum * sum)) / 10;
  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    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    11a3 <main+0x43>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    -0x44(%rbp),%rsi
call   1060 <scanf@plt>
jmp    1176 <main+0x16>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x4c(%rbp)
cmpl   $0xa,-0x4c(%rbp)
jge    12ef <main+0x18f>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x48(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    127a <main+0x11a>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x2711,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  0xe1e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x2711,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  0xdfa(%rip),%xmm1
divsd  %xmm1,%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  0xdc5(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1267 <main+0x107>
movss  0xdc7(%rip),%xmm0
addss  -0x48(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
jmp    126c <main+0x10c>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11d3 <main+0x73>
movss  -0x48(%rbp),%xmm0
cvtsi2ssl -0x44(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  0xd90(%rip),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4c(%rbp),%esi
add    $0x1,%esi
movsd  -0x20(%rbp),%xmm0
lea    0xd9f(%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    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11ba <main+0x5a>
movsd  -0x38(%rbp),%xmm0
movsd  0xd04(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xcc5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    136e <main+0x20e>
movsd  0xcae(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    137d <main+0x21d>
movsd  -0x30(%rbp),%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xce2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xcda(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movl   $0xffffffff,0xc(%rsp)
ff
lea    0xeb9(%rip),%r14
lea    0xed5(%rip),%rbp
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
js     1190 <main+0x30>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe95(%rip),%r14
xor    %ebp,%ebp
jmp    1232 <main+0xd2>
cs nopw 0x0(%rax,%rax,1)
nop
movss  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x8(%rsp),%xmm1
divss  %xmm0,%xmm1
mulss  0xe2d(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
add    $0x1,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x18(%rsp),%xmm3
movsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm0
movapd 0x20(%rsp),%xmm4
addsd  %xmm0,%xmm4
cmp    $0xa,%ebp
je     1324 <main+0x1c4>
mov    0xc(%rsp),%eax
test   %eax,%eax
movsd  %xmm3,0x18(%rsp)
movapd %xmm4,0x20(%rsp)
xorps  %xmm0,%xmm0
jle    11d0 <main+0x70>
movss  %xmm0,0x8(%rsp)
xor    %ebx,%ebx
jmp    126f <main+0x10f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebx
mov    0xc(%rsp),%eax
cmp    %eax,%ebx
jge    11d6 <main+0x76>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0xffffffffd1b1b919,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xd,%ecx
add    %edx,%ecx
imul   $0x2711,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xd5a(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0xffffffffd1b1b919,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xd,%ecx
add    %edx,%ecx
imul   $0x2711,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xd19(%rip),%xmm0
mulsd  %xmm0,%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xd07(%rip),%xmm0
ucomisd %xmm1,%xmm0
movss  0x8(%rsp),%xmm0
addss  0xd05(%rip),%xmm0
jb     1260 <main+0x100>
movss  %xmm0,0x8(%rsp)
jmp    1260 <main+0x100>
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
subsd  %xmm0,%xmm4
divsd  0xcd8(%rip),%xmm4
movapd 0xce0(%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     1369 <main+0x209>
sqrtsd %xmm0,%xmm0
jmp    137a <main+0x21a>
movsd  %xmm3,0x18(%rsp)
call   1070 <sqrt@plt>
movsd  0x18(%rsp),%xmm3
movsd  %xmm0,0x10(%rsp)
divsd  0xc88(%rip),%xmm3
lea    0xce4(%rip),%rdi
movapd %xmm3,%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xcdd(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
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"
@.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 i32
%10 = alloca float
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %9
br label %13
13: ; preds = %16, %0
%14 = load i32, i32* %9
%15 = icmp slt i32 %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), i32* %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 i32 0, i32* %12
br label %27
27: ; preds = %51, %26
%28 = load i32, i32* %12
%29 = load i32, i32* %9
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %54
31: ; preds = %27
%32 = call i32 (...) @rand()
%33 = srem i32 %32, 10001
%34 = sitofp i32 %33 to double
%35 = fdiv double %34, 1.000000e+04
store double %35, double* %2
%36 = call i32 (...) @rand()
%37 = srem i32 %36, 10001
%38 = sitofp i32 %37 to double
%39 = fdiv double %38, 1.000000e+04
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 i32, i32* %12
%53 = add nsw i32 %52, 1
store i32 %53, i32* %12
br label %27
54: ; preds = %27
%55 = load float, float* %10
%56 = load i32, i32* %9
%57 = sitofp i32 %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 = load double, double* %7
%80 = load double, double* %7
%81 = fneg double %79
%82 = call double @llvm.fmuladd.f64(double %81, double %80, double %78)
%83 = fdiv double %82, 1.000000e+01
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"
@.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 = bitcast i32* %1 to i8*
store i32 -1, i32* %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), i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %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 i32, i32* %1
%17 = icmp sgt i32 %16, 0
br i1 %17, label %41, label %29
18: ; preds = %29
%19 = fneg double %38
%20 = call double @llvm.fmuladd.f64(double %19, double %38, double %39)
%21 = fdiv double %20, 1.000000e+01
%22 = fcmp olt double %21, 0.000000e+00
%23 = fneg double %21
%24 = select i1 %22, double %23, double %21
%25 = call double @sqrt(double %24)
%26 = fdiv double %38, 1.000000e+01
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %25)
ret i32 0
29: ; preds = %41, %12
%30 = phi float [ 0.000000e+00, %12 ], [ %56, %41 ]
%31 = phi i32 [ %16, %12 ], [ %58, %41 ]
%32 = sitofp i32 %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 i32 [ %57, %41 ], [ 0, %12 ]
%43 = phi float [ %56, %41 ], [ 0.000000e+00, %12 ]
%44 = call i32 (...) @rand()
%45 = srem i32 %44, 10001
%46 = sitofp i32 %45 to double
%47 = fdiv double %46, 1.000000e+04
%48 = call i32 (...) @rand()
%49 = srem i32 %48, 10001
%50 = sitofp i32 %49 to double
%51 = fdiv double %50, 1.000000e+04
%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 i32 %42, 1
%58 = load i32, i32* %1
%59 = icmp slt i32 %57, %58
br i1 %59, label %41, label %29
}