double _stdnormrnd() {
  double u, v, x, y, q;
  do {
    u = _rnd();
    v = 1.7156 * (_rnd() - 0.5);
    x = u - 0.449871;
    y = fabs(v) + 0.386595;
    q = x * x + y * (0.19600 * y - 0.25472 * x);
  } while (q > 0.27597 && (q > 0.27846 || (v) * (v) > -4 * log(u) * (u) * (u)));
  return v / u;
}


x86 assembly (clang, -O0):
<_stdnormrnd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x0,%al
call   1030 <_rnd@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <_rnd@plt>
cvtsi2sd %eax,%xmm1
movsd  0xedd(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xec9(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xeab(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xece(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe82(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm3
movsd  0xe55(%rip),%xmm4
mulsd  -0x18(%rbp),%xmm4
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
movsd  0xe29(%rip),%xmm5
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xor    %eax,%eax
movsd  0xe31(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x29(%rbp)
jbe    126f <_stdnormrnd+0x14f>
movsd  -0x28(%rbp),%xmm0
mov    $0x1,%al
movsd  0xe1d(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x2a(%rbp)
ja     1269 <_stdnormrnd+0x149>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
movsd  0xdef(%rip),%xmm1
mulsd  %xmm2,%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1128 <_stdnormrnd+0x8>
movsd  -0x10(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_stdnormrnd>:
sub    $0x38,%rsp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <_rnd@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <_rnd@plt>
xorps  %xmm4,%xmm4
cvtsi2sd %eax,%xmm4
addsd  0xea6(%rip),%xmm4
mulsd  0xea6(%rip),%xmm4
movsd  0x8(%rsp),%xmm0
addsd  0xea0(%rip),%xmm0
movapd %xmm4,%xmm1
andpd  0xed4(%rip),%xmm1
addsd  0xe94(%rip),%xmm1
movapd %xmm0,%xmm2
mulsd  0xe90(%rip),%xmm2
movapd %xmm1,%xmm3
mulsd  0xe8c(%rip),%xmm3
addsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm3
mulsd  %xmm0,%xmm0
addsd  %xmm3,%xmm0
ucomisd 0xe7c(%rip),%xmm0
jbe    120f <_stdnormrnd+0xef>
ucomisd 0xe7a(%rip),%xmm0
ja     1130 <_stdnormrnd+0x10>
movapd %xmm4,%xmm0
mulsd  %xmm4,%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
movapd %xmm4,0x20(%rsp)
call   1040 <log@plt>
movapd 0x20(%rsp),%xmm4
mulsd  0xe4f(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movapd 0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1130 <_stdnormrnd+0x10>
divsd  0x8(%rsp),%xmm4
movapd %xmm4,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @_stdnormrnd() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
br label %6
6: ; preds = %48, %0
%7 = call i32 (...) @_rnd()
%8 = sitofp i32 %7 to double
store double %8, double* %1
%9 = call i32 (...) @_rnd()
%10 = sitofp i32 %9 to double
%11 = fsub double %10, 5.000000e-01
%12 = fmul double 1.715600e+00, %11
store double %12, double* %2
%13 = load double, double* %1
%14 = fsub double %13, 4.498710e-01
store double %14, double* %3
%15 = load double, double* %2
%16 = call double @llvm.fabs.f64(double %15)
%17 = fadd double %16, 3.865950e-01
store double %17, double* %4
%18 = load double, double* %3
%19 = load double, double* %3
%20 = load double, double* %4
%21 = load double, double* %4
%22 = load double, double* %3
%23 = fmul double 2.547200e-01, %22
%24 = fneg double %23
%25 = call double @llvm.fmuladd.f64(double 1.960000e-01, double %21, double %24)
%26 = fmul double %20, %25
%27 = call double @llvm.fmuladd.f64(double %18, double %19, double %26)
store double %27, double* %5
br label %28
28: ; preds = %6
%29 = load double, double* %5
%30 = fcmp ogt double %29, 2.759700e-01
br i1 %30, label %31, label %48
31: ; preds = %28
%32 = load double, double* %5
%33 = fcmp ogt double %32, 2.784600e-01
br i1 %33, label %46, label %34
34: ; preds = %31
%35 = load double, double* %2
%36 = load double, double* %2
%37 = fmul double %35, %36
%38 = load double, double* %1
%39 = call double @log(double %38)
%40 = fmul double -4.000000e+00, %39
%41 = load double, double* %1
%42 = fmul double %40, %41
%43 = load double, double* %1
%44 = fmul double %42, %43
%45 = fcmp ogt double %37, %44
br label %46
46: ; preds = %34, %31
%47 = phi i1 [ true, %31 ], [ %45, %34 ]
br label %48
48: ; preds = %46, %28
%49 = phi i1 [ false, %28 ], [ %47, %46 ]
br i1 %49, label %6, label %50
50: ; preds = %48
%51 = load double, double* %2
%52 = load double, double* %1
%53 = fdiv double %51, %52
ret double %53
}

LLVM IR (-O2):
define double @_stdnormrnd() {
br label %1
1: ; preds = %25, %0
%2 = tail call i32 (...) @_rnd()
%3 = sitofp i32 %2 to double
%4 = tail call i32 (...) @_rnd()
%5 = sitofp i32 %4 to double
%6 = fadd double %5, -5.000000e-01
%7 = fmul double %6, 1.715600e+00
%8 = fadd double %3, -4.498710e-01
%9 = tail call double @llvm.fabs.f64(double %7)
%10 = fadd double %9, 3.865950e-01
%11 = fmul double %8, -2.547200e-01
%12 = tail call double @llvm.fmuladd.f64(double %10, double 1.960000e-01, double %11)
%13 = fmul double %10, %12
%14 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %13)
%15 = fcmp ogt double %14, 2.759700e-01
br i1 %15, label %16, label %26
16: ; preds = %1
%17 = fcmp ogt double %14, 2.784600e-01
br i1 %17, label %25, label %18
18: ; preds = %16
%19 = fmul double %7, %7
%20 = tail call double @log(double %3)
%21 = fmul double %20, -4.000000e+00
%22 = fmul double %21, %3
%23 = fmul double %22, %3
%24 = fcmp ogt double %19, %23
br i1 %24, label %25, label %26
25: ; preds = %18, %16
br label %1
26: ; preds = %1, %18
%27 = fdiv double %7, %3
ret double %27
}