#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 */
float fabs(float);
double log(float);
float random_float_unit_uniform();
float random_float_gaussian(const float mean, const float stddev) {
  float q, u, v, x, y;
  do {
    u = 1.0f - random_float_unit_uniform();
    v = 1.7156f * (0.5f - random_float_unit_uniform());
    x = u - 0.449871f;
    y = 0.386595f + fabs(v);
    q = x * x + y * (0.19600f * y - 0.25472f * x);
  } while ((q >= 0.27597) &&
           ((q > 0.27846) || (v * v > -4.0 * log(u) * u * u)));
  return (float)(mean + 2.0 * stddev * v / u);
}


x86 assembly (clang, -O0):
<random_float_gaussian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    $0x0,%al
call   1030 <random_float_unit_uniform@plt>
movaps %xmm0,%xmm1
movss  0xec4(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <random_float_unit_uniform@plt>
movss  0xea8(%rip),%xmm1
subss  %xmm0,%xmm1
movss  0xe98(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xe7e(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <fabs@plt>
movaps %xmm0,%xmm1
movss  0xe5c(%rip),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
movss  -0x1c(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm3
movss  0xe33(%rip),%xmm4
mulss  -0x18(%rbp),%xmm4
movd   %xmm4,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm4
movss  0xe15(%rip),%xmm5
mulss  %xmm5,%xmm3
addss  %xmm4,%xmm3
mulss  %xmm3,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xor    %eax,%eax
movsd  0xe09(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x1d(%rbp)
jb     129f <random_float_gaussian+0x16f>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
movsd  0xdf1(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x1e(%rbp)
ja     1299 <random_float_gaussian+0x169>
movss  -0x14(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x10(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  0xdbf(%rip),%xmm1
mulsd  %xmm2,%xmm1
movss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mulsd  %xmm2,%xmm1
movss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1142 <random_float_gaussian+0x12>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xd74(%rip),%xmm1
mulsd  %xmm2,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
mulsd  %xmm2,%xmm1
movss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_float_gaussian>:
sub    $0x38,%rsp
movss  %xmm1,0x14(%rsp)
movss  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1030 <random_float_unit_uniform@plt>
movss  0xec1(%rip),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
xor    %eax,%eax
call   1030 <random_float_unit_uniform@plt>
movss  0xc(%rsp),%xmm5
movss  0xea6(%rip),%xmm4
subss  %xmm0,%xmm4
mulss  0xe9e(%rip),%xmm4
movaps %xmm5,%xmm0
addss  0xe97(%rip),%xmm0
movaps %xmm4,%xmm1
andps  0xea1(%rip),%xmm1
addss  0xe89(%rip),%xmm1
movaps %xmm0,%xmm2
mulss  0xe82(%rip),%xmm2
movaps %xmm1,%xmm3
mulss  0xe7b(%rip),%xmm3
addss  %xmm2,%xmm3
mulss  %xmm1,%xmm3
mulss  %xmm0,%xmm0
addss  %xmm3,%xmm0
cvtss2sd %xmm0,%xmm0
ucomisd 0xe77(%rip),%xmm0
jb     1218 <random_float_gaussian+0xf8>
ucomisd 0xe75(%rip),%xmm0
ja     1130 <random_float_gaussian+0x10>
movaps %xmm4,%xmm0
mulss  %xmm4,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
movaps %xmm5,%xmm0
movaps %xmm4,0x20(%rsp)
call   1040 <log@plt>
movaps 0x20(%rsp),%xmm4
mulsd  0xe4c(%rip),%xmm0
movss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  0x18(%rsp),%xmm2
ucomisd %xmm0,%xmm2
ja     1130 <random_float_gaussian+0x10>
jmp    121f <random_float_gaussian+0xff>
xorps  %xmm1,%xmm1
cvtss2sd %xmm5,%xmm1
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x14(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
addsd  %xmm2,%xmm2
xorps  %xmm3,%xmm3
cvtss2sd %xmm4,%xmm3
mulsd  %xmm2,%xmm3
divsd  %xmm1,%xmm3
addsd  %xmm0,%xmm3
xorps  %xmm0,%xmm0
cvtsd2ss %xmm3,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define float @random_float_gaussian(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store float %0, float* %3
store float %1, float* %4
br label %10
10: ; preds = %56, %2
%11 = call float (...) @random_float_unit_uniform()
%12 = fsub float 1.000000e+00, %11
store float %12, float* %6
%13 = call float (...) @random_float_unit_uniform()
%14 = fsub float 5.000000e-01, %13
%15 = fmul float 0x3FFB731900000000, %14
store float %15, float* %7
%16 = load float, float* %6
%17 = fsub float %16, 0x3FDCCAAFC0000000
store float %17, float* %8
%18 = load float, float* %7
%19 = call float @fabs(float %18)
%20 = fadd float 0x3FD8BDF900000000, %19
store float %20, float* %9
%21 = load float, float* %8
%22 = load float, float* %8
%23 = load float, float* %9
%24 = load float, float* %9
%25 = load float, float* %8
%26 = fmul float 0x3FD04D5520000000, %25
%27 = fneg float %26
%28 = call float @llvm.fmuladd.f32(float 0x3FC9168720000000, float %24, float %27)
%29 = fmul float %23, %28
%30 = call float @llvm.fmuladd.f32(float %21, float %22, float %29)
store float %30, float* %5
br label %31
31: ; preds = %10
%32 = load float, float* %5
%33 = fpext float %32 to double
%34 = fcmp oge double %33, 2.759700e-01
br i1 %34, label %35, label %56
35: ; preds = %31
%36 = load float, float* %5
%37 = fpext float %36 to double
%38 = fcmp ogt double %37, 2.784600e-01
br i1 %38, label %54, label %39
39: ; preds = %35
%40 = load float, float* %7
%41 = load float, float* %7
%42 = fmul float %40, %41
%43 = fpext float %42 to double
%44 = load float, float* %6
%45 = call double @log(float %44)
%46 = fmul double -4.000000e+00, %45
%47 = load float, float* %6
%48 = fpext float %47 to double
%49 = fmul double %46, %48
%50 = load float, float* %6
%51 = fpext float %50 to double
%52 = fmul double %49, %51
%53 = fcmp ogt double %43, %52
br label %54
54: ; preds = %39, %35
%55 = phi i1 [ true, %35 ], [ %53, %39 ]
br label %56
56: ; preds = %54, %31
%57 = phi i1 [ false, %31 ], [ %55, %54 ]
br i1 %57, label %10, label %58
58: ; preds = %56
%59 = load float, float* %3
%60 = fpext float %59 to double
%61 = load float, float* %4
%62 = fpext float %61 to double
%63 = fmul double 2.000000e+00, %62
%64 = load float, float* %7
%65 = fpext float %64 to double
%66 = fmul double %63, %65
%67 = load float, float* %6
%68 = fpext float %67 to double
%69 = fdiv double %66, %68
%70 = fadd double %60, %69
%71 = fptrunc double %70 to float
ret float %71
}

LLVM IR (-O2):
define float @random_float_gaussian(float %0, float %1) {
br label %3
3: ; preds = %31, %2
%4 = tail call float (...) @random_float_unit_uniform()
%5 = fsub float 1.000000e+00, %4
%6 = tail call float (...) @random_float_unit_uniform()
%7 = fsub float 5.000000e-01, %6
%8 = fmul float %7, 0x3FFB731900000000
%9 = fadd float %5, 0xBFDCCAAFC0000000
%10 = tail call float @llvm.fabs.f32(float %8)
%11 = fadd float %10, 0x3FD8BDF900000000
%12 = fmul float %9, 0xBFD04D5520000000
%13 = tail call float @llvm.fmuladd.f32(float %11, float 0x3FC9168720000000, float %12)
%14 = fmul float %11, %13
%15 = tail call float @llvm.fmuladd.f32(float %9, float %9, float %14)
%16 = fpext float %15 to double
%17 = fcmp ult double %16, 2.759700e-01
br i1 %17, label %18, label %20
18: ; preds = %3
%19 = fpext float %5 to double
br label %32
20: ; preds = %3
%21 = fcmp ogt double %16, 2.784600e-01
br i1 %21, label %31, label %22
22: ; preds = %20
%23 = fmul float %8, %8
%24 = fpext float %23 to double
%25 = tail call double @log(float %5)
%26 = fmul double %25, -4.000000e+00
%27 = fpext float %5 to double
%28 = fmul double %26, %27
%29 = fmul double %28, %27
%30 = fcmp olt double %29, %24
br i1 %30, label %31, label %32
31: ; preds = %22, %20
br label %3
32: ; preds = %22, %18
%33 = phi double [ %19, %18 ], [ %27, %22 ]
%34 = fpext float %0 to double
%35 = fpext float %1 to double
%36 = fmul double %35, 2.000000e+00
%37 = fpext float %8 to double
%38 = fmul double %36, %37
%39 = fdiv double %38, %33
%40 = fadd double %39, %34
%41 = fptrunc double %40 to float
ret float %41
}