#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_2d_canon(double a, double b, double z1, double z2,
                            int iter) {
  int i, j;
  double g, F = 0.0, logz1 = log(z1), logz2 = log(z2);
  for (i = 0; i < iter; i++) {
    for (j = 0; j < iter; j++) {
      g = lgamma(i + a) + lgamma(j + a) - lgamma(i + j + b) + i * logz1 +
          j * logz2 - lfact(i) - lfact(j);
      if ((i > z1 || j > z2) && exp(g) < 1e-8 * F)
        break;
      F += exp(g);
    }
  }
  return 2 * sqrt(M_PI) * F;
}


x86 assembly (clang, -O0):
<compute_1F1_2d_canon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12f4 <compute_1F1_2d_canon+0x1a4>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12e1 <compute_1F1_2d_canon+0x191>
cvtsi2sdl -0x28(%rbp),%xmm0
addsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <lgamma@plt>
movsd  %xmm0,-0x70(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
addsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x28(%rbp),%eax
add    -0x2c(%rbp),%eax
cvtsi2sd %eax,%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
subsd  %xmm1,%xmm0
cvtsi2sdl -0x28(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x28(%rbp),%edi
call   1030 <lfact@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x2c(%rbp),%edi
call   1030 <lfact@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x28(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
ja     1296 <compute_1F1_2d_canon+0x146>
cvtsi2sdl -0x2c(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    12bf <compute_1F1_2d_canon+0x16f>
movsd  -0x38(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  0xd55(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12bf <compute_1F1_2d_canon+0x16f>
jmp    12e1 <compute_1F1_2d_canon+0x191>
movsd  -0x38(%rbp),%xmm0
call   1040 <exp@plt>
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11af <compute_1F1_2d_canon+0x5f>
jmp    12e6 <compute_1F1_2d_canon+0x196>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    119c <compute_1F1_2d_canon+0x4c>
mov    0x2ced(%rip),%rax
mov    (%rax),%edi
call   1070 <sqrt@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x40(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_1F1_2d_canon>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %edi,%r14d
movsd  %xmm3,0x10(%rsp)
movsd  %xmm1,0x38(%rsp)
movsd  %xmm0,0x18(%rsp)
movsd  %xmm2,0x40(%rsp)
movapd %xmm2,%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x28(%rsp)
test   %r14d,%r14d
jle    12ff <compute_1F1_2d_canon+0x1af>
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
jmp    11ca <compute_1F1_2d_canon+0x7a>
nop
movsd  0x20(%rsp),%xmm1
addsd  0xe4a(%rip),%xmm1
add    $0x1,%ebx
cmp    %r14d,%ebx
je     1308 <compute_1F1_2d_canon+0x1b8>
movsd  %xmm1,0x20(%rsp)
movapd %xmm1,%xmm0
addsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%r15d
xor    %ebp,%ebp
jmp    123b <compute_1F1_2d_canon+0xeb>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movapd %xmm3,%xmm0
movsd  %xmm3,0x8(%rsp)
call   1040 <exp@plt>
movsd  0x8(%rsp),%xmm3
movsd  (%rsp),%xmm1
mulsd  0xdee(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     11b0 <compute_1F1_2d_canon+0x60>
movapd %xmm3,%xmm0
call   1040 <exp@plt>
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
add    $0x1,%ebp
cmp    %ebp,%r14d
je     11b0 <compute_1F1_2d_canon+0x60>
mov    %r15d,%edi
call   1050 <lgamma@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd  %xmm1,0x60(%rsp)
movsd  %xmm0,0x8(%rsp)
movapd %xmm1,%xmm0
addsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <lgamma@plt>
lea    (%rbx,%rbp,1),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm0,0x50(%rsp)
addsd  0x38(%rsp),%xmm1
cvttsd2si %xmm1,%edi
call   1050 <lgamma@plt>
movsd  %xmm0,0x48(%rsp)
mov    %ebx,%edi
call   1030 <lfact@plt>
movsd  %xmm0,0x58(%rsp)
mov    %ebp,%edi
call   1030 <lfact@plt>
movsd  0x60(%rsp),%xmm2
movsd  0x20(%rsp),%xmm1
ucomisd 0x40(%rsp),%xmm1
movsd  0x50(%rsp),%xmm3
addsd  0x8(%rsp),%xmm3
subsd  0x48(%rsp),%xmm3
mulsd  0x30(%rsp),%xmm1
addsd  %xmm3,%xmm1
movapd %xmm2,%xmm3
mulsd  0x28(%rsp),%xmm3
addsd  %xmm1,%xmm3
subsd  0x58(%rsp),%xmm3
subsd  %xmm0,%xmm3
ja     11f0 <compute_1F1_2d_canon+0xa0>
ucomisd 0x10(%rsp),%xmm2
jbe    1218 <compute_1F1_2d_canon+0xc8>
jmp    11f0 <compute_1F1_2d_canon+0xa0>
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
call   1070 <sqrt@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @compute_1F1_2d_canon(double %0, double %1, double %2, double %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store i32 %4, i32* %10
store double 0.000000e+00, double* %14
%17 = load double, double* %8
%18 = call double @log(double %17)
store double %18, double* %15
%19 = load double, double* %9
%20 = call double @log(double %19)
store double %20, double* %16
store i32 0, i32* %11
br label %21
21: ; preds = %92, %5
%22 = load i32, i32* %11
%23 = load i32, i32* %10
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %95
25: ; preds = %21
store i32 0, i32* %12
br label %26
26: ; preds = %88, %25
%27 = load i32, i32* %12
%28 = load i32, i32* %10
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %91
30: ; preds = %26
%31 = load i32, i32* %11
%32 = sitofp i32 %31 to double
%33 = load double, double* %6
%34 = fadd double %32, %33
%35 = fptosi double %34 to i32
%36 = call double @lgamma(i32 %35)
%37 = load i32, i32* %12
%38 = sitofp i32 %37 to double
%39 = load double, double* %6
%40 = fadd double %38, %39
%41 = fptosi double %40 to i32
%42 = call double @lgamma(i32 %41)
%43 = fadd double %36, %42
%44 = load i32, i32* %11
%45 = load i32, i32* %12
%46 = add nsw i32 %44, %45
%47 = sitofp i32 %46 to double
%48 = load double, double* %7
%49 = fadd double %47, %48
%50 = fptosi double %49 to i32
%51 = call double @lgamma(i32 %50)
%52 = fsub double %43, %51
%53 = load i32, i32* %11
%54 = sitofp i32 %53 to double
%55 = load double, double* %15
%56 = call double @llvm.fmuladd.f64(double %54, double %55, double %52)
%57 = load i32, i32* %12
%58 = sitofp i32 %57 to double
%59 = load double, double* %16
%60 = call double @llvm.fmuladd.f64(double %58, double %59, double %56)
%61 = load i32, i32* %11
%62 = call double @lfact(i32 %61)
%63 = fsub double %60, %62
%64 = load i32, i32* %12
%65 = call double @lfact(i32 %64)
%66 = fsub double %63, %65
store double %66, double* %13
%67 = load i32, i32* %11
%68 = sitofp i32 %67 to double
%69 = load double, double* %8
%70 = fcmp ogt double %68, %69
br i1 %70, label %76, label %71
71: ; preds = %30
%72 = load i32, i32* %12
%73 = sitofp i32 %72 to double
%74 = load double, double* %9
%75 = fcmp ogt double %73, %74
br i1 %75, label %76, label %83
76: ; preds = %71, %30
%77 = load double, double* %13
%78 = call double @exp(double %77)
%79 = load double, double* %14
%80 = fmul double 1.000000e-08, %79
%81 = fcmp olt double %78, %80
br i1 %81, label %82, label %83
82: ; preds = %76
br label %91
83: ; preds = %76, %71
%84 = load double, double* %13
%85 = call double @exp(double %84)
%86 = load double, double* %14
%87 = fadd double %86, %85
store double %87, double* %14
br label %88
88: ; preds = %83
%89 = load i32, i32* %12
%90 = add nsw i32 %89, 1
store i32 %90, i32* %12
br label %26
91: ; preds = %82, %26
br label %92
92: ; preds = %91
%93 = load i32, i32* %11
%94 = add nsw i32 %93, 1
store i32 %94, i32* %11
br label %21
95: ; preds = %21
%96 = load i32, i32* @M_PI
%97 = call i32 @sqrt(i32 %96)
%98 = mul nsw i32 2, %97
%99 = sitofp i32 %98 to double
%100 = load double, double* %14
%101 = fmul double %99, %100
ret double %101
}

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