#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 log(int);
double sqrt(double);
double gauss(double u) {
  double t = (u < 0.5) ? sqrt(-2.0 * log(u)) : sqrt(-2.0 * log(1 - u));
  t = t - ((0.010328 * t + 0.802853) * t + 2.515517) /
              (((0.001308 * t + 0.189269) * t + 1.432788) * t + 1.);
  return (u < 0.5) ? -t : t;
}


x86 assembly (clang, -O0):
<gauss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xecb(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1168 <gauss+0x48>
cvttsd2si -0x8(%rbp),%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  0xeb3(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1197 <gauss+0x77>
movsd  0xea0(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe7f(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe85(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe81(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe5c(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  0xe3b(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe37(%rip),%xmm3
addsd  %xmm3,%xmm2
movsd  -0x10(%rbp),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xe12(%rip),%xmm3
addsd  %xmm3,%xmm2
movsd  -0x10(%rbp),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xdf5(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xdcc(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1265 <gauss+0x145>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    126f <gauss+0x14f>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gauss>:
sub    $0x18,%rsp
movsd  0xed4(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm0,%xmm2
cmpltsd 0xecb(%rip),%xmm2
andpd  %xmm2,%xmm0
movapd %xmm2,(%rsp)
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
cvttsd2si %xmm2,%edi
call   1030 <log@plt>
mulsd  0xeb1(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     116f <gauss+0x4f>
sqrtsd %xmm0,%xmm0
jmp    1174 <gauss+0x54>
call   1040 <sqrt@plt>
movsd  0xe9c(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe98(%rip),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm1,%xmm2
movapd 0xe98(%rip),%xmm1
unpcklpd %xmm0,%xmm1
mulpd  %xmm2,%xmm1
addpd  0xe98(%rip),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
mulpd  %xmm1,%xmm2
addpd  0xe94(%rip),%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
divsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
movapd (%rsp),%xmm2
movapd %xmm2,%xmm1
andnpd %xmm0,%xmm1
xorpd  0xe7f(%rip),%xmm0
andpd  %xmm2,%xmm0
orpd   %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @gauss(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load double, double* %2
%5 = fcmp olt double %4, 5.000000e-01
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load double, double* %2
%8 = fptosi double %7 to i32
%9 = call double @log(i32 %8)
%10 = fmul double -2.000000e+00, %9
%11 = call double @sqrt(double %10)
br label %19
12: ; preds = %1
%13 = load double, double* %2
%14 = fsub double 1.000000e+00, %13
%15 = fptosi double %14 to i32
%16 = call double @log(i32 %15)
%17 = fmul double -2.000000e+00, %16
%18 = call double @sqrt(double %17)
br label %19
19: ; preds = %12, %6
%20 = phi double [ %11, %6 ], [ %18, %12 ]
store double %20, double* %3
%21 = load double, double* %3
%22 = load double, double* %3
%23 = call double @llvm.fmuladd.f64(double 1.032800e-02, double %22, double 8.028530e-01)
%24 = load double, double* %3
%25 = call double @llvm.fmuladd.f64(double %23, double %24, double 0x40041FC7607C419A)
%26 = load double, double* %3
%27 = call double @llvm.fmuladd.f64(double 1.308000e-03, double %26, double 1.892690e-01)
%28 = load double, double* %3
%29 = call double @llvm.fmuladd.f64(double %27, double %28, double 0x3FF6ECB31C219EB6)
%30 = load double, double* %3
%31 = call double @llvm.fmuladd.f64(double %29, double %30, double 1.000000e+00)
%32 = fdiv double %25, %31
%33 = fsub double %21, %32
store double %33, double* %3
%34 = load double, double* %2
%35 = fcmp olt double %34, 5.000000e-01
br i1 %35, label %36, label %39
36: ; preds = %19
%37 = load double, double* %3
%38 = fneg double %37
br label %41
39: ; preds = %19
%40 = load double, double* %3
br label %41
41: ; preds = %39, %36
%42 = phi double [ %38, %36 ], [ %40, %39 ]
ret double %42
}

LLVM IR (-O2):
define double @gauss(double %0) {
%2 = fcmp olt double %0, 5.000000e-01
%3 = fsub double 1.000000e+00, %0
%4 = select i1 %2, double %0, double %3
%5 = fptosi double %4 to i32
%6 = tail call double @log(i32 %5)
%7 = fmul double %6, -2.000000e+00
%8 = tail call double @sqrt(double %7)
%9 = tail call double @llvm.fmuladd.f64(double %8, double 1.308000e-03, double 1.892690e-01)
%10 = insertelement <2 x double> poison, double %8, i64 0
%11 = insertelement <2 x double> %10, double %9, i64 1
%12 = insertelement <2 x double> <double 1.032800e-02, double poison>, double %8, i64 1
%13 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %11, <2 x double> %12, <2 x double> <double 8.028530e-01, double 0x3FF6ECB31C219EB6>)
%14 = shufflevector <2 x double> %10, <2 x double> poison, <2 x i32> zeroinitializer
%15 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %13, <2 x double> %14, <2 x double> <double 0x40041FC7607C419A, double 1.000000e+00>)
%16 = extractelement <2 x double> %15, i64 0
%17 = extractelement <2 x double> %15, i64 1
%18 = fdiv double %16, %17
%19 = fsub double %8, %18
%20 = fneg double %19
%21 = select i1 %2, double %20, double %19
ret double %21
}