#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 exp(double);
double pow(double, double);
double sqrt(int);
double tgamma(double z) {
  static unsigned int c = 9;
  static double lanczos_coefficients[] = {
      1.000000000000000174663,      5716.400188274341379136,
      -14815.30426768413909044,     14291.49277657478554025,
      -6348.160217641458813289,     1301.608286058321874105,
      -108.1767053514369634679,     2.605696505611755827729,
      -0.7423452510201416151527e-2, 0.5384136432509564062961e-7,
      -0.4023533141268236372067e-8};
  double return_val = 0.0;
  z -= 1.0;
  double temp = z + c + 0.5;
  double A = lanczos_coefficients[0];
  int i = 0;
  for (i = 1; i < c + 2; ++i) {
    A += lanczos_coefficients[i] / (z + i);
  }
  return_val =
      sqrt(2 * 3.14159265358979323846) * pow(temp, z + 0.5) * exp(-temp) * A;
  return return_val;
}


x86 assembly (clang, -O0):
<tgamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xeb6(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    0x2eda(%rip),%eax
cvtsi2sd %rax,%xmm1
addsd  %xmm1,%xmm0
movsd  0xe89(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0x2ec8(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e9c(%rip),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jae    11e9 <tgamma+0xb9>
movslq -0x24(%rbp),%rcx
lea    0x2e96(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x8(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119b <tgamma+0x6b>
mov    $0x6,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xdfb(%rip),%xmm1
addsd  -0x8(%rbp),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tgamma>:
sub    $0x48,%rsp
addsd  0xec4(%rip),%xmm0
movapd %xmm0,(%rsp)
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
movapd 0xecf(%rip),%xmm0
addpd  %xmm1,%xmm0
movapd %xmm1,%xmm3
movapd 0xecf(%rip),%xmm1
divpd  %xmm0,%xmm1
movsd  0xe9b(%rip),%xmm0
addsd  %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movapd 0xebf(%rip),%xmm0
addpd  %xmm3,%xmm0
movapd 0xec3(%rip),%xmm2
divpd  %xmm0,%xmm2
addsd  %xmm2,%xmm1
unpckhpd %xmm2,%xmm2
addsd  %xmm1,%xmm2
movapd 0xebb(%rip),%xmm0
addpd  %xmm3,%xmm0
movapd 0xebf(%rip),%xmm1
divpd  %xmm0,%xmm1
addsd  %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movapd 0xeb7(%rip),%xmm0
addpd  %xmm3,%xmm0
movapd 0xebb(%rip),%xmm2
divpd  %xmm0,%xmm2
addsd  %xmm2,%xmm1
unpckhpd %xmm2,%xmm2
addpd  0xeb7(%rip),%xmm3
addsd  %xmm1,%xmm2
movapd 0xebb(%rip),%xmm0
divpd  %xmm3,%xmm0
addsd  %xmm0,%xmm2
unpckhpd %xmm0,%xmm0
addsd  %xmm2,%xmm0
movapd %xmm0,0x30(%rsp)
addsd  0xdfd(%rip),%xmm3
movapd %xmm3,0x20(%rsp)
mov    $0x6,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,0x18(%rsp)
movapd (%rsp),%xmm1
addsd  0xdda(%rip),%xmm1
movapd 0x20(%rsp),%xmm0
call   1040 <pow@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movapd 0x20(%rsp),%xmm0
xorpd  0xe66(%rip),%xmm0
call   1030 <exp@plt>
mulsd  (%rsp),%xmm0
mulsd  0x30(%rsp),%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
@tgamma.c = internal global i32 9
@tgamma.lanczos_coefficients = internal global [11 x double] [double 0x3FF0000000000001, double 0x40B6546672BD1E8A, double 0xC0CCEFA6F23E544E, double 0x40CBE9BF134D8478, double 0xC0B8CC290405FA4F, double 0x4094566EE28A5C6C, double 0xC05B0B4F23F65CCC, double 0x4004D87768D73B56, double 0xBF7E680DDC1359AC, double 0x3E6CE7E6989F8CA3, double 0xBE3147EBE5B11056]
define double @tgamma(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store double %0, double* %2
store double 0.000000e+00, double* %3
%7 = load double, double* %2
%8 = fsub double %7, 1.000000e+00
store double %8, double* %2
%9 = load double, double* %2
%10 = load i32, i32* @tgamma.c
%11 = uitofp i32 %10 to double
%12 = fadd double %9, %11
%13 = fadd double %12, 5.000000e-01
store double %13, double* %4
%14 = load double, double* getelementptr inbounds ([11 x double], [11 x double]* @tgamma.lanczos_coefficients, i64 0, i64 0)
store double %14, double* %5
store i32 0, i32* %6
store i32 1, i32* %6
br label %15
15: ; preds = %32, %1
%16 = load i32, i32* %6
%17 = load i32, i32* @tgamma.c
%18 = add i32 %17, 2
%19 = icmp ult i32 %16, %18
br i1 %19, label %20, label %35
20: ; preds = %15
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [11 x double], [11 x double]* @tgamma.lanczos_coefficients, i64 0, i64 %22
%24 = load double, double* %23
%25 = load double, double* %2
%26 = load i32, i32* %6
%27 = sitofp i32 %26 to double
%28 = fadd double %25, %27
%29 = fdiv double %24, %28
%30 = load double, double* %5
%31 = fadd double %30, %29
store double %31, double* %5
br label %32
32: ; preds = %20
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %15
35: ; preds = %15
%36 = call double @sqrt(i32 6)
%37 = load double, double* %4
%38 = load double, double* %2
%39 = fadd double %38, 5.000000e-01
%40 = call double @pow(double %37, double %39)
%41 = fmul double %36, %40
%42 = load double, double* %4
%43 = fneg double %42
%44 = call double @exp(double %43)
%45 = fmul double %41, %44
%46 = load double, double* %5
%47 = fmul double %45, %46
store double %47, double* %3
%48 = load double, double* %3
ret double %48
}

LLVM IR (-O2):
define double @tgamma(double %0) {
%2 = fadd double %0, -1.000000e+00
%3 = insertelement <2 x double> poison, double %2, i64 0
%4 = shufflevector <2 x double> %3, <2 x double> poison, <2 x i32> zeroinitializer
%5 = fadd <2 x double> %4, <double 1.000000e+00, double 2.000000e+00>
%6 = fdiv <2 x double> <double 0x40B6546672BD1E8A, double 0xC0CCEFA6F23E544E>, %5
%7 = extractelement <2 x double> %6, i64 0
%8 = fadd double %7, 0x3FF0000000000001
%9 = extractelement <2 x double> %6, i64 1
%10 = fadd double %8, %9
%11 = fadd <2 x double> %4, <double 3.000000e+00, double 4.000000e+00>
%12 = fdiv <2 x double> <double 0x40CBE9BF134D8478, double 0xC0B8CC290405FA4F>, %11
%13 = extractelement <2 x double> %12, i64 0
%14 = fadd double %10, %13
%15 = extractelement <2 x double> %12, i64 1
%16 = fadd double %14, %15
%17 = fadd <2 x double> %4, <double 5.000000e+00, double 6.000000e+00>
%18 = fdiv <2 x double> <double 0x4094566EE28A5C6C, double 0xC05B0B4F23F65CCC>, %17
%19 = extractelement <2 x double> %18, i64 0
%20 = fadd double %16, %19
%21 = extractelement <2 x double> %18, i64 1
%22 = fadd double %20, %21
%23 = fadd <2 x double> %4, <double 7.000000e+00, double 8.000000e+00>
%24 = fdiv <2 x double> <double 0x4004D87768D73B56, double 0xBF7E680DDC1359AC>, %23
%25 = extractelement <2 x double> %24, i64 0
%26 = fadd double %22, %25
%27 = extractelement <2 x double> %24, i64 1
%28 = fadd double %26, %27
%29 = fadd <2 x double> %4, <double 9.000000e+00, double 1.000000e+01>
%30 = fdiv <2 x double> <double 0x3E6CE7E6989F8CA3, double 0xBE3147EBE5B11056>, %29
%31 = extractelement <2 x double> %30, i64 0
%32 = fadd double %28, %31
%33 = extractelement <2 x double> %30, i64 1
%34 = fadd double %32, %33
%35 = extractelement <2 x double> %29, i64 0
%36 = fadd double %35, 5.000000e-01
%37 = tail call double @sqrt(i32 6)
%38 = fadd double %2, 5.000000e-01
%39 = tail call double @pow(double %36, double %38)
%40 = fmul double %37, %39
%41 = fneg double %36
%42 = tail call double @exp(double %41)
%43 = fmul double %40, %42
%44 = fmul double %34, %43
ret double %44
}