double gammq(double a, double x) {
  void gcf(double *gammcf, double a, double x, double *gln);
  void gser(double *gamser, double a, double x, double *gln);
  void nrerror(char error_text[]);
  double gamser, gammcf, gln;
  if (x < 0.0 || a <= 0.0)
    nrerror("Invalid arguments in routine gammq");
  if (x < (a + 1.0)) {
    gser(&gamser, a, x, &gln);
    return 1.0 - gamser;
  } else {
    gcf(&gammcf, a, x, &gln);
    return gammcf;
  }
}


x86 assembly (clang, -O0):
<gammq>:
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 <gammq+0x2e>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     116a <gammq+0x3a>
lea    0xea3(%rip),%rdi
call   1030 <nrerror@plt>
movsd  -0x18(%rbp),%xmm1
movsd  0xe89(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b4 <gammq+0x84>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <gser@plt>
movsd  0xe5b(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d5 <gammq+0xa5>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <gcf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammq>:
sub    $0x28,%rsp
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jae    1144 <gammq+0x14>
ucomisd %xmm1,%xmm2
jbe    1168 <gammq+0x38>
lea    0xebd(%rip),%rdi
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1030 <nrerror@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0xe90(%rip),%xmm2
addsd  %xmm0,%xmm2
lea    0x8(%rsp),%rdi
lea    0x20(%rsp),%rsi
ucomisd %xmm1,%xmm2
jbe    119c <gammq+0x6c>
call   1040 <gser@plt>
movsd  0xe6f(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
ret
call   1050 <gcf@plt>
movsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Invalid arguments in routine gammq\00"
define double @gammq(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 %15
14: ; preds = %11, %2
br label %15
15: ; preds = %14, %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 %25
20: ; preds = %15
%21 = load double, double* %4
%22 = load double, double* %5
%23 = load double, double* %6
%24 = fsub double 1.000000e+00, %23
store double %24, double* %3
br label %29
25: ; preds = %15
%26 = load double, double* %4
%27 = load double, double* %5
%28 = load double, double* %7
store double %28, double* %3
br label %29
29: ; preds = %25, %20
%30 = load double, double* %3
ret double %30
}

LLVM IR (-O2):
@.str = [35 x i8] c"Invalid arguments in routine gammq\00"
define double @gammq(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 %13
12: ; preds = %2
tail call void @nrerror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %2, %12
%14 = fadd double %0, 1.000000e+00
%15 = fcmp ogt double %14, %1
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load double, double* %3
%18 = fsub double 1.000000e+00, %17
br label %21
19: ; preds = %13
%20 = load double, double* %4
br label %21
21: ; preds = %19, %16
%22 = phi double [ %18, %16 ], [ %20, %19 ]
ret double %22
}