#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 __pgr_get_lf(unsigned long long);
double log(double);
double pow(double, double);
double sqrt(double);
double __pgr_get_gauss(unsigned long long _thread) {
  double r, x, y;
  do {
    x = 2.0 * __pgr_get_lf(_thread) - 1.0;
    y = 2.0 * __pgr_get_lf(_thread) - 1.0;
    r = pow(x, 2.0) + pow(y, 2.0);
  } while (r > 1.0 || r == 0.0);
  return x * sqrt(-2.0 * log(r) / r);
}


x86 assembly (clang, -O0):
<__pgr_get_gauss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <__pgr_get_lf@plt>
addsd  %xmm0,%xmm0
movsd  0xea7(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <__pgr_get_lf@plt>
addsd  %xmm0,%xmm0
movsd  0xe89(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe6b(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe54(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
movsd  0xe3f(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x29(%rbp)
ja     11f5 <__pgr_get_gauss+0xb5>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    114c <__pgr_get_gauss+0xc>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xdf9(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__pgr_get_gauss>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <__pgr_get_lf@plt>
movapd %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <__pgr_get_lf@plt>
movapd (%rsp),%xmm1
unpcklpd %xmm0,%xmm1
addpd  %xmm1,%xmm1
addpd  0xe96(%rip),%xmm1
movapd %xmm1,(%rsp)
mulpd  %xmm1,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addpd  %xmm1,%xmm0
ucomisd 0xe89(%rip),%xmm0
ja     1140 <__pgr_get_gauss+0x10>
ucomisd 0xe8f(%rip),%xmm0
jne    1195 <__pgr_get_gauss+0x65>
jnp    1140 <__pgr_get_gauss+0x10>
movapd %xmm0,0x10(%rsp)
call   1040 <log@plt>
mulsd  0xe70(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11be <__pgr_get_gauss+0x8e>
sqrtsd %xmm0,%xmm0
jmp    11c3 <__pgr_get_gauss+0x93>
call   1050 <sqrt@plt>
movapd (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @__pgr_get_gauss(i64 %0) {
%2 = alloca i64
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i64 %0, i64* %2
br label %6
6: ; preds = %24, %1
%7 = load i64, i64* %2
%8 = call double @__pgr_get_lf(i64 %7)
%9 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %8, double -1.000000e+00)
store double %9, double* %4
%10 = load i64, i64* %2
%11 = call double @__pgr_get_lf(i64 %10)
%12 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %11, double -1.000000e+00)
store double %12, double* %5
%13 = load double, double* %4
%14 = call double @pow(double %13, double 2.000000e+00)
%15 = load double, double* %5
%16 = call double @pow(double %15, double 2.000000e+00)
%17 = fadd double %14, %16
store double %17, double* %3
br label %18
18: ; preds = %6
%19 = load double, double* %3
%20 = fcmp ogt double %19, 1.000000e+00
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load double, double* %3
%23 = fcmp oeq double %22, 0.000000e+00
br label %24
24: ; preds = %21, %18
%25 = phi i1 [ true, %18 ], [ %23, %21 ]
br i1 %25, label %6, label %26
26: ; preds = %24
%27 = load double, double* %4
%28 = load double, double* %3
%29 = call double @log(double %28)
%30 = fmul double -2.000000e+00, %29
%31 = load double, double* %3
%32 = fdiv double %30, %31
%33 = call double @sqrt(double %32)
%34 = fmul double %27, %33
ret double %34
}

LLVM IR (-O2):
define double @__pgr_get_gauss(i64 %0) {
br label %2
2: ; preds = %2, %1
%3 = tail call double @__pgr_get_lf(i64 %0)
%4 = tail call double @__pgr_get_lf(i64 %0)
%5 = insertelement <2 x double> poison, double %3, i64 0
%6 = insertelement <2 x double> %5, double %4, i64 1
%7 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %6, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> <double -1.000000e+00, double -1.000000e+00>)
%8 = fmul <2 x double> %7, %7
%9 = shufflevector <2 x double> %8, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%10 = fadd <2 x double> %8, %9
%11 = extractelement <2 x double> %10, i64 0
%12 = fcmp ogt double %11, 1.000000e+00
%13 = fcmp oeq double %11, 0.000000e+00
%14 = or i1 %12, %13
br i1 %14, label %2, label %15
15: ; preds = %2
%16 = extractelement <2 x double> %10, i64 0
%17 = tail call double @log(double %16)
%18 = fmul double %17, -2.000000e+00
%19 = fdiv double %18, %16
%20 = tail call double @sqrt(double %19)
%21 = extractelement <2 x double> %7, i64 0
%22 = fmul double %21, %20
ret double %22
}