#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*/ gammacf(double *, double, double);
int /*<<< orphan*/ gammaser(double *, double, double);
int /*<<< orphan*/ puts(char *);
double gammaq(double a, double x) {
  double retval = 0;
  if (x < 0.0 || a <= 0.0) {
    puts("uwerr: Invalid arguments for gammaq.");
    return 0.0;
  }
  if (x < a + 1.0) {
    gammaser(&retval, a, x);
    return 1.0 - retval;
  }
  gammacf(&retval, a, x);
  return retval;
}


x86 assembly (clang, -O0):
<gammaq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
ja     1166 <gammaq+0x36>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     117f <gammaq+0x4f>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e2 <gammaq+0xb2>
movsd  -0x18(%rbp),%xmm1
movsd  0xe74(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c5 <gammaq+0x95>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x20(%rbp),%rdi
call   1050 <gammaser@plt>
movsd  0xe4a(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e2 <gammaq+0xb2>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x20(%rbp),%rdi
call   1040 <gammacf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammaq>:
push   %rax
movq   $0x0,(%rsp)
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jae    1172 <gammaq+0x42>
ucomisd %xmm1,%xmm2
ja     1172 <gammaq+0x42>
movsd  0xeaf(%rip),%xmm2
addsd  %xmm0,%xmm2
mov    %rsp,%rdi
ucomisd %xmm1,%xmm2
jbe    1184 <gammaq+0x54>
call   1050 <gammaser@plt>
movsd  0xe95(%rip),%xmm0
subsd  (%rsp),%xmm0
pop    %rax
ret
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
xorpd  %xmm0,%xmm0
pop    %rax
ret
call   1040 <gammacf@plt>
movsd  (%rsp),%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
@.str = [37 x i8] c"uwerr: Invalid arguments for gammaq.\00"
define double @gammaq(double %0, double %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
%5 = fcmp olt double %1, 0.000000e+00
%6 = fcmp ole double %0, 0.000000e+00
%7 = or i1 %6, %5
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %20
10: ; preds = %2
%11 = fadd double %0, 1.000000e+00
%12 = fcmp ogt double %11, %1
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = call i32 @gammaser(double* %3, double %0, double %1)
%15 = load double, double* %3
%16 = fsub double 1.000000e+00, %15
br label %20
17: ; preds = %10
%18 = call i32 @gammacf(double* %3, double %0, double %1)
%19 = load double, double* %3
br label %20
20: ; preds = %17, %13, %8
%21 = phi double [ 0.000000e+00, %8 ], [ %16, %13 ], [ %19, %17 ]
ret double %21
}