#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(double);
double nextDouble();
double gauss() {
  double u, v, x;
  do {
    v = nextDouble();
    do
      u = nextDouble();
    while (u == 0);
    x = 1.71552776992141359295 * (v - 0.5) / u;
  } while (x * x > -4.0 * log(u));
  return x;
}


x86 assembly (clang, -O0):
<gauss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <nextDouble@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <nextDouble@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    115d <gauss+0x3d>
jp     115d <gauss+0x3d>
jmp    1134 <gauss+0x14>
movsd  -0x10(%rbp),%xmm1
movsd  0xe9e(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xe8a(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movsd  0xe63(%rip),%xmm1
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
ja     1128 <gauss+0x8>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gauss>:
sub    $0x18,%rsp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <nextDouble@plt>
movsd  %xmm0,0x8(%rsp)
nopl   (%rax)
xor    %eax,%eax
call   1030 <nextDouble@plt>
ucomisd 0xec9(%rip),%xmm0
jne    1153 <gauss+0x33>
jnp    1140 <gauss+0x20>
movsd  0x8(%rsp),%xmm1
addsd  0xe9f(%rip),%xmm1
mulsd  0xe9f(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm1,%xmm1
movsd  %xmm1,0x10(%rsp)
call   1040 <log@plt>
mulsd  0xe86(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1130 <gauss+0x10>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @gauss() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
br label %4
4: ; preds = %17, %0
%5 = call double (...) @nextDouble()
store double %5, double* %2
br label %6
6: ; preds = %8, %4
%7 = call double (...) @nextDouble()
store double %7, double* %1
br label %8
8: ; preds = %6
%9 = load double, double* %1
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %6, label %11
11: ; preds = %8
%12 = load double, double* %2
%13 = fsub double %12, 5.000000e-01
%14 = fmul double 0x3FFB72CD3F331398, %13
%15 = load double, double* %1
%16 = fdiv double %14, %15
store double %16, double* %3
br label %17
17: ; preds = %11
%18 = load double, double* %3
%19 = load double, double* %3
%20 = fmul double %18, %19
%21 = load double, double* %1
%22 = call double @log(double %21)
%23 = fmul double -4.000000e+00, %22
%24 = fcmp ogt double %20, %23
br i1 %24, label %4, label %25
25: ; preds = %17
%26 = load double, double* %3
ret double %26
}

LLVM IR (-O2):
define double @gauss() {
br label %1
1: ; preds = %6, %0
%2 = tail call double (...) @nextDouble()
br label %3
3: ; preds = %3, %1
%4 = tail call double (...) @nextDouble()
%5 = fcmp oeq double %4, 0.000000e+00
br i1 %5, label %3, label %6
6: ; preds = %3
%7 = fadd double %2, -5.000000e-01
%8 = fmul double %7, 0x3FFB72CD3F331398
%9 = fdiv double %8, %4
%10 = fmul double %9, %9
%11 = tail call double @log(double %4)
%12 = fmul double %11, -4.000000e+00
%13 = fcmp ogt double %10, %12
br i1 %13, label %1, label %14
14: ; preds = %6
ret double %9
}