#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 log(double);
double randinter(int, int);
double sqrt(int);
double randGaussian(double mean, double variance) {
  double v, x, y, r;
  do {
    x = (double)2 * randinter(1, 100) / 99;
    y = (double)2 * randinter(1, 100) / 99;
    r = x * x + y * y;
  } while (r >= 1 || r == 0);
  v = x * sqrt(-2 * log(r) / r) * variance + mean;
  return v;
}


x86 assembly (clang, -O0):
<randGaussian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    $0x1,%edi
mov    $0x64,%esi
call   1030 <randinter@plt>
movaps %xmm0,%xmm1
movsd  0xeac(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe98(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x1,%edi
mov    $0x64,%esi
call   1030 <randinter@plt>
movaps %xmm0,%xmm1
movsd  0xe7d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe69(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
movsd  0xe40(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x31(%rbp)
jae    11f4 <randGaussian+0xc4>
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1142 <randGaussian+0x12>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <log@plt>
imul   $0xfffffffe,%eax,%eax
cvtsi2sd %eax,%xmm0
divsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randGaussian>:
sub    $0x28,%rsp
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    $0x1,%edi
mov    $0x64,%esi
call   1030 <randinter@plt>
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xea1(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0x1,%edi
mov    $0x64,%esi
call   1030 <randinter@plt>
addsd  %xmm0,%xmm0
divsd  0xe7c(%rip),%xmm0
mulsd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
ucomisd 0xe6a(%rip),%xmm1
jae    1140 <randGaussian+0x10>
ucomisd 0xe68(%rip),%xmm1
jne    11ac <randGaussian+0x7c>
jnp    1140 <randGaussian+0x10>
movapd %xmm1,%xmm0
movsd  %xmm1,0x10(%rsp)
call   1040 <log@plt>
add    %eax,%eax
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
mulsd  0x8(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @randGaussian(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %3
store double %1, double* %4
br label %9
9: ; preds = %28, %2
%10 = call double @randinter(i32 1, i32 100)
%11 = fmul double 2.000000e+00, %10
%12 = fdiv double %11, 9.900000e+01
store double %12, double* %6
%13 = call double @randinter(i32 1, i32 100)
%14 = fmul double 2.000000e+00, %13
%15 = fdiv double %14, 9.900000e+01
store double %15, double* %7
%16 = load double, double* %6
%17 = load double, double* %6
%18 = load double, double* %7
%19 = load double, double* %7
%20 = fmul double %18, %19
%21 = call double @llvm.fmuladd.f64(double %16, double %17, double %20)
store double %21, double* %8
br label %22
22: ; preds = %9
%23 = load double, double* %8
%24 = fcmp oge double %23, 1.000000e+00
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load double, double* %8
%27 = fcmp oeq double %26, 0.000000e+00
br label %28
28: ; preds = %25, %22
%29 = phi i1 [ true, %22 ], [ %27, %25 ]
br i1 %29, label %9, label %30
30: ; preds = %28
%31 = load double, double* %6
%32 = load double, double* %8
%33 = call i32 @log(double %32)
%34 = mul nsw i32 -2, %33
%35 = sitofp i32 %34 to double
%36 = load double, double* %8
%37 = fdiv double %35, %36
%38 = fptosi double %37 to i32
%39 = call double @sqrt(i32 %38)
%40 = fmul double %31, %39
%41 = load double, double* %4
%42 = load double, double* %3
%43 = call double @llvm.fmuladd.f64(double %40, double %41, double %42)
store double %43, double* %5
%44 = load double, double* %5
ret double %44
}

LLVM IR (-O2):
define double @randGaussian(double %0, double %1) {
br label %3
3: ; preds = %3, %2
%4 = tail call double @randinter(i32 1, i32 100)
%5 = fmul double %4, 2.000000e+00
%6 = fdiv double %5, 9.900000e+01
%7 = tail call double @randinter(i32 1, i32 100)
%8 = fmul double %7, 2.000000e+00
%9 = fdiv double %8, 9.900000e+01
%10 = fmul double %9, %9
%11 = tail call double @llvm.fmuladd.f64(double %6, double %6, double %10)
%12 = fcmp oge double %11, 1.000000e+00
%13 = fcmp oeq double %11, 0.000000e+00
%14 = or i1 %12, %13
br i1 %14, label %3, label %15
15: ; preds = %3
%16 = tail call i32 @log(double %11)
%17 = mul nsw i32 %16, -2
%18 = sitofp i32 %17 to double
%19 = fdiv double %18, %11
%20 = fptosi double %19 to i32
%21 = tail call double @sqrt(i32 %20)
%22 = fmul double %6, %21
%23 = tail call double @llvm.fmuladd.f64(double %22, double %1, double %0)
ret double %23
}