#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 ranf();
double sqrt(double);
double normal(double x, double s) {
  double v1, v2, w, z1;
  static double z2 = 0.0;
  if (z2 != 0.0) {
    z1 = z2;
    z2 = 0.0;
  } else {
    do {
      v1 = 2.0 * ranf() - 1.0;
      v2 = 2.0 * ranf() - 1.0;
      w = v1 * v1 + v2 * v2;
    } while (w >= 1.0);
    w = sqrt((-2.0 * log(w)) / w);
    z1 = v1 * w;
    z2 = v2 * w;
  }
  return (x + z1 * s);
}


x86 assembly (clang, -O0):
<normal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  0x2ef6(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1162 <normal+0x32>
jp     1162 <normal+0x32>
jmp    117f <normal+0x4f>
movsd  0x2ed6(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,0x2ec6(%rip)
jmp    123d <normal+0x10d>
jmp    1184 <normal+0x54>
mov    $0x0,%al
call   1030 <ranf@plt>
addsd  %xmm0,%xmm0
movsd  0xe69(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <ranf@plt>
addsd  %xmm0,%xmm0
movsd  0xe4d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe1e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1184 <normal+0x54>
movsd  -0x28(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe07(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,0x2e03(%rip)
movsd  -0x8(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normal>:
sub    $0x38,%rsp
movapd %xmm0,%xmm2
movsd  0x2f00(%rip),%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
jne    114c <normal+0x1c>
jnp    1159 <normal+0x29>
xorpd  %xmm3,%xmm3
unpcklpd %xmm0,%xmm3
jmp    1209 <normal+0xd9>
movsd  %xmm1,(%rsp)
movsd  %xmm2,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <ranf@plt>
movapd %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1030 <ranf@plt>
unpcklpd 0x10(%rsp),%xmm0
addpd  %xmm0,%xmm0
addpd  0xe6a(%rip),%xmm0
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
ucomisd 0xe5a(%rip),%xmm2
jae    1170 <normal+0x40>
movapd %xmm0,0x10(%rsp)
movapd %xmm2,%xmm0
movapd %xmm2,0x20(%rsp)
call   1040 <log@plt>
mulsd  0xe43(%rip),%xmm0
divsd  0x20(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11eb <normal+0xbb>
sqrtsd %xmm0,%xmm0
jmp    11f0 <normal+0xc0>
call   1050 <sqrt@plt>
movsd  0x8(%rsp),%xmm2
movsd  (%rsp),%xmm1
unpcklpd %xmm0,%xmm0
movapd 0x10(%rsp),%xmm3
mulpd  %xmm0,%xmm3
movlpd %xmm3,0x2e2f(%rip)
unpckhpd %xmm3,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
movapd %xmm3,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
@normal.z2 = internal global double 0.000000e+00
define double @normal(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %3
store double %1, double* %4
%9 = load double, double* @normal.z2
%10 = fcmp une double %9, 0.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load double, double* @normal.z2
store double %12, double* %8
store double 0.000000e+00, double* @normal.z2
br label %41
13: ; preds = %2
br label %14
14: ; preds = %25, %13
%15 = call double (...) @ranf()
%16 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %15, double -1.000000e+00)
store double %16, double* %5
%17 = call double (...) @ranf()
%18 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %17, double -1.000000e+00)
store double %18, double* %6
%19 = load double, double* %5
%20 = load double, double* %5
%21 = load double, double* %6
%22 = load double, double* %6
%23 = fmul double %21, %22
%24 = call double @llvm.fmuladd.f64(double %19, double %20, double %23)
store double %24, double* %7
br label %25
25: ; preds = %14
%26 = load double, double* %7
%27 = fcmp oge double %26, 1.000000e+00
br i1 %27, label %14, label %28
28: ; preds = %25
%29 = load double, double* %7
%30 = call double @log(double %29)
%31 = fmul double -2.000000e+00, %30
%32 = load double, double* %7
%33 = fdiv double %31, %32
%34 = call double @sqrt(double %33)
store double %34, double* %7
%35 = load double, double* %5
%36 = load double, double* %7
%37 = fmul double %35, %36
store double %37, double* %8
%38 = load double, double* %6
%39 = load double, double* %7
%40 = fmul double %38, %39
store double %40, double* @normal.z2
br label %41
41: ; preds = %28, %11
%42 = load double, double* %3
%43 = load double, double* %8
%44 = load double, double* %4
%45 = call double @llvm.fmuladd.f64(double %43, double %44, double %42)
ret double %45
}

LLVM IR (-O2):
@normal.z2 = internal unnamed_addr global double 0.000000e+00
define double @normal(double %0, double %1) {
%3 = load double, double* @normal.z2
%4 = fcmp une double %3, 0.000000e+00
%5 = insertelement <2 x double> <double 0.000000e+00, double poison>, double %3, i64 1
br i1 %4, label %25, label %6
6: ; preds = %2, %6
%7 = tail call double (...) @ranf()
%8 = tail call double (...) @ranf()
%9 = insertelement <2 x double> poison, double %8, i64 0
%10 = insertelement <2 x double> %9, double %7, i64 1
%11 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %10, <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double> <double -1.000000e+00, double -1.000000e+00>)
%12 = fmul <2 x double> %11, %11
%13 = extractelement <2 x double> %12, i64 0
%14 = extractelement <2 x double> %11, i64 1
%15 = tail call double @llvm.fmuladd.f64(double %14, double %14, double %13)
%16 = fcmp ult double %15, 1.000000e+00
br i1 %16, label %17, label %6
17: ; preds = %6
%18 = tail call double @log(double %15)
%19 = fmul double %18, -2.000000e+00
%20 = fdiv double %19, %15
%21 = tail call double @sqrt(double %20)
%22 = insertelement <2 x double> poison, double %21, i64 0
%23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
%24 = fmul <2 x double> %11, %23
br label %25
25: ; preds = %2, %17
%26 = phi <2 x double> [ %24, %17 ], [ %5, %2 ]
%27 = extractelement <2 x double> %26, i64 0
store double %27, double* @normal.z2
%28 = extractelement <2 x double> %26, i64 1
%29 = tail call double @llvm.fmuladd.f64(double %28, double %1, double %0)
ret double %29
}