#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*/ exit(int);
double pgamma(double, double);
int /*<<< orphan*/ printf(char *);
double gammacdf(double x, double k, double th) {
  double oup, t;
  if (k <= 0. || th <= 0.) {
    printf("Gamma Distribution parameters must be positive and real.");
    exit(1);
  }
  if (x <= 0.) {
    x = 0.;
  }
  t = x / th;
  oup = pgamma(t, k);
  return oup;
}


x86 assembly (clang, -O0):
<gammacdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jae    1163 <gammacdf+0x33>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     1179 <gammacdf+0x49>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     118f <gammacdf+0x5f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1030 <pgamma@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammacdf>:
xorpd  %xmm3,%xmm3
ucomisd %xmm1,%xmm3
jae    115e <gammacdf+0x2e>
ucomisd %xmm2,%xmm3
jae    115e <gammacdf+0x2e>
xorpd  %xmm4,%xmm4
movapd %xmm0,%xmm3
cmplesd %xmm4,%xmm3
andnpd %xmm0,%xmm3
divsd  %xmm2,%xmm3
movapd %xmm3,%xmm0
jmp    1030 <pgamma@plt>
push   %rax
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [57 x i8] c"Gamma Distribution parameters must be positive and real.\00"
define double @gammacdf(double %0, double %1, double %2) {
%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 %2, double* %6
%9 = load double, double* %5
%10 = fcmp ole double %9, 0.000000e+00
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = load double, double* %6
%13 = fcmp ole double %12, 0.000000e+00
br i1 %13, label %14, label %17
14: ; preds = %11, %3
%15 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %11
%18 = load double, double* %4
%19 = fcmp ole double %18, 0.000000e+00
br i1 %19, label %20, label %21
20: ; preds = %17
store double 0.000000e+00, double* %4
br label %21
21: ; preds = %20, %17
%22 = load double, double* %4
%23 = load double, double* %6
%24 = fdiv double %22, %23
store double %24, double* %8
%25 = load double, double* %8
%26 = load double, double* %5
%27 = call double @pgamma(double %25, double %26)
store double %27, double* %7
%28 = load double, double* %7
ret double %28
}

LLVM IR (-O2):
@.str = [57 x i8] c"Gamma Distribution parameters must be positive and real.\00"
define double @gammacdf(double %0, double %1, double %2) {
%4 = fcmp ole double %1, 0.000000e+00
%5 = fcmp ole double %2, 0.000000e+00
%6 = or i1 %4, %5
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %3
%11 = fcmp ole double %0, 0.000000e+00
%12 = select i1 %11, double 0.000000e+00, double %0
%13 = fdiv double %12, %2
%14 = tail call double @pgamma(double %13, double %1)
ret double %14
}