#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 pow(double, double);
double sqrt(double);
double norm_percent(const double alpha) {
  int i;
  double a, x, u;
  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};
  if (alpha == 0.5) {
    return 0.0;
  }
  a = alpha;
  if (a > 0.5) {
    a = 1.0 - a;
  }
  x = -log(4.0 * a * (1.0 - a));
  u = b[0];
  for (i = 1; i < 11; i++) {
    u += (b[i] * pow(x, (double)i));
  }
  if (alpha > 0.5) {
    return -sqrt(u * x);
  } else {
    return sqrt(u * x);
  }
}


x86 assembly (clang, -O0):
<norm_percent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeb6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1167 <norm_percent+0x37>
jp     1167 <norm_percent+0x37>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    129e <norm_percent+0x16e>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe82(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119a <norm_percent+0x6a>
movsd  0xe78(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe6e(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xe59(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0x2e5f(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0xb,-0x14(%rbp)
jge    1243 <norm_percent+0x113>
movslq -0x14(%rbp),%rcx
lea    0x2e3e(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ed <norm_percent+0xbd>
movsd  -0x10(%rbp),%xmm0
movsd  0xdb0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    128a <norm_percent+0x15a>
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1050 <sqrt@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    129e <norm_percent+0x16e>
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<norm_percent>:
sub    $0x38,%rsp
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd 0xebc(%rip),%xmm3
jne    114d <norm_percent+0x1d>
jp     114d <norm_percent+0x1d>
add    $0x38,%rsp
ret
movsd  0xeb3(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm3,%xmm2
movsd  0xe9b(%rip),%xmm0
cmpltsd %xmm3,%xmm0
andpd  %xmm0,%xmm2
movapd %xmm3,0x20(%rsp)
andnpd %xmm3,%xmm0
orpd   %xmm2,%xmm0
subsd  %xmm0,%xmm1
mulsd  0xe88(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <log@plt>
movapd %xmm0,%xmm2
movapd 0xf13(%rip),%xmm0
xorpd  %xmm2,%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0xe69(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xe65(%rip),%xmm1
mulsd  %xmm2,%xmm2
mulsd  0xe61(%rip),%xmm2
addsd  %xmm1,%xmm2
movapd %xmm2,(%rsp)
movsd  0xe58(%rip),%xmm1
call   1040 <pow@plt>
mulsd  0xe53(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
movsd  0xe13(%rip),%xmm1
call   1040 <pow@plt>
mulsd  0xe36(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe2c(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1040 <pow@plt>
mulsd  0xe21(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe17(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1040 <pow@plt>
mulsd  0xe0c(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe02(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1040 <pow@plt>
mulsd  0xdf7(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xded(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1040 <pow@plt>
mulsd  0xde2(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xdd8(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1040 <pow@plt>
mulsd  0xdcd(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xdc3(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1040 <pow@plt>
mulsd  0xdb8(%rip),%xmm0
addsd  (%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1303 <norm_percent+0x1d3>
sqrtsd %xmm0,%xmm0
jmp    1308 <norm_percent+0x1d8>
call   1050 <sqrt@plt>
movapd 0x20(%rsp),%xmm1
ucomisd 0xcea(%rip),%xmm1
jbe    1148 <norm_percent+0x18>
xorpd  0xd8c(%rip),%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
@norm_percent.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]
define double @norm_percent(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
%8 = load double, double* %3
%9 = fcmp oeq double %8, 5.000000e-01
br i1 %9, label %10, label %11
10: ; preds = %1
store double 0.000000e+00, double* %2
br label %58
11: ; preds = %1
%12 = load double, double* %3
store double %12, double* %5
%13 = load double, double* %5
%14 = fcmp ogt double %13, 5.000000e-01
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load double, double* %5
%17 = fsub double 1.000000e+00, %16
store double %17, double* %5
br label %18
18: ; preds = %15, %11
%19 = load double, double* %5
%20 = fmul double 4.000000e+00, %19
%21 = load double, double* %5
%22 = fsub double 1.000000e+00, %21
%23 = fmul double %20, %22
%24 = call double @log(double %23)
%25 = fneg double %24
store double %25, double* %6
%26 = load double, double* getelementptr inbounds ([11 x double], [11 x double]* @norm_percent.b, i64 0, i64 0)
store double %26, double* %7
store i32 1, i32* %4
br label %27
27: ; preds = %41, %18
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 11
br i1 %29, label %30, label %44
30: ; preds = %27
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [11 x double], [11 x double]* @norm_percent.b, i64 0, i64 %32
%34 = load double, double* %33
%35 = load double, double* %6
%36 = load i32, i32* %4
%37 = sitofp i32 %36 to double
%38 = call double @pow(double %35, double %37)
%39 = load double, double* %7
%40 = call double @llvm.fmuladd.f64(double %34, double %38, double %39)
store double %40, double* %7
br label %41
41: ; preds = %30
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %27
44: ; preds = %27
%45 = load double, double* %3
%46 = fcmp ogt double %45, 5.000000e-01
br i1 %46, label %47, label %53
47: ; preds = %44
%48 = load double, double* %7
%49 = load double, double* %6
%50 = fmul double %48, %49
%51 = call double @sqrt(double %50)
%52 = fneg double %51
store double %52, double* %2
br label %58
53: ; preds = %44
%54 = load double, double* %7
%55 = load double, double* %6
%56 = fmul double %54, %55
%57 = call double @sqrt(double %56)
store double %57, double* %2
br label %58
58: ; preds = %53, %47, %10
%59 = load double, double* %2
ret double %59
}

LLVM IR (-O2):
define double @norm_percent(double %0) {
%2 = fcmp oeq double %0, 5.000000e-01
br i1 %2, label %35, label %3
3: ; preds = %1
%4 = fcmp ogt double %0, 5.000000e-01
%5 = fsub double 1.000000e+00, %0
%6 = select i1 %4, double %5, double %0
%7 = fmul double %6, 4.000000e+00
%8 = fsub double 1.000000e+00, %6
%9 = fmul double %7, %8
%10 = tail call double @log(double %9)
%11 = fneg double %10
%12 = tail call double @llvm.fmuladd.f64(double %11, double 0x3FA2FAD2BC7570AB, double 0x3FF921FB49DA360E)
%13 = fmul double %10, %10
%14 = tail call double @llvm.fmuladd.f64(double %13, double 0xBF4B6887417F2C60, double %12)
%15 = tail call double @pow(double %11, double 3.000000e+00)
%16 = tail call double @llvm.fmuladd.f64(double %15, double 0xBF2D80ECE6B44DAA, double %14)
%17 = tail call double @pow(double %11, double 4.000000e+00)
%18 = tail call double @llvm.fmuladd.f64(double %17, double 0x3EDCB1B3C4588BE6, double %16)
%19 = tail call double @pow(double %11, double 5.000000e+00)
%20 = tail call double @llvm.fmuladd.f64(double %19, double 0x3ED86DBA7E177BCB, double %18)
%21 = tail call double @pow(double %11, double 6.000000e+00)
%22 = tail call double @llvm.fmuladd.f64(double %21, double 0xBEB1896BFBD6446E, double %20)
%23 = tail call double @pow(double %11, double 7.000000e+00)
%24 = tail call double @llvm.fmuladd.f64(double %23, double 0x3E7671979857A092, double %22)
%25 = tail call double @pow(double %11, double 8.000000e+00)
%26 = tail call double @llvm.fmuladd.f64(double %25, double 0xBE2BC1390DEC58E7, double %24)
%27 = tail call double @pow(double %11, double 9.000000e+00)
%28 = tail call double @llvm.fmuladd.f64(double %27, double 0x3DC41BD805096DF9, double %26)
%29 = tail call double @pow(double %11, double 1.000000e+01)
%30 = tail call double @llvm.fmuladd.f64(double %29, double 0x3D68679AA9EC9A38, double %28)
%31 = fmul double %30, %11
%32 = tail call double @sqrt(double %31)
br i1 %4, label %33, label %35
33: ; preds = %3
%34 = fneg double %32
br label %35
35: ; preds = %3, %1, %33
%36 = phi double [ %34, %33 ], [ 0.000000e+00, %1 ], [ %32, %3 ]
ret double %36
}