double gammp(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 gammp");
  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     116a <gammp+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    11ac <gammp+0x7c>
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    11d5 <gammp+0xa5>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <gcf@plt>
movsd  0xe35(%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    $0x28,%rsp
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jae    1144 <gammp+0x14>
ucomisd %xmm1,%xmm2
jbe    1168 <gammp+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    1194 <gammp+0x64>
call   1040 <gser@plt>
movsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
ret
call   1050 <gcf@plt>
movsd  0xe5f(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
add    $0x28,%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 %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 %24
20: ; preds = %15
%21 = load double, double* %4
%22 = load double, double* %5
%23 = load double, double* %6
store double %23, double* %3
br label %29
24: ; preds = %15
%25 = load double, double* %4
%26 = load double, double* %5
%27 = load double, double* %7
%28 = fsub double 1.000000e+00, %27
store double %28, double* %3
br label %29
29: ; preds = %24, %20
%30 = load double, double* %3
ret double %30
}

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 %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 %18
16: ; preds = %13
%17 = load double, double* %3
br label %21
18: ; preds = %13
%19 = load double, double* %4
%20 = fsub double 1.000000e+00, %19
br label %21
21: ; preds = %18, %16
%22 = phi double [ %17, %16 ], [ %20, %18 ]
ret double %22
}