#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);
double gammln(double xx) {
  double x, y, tmp, ser;
  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    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
movsd  0xef8(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xee3(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xece(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xea4(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe8f(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  0xe6b(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe51(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x70(%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  0xdfc(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x5,-0x64(%rbp)
jg     1252 <gammln+0x132>
movslq -0x64(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm0
movsd  0xe24(%rip),%xmm1
addsd  -0x18(%rbp),%xmm1
movsd  %xmm1,-0x18(%rbp)
divsd  %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1210 <gammln+0xf0>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xdcd(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
addsd  %xmm1,%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammln>:
sub    $0x18,%rsp
movapd %xmm0,%xmm1
movsd  %xmm0,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
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @gammln(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca [6 x double]
%8 = alloca i32
store double %0, double* %2
%9 = bitcast [6 x double]* %7 to i8*
%10 = bitcast i8* %9 to [6 x double]*
%11 = getelementptr inbounds [6 x double], [6 x double]* %10, i32 0, i32 0
store double 0x40530B869F76170A, double* %11
%12 = getelementptr inbounds [6 x double], [6 x double]* %10, i32 0, i32 1
store double 0xC055A0572B143656, double* %12
%13 = getelementptr inbounds [6 x double], [6 x double]* %10, i32 0, i32 2
store double 0x4038039BF13B4CC6, double* %13
%14 = getelementptr inbounds [6 x double], [6 x double]* %10, i32 0, i32 3
store double 0xBFF3B5348DCDCC8C, double* %14
%15 = getelementptr inbounds [6 x double], [6 x double]* %10, i32 0, i32 4
store double 0x3F53CD7319EC12D8, double* %15
%16 = getelementptr inbounds [6 x double], [6 x double]* %10, i32 0, i32 5
store double 0xBED6A1181C0E9888, double* %16
%17 = load double, double* %2
store double %17, double* %3
store double %17, double* %4
%18 = load double, double* %3
%19 = fadd double %18, 5.500000e+00
store double %19, double* %5
%20 = load double, double* %3
%21 = fadd double %20, 5.000000e-01
%22 = load double, double* %5
%23 = call double @log(double %22)
%24 = load double, double* %5
%25 = fneg double %21
%26 = call double @llvm.fmuladd.f64(double %25, double %23, double %24)
store double %26, double* %5
store double 0x3FF00000000D0EC7, double* %6
store i32 0, i32* %8
br label %27
27: ; preds = %40, %1
%28 = load i32, i32* %8
%29 = icmp sle i32 %28, 5
br i1 %29, label %30, label %43
30: ; preds = %27
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [6 x double], [6 x double]* %7, i64 0, i64 %32
%34 = load double, double* %33
%35 = load double, double* %4
%36 = fadd double %35, 1.000000e+00
store double %36, double* %4
%37 = fdiv double %34, %36
%38 = load double, double* %6
%39 = fadd double %38, %37
store double %39, double* %6
br label %40
40: ; preds = %30
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
br label %27
43: ; preds = %27
%44 = load double, double* %5
%45 = fneg double %44
%46 = load double, double* %6
%47 = fmul double 0x40040D931FF62706, %46
%48 = load double, double* %3
%49 = fdiv double %47, %48
%50 = call double @log(double %49)
%51 = fadd double %45, %50
ret double %51
}

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