#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 */
double Entire_Incomplete_Gamma_Function(double, double);
double Gamma_Function(double);
double Gamma_Function_Max_Arg();
double Ln_Gamma_Function(double);
double exp(double);
double log(double);
double pow(double, double);
void Gamma_Distribution_Tables(double a, double start, double delta, int nsteps,
                               double *density, double *distribution_function) {
  double x = start;
  int i;
  for (i = 0; i <= nsteps; i++) {
    if (x <= 0.0) {
      density[i] = 0.0;
      distribution_function[i] = 0.0;
    } else {
      if (a <= Gamma_Function_Max_Arg())
        density[i] = pow(x, a - 1.0) * exp(-x) / Gamma_Function(a);
      else
        density[i] = exp((a - 1.0) * log(x) - x - Ln_Gamma_Function(a));
      distribution_function[i] = Entire_Incomplete_Gamma_Function(x, a);
    }
    x += delta;
  }
}


x86 assembly (clang, -O0):
<Gamma_Distribution_Tables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     132e <Gamma_Distribution_Tables+0x1be>
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jb     11e2 <Gamma_Distribution_Tables+0x72>
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1311 <Gamma_Distribution_Tables+0x1a1>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    $0x0,%al
call   1050 <Gamma_Function_Max_Arg@plt>
movsd  -0x48(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jb     127c <Gamma_Distribution_Tables+0x10c>
movsd  -0x38(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xdec(%rip),%xmm2
subsd  %xmm2,%xmm1
call   1080 <pow@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1060 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <Gamma_Function@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    12f5 <Gamma_Distribution_Tables+0x185>
movsd  -0x8(%rbp),%xmm0
movsd  0xd77(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1070 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1090 <Ln_Gamma_Function@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
subsd  %xmm1,%xmm0
call   1060 <exp@plt>
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1030 <Entire_Incomplete_Gamma_Function@plt>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x18(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11a3 <Gamma_Distribution_Tables+0x33>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Gamma_Distribution_Tables>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
movsd  %xmm0,(%rsp)
test   %edi,%edi
js     12cc <Gamma_Distribution_Tables+0x15c>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
movsd  0xe67(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
add    $0x1,%r12d
xorpd  %xmm3,%xmm3
xor    %ebx,%ebx
movsd  %xmm2,0x30(%rsp)
jmp    11e3 <Gamma_Distribution_Tables+0x73>
cs nopw 0x0(%rax,%rax,1)
movq   $0x0,(%r15,%rbx,8)
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
addsd  %xmm2,%xmm1
add    $0x1,%rbx
cmp    %rbx,%r12
je     12cc <Gamma_Distribution_Tables+0x15c>
ucomisd %xmm1,%xmm3
jae    11c0 <Gamma_Distribution_Tables+0x50>
movapd %xmm1,0x10(%rsp)
xor    %eax,%eax
call   1050 <Gamma_Function_Max_Arg@plt>
ucomisd (%rsp),%xmm0
jae    1250 <Gamma_Distribution_Tables+0xe0>
movapd 0x10(%rsp),%xmm0
call   1070 <log@plt>
mulsd  0x28(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1090 <Ln_Gamma_Function@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1060 <exp@plt>
movsd  (%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
jmp    12a8 <Gamma_Distribution_Tables+0x138>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movaps 0x10(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
call   1080 <pow@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x10(%rsp),%xmm0
xorpd  0xd9c(%rip),%xmm0
call   1060 <exp@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1040 <Gamma_Function@plt>
movsd  (%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
divsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movapd %xmm2,%xmm0
call   1030 <Entire_Incomplete_Gamma_Function@plt>
movapd 0x10(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
xorpd  %xmm3,%xmm3
jmp    11cc <Gamma_Distribution_Tables+0x5c>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @Gamma_Distribution_Tables(double %0, double %1, double %2, i32 %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca double
%14 = alloca i32
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store i32 %3, i32* %10
store double* %4, double** %11
store double* %5, double** %12
%15 = load double, double* %8
store double %15, double* %13
store i32 0, i32* %14
br label %16
16: ; preds = %80, %6
%17 = load i32, i32* %14
%18 = load i32, i32* %10
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %83
20: ; preds = %16
%21 = load double, double* %13
%22 = fcmp ole double %21, 0.000000e+00
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = load double*, double** %11
%25 = load i32, i32* %14
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
store double 0.000000e+00, double* %27
%28 = load double*, double** %12
%29 = load i32, i32* %14
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
store double 0.000000e+00, double* %31
br label %76
32: ; preds = %20
%33 = load double, double* %7
%34 = call double (...) @Gamma_Function_Max_Arg()
%35 = fcmp ole double %33, %34
br i1 %35, label %36, label %52
36: ; preds = %32
%37 = load double, double* %13
%38 = load double, double* %7
%39 = fsub double %38, 1.000000e+00
%40 = call double @pow(double %37, double %39)
%41 = load double, double* %13
%42 = fneg double %41
%43 = call double @exp(double %42)
%44 = fmul double %40, %43
%45 = load double, double* %7
%46 = call double @Gamma_Function(double %45)
%47 = fdiv double %44, %46
%48 = load double*, double** %11
%49 = load i32, i32* %14
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
store double %47, double* %51
br label %68
52: ; preds = %32
%53 = load double, double* %7
%54 = fsub double %53, 1.000000e+00
%55 = load double, double* %13
%56 = call double @log(double %55)
%57 = load double, double* %13
%58 = fneg double %57
%59 = call double @llvm.fmuladd.f64(double %54, double %56, double %58)
%60 = load double, double* %7
%61 = call double @Ln_Gamma_Function(double %60)
%62 = fsub double %59, %61
%63 = call double @exp(double %62)
%64 = load double*, double** %11
%65 = load i32, i32* %14
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
store double %63, double* %67
br label %68
68: ; preds = %52, %36
%69 = load double, double* %13
%70 = load double, double* %7
%71 = call double @Entire_Incomplete_Gamma_Function(double %69, double %70)
%72 = load double*, double** %12
%73 = load i32, i32* %14
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %72, i64 %74
store double %71, double* %75
br label %76
76: ; preds = %68, %23
%77 = load double, double* %9
%78 = load double, double* %13
%79 = fadd double %78, %77
store double %79, double* %13
br label %80
80: ; preds = %76
%81 = load i32, i32* %14
%82 = add nsw i32 %81, 1
store i32 %82, i32* %14
br label %16
83: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @Gamma_Distribution_Tables(double %0, double %1, double %2, i32 %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = icmp slt i32 %3, 0
br i1 %7, label %45, label %8
8: ; preds = %6
%9 = fadd double %0, -1.000000e+00
%10 = add nuw i32 %3, 1
%11 = zext i32 %10 to i64
br label %12
12: ; preds = %8, %39
%13 = phi i64 [ 0, %8 ], [ %43, %39 ]
%14 = phi double [ %1, %8 ], [ %42, %39 ]
%15 = fcmp ugt double %14, 0.000000e+00
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = getelementptr inbounds double, double* %4, i64 %13
store double 0.000000e+00, double* %17
br label %39
18: ; preds = %12
%19 = tail call double (...) @Gamma_Function_Max_Arg()
%20 = fcmp ult double %19, %0
br i1 %20, label %28, label %21
21: ; preds = %18
%22 = tail call double @pow(double %14, double %9)
%23 = fneg double %14
%24 = tail call double @exp(double %23)
%25 = fmul double %22, %24
%26 = tail call double @Gamma_Function(double %0)
%27 = fdiv double %25, %26
br label %35
28: ; preds = %18
%29 = tail call double @log(double %14)
%30 = fneg double %14
%31 = tail call double @llvm.fmuladd.f64(double %9, double %29, double %30)
%32 = tail call double @Ln_Gamma_Function(double %0)
%33 = fsub double %31, %32
%34 = tail call double @exp(double %33)
br label %35
35: ; preds = %28, %21
%36 = phi double [ %34, %28 ], [ %27, %21 ]
%37 = getelementptr inbounds double, double* %4, i64 %13
store double %36, double* %37
%38 = tail call double @Entire_Incomplete_Gamma_Function(double %14, double %0)
br label %39
39: ; preds = %35, %16
%40 = phi double [ %38, %35 ], [ 0.000000e+00, %16 ]
%41 = getelementptr inbounds double, double* %5, i64 %13
store double %40, double* %41
%42 = fadd double %14, %2
%43 = add nuw nsw i64 %13, 1
%44 = icmp eq i64 %43, %11
br i1 %44, label %45, label %12
45: ; preds = %39, %6
ret void
}