#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
double log(int);
double pow(double, double);
double sqrt(double);
int /*<<< orphan*/ stderr;
double pnorm(double qn) {
  static double b[11] = {1.570796288,      0.03706987906,   -0.8364353589e-3,
                         -0.2250947176e-3, 0.6841218299e-5, 0.5824238515e-5,
                         -0.104527497e-5,  0.8360937017e-7, -0.3231081277e-8,
                         0.3657763036e-10, 0.6936233982e-12};
  double w1, w3;
  int i;
  if (qn < 0. || 1. < qn) {
    fprintf(stderr, "Error : qn <= 0 or qn >= 1  in pnorm()!\n");
    return 0.;
  }
  if (qn == 0.5)
    return 0.;
  w1 = qn;
  if (qn > 0.5)
    w1 = 1. - w1;
  w3 = -log(4. * w1 * (1. - w1));
  w1 = b[0];
  for (i = 1; i < 11; i++)
    w1 += (b[i] * pow(w3, (double)i));
  if (qn > 0.5)
    return sqrt(w1 * w3);
  return -sqrt(w1 * w3);
}


x86 assembly (clang, -O0):
<pnorm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     1172 <pnorm+0x32>
movsd  -0x10(%rbp),%xmm0
movsd  0xe98(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1194 <pnorm+0x54>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f9 <pnorm+0x1b9>
movsd  -0x10(%rbp),%xmm0
movsd  0xe67(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11be <pnorm+0x7e>
jp     11be <pnorm+0x7e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f9 <pnorm+0x1b9>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe33(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11f1 <pnorm+0xb1>
movsd  0xe19(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe17(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xdfa(%rip),%xmm1
subsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0x2e14(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0xb,-0x24(%rbp)
jge    129e <pnorm+0x15e>
movslq -0x24(%rbp),%rcx
lea    0x2df3(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1248 <pnorm+0x108>
movsd  -0x10(%rbp),%xmm0
movsd  0xd5d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12ce <pnorm+0x18e>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    12f9 <pnorm+0x1b9>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1060 <sqrt@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pnorm>:
sub    $0x38,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1331 <pnorm+0x1f1>
ucomisd 0xea6(%rip),%xmm0
ja     1331 <pnorm+0x1f1>
xorpd  %xmm1,%xmm1
ucomisd 0xe9c(%rip),%xmm0
jne    1174 <pnorm+0x34>
jnp    134a <pnorm+0x20a>
movsd  0xe84(%rip),%xmm3
movapd %xmm3,%xmm1
subsd  %xmm0,%xmm1
movsd  0xe7c(%rip),%xmm2
cmpltsd %xmm0,%xmm2
andpd  %xmm2,%xmm1
movapd %xmm0,0x20(%rsp)
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
subsd  %xmm2,%xmm3
mulsd  0xe61(%rip),%xmm2
mulsd  %xmm3,%xmm2
cvttsd2si %xmm2,%edi
call   1040 <log@plt>
movapd %xmm0,%xmm2
movapd 0xee8(%rip),%xmm0
xorpd  %xmm2,%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0xe3e(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xe3a(%rip),%xmm1
mulsd  %xmm2,%xmm2
mulsd  0xe36(%rip),%xmm2
addsd  %xmm1,%xmm2
movapd %xmm2,(%rsp)
movsd  0xe2d(%rip),%xmm1
call   1050 <pow@plt>
mulsd  0xe28(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
movsd  0xde8(%rip),%xmm1
call   1050 <pow@plt>
mulsd  0xe0b(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe01(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1050 <pow@plt>
mulsd  0xdf6(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xdec(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1050 <pow@plt>
mulsd  0xde1(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xdd7(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1050 <pow@plt>
mulsd  0xdcc(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xdc2(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1050 <pow@plt>
mulsd  0xdb7(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xdad(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1050 <pow@plt>
mulsd  0xda2(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xd98(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1050 <pow@plt>
mulsd  0xd8d(%rip),%xmm0
addsd  (%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1353 <pnorm+0x213>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    135c <pnorm+0x21c>
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
lea    0xd7f(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm1,%xmm1
movapd %xmm1,%xmm0
add    $0x38,%rsp
ret
call   1060 <sqrt@plt>
movapd %xmm0,%xmm1
movapd 0x20(%rsp),%xmm0
ucomisd 0xc9e(%rip),%xmm0
ja     134a <pnorm+0x20a>
xorpd  0xd3c(%rip),%xmm1
jmp    134a <pnorm+0x20a>

LLVM IR (-O0):
@pnorm.b = internal global [11 x double] [double 0x3FF921FB49DA360E, double 0x3FA2FAD2BC7570AB, double 0xBF4B6887417F2C60, double 0xBF2D80ECE6B44DAA, double 0x3EDCB1B3C4588BE6, double 0x3ED86DBA7E177BCB, double 0xBEB1896BFBD6446E, double 0x3E7671979857A092, double 0xBE2BC1390DEC58E7, double 0x3DC41BD805096DF9, double 0x3D68679AA9EC9A38]
@stderr = global i32 0
@.str = [41 x i8] c"Error : qn <= 0 or qn >= 1 in pnorm()!\0A\00"
define double @pnorm(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store double %0, double* %3
%7 = load double, double* %3
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = load double, double* %3
%11 = fcmp olt double 1.000000e+00, %10
br i1 %11, label %12, label %15
12: ; preds = %9, %1
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %2
br label %67
15: ; preds = %9
%16 = load double, double* %3
%17 = fcmp oeq double %16, 5.000000e-01
br i1 %17, label %18, label %19
18: ; preds = %15
store double 0.000000e+00, double* %2
br label %67
19: ; preds = %15
%20 = load double, double* %3
store double %20, double* %4
%21 = load double, double* %3
%22 = fcmp ogt double %21, 5.000000e-01
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load double, double* %4
%25 = fsub double 1.000000e+00, %24
store double %25, double* %4
br label %26
26: ; preds = %23, %19
%27 = load double, double* %4
%28 = fmul double 4.000000e+00, %27
%29 = load double, double* %4
%30 = fsub double 1.000000e+00, %29
%31 = fmul double %28, %30
%32 = fptosi double %31 to i32
%33 = call double @log(i32 %32)
%34 = fneg double %33
store double %34, double* %5
%35 = load double, double* getelementptr inbounds ([11 x double], [11 x double]* @pnorm.b, i64 0, i64 0)
store double %35, double* %4
store i32 1, i32* %6
br label %36
36: ; preds = %50, %26
%37 = load i32, i32* %6
%38 = icmp slt i32 %37, 11
br i1 %38, label %39, label %53
39: ; preds = %36
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [11 x double], [11 x double]* @pnorm.b, i64 0, i64 %41
%43 = load double, double* %42
%44 = load double, double* %5
%45 = load i32, i32* %6
%46 = sitofp i32 %45 to double
%47 = call double @pow(double %44, double %46)
%48 = load double, double* %4
%49 = call double @llvm.fmuladd.f64(double %43, double %47, double %48)
store double %49, double* %4
br label %50
50: ; preds = %39
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %36
53: ; preds = %36
%54 = load double, double* %3
%55 = fcmp ogt double %54, 5.000000e-01
br i1 %55, label %56, label %61
56: ; preds = %53
%57 = load double, double* %4
%58 = load double, double* %5
%59 = fmul double %57, %58
%60 = call double @sqrt(double %59)
store double %60, double* %2
br label %67
61: ; preds = %53
%62 = load double, double* %4
%63 = load double, double* %5
%64 = fmul double %62, %63
%65 = call double @sqrt(double %64)
%66 = fneg double %65
store double %66, double* %2
br label %67
67: ; preds = %61, %56, %18, %12
%68 = load double, double* %2
ret double %68
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"Error : qn <= 0 or qn >= 1 in pnorm()!\0A\00"
define double @pnorm(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = fcmp ogt double %0, 1.000000e+00
%4 = or i1 %2, %3
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %43
8: ; preds = %1
%9 = fcmp oeq double %0, 5.000000e-01
br i1 %9, label %43, label %10
10: ; preds = %8
%11 = fcmp ogt double %0, 5.000000e-01
%12 = fsub double 1.000000e+00, %0
%13 = select i1 %11, double %12, double %0
%14 = fmul double %13, 4.000000e+00
%15 = fsub double 1.000000e+00, %13
%16 = fmul double %14, %15
%17 = fptosi double %16 to i32
%18 = tail call double @log(i32 %17)
%19 = fneg double %18
%20 = tail call double @llvm.fmuladd.f64(double %19, double 0x3FA2FAD2BC7570AB, double 0x3FF921FB49DA360E)
%21 = fmul double %18, %18
%22 = tail call double @llvm.fmuladd.f64(double %21, double 0xBF4B6887417F2C60, double %20)
%23 = tail call double @pow(double %19, double 3.000000e+00)
%24 = tail call double @llvm.fmuladd.f64(double %23, double 0xBF2D80ECE6B44DAA, double %22)
%25 = tail call double @pow(double %19, double 4.000000e+00)
%26 = tail call double @llvm.fmuladd.f64(double %25, double 0x3EDCB1B3C4588BE6, double %24)
%27 = tail call double @pow(double %19, double 5.000000e+00)
%28 = tail call double @llvm.fmuladd.f64(double %27, double 0x3ED86DBA7E177BCB, double %26)
%29 = tail call double @pow(double %19, double 6.000000e+00)
%30 = tail call double @llvm.fmuladd.f64(double %29, double 0xBEB1896BFBD6446E, double %28)
%31 = tail call double @pow(double %19, double 7.000000e+00)
%32 = tail call double @llvm.fmuladd.f64(double %31, double 0x3E7671979857A092, double %30)
%33 = tail call double @pow(double %19, double 8.000000e+00)
%34 = tail call double @llvm.fmuladd.f64(double %33, double 0xBE2BC1390DEC58E7, double %32)
%35 = tail call double @pow(double %19, double 9.000000e+00)
%36 = tail call double @llvm.fmuladd.f64(double %35, double 0x3DC41BD805096DF9, double %34)
%37 = tail call double @pow(double %19, double 1.000000e+01)
%38 = tail call double @llvm.fmuladd.f64(double %37, double 0x3D68679AA9EC9A38, double %36)
%39 = fmul double %38, %19
%40 = tail call double @sqrt(double %39)
br i1 %11, label %43, label %41
41: ; preds = %10
%42 = fneg double %40
br label %43
43: ; preds = %10, %8, %41, %5
%44 = phi double [ 0.000000e+00, %5 ], [ %42, %41 ], [ 0.000000e+00, %8 ], [ %40, %10 ]
ret double %44
}