#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 cdfErlang(long, double, double);
double fabs(double);
double pdfErlang(long, double, double);
double idfErlang(long n, double b, double u) {
  double t, x = n * b;
  do {
    t = x;
    x = t + (u - cdfErlang(n, b, t)) / pdfErlang(n, b, t);
    if (x <= 0.0)
      x = 0.5 * t;
  } while (fabs(x - t) >= 1.0e-10);
  return (x);
}


x86 assembly (clang, -O0):
<idfErlang>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <cdfErlang@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1040 <pdfErlang@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     11d5 <idfErlang+0xb5>
movsd  0xe35(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11da <idfErlang+0xba>
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movaps 0xe25(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe11(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1146 <idfErlang+0x26>
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<idfErlang>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm1,0x18(%rsp)
movapd %xmm0,%xmm1
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %rdi,%xmm0
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm1,%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movapd %xmm0,%xmm1
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <cdfErlang@plt>
movsd  0x18(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1040 <pdfErlang@plt>
movapd 0x20(%rsp),%xmm3
divsd  %xmm0,%xmm3
movsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm3
movapd %xmm0,%xmm1
movapd %xmm0,%xmm2
mulsd  0xe50(%rip),%xmm1
movapd %xmm3,%xmm0
cmpnlesd 0xe53(%rip),%xmm0
andpd  %xmm0,%xmm3
andnpd %xmm1,%xmm0
orpd   %xmm3,%xmm0
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
andpd  0xe47(%rip),%xmm1
ucomisd 0xe27(%rip),%xmm1
jae    1150 <idfErlang+0x30>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @idfErlang(i64 %0, double %1, double %2) {
%4 = alloca i64
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i64 %0, i64* %4
store double %1, double* %5
store double %2, double* %6
%9 = load i64, i64* %4
%10 = sitofp i64 %9 to double
%11 = load double, double* %5
%12 = fmul double %10, %11
store double %12, double* %8
br label %13
13: ; preds = %34, %3
%14 = load double, double* %8
store double %14, double* %7
%15 = load double, double* %7
%16 = load double, double* %6
%17 = load i64, i64* %4
%18 = load double, double* %5
%19 = load double, double* %7
%20 = call double @cdfErlang(i64 %17, double %18, double %19)
%21 = fsub double %16, %20
%22 = load i64, i64* %4
%23 = load double, double* %5
%24 = load double, double* %7
%25 = call double @pdfErlang(i64 %22, double %23, double %24)
%26 = fdiv double %21, %25
%27 = fadd double %15, %26
store double %27, double* %8
%28 = load double, double* %8
%29 = fcmp ole double %28, 0.000000e+00
br i1 %29, label %30, label %33
30: ; preds = %13
%31 = load double, double* %7
%32 = fmul double 5.000000e-01, %31
store double %32, double* %8
br label %33
33: ; preds = %30, %13
br label %34
34: ; preds = %33
%35 = load double, double* %8
%36 = load double, double* %7
%37 = fsub double %35, %36
%38 = call double @llvm.fabs.f64(double %37)
%39 = fcmp oge double %38, 1.000000e-10
br i1 %39, label %13, label %40
40: ; preds = %34
%41 = load double, double* %8
ret double %41
}

LLVM IR (-O2):
define double @idfErlang(i64 %0, double %1, double %2) {
%4 = sitofp i64 %0 to double
%5 = fmul double %4, %1
br label %6
6: ; preds = %6, %3
%7 = phi double [ %5, %3 ], [ %15, %6 ]
%8 = tail call double @cdfErlang(i64 %0, double %1, double %7)
%9 = fsub double %2, %8
%10 = tail call double @pdfErlang(i64 %0, double %1, double %7)
%11 = fdiv double %9, %10
%12 = fadd double %7, %11
%13 = fcmp ugt double %12, 0.000000e+00
%14 = fmul double %7, 5.000000e-01
%15 = select i1 %13, double %12, double %14
%16 = fsub double %15, %7
%17 = tail call double @llvm.fabs.f64(double %16)
%18 = fcmp ult double %17, 1.000000e-10
br i1 %18, label %19, label %6
19: ; preds = %6
ret double %15
}