#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 */
int log(double);
int rndu();
double sqrt(int);
double rndNormal(void) {
  double u, v, s;
  for (;;) {
    u = 2 * rndu() - 1;
    v = 2 * rndu() - 1;
    s = u * u + v * v;
    if (s > 0 && s < 1)
      break;
  }
  s = sqrt(-2 * log(s) / s);
  return (u * s);
}


x86 assembly (clang, -O0):
<rndNormal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <rndu@plt>
shl    $0x1,%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <rndu@plt>
shl    $0x1,%eax
sub    $0x1,%eax
cvtsi2sd %eax,%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
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11af <rndNormal+0x7f>
movsd  0xe61(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11af <rndNormal+0x7f>
jmp    11b4 <rndNormal+0x84>
jmp    1138 <rndNormal+0x8>
movsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
imul   $0xfffffffe,%eax,%eax
cvtsi2sd %eax,%xmm0
divsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rndNormal>:
sub    $0x18,%rsp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <rndu@plt>
add    %eax,%eax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <rndu@plt>
add    %eax,%eax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
ucomisd 0xe82(%rip),%xmm1
jbe    1140 <rndNormal+0x10>
movsd  0xe70(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1140 <rndNormal+0x10>
movapd %xmm1,%xmm0
movsd  %xmm1,0x10(%rsp)
call   1040 <log@plt>
add    %eax,%eax
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @rndNormal() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
br label %4
4: ; preds = %25, %0
%5 = call i32 (...) @rndu()
%6 = mul nsw i32 2, %5
%7 = sub nsw i32 %6, 1
%8 = sitofp i32 %7 to double
store double %8, double* %1
%9 = call i32 (...) @rndu()
%10 = mul nsw i32 2, %9
%11 = sub nsw i32 %10, 1
%12 = sitofp i32 %11 to double
store double %12, double* %2
%13 = load double, double* %1
%14 = load double, double* %1
%15 = load double, double* %2
%16 = load double, double* %2
%17 = fmul double %15, %16
%18 = call double @llvm.fmuladd.f64(double %13, double %14, double %17)
store double %18, double* %3
%19 = load double, double* %3
%20 = fcmp ogt double %19, 0.000000e+00
br i1 %20, label %21, label %25
21: ; preds = %4
%22 = load double, double* %3
%23 = fcmp olt double %22, 1.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %21
br label %26
25: ; preds = %21, %4
br label %4
26: ; preds = %24
%27 = load double, double* %3
%28 = call i32 @log(double %27)
%29 = mul nsw i32 -2, %28
%30 = sitofp i32 %29 to double
%31 = load double, double* %3
%32 = fdiv double %30, %31
%33 = fptosi double %32 to i32
%34 = call double @sqrt(i32 %33)
store double %34, double* %3
%35 = load double, double* %1
%36 = load double, double* %3
%37 = fmul double %35, %36
ret double %37
}

LLVM IR (-O2):
define double @rndNormal() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 (...) @rndu()
%3 = shl nsw i32 %2, 1
%4 = add nsw i32 %3, -1
%5 = sitofp i32 %4 to double
%6 = tail call i32 (...) @rndu()
%7 = shl nsw i32 %6, 1
%8 = add nsw i32 %7, -1
%9 = sitofp i32 %8 to double
%10 = fmul double %9, %9
%11 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %10)
%12 = fcmp ogt double %11, 0.000000e+00
%13 = fcmp olt double %11, 1.000000e+00
%14 = and i1 %12, %13
br i1 %14, label %15, label %1
15: ; preds = %1
%16 = tail call i32 @log(double %11)
%17 = mul nsw i32 %16, -2
%18 = sitofp i32 %17 to double
%19 = fdiv double %18, %11
%20 = fptosi double %19 to i32
%21 = tail call double @sqrt(i32 %20)
%22 = fmul double %21, %5
ret double %22
}