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


x86 assembly (clang, -O0):
<tgammaf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xeb3(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
mov    0x2edb(%rip),%eax
cvtsi2ss %rax,%xmm1
addss  %xmm1,%xmm0
movss  0xe8a(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0x2ec9(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e9d(%rip),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jae    11e8 <tgammaf+0xb8>
movslq -0x14(%rbp),%rcx
lea    0x2e97(%rip),%rax
movss  (%rax,%rcx,4),%xmm0
movss  -0x4(%rbp),%xmm1
cvtsi2ssl -0x14(%rbp),%xmm2
addss  %xmm2,%xmm1
divss  %xmm1,%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119a <tgammaf+0x6a>
mov    $0x6,%edi
call   1050 <sqrt@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xdfc(%rip),%xmm1
addss  -0x4(%rbp),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
mulss  %xmm1,%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tgammaf>:
sub    $0x48,%rsp
addss  0xec4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,%xmm1
shufps $0x0,%xmm0,%xmm1
movaps 0xec1(%rip),%xmm0
addps  %xmm1,%xmm0
movaps %xmm1,%xmm3
movaps 0xec4(%rip),%xmm1
divps  %xmm0,%xmm1
movss  0xe9d(%rip),%xmm0
addss  %xmm1,%xmm0
shufps $0x55,%xmm1,%xmm1
addss  %xmm0,%xmm1
movaps 0xeb6(%rip),%xmm0
addps  %xmm3,%xmm0
movaps 0xebc(%rip),%xmm2
divps  %xmm0,%xmm2
addss  %xmm2,%xmm1
shufps $0x55,%xmm2,%xmm2
addss  %xmm1,%xmm2
movaps 0xeb6(%rip),%xmm0
addps  %xmm3,%xmm0
movaps 0xebc(%rip),%xmm1
divps  %xmm0,%xmm1
addss  %xmm1,%xmm2
shufps $0x55,%xmm1,%xmm1
addss  %xmm2,%xmm1
movaps 0xeb6(%rip),%xmm0
addps  %xmm3,%xmm0
movaps 0xebc(%rip),%xmm2
divps  %xmm0,%xmm2
addss  %xmm2,%xmm1
shufps $0x55,%xmm2,%xmm2
addps  0xeba(%rip),%xmm3
addss  %xmm1,%xmm2
movaps 0xebf(%rip),%xmm0
divps  %xmm3,%xmm0
addss  %xmm0,%xmm2
shufps $0x55,%xmm0,%xmm0
addss  %xmm2,%xmm0
movaps %xmm0,0x30(%rsp)
addss  0xe0b(%rip),%xmm3
movaps %xmm3,0x20(%rsp)
mov    $0x6,%edi
call   1050 <sqrt@plt>
movss  %xmm0,0xc(%rsp)
movaps 0x10(%rsp),%xmm1
addss  0xde9(%rip),%xmm1
movaps 0x20(%rsp),%xmm0
call   1040 <pow@plt>
mulss  0xc(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
movaps 0x20(%rsp),%xmm0
xorps  0xe6f(%rip),%xmm0
call   1030 <exp@plt>
mulss  0x10(%rsp),%xmm0
mulss  0x30(%rsp),%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
@tgammaf.c = internal global i32 9
@tgammaf.lanczos_coefficients = internal global [11 x float] [float 1.000000e+00, float 0x40B6546680000000, float 0xC0CCEFA700000000, float 0x40CBE9BF20000000, float 0xC0B8CC2900000000, float 0x4094566EE0000000, float 0xC05B0B4F20000000, float 0x4004D87760000000, float 0xBF7E680DE0000000, float 0x3E6CE7E6A0000000, float 0xBE3147EBE0000000]
define float @tgammaf(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
store float %0, float* %2
store float 0.000000e+00, float* %3
%7 = load float, float* %2
%8 = fsub float %7, 1.000000e+00
store float %8, float* %2
%9 = load float, float* %2
%10 = load i32, i32* @tgammaf.c
%11 = uitofp i32 %10 to float
%12 = fadd float %9, %11
%13 = fadd float %12, 5.000000e-01
store float %13, float* %4
%14 = load float, float* getelementptr inbounds ([11 x float], [11 x float]* @tgammaf.lanczos_coefficients, i64 0, i64 0)
store float %14, float* %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* @tgammaf.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 float], [11 x float]* @tgammaf.lanczos_coefficients, i64 0, i64 %22
%24 = load float, float* %23
%25 = load float, float* %2
%26 = load i32, i32* %6
%27 = sitofp i32 %26 to float
%28 = fadd float %25, %27
%29 = fdiv float %24, %28
%30 = load float, float* %5
%31 = fadd float %30, %29
store float %31, float* %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 float @sqrt(i32 6)
%37 = load float, float* %4
%38 = load float, float* %2
%39 = fadd float %38, 5.000000e-01
%40 = call float @pow(float %37, float %39)
%41 = fmul float %36, %40
%42 = load float, float* %4
%43 = fneg float %42
%44 = call float @exp(float %43)
%45 = fmul float %41, %44
%46 = load float, float* %5
%47 = fmul float %45, %46
store float %47, float* %3
%48 = load float, float* %3
ret float %48
}

LLVM IR (-O2):
define float @tgammaf(float %0) {
%2 = fadd float %0, -1.000000e+00
%3 = insertelement <2 x float> poison, float %2, i64 0
%4 = shufflevector <2 x float> %3, <2 x float> poison, <2 x i32> zeroinitializer
%5 = fadd <2 x float> %4, <float 1.000000e+00, float 2.000000e+00>
%6 = fdiv <2 x float> <float 0x40B6546680000000, float 0xC0CCEFA700000000>, %5
%7 = extractelement <2 x float> %6, i64 0
%8 = fadd float %7, 1.000000e+00
%9 = extractelement <2 x float> %6, i64 1
%10 = fadd float %8, %9
%11 = fadd <2 x float> %4, <float 3.000000e+00, float 4.000000e+00>
%12 = fdiv <2 x float> <float 0x40CBE9BF20000000, float 0xC0B8CC2900000000>, %11
%13 = extractelement <2 x float> %12, i64 0
%14 = fadd float %10, %13
%15 = extractelement <2 x float> %12, i64 1
%16 = fadd float %14, %15
%17 = fadd <2 x float> %4, <float 5.000000e+00, float 6.000000e+00>
%18 = fdiv <2 x float> <float 0x4094566EE0000000, float 0xC05B0B4F20000000>, %17
%19 = extractelement <2 x float> %18, i64 0
%20 = fadd float %16, %19
%21 = extractelement <2 x float> %18, i64 1
%22 = fadd float %20, %21
%23 = fadd <2 x float> %4, <float 7.000000e+00, float 8.000000e+00>
%24 = fdiv <2 x float> <float 0x4004D87760000000, float 0xBF7E680DE0000000>, %23
%25 = extractelement <2 x float> %24, i64 0
%26 = fadd float %22, %25
%27 = extractelement <2 x float> %24, i64 1
%28 = fadd float %26, %27
%29 = fadd <2 x float> %4, <float 9.000000e+00, float 1.000000e+01>
%30 = fdiv <2 x float> <float 0x3E6CE7E6A0000000, float 0xBE3147EBE0000000>, %29
%31 = extractelement <2 x float> %30, i64 0
%32 = fadd float %28, %31
%33 = extractelement <2 x float> %30, i64 1
%34 = fadd float %32, %33
%35 = extractelement <2 x float> %29, i64 0
%36 = fadd float %35, 5.000000e-01
%37 = tail call float @sqrt(i32 6)
%38 = fadd float %2, 5.000000e-01
%39 = tail call float @pow(float %36, float %38)
%40 = fmul float %37, %39
%41 = fneg float %36
%42 = tail call float @exp(float %41)
%43 = fmul float %40, %42
%44 = fmul float %34, %43
ret float %44
}