#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 acos(double);
double fabs(double);
double log(double);
double sqrt(double);
double zzprob(double pval) {
  double x, dev, p, q, d, h, u;
  double pi;
  int iter;
  if (pval == 0.0)
    return 50.0;
  pi = 2.0 * acos(0.0);
  u = -log(sqrt(2.0 * pi) * pval);
  x = sqrt(2.0 * u);
  for (iter = 1; iter <= 10; ++iter) {
    q = (0.5 * x * x) + log(x);
    d = x + (1.0 / x);
    dev = u - q;
    h = dev / d;
    x += h;
    if (fabs(h) < 1.0e-7)
      return x;
  }
  return x;
}


x86 assembly (clang, -O0):
<zzprob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1167 <zzprob+0x37>
jp     1167 <zzprob+0x37>
movsd  0xec3(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b9 <zzprob+0x189>
xorps  %xmm0,%xmm0
call   1030 <acos@plt>
movaps %xmm0,%xmm1
movsd  0xe86(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe75(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
call   1050 <sqrt@plt>
mulsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe3d(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x54(%rbp)
cmpl   $0xa,-0x54(%rbp)
jg     12af <zzprob+0x17f>
movsd  0xe2d(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <log@plt>
movsd  -0x68(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xde0(%rip),%xmm1
divsd  -0x18(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x40(%rbp),%xmm1
movaps 0xdb9(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd85(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    129c <zzprob+0x16c>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b9 <zzprob+0x189>
jmp    12a1 <zzprob+0x171>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11d9 <zzprob+0xa9>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zzprob>:
push   %rbx
sub    $0x20,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    113e <zzprob+0x1e>
jp     113e <zzprob+0x1e>
movsd  0xec7(%rip),%xmm0
jmp    11f9 <zzprob+0xd9>
mulsd  0xec2(%rip),%xmm0
call   1030 <log@plt>
movapd 0xeed(%rip),%xmm1
xorpd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
mulsd  0xeab(%rip),%xmm0
ucomisd 0xec3(%rip),%xmm0
jb     1175 <zzprob+0x55>
sqrtsd %xmm0,%xmm0
jmp    117a <zzprob+0x5a>
call   1040 <sqrt@plt>
mov    $0x9,%ebx
nop
movsd  %xmm0,(%rsp)
mulsd  0xe8b(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1030 <log@plt>
movsd  0x8(%rsp),%xmm1
mulsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm2
movsd  0xe68(%rip),%xmm0
divsd  (%rsp),%xmm0
addsd  (%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
andpd  0xe6f(%rip),%xmm1
sub    $0x1,%ebx
setb   %al
movsd  0xe39(%rip),%xmm2
ucomisd %xmm1,%xmm2
ja     11f9 <zzprob+0xd9>
test   %al,%al
je     1180 <zzprob+0x60>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @zzprob(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
store double %0, double* %3
%13 = load double, double* %3
%14 = fcmp oeq double %13, 0.000000e+00
br i1 %14, label %15, label %16
15: ; preds = %1
store double 5.000000e+01, double* %2
br label %63
16: ; preds = %1
%17 = call double @acos(double 0.000000e+00)
%18 = fmul double 2.000000e+00, %17
store double %18, double* %11
%19 = load double, double* %11
%20 = fmul double 2.000000e+00, %19
%21 = call double @sqrt(double %20)
%22 = load double, double* %3
%23 = fmul double %21, %22
%24 = call double @log(double %23)
%25 = fneg double %24
store double %25, double* %10
%26 = load double, double* %10
%27 = fmul double 2.000000e+00, %26
%28 = call double @sqrt(double %27)
store double %28, double* %4
store i32 1, i32* %12
br label %29
29: ; preds = %58, %16
%30 = load i32, i32* %12
%31 = icmp sle i32 %30, 10
br i1 %31, label %32, label %61
32: ; preds = %29
%33 = load double, double* %4
%34 = fmul double 5.000000e-01, %33
%35 = load double, double* %4
%36 = load double, double* %4
%37 = call double @log(double %36)
%38 = call double @llvm.fmuladd.f64(double %34, double %35, double %37)
store double %38, double* %7
%39 = load double, double* %4
%40 = load double, double* %4
%41 = fdiv double 1.000000e+00, %40
%42 = fadd double %39, %41
store double %42, double* %8
%43 = load double, double* %10
%44 = load double, double* %7
%45 = fsub double %43, %44
store double %45, double* %5
%46 = load double, double* %5
%47 = load double, double* %8
%48 = fdiv double %46, %47
store double %48, double* %9
%49 = load double, double* %9
%50 = load double, double* %4
%51 = fadd double %50, %49
store double %51, double* %4
%52 = load double, double* %9
%53 = call double @llvm.fabs.f64(double %52)
%54 = fcmp olt double %53, 0x3E7AD7F29ABCAF48
br i1 %54, label %55, label %57
55: ; preds = %32
%56 = load double, double* %4
store double %56, double* %2
br label %63
57: ; preds = %32
br label %58
58: ; preds = %57
%59 = load i32, i32* %12
%60 = add nsw i32 %59, 1
store i32 %60, i32* %12
br label %29
61: ; preds = %29
%62 = load double, double* %4
store double %62, double* %2
br label %63
63: ; preds = %61, %55, %15
%64 = load double, double* %2
ret double %64
}

LLVM IR (-O2):
define double @zzprob(double %0) {
%2 = fcmp oeq double %0, 0.000000e+00
br i1 %2, label %25, label %3
3: ; preds = %1
%4 = fmul double %0, 0x40040D931FF62705
%5 = tail call double @log(double %4)
%6 = fneg double %5
%7 = fmul double %5, -2.000000e+00
%8 = tail call double @sqrt(double %7)
br label %9
9: ; preds = %9, %3
%10 = phi i32 [ 1, %3 ], [ %22, %9 ]
%11 = phi double [ %8, %3 ], [ %19, %9 ]
%12 = fmul double %11, 5.000000e-01
%13 = tail call double @log(double %11)
%14 = tail call double @llvm.fmuladd.f64(double %12, double %11, double %13)
%15 = fdiv double 1.000000e+00, %11
%16 = fadd double %11, %15
%17 = fsub double %6, %14
%18 = fdiv double %17, %16
%19 = fadd double %11, %18
%20 = tail call double @llvm.fabs.f64(double %18)
%21 = fcmp olt double %20, 0x3E7AD7F29ABCAF48
%22 = add nuw nsw i32 %10, 1
%23 = icmp eq i32 %22, 11
%24 = select i1 %21, i1 true, i1 %23
br i1 %24, label %25, label %9
25: ; preds = %9, %1
%26 = phi double [ 5.000000e+01, %1 ], [ %19, %9 ]
ret double %26
}