#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 */
scalar_t__ RAND_MAX;
int cos(int);
double density_N01(double);
double inv_distr_N01(double);
int log(double);
int const rand();
int sqrt(int);
void ArrayOfN01(double x[], int const nVal, int const UseDiscretizing) {
  int i, index;
  if (!UseDiscretizing) {
    for (i = 0; i < nVal; i++)
      x[i] = (double)(sqrt(-2 * log((((double)rand() + 0.5) /
                                     ((double)RAND_MAX + 1.0)))) *
                      cos(2 * 3.1415926535 *
                          (((double)rand() + 0.5) / ((double)RAND_MAX + 1.0))));
  } else {
    double perc_low, perc_high = 1;
    double outc_low, outc_high = 1e10;
    double temp;
    for (i = 0; i < nVal; i++) {
      if (i == 0) {
        perc_low = 0;
        outc_low = -1e10;
      } else {
        perc_low = perc_high;
        outc_low = outc_high;
      }
      if (i == nVal - 1) {
        perc_high = 1;
        outc_high = 1e10;
      } else {
        perc_high = (double)(i + 1) / nVal;
        outc_high = inv_distr_N01(perc_high);
      }
      x[i] = (density_N01(outc_high) - density_N01(outc_low)) /
             (perc_high - perc_low);
    }
    for (i = 0; i < nVal; i++) {
      index = i + (rand() % (nVal - i));
      temp = x[i];
      x[i] = x[index];
      x[index] = temp;
    }
  }
}


x86 assembly (clang, -O0):
<ArrayOfN01>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1249 <ArrayOfN01+0xe9>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1244 <ArrayOfN01+0xe4>
mov    $0x0,%al
call   1080 <rand@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe6e(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    0x2e3b(%rip),%rax
cvtsi2sdq (%rax),%xmm1
movsd  0xe4e(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1060 <log@plt>
imul   $0xfffffffe,%eax,%edi
call   1070 <sqrt@plt>
mov    %eax,-0x44(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe28(%rip),%xmm0
addsd  %xmm0,%xmm1
mov    0x2df5(%rip),%rax
cvtsi2sdq (%rax),%xmm0
movsd  0xe08(%rip),%xmm2
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  0xdf0(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1183 <ArrayOfN01+0x23>
jmp    13d5 <ArrayOfN01+0x275>
movsd  0xdb7(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdba(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1353 <ArrayOfN01+0x1f3>
cmpl   $0x0,-0x14(%rbp)
jne    129a <ArrayOfN01+0x13a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xd90(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12ae <ArrayOfN01+0x14e>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    12de <ArrayOfN01+0x17e>
movsd  0xd41(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xd44(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1305 <ArrayOfN01+0x1a5>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <inv_distr_N01@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <density_N01@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <density_N01@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    126a <ArrayOfN01+0x10a>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    13d0 <ArrayOfN01+0x270>
mov    -0x14(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    -0xc(%rbp),%ecx
sub    -0x14(%rbp),%ecx
cltd
idiv   %ecx
mov    -0x54(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    135a <ArrayOfN01+0x1fa>
jmp    13d5 <ArrayOfN01+0x275>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ArrayOfN01>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %esi,%r14d
mov    %rdi,%r12
test   %edx,%edx
je     12c8 <ArrayOfN01+0x168>
test   %r14d,%r14d
jle    137b <ArrayOfN01+0x21b>
lea    -0x1(%r14),%r15d
cvtsi2sd %r14d,%xmm0
movsd  %xmm0,0x18(%rsp)
mov    %r14d,%r13d
movsd  0xe61(%rip),%xmm0
movsd  0xe61(%rip),%xmm1
xor    %ebx,%ebx
movsd  %xmm1,0x8(%rsp)
jmp    120c <ArrayOfN01+0xac>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
call   1030 <density_N01@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x28(%rsp),%xmm0
call   1030 <density_N01@plt>
movsd  0x20(%rsp),%xmm2
subsd  %xmm0,%xmm2
movsd  0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
subsd  0x30(%rsp),%xmm0
divsd  %xmm0,%xmm2
movsd  %xmm2,(%r12,%rbx,8)
mov    %rbp,%rbx
cmp    %rbp,%r13
movapd %xmm1,%xmm0
je     1278 <ArrayOfN01+0x118>
xorpd  %xmm1,%xmm1
test   %rbx,%rbx
je     1219 <ArrayOfN01+0xb9>
movapd %xmm0,%xmm1
movsd  0xdef(%rip),%xmm0
je     1229 <ArrayOfN01+0xc9>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  %xmm1,0x30(%rsp)
lea    0x1(%rbx),%rbp
movsd  0xdbf(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xdb9(%rip),%xmm0
cmp    %rbx,%r15
je     11c0 <ArrayOfN01+0x60>
lea    0x1(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1050 <inv_distr_N01@plt>
jmp    11c0 <ArrayOfN01+0x60>
test   %r14d,%r14d
jle    137b <ArrayOfN01+0x21b>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1080 <rand@plt>
cltd
idiv   %r13d
movsd  (%r12,%rbx,8),%xmm0
movslq %edx,%rax
add    %rbx,%rax
movsd  (%r12,%rax,8),%xmm1
movsd  %xmm1,(%r12,%rbx,8)
movsd  %xmm0,(%r12,%rax,8)
add    $0x1,%rbx
add    $0xffffffffffffffff,%r13
jne    1290 <ArrayOfN01+0x130>
jmp    137b <ArrayOfN01+0x21b>
test   %r14d,%r14d
jle    137b <ArrayOfN01+0x21b>
mov    %r14d,%r14d
mov    0x2d0d(%rip),%r15
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xd22(%rip),%xmm1
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%r15),%xmm1
movsd  0xcf6(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1060 <log@plt>
lea    (%rax,%rax,1),%edi
neg    %edi
call   1070 <sqrt@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xcdf(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%r15),%xmm1
addsd  0xcb7(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  0xccb(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
imul   %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    12e0 <ArrayOfN01+0x180>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define void @ArrayOfN01(double* %0, i32 %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double* %0, double** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 0
br i1 %15, label %52, label %16
16: ; preds = %3
store i32 0, i32* %7
br label %17
17: ; preds = %48, %16
%18 = load i32, i32* %7
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %51
21: ; preds = %17
%22 = call i32 (...) @rand()
%23 = sitofp i32 %22 to double
%24 = fadd double %23, 5.000000e-01
%25 = load i64, i64* @RAND_MAX
%26 = sitofp i64 %25 to double
%27 = fadd double %26, 1.000000e+00
%28 = fdiv double %24, %27
%29 = call i32 @log(double %28)
%30 = mul nsw i32 -2, %29
%31 = call i32 @sqrt(i32 %30)
%32 = call i32 (...) @rand()
%33 = sitofp i32 %32 to double
%34 = fadd double %33, 5.000000e-01
%35 = load i64, i64* @RAND_MAX
%36 = sitofp i64 %35 to double
%37 = fadd double %36, 1.000000e+00
%38 = fdiv double %34, %37
%39 = fmul double 0x401921FB54411744, %38
%40 = fptosi double %39 to i32
%41 = call i32 @cos(i32 %40)
%42 = mul nsw i32 %31, %41
%43 = sitofp i32 %42 to double
%44 = load double*, double** %4
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
store double %43, double* %47
br label %48
48: ; preds = %21
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %17
51: ; preds = %17
br label %132
52: ; preds = %3
store double 1.000000e+00, double* %10
store double 1.000000e+10, double* %12
store i32 0, i32* %7
br label %53
53: ; preds = %93, %52
%54 = load i32, i32* %7
%55 = load i32, i32* %5
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %96
57: ; preds = %53
%58 = load i32, i32* %7
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %57
store double 0.000000e+00, double* %9
store double -1.000000e+10, double* %11
br label %64
61: ; preds = %57
%62 = load double, double* %10
store double %62, double* %9
%63 = load double, double* %12
store double %63, double* %11
br label %64
64: ; preds = %61, %60
%65 = load i32, i32* %7
%66 = load i32, i32* %5
%67 = sub nsw i32 %66, 1
%68 = icmp eq i32 %65, %67
br i1 %68, label %69, label %70
69: ; preds = %64
store double 1.000000e+00, double* %10
store double 1.000000e+10, double* %12
br label %79
70: ; preds = %64
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
%73 = sitofp i32 %72 to double
%74 = load i32, i32* %5
%75 = sitofp i32 %74 to double
%76 = fdiv double %73, %75
store double %76, double* %10
%77 = load double, double* %10
%78 = call double @inv_distr_N01(double %77)
store double %78, double* %12
br label %79
79: ; preds = %70, %69
%80 = load double, double* %12
%81 = call double @density_N01(double %80)
%82 = load double, double* %11
%83 = call double @density_N01(double %82)
%84 = fsub double %81, %83
%85 = load double, double* %10
%86 = load double, double* %9
%87 = fsub double %85, %86
%88 = fdiv double %84, %87
%89 = load double*, double** %4
%90 = load i32, i32* %7
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %89, i64 %91
store double %88, double* %92
br label %93
93: ; preds = %79
%94 = load i32, i32* %7
%95 = add nsw i32 %94, 1
store i32 %95, i32* %7
br label %53
96: ; preds = %53
store i32 0, i32* %7
br label %97
97: ; preds = %128, %96
%98 = load i32, i32* %7
%99 = load i32, i32* %5
%100 = icmp slt i32 %98, %99
br i1 %100, label %101, label %131
101: ; preds = %97
%102 = load i32, i32* %7
%103 = call i32 (...) @rand()
%104 = load i32, i32* %5
%105 = load i32, i32* %7
%106 = sub nsw i32 %104, %105
%107 = srem i32 %103, %106
%108 = add nsw i32 %102, %107
store i32 %108, i32* %8
%109 = load double*, double** %4
%110 = load i32, i32* %7
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double, double* %109, i64 %111
%113 = load double, double* %112
store double %113, double* %13
%114 = load double*, double** %4
%115 = load i32, i32* %8
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds double, double* %114, i64 %116
%118 = load double, double* %117
%119 = load double*, double** %4
%120 = load i32, i32* %7
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds double, double* %119, i64 %121
store double %118, double* %122
%123 = load double, double* %13
%124 = load double*, double** %4
%125 = load i32, i32* %8
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds double, double* %124, i64 %126
store double %123, double* %127
br label %128
128: ; preds = %101
%129 = load i32, i32* %7
%130 = add nsw i32 %129, 1
store i32 %130, i32* %7
br label %97
131: ; preds = %97
br label %132
132: ; preds = %131, %51
ret void
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define void @ArrayOfN01(double* nocapture %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
%5 = icmp sgt i32 %1, 0
br i1 %4, label %12, label %6
6: ; preds = %3
br i1 %5, label %7, label %83
7: ; preds = %6
%8 = add nsw i32 %1, -1
%9 = sitofp i32 %1 to double
%10 = zext i32 %8 to i64
%11 = zext i32 %1 to i64
br label %45
12: ; preds = %3
br i1 %5, label %13, label %83
13: ; preds = %12
%14 = zext i32 %1 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %40, %15 ]
%17 = tail call i32 (...) @rand()
%18 = sitofp i32 %17 to double
%19 = fadd double %18, 5.000000e-01
%20 = load i64, i64* @RAND_MAX
%21 = sitofp i64 %20 to double
%22 = fadd double %21, 1.000000e+00
%23 = fdiv double %19, %22
%24 = tail call i32 @log(double %23)
%25 = mul nsw i32 %24, -2
%26 = tail call i32 @sqrt(i32 %25)
%27 = tail call i32 (...) @rand()
%28 = sitofp i32 %27 to double
%29 = fadd double %28, 5.000000e-01
%30 = load i64, i64* @RAND_MAX
%31 = sitofp i64 %30 to double
%32 = fadd double %31, 1.000000e+00
%33 = fdiv double %29, %32
%34 = fmul double %33, 0x401921FB54411744
%35 = fptosi double %34 to i32
%36 = tail call i32 @cos(i32 %35)
%37 = mul nsw i32 %36, %26
%38 = sitofp i32 %37 to double
%39 = getelementptr inbounds double, double* %0, i64 %16
store double %38, double* %39
%40 = add nuw nsw i64 %16, 1
%41 = icmp eq i64 %40, %14
br i1 %41, label %83, label %15
42: ; preds = %59
br i1 %5, label %43, label %83
43: ; preds = %42
%44 = zext i32 %1 to i64
br label %69
45: ; preds = %7, %59
%46 = phi i64 [ 0, %7 ], [ %53, %59 ]
%47 = phi double [ 1.000000e+10, %7 ], [ %61, %59 ]
%48 = phi double [ 1.000000e+00, %7 ], [ %60, %59 ]
%49 = icmp eq i64 %46, 0
%50 = select i1 %49, double 0.000000e+00, double %48
%51 = select i1 %49, double -1.000000e+10, double %47
%52 = icmp eq i64 %46, %10
%53 = add nuw nsw i64 %46, 1
br i1 %52, label %59, label %54
54: ; preds = %45
%55 = trunc i64 %53 to i32
%56 = sitofp i32 %55 to double
%57 = fdiv double %56, %9
%58 = tail call double @inv_distr_N01(double %57)
br label %59
59: ; preds = %45, %54
%60 = phi double [ %57, %54 ], [ 1.000000e+00, %45 ]
%61 = phi double [ %58, %54 ], [ 1.000000e+10, %45 ]
%62 = tail call double @density_N01(double %61)
%63 = tail call double @density_N01(double %51)
%64 = fsub double %62, %63
%65 = fsub double %60, %50
%66 = fdiv double %64, %65
%67 = getelementptr inbounds double, double* %0, i64 %46
store double %66, double* %67
%68 = icmp eq i64 %53, %11
br i1 %68, label %42, label %45
69: ; preds = %43, %69
%70 = phi i64 [ 0, %43 ], [ %81, %69 ]
%71 = tail call i32 (...) @rand()
%72 = trunc i64 %70 to i32
%73 = sub nsw i32 %1, %72
%74 = srem i32 %71, %73
%75 = add nsw i32 %74, %72
%76 = getelementptr inbounds double, double* %0, i64 %70
%77 = load double, double* %76
%78 = sext i32 %75 to i64
%79 = getelementptr inbounds double, double* %0, i64 %78
%80 = load double, double* %79
store double %80, double* %76
store double %77, double* %79
%81 = add nuw nsw i64 %70, 1
%82 = icmp eq i64 %81, %44
br i1 %82, label %83, label %69
83: ; preds = %69, %15, %6, %42, %12
ret void
}