#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*/ chiGammaFlagError(char *);
int /*<<< orphan*/ gcf(double *, double, double, double *);
int /*<<< orphan*/ gser(double *, double, double, double *);
double gammp(double a, double x) {
  double gamser, gammcf, gln;
  if (x < 0.0 || a <= 0.0) {
    chiGammaFlagError("Invalid arguments in routine gammp");
    return (0.0);
  }
  if (x < (a + 1.0)) {
    gser(&gamser, a, x, &gln);
    return (gamser);
  } else {
    gcf(&gammcf, a, x, &gln);
    return (1.0 - gammcf);
  }
}


x86 assembly (clang, -O0):
<gammp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
ja     115e <gammp+0x2e>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1177 <gammp+0x47>
lea    0xea3(%rip),%rdi
call   1030 <chiGammaFlagError@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e2 <gammp+0xb2>
movsd  -0x18(%rbp),%xmm1
movsd  0xe7c(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b9 <gammp+0x89>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <gser@plt>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e2 <gammp+0xb2>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <gcf@plt>
movsd  0xe28(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammp>:
sub    $0x18,%rsp
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jae    1170 <gammp+0x40>
ucomisd %xmm1,%xmm2
ja     1170 <gammp+0x40>
movsd  0xeb4(%rip),%xmm2
addsd  %xmm0,%xmm2
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
ucomisd %xmm1,%xmm2
jbe    1185 <gammp+0x55>
call   1040 <gser@plt>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret
lea    0xe91(%rip),%rdi
call   1030 <chiGammaFlagError@plt>
xorpd  %xmm0,%xmm0
add    $0x18,%rsp
ret
call   1050 <gcf@plt>
movsd  0xe6e(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Invalid arguments in routine gammp\00"
define double @gammp(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
%9 = load double, double* %5
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load double, double* %4
%13 = fcmp ole double %12, 0.000000e+00
br i1 %13, label %14, label %16
14: ; preds = %11, %2
%15 = call i32 @chiGammaFlagError(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %3
br label %32
16: ; preds = %11
%17 = load double, double* %5
%18 = load double, double* %4
%19 = fadd double %18, 1.000000e+00
%20 = fcmp olt double %17, %19
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = load double, double* %4
%23 = load double, double* %5
%24 = call i32 @gser(double* %6, double %22, double %23, double* %8)
%25 = load double, double* %6
store double %25, double* %3
br label %32
26: ; preds = %16
%27 = load double, double* %4
%28 = load double, double* %5
%29 = call i32 @gcf(double* %7, double %27, double %28, double* %8)
%30 = load double, double* %7
%31 = fsub double 1.000000e+00, %30
store double %31, double* %3
br label %32
32: ; preds = %26, %21, %14
%33 = load double, double* %3
ret double %33
}

LLVM IR (-O2):
@.str = [35 x i8] c"Invalid arguments in routine gammp\00"
define double @gammp(double %0, double %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 = fcmp olt double %1, 0.000000e+00
%10 = fcmp ole double %0, 0.000000e+00
%11 = or i1 %10, %9
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 @chiGammaFlagError(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %24
14: ; preds = %2
%15 = fadd double %0, 1.000000e+00
%16 = fcmp ogt double %15, %1
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = call i32 @gser(double* %3, double %0, double %1, double* %5)
%19 = load double, double* %3
br label %24
20: ; preds = %14
%21 = call i32 @gcf(double* %4, double %0, double %1, double* %5)
%22 = load double, double* %4
%23 = fsub double 1.000000e+00, %22
br label %24
24: ; preds = %20, %17, %12
%25 = phi double [ 0.000000e+00, %12 ], [ %19, %17 ], [ %23, %20 ]
ret double %25
}