#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 drand48();
double log(double);
double sqrt(double);
float gaussGen() {
  double x1, x2, w, y1;
  do {
    x1 = 2.0 * drand48() - 1.0;
    x2 = 2.0 * drand48() - 1.0;
    w = x1 * x1 + x2 * x2;
  } while (w >= 1.0);
  w = sqrt((-2.0 * log(w)) / w);
  y1 = x1 * w;
  return (float)y1;
}


x86 assembly (clang, -O0):
<gaussGen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <drand48@plt>
addsd  %xmm0,%xmm0
movsd  0xeb5(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1050 <drand48@plt>
addsd  %xmm0,%xmm0
movsd  0xe99(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe6a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1138 <gaussGen+0x8>
movsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe53(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gaussGen>:
sub    $0x18,%rsp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <drand48@plt>
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xea9(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %eax,%eax
call   1050 <drand48@plt>
movsd  0x8(%rsp),%xmm2
addsd  %xmm0,%xmm0
addsd  0xe86(%rip),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
ucomisd 0xe7a(%rip),%xmm2
jae    1140 <gaussGen+0x10>
movapd %xmm2,%xmm0
movsd  %xmm2,0x10(%rsp)
call   1030 <log@plt>
mulsd  0xe69(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11bd <gaussGen+0x8d>
sqrtsd %xmm0,%xmm0
jmp    11c2 <gaussGen+0x92>
call   1040 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @gaussGen() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
br label %5
5: ; preds = %16, %0
%6 = call double (...) @drand48()
%7 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %6, double -1.000000e+00)
store double %7, double* %1
%8 = call double (...) @drand48()
%9 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %8, double -1.000000e+00)
store double %9, double* %2
%10 = load double, double* %1
%11 = load double, double* %1
%12 = load double, double* %2
%13 = load double, double* %2
%14 = fmul double %12, %13
%15 = call double @llvm.fmuladd.f64(double %10, double %11, double %14)
store double %15, double* %3
br label %16
16: ; preds = %5
%17 = load double, double* %3
%18 = fcmp oge double %17, 1.000000e+00
br i1 %18, label %5, label %19
19: ; preds = %16
%20 = load double, double* %3
%21 = call double @log(double %20)
%22 = fmul double -2.000000e+00, %21
%23 = load double, double* %3
%24 = fdiv double %22, %23
%25 = call double @sqrt(double %24)
store double %25, double* %3
%26 = load double, double* %1
%27 = load double, double* %3
%28 = fmul double %26, %27
store double %28, double* %4
%29 = load double, double* %4
%30 = fptrunc double %29 to float
ret float %30
}

LLVM IR (-O2):
define float @gaussGen() {
br label %1
1: ; preds = %1, %0
%2 = tail call double (...) @drand48()
%3 = tail call double @llvm.fmuladd.f64(double %2, double 2.000000e+00, double -1.000000e+00)
%4 = tail call double (...) @drand48()
%5 = tail call double @llvm.fmuladd.f64(double %4, double 2.000000e+00, double -1.000000e+00)
%6 = fmul double %5, %5
%7 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %6)
%8 = fcmp ult double %7, 1.000000e+00
br i1 %8, label %9, label %1
9: ; preds = %1
%10 = tail call double @log(double %7)
%11 = fmul double %10, -2.000000e+00
%12 = fdiv double %11, %7
%13 = tail call double @sqrt(double %12)
%14 = fmul double %3, %13
%15 = fptrunc double %14 to float
ret float %15
}