#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 DBL_MIN;
double cos(double const);
double frand();
double log(double);
double sin(double const);
double sqrt(double);
double gaussian(double mu, double sigma) {
  const double epsilon = DBL_MIN;
  const double two_pi = 2.0 * 3.14159265358979323846;
  static double z0, z1;
  static int generate;
  generate = !generate;
  if (!generate)
    return z1 * sigma + mu;
  double u1, u2;
  do {
    u1 = frand();
    u2 = frand();
  } while (u1 <= epsilon);
  z0 = sqrt(-2.0 * log(u1)) * cos(two_pi * u2);
  z1 = sqrt(-2.0 * log(u1)) * sin(two_pi * u2);
  return z0 * sigma + mu;
}


x86 assembly (clang, -O0):
<gaussian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    0x2e77(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe86(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x0,0x2ee2(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2ed2(%rip)
cmpl   $0x0,0x2ecb(%rip)
jne    11c7 <gaussian+0x77>
movsd  0x2eb5(%rip),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a9 <gaussian+0x159>
jmp    11cc <gaussian+0x7c>
mov    $0x0,%al
call   1040 <frand@plt>
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1040 <frand@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jae    11cc <gaussian+0x7c>
movsd  -0x30(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  0xdfb(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xddd(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x2e17(%rip)
movsd  -0x30(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  0xdb2(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0xd94(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x2dd6(%rip)
movsd  0x2dc6(%rip),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gaussian>:
sub    $0x28,%rsp
mov    0x2e85(%rip),%rax
movsd  (%rax),%xmm2
xor    %eax,%eax
cmpl   $0x0,0x2f00(%rip)
sete   %al
mov    %eax,0x2ef7(%rip)
je     117f <gaussian+0x2f>
lea    0x2ee6(%rip),%rax
jmp    1264 <gaussian+0x114>
movsd  %xmm0,0x18(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm2,(%rsp)
xor    %eax,%eax
call   1040 <frand@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1040 <frand@plt>
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm2
jae    1190 <gaussian+0x40>
movsd  %xmm0,(%rsp)
movapd %xmm1,%xmm0
call   1060 <log@plt>
mulsd  0xe35(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11db <gaussian+0x8b>
sqrtsd %xmm0,%xmm0
jmp    11e0 <gaussian+0x90>
call   1070 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
mulsd  0xe15(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   1050 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x2e4d(%rip)
movsd  0x8(%rsp),%xmm0
call   1060 <log@plt>
mulsd  0xde2(%rip),%xmm0
ucomisd 0xdea(%rip),%xmm0
jb     122e <gaussian+0xde>
sqrtsd %xmm0,%xmm0
jmp    1233 <gaussian+0xe3>
call   1070 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x2e0f(%rip)
lea    0x2e00(%rip),%rax
movsd  0x20(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
mulsd  (%rax),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@DBL_MIN = global double 0.000000e+00
@gaussian.z0 = internal global double 0.000000e+00
@gaussian.z1 = internal global double 0.000000e+00
@gaussian.generate = internal global i32 0
define double @gaussian(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %4
store double %1, double* %5
%10 = load double, double* @DBL_MIN
store double %10, double* %6
store double 0x401921FB54442D18, double* %7
%11 = load i32, i32* @gaussian.generate
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
%14 = zext i1 %13 to i32
store i32 %14, i32* @gaussian.generate
%15 = load i32, i32* @gaussian.generate
%16 = icmp ne i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %2
%18 = load double, double* @gaussian.z1
%19 = load double, double* %5
%20 = load double, double* %4
%21 = call double @llvm.fmuladd.f64(double %18, double %19, double %20)
store double %21, double* %3
br label %51
22: ; preds = %2
br label %23
23: ; preds = %26, %22
%24 = call double (...) @frand()
store double %24, double* %8
%25 = call double (...) @frand()
store double %25, double* %9
br label %26
26: ; preds = %23
%27 = load double, double* %8
%28 = load double, double* %6
%29 = fcmp ole double %27, %28
br i1 %29, label %23, label %30
30: ; preds = %26
%31 = load double, double* %8
%32 = call double @log(double %31)
%33 = fmul double -2.000000e+00, %32
%34 = call double @sqrt(double %33)
%35 = load double, double* %9
%36 = fmul double 0x401921FB54442D18, %35
%37 = call double @cos(double %36)
%38 = fmul double %34, %37
store double %38, double* @gaussian.z0
%39 = load double, double* %8
%40 = call double @log(double %39)
%41 = fmul double -2.000000e+00, %40
%42 = call double @sqrt(double %41)
%43 = load double, double* %9
%44 = fmul double 0x401921FB54442D18, %43
%45 = call double @sin(double %44)
%46 = fmul double %42, %45
store double %46, double* @gaussian.z1
%47 = load double, double* @gaussian.z0
%48 = load double, double* %5
%49 = load double, double* %4
%50 = call double @llvm.fmuladd.f64(double %47, double %48, double %49)
store double %50, double* %3
br label %51
51: ; preds = %30, %17
%52 = load double, double* %3
ret double %52
}

LLVM IR (-O2):
@DBL_MIN = global double 0.000000e+00
@gaussian.z0 = internal unnamed_addr global double 0.000000e+00
@gaussian.z1 = internal unnamed_addr global double 0.000000e+00
@gaussian.generate = internal unnamed_addr global i32 0
define double @gaussian(double %0, double %1) {
%3 = load double, double* @DBL_MIN
%4 = load i32, i32* @gaussian.generate
%5 = icmp eq i32 %4, 0
%6 = zext i1 %5 to i32
store i32 %6, i32* @gaussian.generate
br i1 %5, label %7, label %23
7: ; preds = %2, %7
%8 = tail call double (...) @frand()
%9 = tail call double (...) @frand()
%10 = fcmp ugt double %8, %3
br i1 %10, label %11, label %7
11: ; preds = %7
%12 = tail call double @log(double %8)
%13 = fmul double %12, -2.000000e+00
%14 = tail call double @sqrt(double %13)
%15 = fmul double %9, 0x401921FB54442D18
%16 = tail call double @cos(double %15)
%17 = fmul double %14, %16
store double %17, double* @gaussian.z0
%18 = tail call double @log(double %8)
%19 = fmul double %18, -2.000000e+00
%20 = tail call double @sqrt(double %19)
%21 = tail call double @sin(double %15)
%22 = fmul double %20, %21
store double %22, double* @gaussian.z1
br label %23
23: ; preds = %2, %11
%24 = phi double* [ @gaussian.z0, %11 ], [ @gaussian.z1, %2 ]
%25 = load double, double* %24
%26 = tail call double @llvm.fmuladd.f64(double %25, double %1, double %0)
ret double %26
}