#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 random();
double gen_norm(void) {
  double r1, r2, x, w;
  do {
    r1 = ((random() + 0.5) / 2147483648.0);
    r2 = ((random() + 0.5) / 2147483648.0);
    x = 0.857763884961 * (r2 + r2 - 1) / r1;
    w = 0.25 * x * x;
    if (1 - r1 >= w)
      return x;
  } while (0.259240260646 < (w - 0.35) * r1 || log(r1) > -w);
  return x;
}


x86 assembly (clang, -O0):
<gen_norm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1030 <random@plt>
movsd  0xee9(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xed5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
movsd  0xec5(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xeb1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
addsd  -0x18(%rbp),%xmm1
movsd  0xe7e(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xe82(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe64(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe45(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     11da <gen_norm+0xba>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1251 <gen_norm+0x131>
jmp    11df <gen_norm+0xbf>
movsd  -0x28(%rbp),%xmm0
movsd  0xe44(%rip),%xmm1
subsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
movsd  0xe29(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x29(%rbp)
ja     123c <gen_norm+0x11c>
movsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1128 <gen_norm+0x8>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_norm>:
sub    $0x28,%rsp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <random@plt>
movapd %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <random@plt>
movapd %xmm0,%xmm2
addsd  0xeb1(%rip),%xmm2
mulsd  0xeb1(%rip),%xmm2
addsd  %xmm2,%xmm2
unpcklpd (%rsp),%xmm2
addpd  0xec8(%rip),%xmm2
mulpd  0xed0(%rip),%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm3
mulsd  0xe88(%rip),%xmm3
mulsd  %xmm2,%xmm3
movsd  0xe84(%rip),%xmm1
subsd  %xmm0,%xmm1
ucomisd %xmm3,%xmm1
jae    11e9 <gen_norm+0xc9>
movapd %xmm3,%xmm1
addsd  0xe76(%rip),%xmm1
mulsd  %xmm0,%xmm1
ucomisd 0xe72(%rip),%xmm1
ja     1130 <gen_norm+0x10>
movapd %xmm2,(%rsp)
movapd %xmm3,0x10(%rsp)
call   1040 <log@plt>
movapd (%rsp),%xmm2
movapd 0x10(%rsp),%xmm1
xorpd  0xe71(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1130 <gen_norm+0x10>
movapd %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @gen_norm() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
br label %6
6: ; preds = %43, %0
%7 = call double (...) @random()
%8 = fadd double %7, 5.000000e-01
%9 = fdiv double %8, 0x41E0000000000000
store double %9, double* %2
%10 = call double (...) @random()
%11 = fadd double %10, 5.000000e-01
%12 = fdiv double %11, 0x41E0000000000000
store double %12, double* %3
%13 = load double, double* %3
%14 = load double, double* %3
%15 = fadd double %13, %14
%16 = fsub double %15, 1.000000e+00
%17 = fmul double 0x3FEB72CD3F331DE9, %16
%18 = load double, double* %2
%19 = fdiv double %17, %18
store double %19, double* %4
%20 = load double, double* %4
%21 = fmul double 2.500000e-01, %20
%22 = load double, double* %4
%23 = fmul double %21, %22
store double %23, double* %5
%24 = load double, double* %2
%25 = fsub double 1.000000e+00, %24
%26 = load double, double* %5
%27 = fcmp oge double %25, %26
br i1 %27, label %28, label %30
28: ; preds = %6
%29 = load double, double* %4
store double %29, double* %1
br label %47
30: ; preds = %6
br label %31
31: ; preds = %30
%32 = load double, double* %5
%33 = fsub double %32, 3.500000e-01
%34 = load double, double* %2
%35 = fmul double %33, %34
%36 = fcmp olt double 0x3FD097647651FD4F, %35
br i1 %36, label %43, label %37
37: ; preds = %31
%38 = load double, double* %2
%39 = call double @log(double %38)
%40 = load double, double* %5
%41 = fneg double %40
%42 = fcmp ogt double %39, %41
br label %43
43: ; preds = %37, %31
%44 = phi i1 [ true, %31 ], [ %42, %37 ]
br i1 %44, label %6, label %45
45: ; preds = %43
%46 = load double, double* %4
store double %46, double* %1
br label %47
47: ; preds = %45, %28
%48 = load double, double* %1
ret double %48
}

LLVM IR (-O2):
define double @gen_norm() {
br label %1
1: ; preds = %26, %0
%2 = tail call double (...) @random()
%3 = tail call double (...) @random()
%4 = fadd double %3, 5.000000e-01
%5 = fmul double %4, 0x3E00000000000000
%6 = fadd double %5, %5
%7 = insertelement <2 x double> poison, double %6, i64 0
%8 = insertelement <2 x double> %7, double %2, i64 1
%9 = fadd <2 x double> %8, <double -1.000000e+00, double 5.000000e-01>
%10 = fmul <2 x double> %9, <double 0x3FEB72CD3F331DE9, double 0x3E00000000000000>
%11 = extractelement <2 x double> %10, i64 0
%12 = extractelement <2 x double> %10, i64 1
%13 = fdiv double %11, %12
%14 = fmul double %13, 2.500000e-01
%15 = fmul double %13, %14
%16 = fsub double 1.000000e+00, %12
%17 = fcmp ult double %16, %15
br i1 %17, label %18, label %27
18: ; preds = %1
%19 = fadd double %15, -3.500000e-01
%20 = fmul double %12, %19
%21 = fcmp ogt double %20, 0x3FD097647651FD4F
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = tail call double @log(double %12)
%24 = fneg double %15
%25 = fcmp ogt double %23, %24
br i1 %25, label %26, label %27
26: ; preds = %22, %18
br label %1
27: ; preds = %22, %1
ret double %13
}