#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 pow(double, double);
double sqrt(double);
double twnorm(double lam, double p, double n) {
  double mu, phi, y1, y2;
  if (n < 0.0)
    return -10.0;
  if (p < 0.0)
    return -10.0;
  if (n < p)
    return twnorm(lam, n, p);
  y1 = sqrt(n - 1) + sqrt(p);
  mu = y1 * y1;
  y2 = (1.0 / sqrt(n - 1)) + 1.0 / sqrt(p);
  phi = y1 * pow(y2, 1.0 / 3.0);
  return (lam - mu) / phi;
}


x86 assembly (clang, -O0):
<twnorm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1167 <twnorm+0x37>
movsd  0xeb3(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1290 <twnorm+0x160>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1187 <twnorm+0x57>
movsd  0xe93(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1290 <twnorm+0x160>
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b9 <twnorm+0x89>
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1030 <twnorm@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1290 <twnorm+0x160>
movsd  -0x20(%rbp),%xmm0
movsd  0xe42(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xdfd(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xde9(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
movsd  0xdc6(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xd9a(%rip),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<twnorm>:
sub    $0x28,%rsp
movapd %xmm0,%xmm3
xorpd  %xmm4,%xmm4
movsd  0xecc(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
ucomisd %xmm1,%xmm4
ja     1274 <twnorm+0x154>
movapd %xmm2,%xmm5
ucomisd %xmm2,%xmm4
ja     1274 <twnorm+0x154>
movapd %xmm1,%xmm2
ucomisd %xmm5,%xmm1
movapd %xmm5,%xmm1
ja     1140 <twnorm+0x20>
addsd  0xe9a(%rip),%xmm5
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm5
movsd  %xmm2,(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm5,0x10(%rsp)
jb     11ad <twnorm+0x8d>
xorps  %xmm1,%xmm1
sqrtsd %xmm5,%xmm1
ucomisd %xmm0,%xmm2
jae    11c9 <twnorm+0xa9>
movapd %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1040 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
jmp    11d0 <twnorm+0xb0>
movapd %xmm5,%xmm0
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm2
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     1196 <twnorm+0x76>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
movsd  0x10(%rsp),%xmm2
addsd  %xmm0,%xmm1
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm2
movsd  %xmm1,0x8(%rsp)
jb     11f0 <twnorm+0xd0>
sqrtsd %xmm2,%xmm2
jmp    1207 <twnorm+0xe7>
movapd %xmm2,%xmm0
call   1040 <sqrt@plt>
xorpd  %xmm3,%xmm3
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm2
movsd  (%rsp),%xmm0
mulsd  %xmm1,%xmm1
movsd  %xmm1,(%rsp)
ucomisd %xmm3,%xmm0
jb     1221 <twnorm+0x101>
sqrtsd %xmm0,%xmm0
jmp    1232 <twnorm+0x112>
movapd %xmm2,0x10(%rsp)
call   1040 <sqrt@plt>
movapd 0x10(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
movapd 0xde2(%rip),%xmm1
divpd  %xmm2,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdba(%rip),%xmm1
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x20(%rsp),%xmm0
subsd  (%rsp),%xmm0
divsd  %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @twnorm(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%12 = load double, double* %7
%13 = fcmp olt double %12, 0.000000e+00
br i1 %13, label %14, label %15
14: ; preds = %3
store double -1.000000e+01, double* %4
br label %55
15: ; preds = %3
%16 = load double, double* %6
%17 = fcmp olt double %16, 0.000000e+00
br i1 %17, label %18, label %19
18: ; preds = %15
store double -1.000000e+01, double* %4
br label %55
19: ; preds = %15
%20 = load double, double* %7
%21 = load double, double* %6
%22 = fcmp olt double %20, %21
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load double, double* %5
%25 = load double, double* %7
%26 = load double, double* %6
%27 = call double @twnorm(double %24, double %25, double %26)
store double %27, double* %4
br label %55
28: ; preds = %19
%29 = load double, double* %7
%30 = fsub double %29, 1.000000e+00
%31 = call double @sqrt(double %30)
%32 = load double, double* %6
%33 = call double @sqrt(double %32)
%34 = fadd double %31, %33
store double %34, double* %10
%35 = load double, double* %10
%36 = load double, double* %10
%37 = fmul double %35, %36
store double %37, double* %8
%38 = load double, double* %7
%39 = fsub double %38, 1.000000e+00
%40 = call double @sqrt(double %39)
%41 = fdiv double 1.000000e+00, %40
%42 = load double, double* %6
%43 = call double @sqrt(double %42)
%44 = fdiv double 1.000000e+00, %43
%45 = fadd double %41, %44
store double %45, double* %11
%46 = load double, double* %10
%47 = load double, double* %11
%48 = call double @pow(double %47, double 0x3FD5555555555555)
%49 = fmul double %46, %48
store double %49, double* %9
%50 = load double, double* %5
%51 = load double, double* %8
%52 = fsub double %50, %51
%53 = load double, double* %9
%54 = fdiv double %52, %53
store double %54, double* %4
br label %55
55: ; preds = %28, %23, %18, %14
%56 = load double, double* %4
ret double %56
}

LLVM IR (-O2):
define double @twnorm(double %0, double %1, double %2) {
br label %4
4: ; preds = %10, %3
%5 = phi double [ %1, %3 ], [ %6, %10 ]
%6 = phi double [ %2, %3 ], [ %5, %10 ]
%7 = fcmp olt double %6, 0.000000e+00
%8 = fcmp olt double %5, 0.000000e+00
%9 = or i1 %8, %7
br i1 %9, label %30, label %10
10: ; preds = %4
%11 = fcmp olt double %6, %5
br i1 %11, label %4, label %12
12: ; preds = %10
%13 = fadd double %6, -1.000000e+00
%14 = tail call double @sqrt(double %13)
%15 = tail call double @sqrt(double %5)
%16 = fadd double %14, %15
%17 = fmul double %16, %16
%18 = tail call double @sqrt(double %13)
%19 = tail call double @sqrt(double %5)
%20 = insertelement <2 x double> poison, double %18, i64 0
%21 = insertelement <2 x double> %20, double %19, i64 1
%22 = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %21
%23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%24 = fadd <2 x double> %22, %23
%25 = extractelement <2 x double> %24, i64 0
%26 = tail call double @pow(double %25, double 0x3FD5555555555555)
%27 = fmul double %16, %26
%28 = fsub double %0, %17
%29 = fdiv double %28, %27
br label %30
30: ; preds = %4, %12
%31 = phi double [ %29, %12 ], [ -1.000000e+01, %4 ]
ret double %31
}