#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*/ gamma_continued_frac(double *, double, double, double *);
int /*<<< orphan*/ gamma_series_rep(double *, double, double, double *);
double gammaq(double a, double x) {
  double gamser = 0.0, gammcf = 0.0, gln = 0.0;
  if (x < 0.0 || a <= 0.0)
    return -1.0;
  if (x < (a + 1.0)) {
    gamma_series_rep(&gamser, a, x, &gln);
    return 1.0 - gamser;
  } else {
    gamma_continued_frac(&gammcf, a, x, &gln);
    return gammcf;
  }
}


x86 assembly (clang, -O0):
<gammaq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
ja     1166 <gammaq+0x46>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1178 <gammaq+0x58>
movsd  0xe9a(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e3 <gammaq+0xc3>
movsd  -0x18(%rbp),%xmm1
movsd  0xe7b(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c2 <gammaq+0xa2>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <gamma_series_rep@plt>
movsd  0xe4d(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e3 <gammaq+0xc3>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <gamma_continued_frac@plt>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammaq>:
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
xorpd  %xmm3,%xmm3
ucomisd %xmm0,%xmm3
movsd  0xeb2(%rip),%xmm2
jae    1198 <gammaq+0x78>
ucomisd %xmm1,%xmm3
ja     1198 <gammaq+0x78>
movsd  0xeaa(%rip),%xmm2
addsd  %xmm0,%xmm2
ucomisd %xmm1,%xmm2
jbe    1185 <gammaq+0x65>
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <gamma_series_rep@plt>
movsd  0xe8b(%rip),%xmm2
subsd  0x10(%rsp),%xmm2
jmp    1198 <gammaq+0x78>
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <gamma_continued_frac@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @gammaq(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
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
%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 %15
14: ; preds = %11, %2
store double -1.000000e+00, double* %3
br label %31
15: ; preds = %11
%16 = load double, double* %5
%17 = load double, double* %4
%18 = fadd double %17, 1.000000e+00
%19 = fcmp olt double %16, %18
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = load double, double* %4
%22 = load double, double* %5
%23 = call i32 @gamma_series_rep(double* %6, double %21, double %22, double* %8)
%24 = load double, double* %6
%25 = fsub double 1.000000e+00, %24
store double %25, double* %3
br label %31
26: ; preds = %15
%27 = load double, double* %4
%28 = load double, double* %5
%29 = call i32 @gamma_continued_frac(double* %7, double %27, double %28, double* %8)
%30 = load double, double* %7
store double %30, double* %3
br label %31
31: ; preds = %26, %20, %14
%32 = load double, double* %3
ret double %32
}

LLVM IR (-O2):
define double @gammaq(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
%7 = bitcast double* %4 to i8*
store double 0.000000e+00, double* %4
%8 = bitcast double* %5 to i8*
store double 0.000000e+00, double* %5
%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 %22, label %12
12: ; preds = %2
%13 = fadd double %0, 1.000000e+00
%14 = fcmp ogt double %13, %1
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = call i32 @gamma_series_rep(double* %3, double %0, double %1, double* %5)
%17 = load double, double* %3
%18 = fsub double 1.000000e+00, %17
br label %22
19: ; preds = %12
%20 = call i32 @gamma_continued_frac(double* %4, double %0, double %1, double* %5)
%21 = load double, double* %4
br label %22
22: ; preds = %2, %19, %15
%23 = phi double [ %18, %15 ], [ %21, %19 ], [ -1.000000e+00, %2 ]
ret double %23
}