#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 dr250();
double log(double);
double sqrt(double);
double rnormal01(void) {
  static char f = 1;
  static double y;
  double a, b, s;
  double mean = 0;
  double sd = 1;
  f = -f;
  if (f > 0)
    return y;
  for (;;) {
    a = 2.0 * dr250() - 1.0;
    b = 2.0 * dr250() - 1.0;
    s = a * a + b * b;
    if ((s < 1.0) && (s != 0))
      break;
  }
  s = sqrt(-2.0 * log(s) / s);
  y = sd * s * a + mean;
  return sd * s * b + mean;
}


x86 assembly (clang, -O0):
<rnormal01>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsbl 0x2ee4(%rip),%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %al,0x2eda(%rip)
movsbl 0x2ed3(%rip),%eax
cmp    $0x0,%eax
jle    1180 <rnormal01+0x50>
movsd  0x2ed2(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1285 <rnormal01+0x155>
jmp    1185 <rnormal01+0x55>
mov    $0x0,%al
call   1030 <dr250@plt>
addsd  %xmm0,%xmm0
movsd  0xe70(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <dr250@plt>
addsd  %xmm0,%xmm0
movsd  0xe54(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe1a(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1213 <rnormal01+0xe3>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    120e <rnormal01+0xde>
jp     120e <rnormal01+0xde>
jmp    1213 <rnormal01+0xe3>
jmp    1218 <rnormal01+0xe8>
jmp    1185 <rnormal01+0x55>
movsd  -0x20(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xde3(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x20(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x2de4(%rip)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rnormal01>:
sub    $0x18,%rsp
xor    %eax,%eax
sub    0x2efc(%rip),%al
mov    %al,0x2ef6(%rip)
test   %al,%al
jle    1160 <rnormal01+0x30>
movsd  0x2efa(%rip),%xmm0
add    $0x18,%rsp
ret
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1030 <dr250@plt>
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe89(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
xor    %eax,%eax
call   1030 <dr250@plt>
addsd  %xmm0,%xmm0
addsd  0xe6d(%rip),%xmm0
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  (%rsp),%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movsd  0xe58(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    1160 <rnormal01+0x30>
ucomisd 0xe5a(%rip),%xmm2
jne    11c2 <rnormal01+0x92>
jnp    1160 <rnormal01+0x30>
movsd  %xmm0,0x10(%rsp)
movapd %xmm2,%xmm0
movsd  %xmm2,0x8(%rsp)
call   1040 <log@plt>
mulsd  0xe31(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     11f5 <rnormal01+0xc5>
sqrtsd %xmm0,%xmm0
jmp    11fe <rnormal01+0xce>
call   1050 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x2e35(%rip)
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@rnormal01.f = internal global i8 1
@rnormal01.y = internal global double 0.000000e+00
define double @rnormal01() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double 0.000000e+00, double* %5
store double 1.000000e+00, double* %6
%7 = load i8, i8* @rnormal01.f
%8 = sext i8 %7 to i32
%9 = sub nsw i32 0, %8
%10 = trunc i32 %9 to i8
store i8 %10, i8* @rnormal01.f
%11 = load i8, i8* @rnormal01.f
%12 = sext i8 %11 to i32
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = load double, double* @rnormal01.y
store double %15, double* %1
br label %54
16: ; preds = %0
br label %17
17: ; preds = %34, %16
%18 = call double (...) @dr250()
%19 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %18, double -1.000000e+00)
store double %19, double* %2
%20 = call double (...) @dr250()
%21 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %20, double -1.000000e+00)
store double %21, double* %3
%22 = load double, double* %2
%23 = load double, double* %2
%24 = load double, double* %3
%25 = load double, double* %3
%26 = fmul double %24, %25
%27 = call double @llvm.fmuladd.f64(double %22, double %23, double %26)
store double %27, double* %4
%28 = load double, double* %4
%29 = fcmp olt double %28, 1.000000e+00
br i1 %29, label %30, label %34
30: ; preds = %17
%31 = load double, double* %4
%32 = fcmp une double %31, 0.000000e+00
br i1 %32, label %33, label %34
33: ; preds = %30
br label %35
34: ; preds = %30, %17
br label %17
35: ; preds = %33
%36 = load double, double* %4
%37 = call double @log(double %36)
%38 = fmul double -2.000000e+00, %37
%39 = load double, double* %4
%40 = fdiv double %38, %39
%41 = call double @sqrt(double %40)
store double %41, double* %4
%42 = load double, double* %6
%43 = load double, double* %4
%44 = fmul double %42, %43
%45 = load double, double* %2
%46 = load double, double* %5
%47 = call double @llvm.fmuladd.f64(double %44, double %45, double %46)
store double %47, double* @rnormal01.y
%48 = load double, double* %6
%49 = load double, double* %4
%50 = fmul double %48, %49
%51 = load double, double* %3
%52 = load double, double* %5
%53 = call double @llvm.fmuladd.f64(double %50, double %51, double %52)
store double %53, double* %1
br label %54
54: ; preds = %35, %14
%55 = load double, double* %1
ret double %55
}

LLVM IR (-O2):
@rnormal01.f = internal unnamed_addr global i8 1
@rnormal01.y = internal unnamed_addr global double 0.000000e+00
define double @rnormal01() {
%1 = load i8, i8* @rnormal01.f
%2 = sub i8 0, %1
store i8 %2, i8* @rnormal01.f
%3 = icmp sgt i8 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = load double, double* @rnormal01.y
br label %23
6: ; preds = %0, %6
%7 = tail call double (...) @dr250()
%8 = tail call double @llvm.fmuladd.f64(double %7, double 2.000000e+00, double -1.000000e+00)
%9 = tail call double (...) @dr250()
%10 = tail call double @llvm.fmuladd.f64(double %9, double 2.000000e+00, double -1.000000e+00)
%11 = fmul double %10, %10
%12 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %11)
%13 = fcmp olt double %12, 1.000000e+00
%14 = fcmp une double %12, 0.000000e+00
%15 = and i1 %13, %14
br i1 %15, label %16, label %6
16: ; preds = %6
%17 = tail call double @log(double %12)
%18 = fmul double %17, -2.000000e+00
%19 = fdiv double %18, %12
%20 = tail call double @sqrt(double %19)
%21 = tail call double @llvm.fmuladd.f64(double %20, double %8, double 0.000000e+00)
store double %21, double* @rnormal01.y
%22 = tail call double @llvm.fmuladd.f64(double %20, double %10, double 0.000000e+00)
br label %23
23: ; preds = %16, %4
%24 = phi double [ %5, %4 ], [ %22, %16 ]
ret double %24
}