#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*/ gcf(double *, double, double, double *);
int /*<<< orphan*/ gser(double *, double, double, double *);
double chitest(double chi, int fr) {
  double a, x, gamser, gln, gammcf;
  a = (double)fr / 2.;
  x = chi / 2;
  if (x < a + 1) {
    gser(&gamser, a, x, &gln);
    gammcf = 1 - gamser;
  } else
    gcf(&gammcf, a, x, &gln);
  return (gammcf);
}


x86 assembly (clang, -O0):
<chitest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xecb(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xeb5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xe97(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a6 <chitest+0x86>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <gser@plt>
movsd  0xe69(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11bd <chitest+0x9d>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    -0x38(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <gcf@plt>
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chitest>:
sub    $0x18,%rsp
cvtsi2sd %edi,%xmm2
movapd %xmm0,%xmm1
movsd  0xecc(%rip),%xmm0
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm1
movsd  0xec4(%rip),%xmm0
addsd  %xmm2,%xmm0
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
ucomisd %xmm1,%xmm0
jbe    1174 <chitest+0x54>
movapd %xmm2,%xmm0
call   1030 <gser@plt>
movsd  0xe9f(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret
movapd %xmm2,%xmm0
call   1040 <gcf@plt>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @chitest(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
%10 = load i32, i32* %4
%11 = sitofp i32 %10 to double
%12 = fdiv double %11, 2.000000e+00
store double %12, double* %5
%13 = load double, double* %3
%14 = fdiv double %13, 2.000000e+00
store double %14, double* %6
%15 = load double, double* %6
%16 = load double, double* %5
%17 = fadd double %16, 1.000000e+00
%18 = fcmp olt double %15, %17
br i1 %18, label %19, label %25
19: ; preds = %2
%20 = load double, double* %5
%21 = load double, double* %6
%22 = call i32 @gser(double* %7, double %20, double %21, double* %8)
%23 = load double, double* %7
%24 = fsub double 1.000000e+00, %23
store double %24, double* %9
br label %29
25: ; preds = %2
%26 = load double, double* %5
%27 = load double, double* %6
%28 = call i32 @gcf(double* %9, double %26, double %27, double* %8)
br label %29
29: ; preds = %25, %19
%30 = load double, double* %9
ret double %30
}

LLVM IR (-O2):
define double @chitest(double %0, i32 %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %3 to i8*
%7 = bitcast double* %4 to i8*
%8 = bitcast double* %5 to i8*
%9 = sitofp i32 %1 to double
%10 = fmul double %9, 5.000000e-01
%11 = fmul double %0, 5.000000e-01
%12 = fadd double %10, 1.000000e+00
%13 = fcmp olt double %11, %12
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = call i32 @gser(double* %3, double %10, double %11, double* %4)
%16 = load double, double* %3
%17 = fsub double 1.000000e+00, %16
br label %21
18: ; preds = %2
%19 = call i32 @gcf(double* %5, double %10, double %11, double* %4)
%20 = load double, double* %5
br label %21
21: ; preds = %18, %14
%22 = phi double [ %20, %18 ], [ %17, %14 ]
ret double %22
}