#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*/ assert(int);
double cfrac(double, double);
double exp(scalar_t__);
double log(double);
scalar_t__ logGamma(double);
int series(double, double);
double GammaQ(double n, double x) {
  assert((n > 0) && (x >= 0));
  if (x <= 0)
    return 1;
  if (x < n + 1)
    return 1 - series(n, x) * exp(n * log(x) - x - logGamma(n));
  return cfrac(n, x) * exp(n * log(x) - x - logGamma(n));
}


x86 assembly (clang, -O0):
<GammaQ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x19(%rbp)
jbe    119b <GammaQ+0x3b>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11c8 <GammaQ+0x68>
movsd  0xe42(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1328 <GammaQ+0x1c8>
movsd  -0x18(%rbp),%xmm1
movsd  0xe2b(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    129c <GammaQ+0x13c>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <series@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1080 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <logGamma@plt>
movsd  -0x30(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1060 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd72(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1328 <GammaQ+0x1c8>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <cfrac@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1080 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <logGamma@plt>
movsd  -0x48(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1060 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GammaQ>:
sub    $0x18,%rsp
movsd  %xmm1,(%rsp)
xorpd  %xmm2,%xmm2
movsd  %xmm0,0x8(%rsp)
ucomisd %xmm2,%xmm0
seta   %al
ucomisd %xmm2,%xmm1
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1050 <assert@plt>
movsd  (%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jae    122b <GammaQ+0xcb>
movsd  0xe5a(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1238 <GammaQ+0xd8>
movsd  0x8(%rsp),%xmm0
call   1030 <series@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1080 <log@plt>
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm1
subsd  (%rsp),%xmm1
movsd  %xmm1,(%rsp)
call   1070 <logGamma@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1060 <exp@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0xde2(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret
movsd  0xdcd(%rip),%xmm0
add    $0x18,%rsp
ret
movsd  0x8(%rsp),%xmm0
call   1040 <cfrac@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1080 <log@plt>
movapd %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm1
subsd  (%rsp),%xmm1
movsd  %xmm1,(%rsp)
call   1070 <logGamma@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1060 <exp@plt>
mulsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @GammaQ(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %4
%7 = fcmp ogt double %6, 0.000000e+00
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load double, double* %5
%10 = fcmp oge double %9, 0.000000e+00
br label %11
11: ; preds = %8, %2
%12 = phi i1 [ false, %2 ], [ %10, %8 ]
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load double, double* %5
%16 = fcmp ole double %15, 0.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %11
store double 1.000000e+00, double* %3
br label %59
18: ; preds = %11
%19 = load double, double* %5
%20 = load double, double* %4
%21 = fadd double %20, 1.000000e+00
%22 = fcmp olt double %19, %21
br i1 %22, label %23, label %42
23: ; preds = %18
%24 = load double, double* %4
%25 = load double, double* %5
%26 = call i32 @series(double %24, double %25)
%27 = sitofp i32 %26 to double
%28 = load double, double* %4
%29 = load double, double* %5
%30 = call double @log(double %29)
%31 = load double, double* %5
%32 = fneg double %31
%33 = call double @llvm.fmuladd.f64(double %28, double %30, double %32)
%34 = load double, double* %4
%35 = call i64 @logGamma(double %34)
%36 = sitofp i64 %35 to double
%37 = fsub double %33, %36
%38 = fptosi double %37 to i64
%39 = call double @exp(i64 %38)
%40 = fneg double %27
%41 = call double @llvm.fmuladd.f64(double %40, double %39, double 1.000000e+00)
store double %41, double* %3
br label %59
42: ; preds = %18
%43 = load double, double* %4
%44 = load double, double* %5
%45 = call double @cfrac(double %43, double %44)
%46 = load double, double* %4
%47 = load double, double* %5
%48 = call double @log(double %47)
%49 = load double, double* %5
%50 = fneg double %49
%51 = call double @llvm.fmuladd.f64(double %46, double %48, double %50)
%52 = load double, double* %4
%53 = call i64 @logGamma(double %52)
%54 = sitofp i64 %53 to double
%55 = fsub double %51, %54
%56 = fptosi double %55 to i64
%57 = call double @exp(i64 %56)
%58 = fmul double %45, %57
store double %58, double* %3
br label %59
59: ; preds = %42, %23, %17
%60 = load double, double* %3
ret double %60
}

LLVM IR (-O2):
define double @GammaQ(double %0, double %1) {
%3 = fcmp ogt double %0, 0.000000e+00
%4 = fcmp oge double %1, 0.000000e+00
%5 = and i1 %3, %4
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = fcmp ugt double %1, 0.000000e+00
br i1 %8, label %9, label %36
9: ; preds = %2
%10 = fadd double %0, 1.000000e+00
%11 = fcmp ogt double %10, %1
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = tail call i32 @series(double %0, double %1)
%14 = sitofp i32 %13 to double
%15 = tail call double @log(double %1)
%16 = fneg double %1
%17 = tail call double @llvm.fmuladd.f64(double %0, double %15, double %16)
%18 = tail call i64 @logGamma(double %0)
%19 = sitofp i64 %18 to double
%20 = fsub double %17, %19
%21 = fptosi double %20 to i64
%22 = tail call double @exp(i64 %21)
%23 = fneg double %14
%24 = tail call double @llvm.fmuladd.f64(double %23, double %22, double 1.000000e+00)
br label %36
25: ; preds = %9
%26 = tail call double @cfrac(double %0, double %1)
%27 = tail call double @log(double %1)
%28 = fneg double %1
%29 = tail call double @llvm.fmuladd.f64(double %0, double %27, double %28)
%30 = tail call i64 @logGamma(double %0)
%31 = sitofp i64 %30 to double
%32 = fsub double %29, %31
%33 = fptosi double %32 to i64
%34 = tail call double @exp(i64 %33)
%35 = fmul double %26, %34
br label %36
36: ; preds = %2, %25, %12
%37 = phi double [ %24, %12 ], [ %35, %25 ], [ 1.000000e+00, %2 ]
ret double %37
}