#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 log(double);
float gammln(float xx) {
  double x, tmp, ser;
  static double cof[6] = {76.18009173,  -86.50532033,   24.01409822,
                          -1.231739516, 0.120858003e-2, -0.536382e-5};
  int j;
  x = xx - 1.0;
  tmp = x + 5.5;
  tmp -= (x + 0.5) * log(tmp);
  ser = 1.0;
  for (j = 0; j <= 5; j++) {
    x += 1.0;
    ser += cof[j] / x;
  }
  return -tmp + log(2.50662827465 * ser);
}


x86 assembly (clang, -O0):
<gammln>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xed2(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xed1(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeb7(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe62(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jg     11f3 <gammln+0xe3>
movsd  0xe44(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movslq -0x24(%rbp),%rcx
lea    0x2e5f(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11aa <gammln+0x9a>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xdfc(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammln>:
sub    $0x18,%rsp
cvtss2sd %xmm0,%xmm1
addsd  0xee0(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xeda(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <log@plt>
movsd  0xecb(%rip),%xmm1
movsd  0x10(%rsp),%xmm6
movapd %xmm6,%xmm2
addsd  %xmm1,%xmm2
movapd %xmm2,%xmm3
addsd  %xmm1,%xmm3
unpcklpd %xmm3,%xmm2
movapd 0xec9(%rip),%xmm4
divpd  %xmm2,%xmm4
movapd %xmm4,%xmm2
addsd  %xmm1,%xmm2
unpckhpd %xmm4,%xmm4
addsd  %xmm2,%xmm4
addsd  %xmm1,%xmm3
movapd %xmm3,%xmm2
addsd  %xmm1,%xmm2
unpcklpd %xmm2,%xmm3
movapd 0xead(%rip),%xmm5
divpd  %xmm3,%xmm5
addsd  %xmm5,%xmm4
unpckhpd %xmm5,%xmm5
addsd  %xmm4,%xmm5
addsd  %xmm1,%xmm2
addsd  %xmm2,%xmm1
unpcklpd %xmm1,%xmm2
movapd 0xe99(%rip),%xmm1
divpd  %xmm2,%xmm1
addsd  %xmm1,%xmm5
unpckhpd %xmm1,%xmm1
addsd  %xmm5,%xmm1
movapd %xmm6,%xmm2
addsd  0xe45(%rip),%xmm2
mulsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  0xe31(%rip),%xmm1
movapd %xmm1,%xmm0
call   1030 <log@plt>
subsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@gammln.cof = internal global [6 x double] [double 0x40530B869F76A853, double 0xC055A0572B14D6A7, double 0x4038039BF0E1D4F2, double 0xBFF3B5347EA692EB, double 0x3F53CD26ED054DB1, double 0xBED67F5B9D652131]
define float @gammln(float %0) {
%2 = alloca float
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store float %0, float* %2
%7 = load float, float* %2
%8 = fpext float %7 to double
%9 = fsub double %8, 1.000000e+00
store double %9, double* %3
%10 = load double, double* %3
%11 = fadd double %10, 5.500000e+00
store double %11, double* %4
%12 = load double, double* %3
%13 = fadd double %12, 5.000000e-01
%14 = load double, double* %4
%15 = call double @log(double %14)
%16 = load double, double* %4
%17 = fneg double %13
%18 = call double @llvm.fmuladd.f64(double %17, double %15, double %16)
store double %18, double* %4
store double 1.000000e+00, double* %5
store i32 0, i32* %6
br label %19
19: ; preds = %33, %1
%20 = load i32, i32* %6
%21 = icmp sle i32 %20, 5
br i1 %21, label %22, label %36
22: ; preds = %19
%23 = load double, double* %3
%24 = fadd double %23, 1.000000e+00
store double %24, double* %3
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [6 x double], [6 x double]* @gammln.cof, i64 0, i64 %26
%28 = load double, double* %27
%29 = load double, double* %3
%30 = fdiv double %28, %29
%31 = load double, double* %5
%32 = fadd double %31, %30
store double %32, double* %5
br label %33
33: ; preds = %22
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %19
36: ; preds = %19
%37 = load double, double* %4
%38 = fneg double %37
%39 = load double, double* %5
%40 = fmul double 0x40040D931FF6CE25, %39
%41 = call double @log(double %40)
%42 = fadd double %38, %41
%43 = fptrunc double %42 to float
ret float %43
}

LLVM IR (-O2):
define float @gammln(float %0) {
%2 = fpext float %0 to double
%3 = fadd double %2, -1.000000e+00
%4 = fadd double %3, 5.500000e+00
%5 = tail call double @log(double %4)
%6 = fadd double %3, 1.000000e+00
%7 = fadd double %6, 1.000000e+00
%8 = insertelement <2 x double> poison, double %6, i64 0
%9 = insertelement <2 x double> %8, double %7, i64 1
%10 = fdiv <2 x double> <double 0x40530B869F76A853, double 0xC055A0572B14D6A7>, %9
%11 = extractelement <2 x double> %10, i64 0
%12 = fadd double %11, 1.000000e+00
%13 = extractelement <2 x double> %10, i64 1
%14 = fadd double %12, %13
%15 = fadd double %7, 1.000000e+00
%16 = fadd double %15, 1.000000e+00
%17 = insertelement <2 x double> poison, double %15, i64 0
%18 = insertelement <2 x double> %17, double %16, i64 1
%19 = fdiv <2 x double> <double 0x4038039BF0E1D4F2, double 0xBFF3B5347EA692EB>, %18
%20 = extractelement <2 x double> %19, i64 0
%21 = fadd double %14, %20
%22 = extractelement <2 x double> %19, i64 1
%23 = fadd double %21, %22
%24 = fadd double %16, 1.000000e+00
%25 = fadd double %24, 1.000000e+00
%26 = insertelement <2 x double> poison, double %24, i64 0
%27 = insertelement <2 x double> %26, double %25, i64 1
%28 = fdiv <2 x double> <double 0x3F53CD26ED054DB1, double 0xBED67F5B9D652131>, %27
%29 = extractelement <2 x double> %28, i64 0
%30 = fadd double %23, %29
%31 = extractelement <2 x double> %28, i64 1
%32 = fadd double %30, %31
%33 = fadd double %3, 5.000000e-01
%34 = fneg double %33
%35 = tail call double @llvm.fmuladd.f64(double %34, double %5, double %4)
%36 = fmul double %32, 0x40040D931FF6CE25
%37 = tail call double @log(double %36)
%38 = fsub double %37, %35
%39 = fptrunc double %38 to float
ret float %39
}