#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*/ M_PI;
double exp(double);
double lfact(int);
double lgamma(int);
double log(double);
int sqrt(int /*<<< orphan*/);
double compute_1F1_1d_canon(double a, double b, double z, int iter) {
  int i;
  double g, F = 0.0, logz = log(z);
  for (i = 0; i < iter; i++) {
    g = lgamma(i + a) - lgamma(i + b) + i * logz - lfact(i);
    if (i > z && exp(g) < 1e-8 * F)
      break;
    F += exp(g);
  }
  return 2 * sqrt(M_PI) * F;
}


x86 assembly (clang, -O0):
<compute_1F1_1d_canon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1253 <compute_1F1_1d_canon+0x103>
cvtsi2sdl -0x20(%rbp),%xmm0
addsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <lgamma@plt>
movsd  %xmm0,-0x48(%rbp)
cvtsi2sdl -0x20(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <lgamma@plt>
movsd  -0x48(%rbp),%xmm1
subsd  %xmm0,%xmm1
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%edi
call   1030 <lfact@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x20(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1231 <compute_1F1_1d_canon+0xe1>
movsd  -0x28(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  0xde3(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1231 <compute_1F1_1d_canon+0xe1>
jmp    1253 <compute_1F1_1d_canon+0x103>
movsd  -0x28(%rbp),%xmm0
call   1040 <exp@plt>
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1188 <compute_1F1_1d_canon+0x38>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
call   1070 <sqrt@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x30(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_1F1_1d_canon>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %edi,%ebx
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x20(%rsp)
movsd  %xmm2,0x30(%rsp)
movapd %xmm2,%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x18(%rsp)
xorpd  %xmm0,%xmm0
test   %ebx,%ebx
jle    125a <compute_1F1_1d_canon+0x10a>
movsd  %xmm0,(%rsp)
xor    %ebp,%ebp
jmp    11b2 <compute_1F1_1d_canon+0x62>
xchg   %ax,%ax
movapd %xmm1,%xmm0
call   1040 <exp@plt>
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
add    $0x1,%ebp
cmp    %ebp,%ebx
je     125f <compute_1F1_1d_canon+0x10f>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x10(%rsp)
addsd  0x20(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <lgamma@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <lgamma@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
call   1030 <lfact@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
ucomisd 0x30(%rsp),%xmm0
jbe    1190 <compute_1F1_1d_canon+0x40>
movapd %xmm1,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1040 <exp@plt>
movsd  (%rsp),%xmm1
mulsd  0xdb8(%rip),%xmm1
ucomisd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm1
jbe    1190 <compute_1F1_1d_canon+0x40>
jmp    125f <compute_1F1_1d_canon+0x10f>
movsd  %xmm0,(%rsp)
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1070 <sqrt@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@M_PI = global i32 0
define double @compute_1F1_1d_canon(double %0, double %1, double %2, i32 %3) {
%5 = tail call double @log(double %2)
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %31
7: ; preds = %4, %26
%8 = phi i32 [ %29, %26 ], [ 0, %4 ]
%9 = phi double [ %28, %26 ], [ 0.000000e+00, %4 ]
%10 = sitofp i32 %8 to double
%11 = fadd double %10, %0
%12 = fptosi double %11 to i32
%13 = tail call double @lgamma(i32 %12)
%14 = fadd double %10, %1
%15 = fptosi double %14 to i32
%16 = tail call double @lgamma(i32 %15)
%17 = fsub double %13, %16
%18 = tail call double @llvm.fmuladd.f64(double %10, double %5, double %17)
%19 = tail call double @lfact(i32 %8)
%20 = fsub double %18, %19
%21 = fcmp ogt double %10, %2
br i1 %21, label %22, label %26
22: ; preds = %7
%23 = tail call double @exp(double %20)
%24 = fmul double %9, 1.000000e-08
%25 = fcmp olt double %23, %24
br i1 %25, label %31, label %26
26: ; preds = %22, %7
%27 = tail call double @exp(double %20)
%28 = fadd double %9, %27
%29 = add nuw nsw i32 %8, 1
%30 = icmp eq i32 %29, %3
br i1 %30, label %31, label %7
31: ; preds = %26, %22, %4
%32 = phi double [ 0.000000e+00, %4 ], [ %9, %22 ], [ %28, %26 ]
%33 = load i32, i32* @M_PI
%34 = tail call i32 @sqrt(i32 %33)
%35 = shl nsw i32 %34, 1
%36 = sitofp i32 %35 to double
%37 = fmul double %32, %36
ret double %37
}