#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 sqrt(double);
double Z(double p) {
  double q, z1, n, d;
  q = (p > 0.5) ? (1 - p) : p;
  z1 = sqrt(-2.0 * log(q));
  n = (0.010328 * z1 + 0.802853) * z1 + 2.515517;
  d = ((0.001308 * z1 + 0.189269) * z1 + 1.43278) * z1 + 1;
  z1 -= n / d;
  if (p > 0.5)
    z1 = -z1;
  return (z1);
}


x86 assembly (clang, -O0):
<Z>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xec6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    115b <Z+0x3b>
movsd  0xebc(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1165 <Z+0x45>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  0xebc(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe91(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe68(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe42(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe3e(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe19(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdfc(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
divsd  -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xdc6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1265 <Z+0x145>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Z>:
sub    $0x18,%rsp
movsd  0xed4(%rip),%xmm2
subsd  %xmm0,%xmm2
movsd  0xed0(%rip),%xmm1
cmpltsd %xmm0,%xmm1
andpd  %xmm1,%xmm2
movapd %xmm1,(%rsp)
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
movapd %xmm1,%xmm0
call   1030 <log@plt>
mulsd  0xeb1(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     116f <Z+0x4f>
sqrtsd %xmm0,%xmm0
jmp    1174 <Z+0x54>
call   1040 <sqrt@plt>
movsd  0xe9c(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe98(%rip),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm1,%xmm2
movapd 0xe98(%rip),%xmm1
unpcklpd %xmm0,%xmm1
mulpd  %xmm2,%xmm1
addpd  0xe98(%rip),%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
mulpd  %xmm1,%xmm2
addpd  0xe94(%rip),%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
divsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
movapd (%rsp),%xmm2
movapd %xmm2,%xmm1
andnpd %xmm0,%xmm1
xorpd  0xe7f(%rip),%xmm0
andpd  %xmm2,%xmm0
orpd   %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @Z(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %2
%7 = load double, double* %2
%8 = fcmp ogt double %7, 5.000000e-01
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load double, double* %2
%11 = fsub double 1.000000e+00, %10
br label %14
12: ; preds = %1
%13 = load double, double* %2
br label %14
14: ; preds = %12, %9
%15 = phi double [ %11, %9 ], [ %13, %12 ]
store double %15, double* %3
%16 = load double, double* %3
%17 = call double @log(double %16)
%18 = fmul double -2.000000e+00, %17
%19 = call double @sqrt(double %18)
store double %19, double* %4
%20 = load double, double* %4
%21 = call double @llvm.fmuladd.f64(double 1.032800e-02, double %20, double 8.028530e-01)
%22 = load double, double* %4
%23 = call double @llvm.fmuladd.f64(double %21, double %22, double 0x40041FC7607C419A)
store double %23, double* %5
%24 = load double, double* %4
%25 = call double @llvm.fmuladd.f64(double 1.308000e-03, double %24, double 1.892690e-01)
%26 = load double, double* %4
%27 = call double @llvm.fmuladd.f64(double %25, double %26, double 1.432780e+00)
%28 = load double, double* %4
%29 = call double @llvm.fmuladd.f64(double %27, double %28, double 1.000000e+00)
store double %29, double* %6
%30 = load double, double* %5
%31 = load double, double* %6
%32 = fdiv double %30, %31
%33 = load double, double* %4
%34 = fsub double %33, %32
store double %34, double* %4
%35 = load double, double* %2
%36 = fcmp ogt double %35, 5.000000e-01
br i1 %36, label %37, label %40
37: ; preds = %14
%38 = load double, double* %4
%39 = fneg double %38
store double %39, double* %4
br label %40
40: ; preds = %37, %14
%41 = load double, double* %4
ret double %41
}

LLVM IR (-O2):
define double @Z(double %0) {
%2 = fcmp ogt double %0, 5.000000e-01
%3 = fsub double 1.000000e+00, %0
%4 = select i1 %2, double %3, double %0
%5 = tail call double @log(double %4)
%6 = fmul double %5, -2.000000e+00
%7 = tail call double @sqrt(double %6)
%8 = tail call double @llvm.fmuladd.f64(double %7, double 1.308000e-03, double 1.892690e-01)
%9 = insertelement <2 x double> poison, double %7, i64 0
%10 = insertelement <2 x double> %9, double %8, i64 1
%11 = insertelement <2 x double> <double 1.032800e-02, double poison>, double %7, i64 1
%12 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %10, <2 x double> %11, <2 x double> <double 8.028530e-01, double 1.432780e+00>)
%13 = shufflevector <2 x double> %9, <2 x double> poison, <2 x i32> zeroinitializer
%14 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %12, <2 x double> %13, <2 x double> <double 0x40041FC7607C419A, double 1.000000e+00>)
%15 = extractelement <2 x double> %14, i64 0
%16 = extractelement <2 x double> %14, i64 1
%17 = fdiv double %15, %16
%18 = fsub double %7, %17
%19 = fneg double %18
%20 = select i1 %2, double %19, double %18
ret double %20
}