#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 uniformrng();
double normalrng_ratio(void) {
  double rnd;
  double u;
  double v;
  double z;
  int Q;
  do {
    u = uniformrng();
    v = 0.857763884960707 * (2.0 * uniformrng() - 1.0);
    rnd = v / u;
    z = 0.25 * rnd * rnd;
    if (z < 1.0 - u)
      break;
    Q = (z > (0.259240260645892 / u + 0.35)) || (z > -log(u));
  } while (Q);
  return rnd;
}


x86 assembly (clang, -O0):
<normalrng_ratio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1030 <uniformrng@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <uniformrng@plt>
movaps %xmm0,%xmm1
addsd  %xmm1,%xmm1
movsd  0xece(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xeba(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xe92(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xe6e(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a6 <normalrng_ratio+0x86>
jmp    1225 <normalrng_ratio+0x105>
movsd  -0x20(%rbp),%xmm0
movsd  0xe75(%rip),%xmm1
divsd  -0x10(%rbp),%xmm1
movsd  0xe60(%rip),%xmm2
addsd  %xmm2,%xmm1
mov    $0x1,%al
ucomisd %xmm1,%xmm0
mov    %al,-0x25(%rbp)
ja     1210 <normalrng_ratio+0xf0>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1128 <normalrng_ratio+0x8>
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalrng_ratio>:
sub    $0x18,%rsp
xor    %eax,%eax
call   1030 <uniformrng@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <uniformrng@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
addsd  0xeb2(%rip),%xmm1
mulsd  0xeb2(%rip),%xmm1
divsd  %xmm2,%xmm1
movsd  0xeae(%rip),%xmm3
mulsd  %xmm1,%xmm3
jmp    11b2 <normalrng_ratio+0x92>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <uniformrng@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <uniformrng@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
addsd  0xe66(%rip),%xmm1
mulsd  0xe66(%rip),%xmm1
divsd  %xmm2,%xmm1
movapd %xmm1,%xmm3
mulsd  0xe5e(%rip),%xmm3
mulsd  %xmm1,%xmm3
movsd  0xe5a(%rip),%xmm0
subsd  %xmm2,%xmm0
ucomisd %xmm3,%xmm0
ja     1215 <normalrng_ratio+0xf5>
movsd  0xe50(%rip),%xmm0
divsd  %xmm2,%xmm0
addsd  0xe4c(%rip),%xmm0
ucomisd %xmm0,%xmm3
ja     1170 <normalrng_ratio+0x50>
movapd %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
movsd  %xmm3,0x10(%rsp)
call   1040 <log@plt>
movsd  0x8(%rsp),%xmm1
xorpd  0xe2b(%rip),%xmm0
movsd  0x10(%rsp),%xmm2
ucomisd %xmm0,%xmm2
ja     1170 <normalrng_ratio+0x50>
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @normalrng_ratio() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
br label %6
6: ; preds = %38, %0
%7 = call double (...) @uniformrng()
store double %7, double* %2
%8 = call double (...) @uniformrng()
%9 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %8, double -1.000000e+00)
%10 = fmul double 0x3FEB72CD3F33139A, %9
store double %10, double* %3
%11 = load double, double* %3
%12 = load double, double* %2
%13 = fdiv double %11, %12
store double %13, double* %1
%14 = load double, double* %1
%15 = fmul double 2.500000e-01, %14
%16 = load double, double* %1
%17 = fmul double %15, %16
store double %17, double* %4
%18 = load double, double* %4
%19 = load double, double* %2
%20 = fsub double 1.000000e+00, %19
%21 = fcmp olt double %18, %20
br i1 %21, label %22, label %23
22: ; preds = %6
br label %41
23: ; preds = %6
%24 = load double, double* %4
%25 = load double, double* %2
%26 = fdiv double 0x3FD097647651F5B6, %25
%27 = fadd double %26, 3.500000e-01
%28 = fcmp ogt double %24, %27
br i1 %28, label %35, label %29
29: ; preds = %23
%30 = load double, double* %4
%31 = load double, double* %2
%32 = call double @log(double %31)
%33 = fneg double %32
%34 = fcmp ogt double %30, %33
br label %35
35: ; preds = %29, %23
%36 = phi i1 [ true, %23 ], [ %34, %29 ]
%37 = zext i1 %36 to i32
store i32 %37, i32* %5
br label %38
38: ; preds = %35
%39 = load i32, i32* %5
%40 = icmp ne i32 %39, 0
br i1 %40, label %6, label %41
41: ; preds = %38, %22
%42 = load double, double* %1
ret double %42
}

LLVM IR (-O2):
define double @normalrng_ratio() {
%1 = tail call double (...) @uniformrng()
%2 = tail call double (...) @uniformrng()
%3 = tail call double @llvm.fmuladd.f64(double %2, double 2.000000e+00, double -1.000000e+00)
%4 = fmul double %3, 0x3FEB72CD3F33139A
%5 = fdiv double %4, %1
%6 = fmul double %5, 2.500000e-01
%7 = fmul double %5, %6
%8 = fsub double 1.000000e+00, %1
%9 = fcmp olt double %7, %8
br i1 %9, label %31, label %10
10: ; preds = %0, %21
%11 = phi double [ %28, %21 ], [ %7, %0 ]
%12 = phi double [ %26, %21 ], [ %5, %0 ]
%13 = phi double [ %22, %21 ], [ %1, %0 ]
%14 = fdiv double 0x3FD097647651F5B6, %13
%15 = fadd double %14, 3.500000e-01
%16 = fcmp ogt double %11, %15
br i1 %16, label %21, label %17
17: ; preds = %10
%18 = tail call double @log(double %13)
%19 = fneg double %18
%20 = fcmp ogt double %11, %19
br i1 %20, label %21, label %31
21: ; preds = %17, %10
%22 = tail call double (...) @uniformrng()
%23 = tail call double (...) @uniformrng()
%24 = tail call double @llvm.fmuladd.f64(double %23, double 2.000000e+00, double -1.000000e+00)
%25 = fmul double %24, 0x3FEB72CD3F33139A
%26 = fdiv double %25, %22
%27 = fmul double %26, 2.500000e-01
%28 = fmul double %26, %27
%29 = fsub double 1.000000e+00, %22
%30 = fcmp olt double %28, %29
br i1 %30, label %31, label %10
31: ; preds = %17, %21, %0
%32 = phi double [ %5, %0 ], [ %26, %21 ], [ %12, %17 ]
ret double %32
}