#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, y, tmp, ser;
  static double cof[6] = {76.18009172947146,     -86.50532032941677,
                          24.01409824083091,     -1.231739572450155,
                          0.1208650973866179e-2, -0.5395239384953e-5};
  int j;
  y = x = xx;
  tmp = x + 5.5;
  tmp -= (x + 0.5) * log(tmp);
  ser = 1.000000000190015;
  for (j = 0; j <= 5; j++)
    ser += cof[j] / ++y;
  return -tmp + log(2.5066282746310005 * ser / x);
}


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  %xmm0,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  0xed8(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xebe(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe69(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x5,-0x2c(%rbp)
jg     11eb <gammln+0xdb>
movslq -0x2c(%rbp),%rcx
lea    0x2e78(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe5b(%rip),%xmm1
addsd  -0x18(%rbp),%xmm1
movsd  %xmm1,-0x18(%rbp)
divsd  %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a3 <gammln+0x93>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe04(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%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
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 0xed1(%rip),%xmm4
divpd  %xmm2,%xmm4
movsd  0xea5(%rip),%xmm2
addsd  %xmm4,%xmm2
unpckhpd %xmm4,%xmm4
addsd  %xmm2,%xmm4
addsd  %xmm1,%xmm3
movapd %xmm3,%xmm2
addsd  %xmm1,%xmm2
unpcklpd %xmm2,%xmm3
movapd 0xeb1(%rip),%xmm5
divpd  %xmm3,%xmm5
addsd  %xmm5,%xmm4
unpckhpd %xmm5,%xmm5
addsd  %xmm4,%xmm5
addsd  %xmm1,%xmm2
addsd  %xmm2,%xmm1
unpcklpd %xmm1,%xmm2
movapd 0xe9d(%rip),%xmm1
divpd  %xmm2,%xmm1
addsd  %xmm1,%xmm5
unpckhpd %xmm1,%xmm1
addsd  %xmm5,%xmm1
movsd  0xe4d(%rip),%xmm2
addsd  %xmm6,%xmm2
mulsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  0xe35(%rip),%xmm1
divsd  %xmm6,%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 0x40530B869F76170A, double 0xC055A0572B143656, double 0x4038039BF13B4CC6, double 0xBFF3B5348DCDCC8C, double 0x3F53CD7319EC12D8, double 0xBED6A1181C0E9888]
define float @gammln(float %0) {
%2 = alloca float
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store float %0, float* %2
%8 = load float, float* %2
%9 = fpext float %8 to double
store double %9, double* %3
store double %9, double* %4
%10 = load double, double* %3
%11 = fadd double %10, 5.500000e+00
store double %11, double* %5
%12 = load double, double* %3
%13 = fadd double %12, 5.000000e-01
%14 = load double, double* %5
%15 = call double @log(double %14)
%16 = load double, double* %5
%17 = fneg double %13
%18 = call double @llvm.fmuladd.f64(double %17, double %15, double %16)
store double %18, double* %5
store double 0x3FF00000000D0EC7, double* %6
store i32 0, i32* %7
br label %19
19: ; preds = %32, %1
%20 = load i32, i32* %7
%21 = icmp sle i32 %20, 5
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [6 x double], [6 x double]* @gammln.cof, i64 0, i64 %24
%26 = load double, double* %25
%27 = load double, double* %4
%28 = fadd double %27, 1.000000e+00
store double %28, double* %4
%29 = fdiv double %26, %28
%30 = load double, double* %6
%31 = fadd double %30, %29
store double %31, double* %6
br label %32
32: ; preds = %22
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %19
35: ; preds = %19
%36 = load double, double* %5
%37 = fneg double %36
%38 = load double, double* %6
%39 = fmul double 0x40040D931FF62706, %38
%40 = load double, double* %3
%41 = fdiv double %39, %40
%42 = call double @log(double %41)
%43 = fadd double %37, %42
%44 = fptrunc double %43 to float
ret float %44
}

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