float gammln(xx)
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
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xece(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xecd(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeb3(%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  0xe5e(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jg     11f7 <gammln+0xe7>
movsd  0xe40(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movslq -0x24(%rbp),%rcx
lea    0x2e5b(%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    11ae <gammln+0x9e>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xdf8(%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
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm1
addsd  0xedc(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xed6(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <log@plt>
movsd  0xec7(%rip),%xmm1
movsd  0x10(%rsp),%xmm6
movapd %xmm6,%xmm2
addsd  %xmm1,%xmm2
movapd %xmm2,%xmm3
addsd  %xmm1,%xmm3
unpcklpd %xmm3,%xmm2
movapd 0xec5(%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 0xea9(%rip),%xmm5
divpd  %xmm3,%xmm5
addsd  %xmm5,%xmm4
unpckhpd %xmm5,%xmm5
addsd  %xmm4,%xmm5
addsd  %xmm1,%xmm2
addsd  %xmm2,%xmm1
unpcklpd %xmm1,%xmm2
movapd 0xe95(%rip),%xmm1
divpd  %xmm2,%xmm1
addsd  %xmm1,%xmm5
unpckhpd %xmm1,%xmm1
addsd  %xmm5,%xmm1
movapd %xmm6,%xmm2
addsd  0xe41(%rip),%xmm2
mulsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  0xe2d(%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(double %0) {
%2 = alloca float
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = fptrunc double %0 to float
store float %7, float* %2
%8 = load float, float* %2
%9 = fpext float %8 to double
%10 = fsub double %9, 1.000000e+00
store double %10, double* %3
%11 = load double, double* %3
%12 = fadd double %11, 5.500000e+00
store double %12, double* %4
%13 = load double, double* %3
%14 = fadd double %13, 5.000000e-01
%15 = load double, double* %4
%16 = call double @log(double %15)
%17 = load double, double* %4
%18 = fneg double %14
%19 = call double @llvm.fmuladd.f64(double %18, double %16, double %17)
store double %19, double* %4
store double 1.000000e+00, double* %5
store i32 0, i32* %6
br label %20
20: ; preds = %34, %1
%21 = load i32, i32* %6
%22 = icmp sle i32 %21, 5
br i1 %22, label %23, label %37
23: ; preds = %20
%24 = load double, double* %3
%25 = fadd double %24, 1.000000e+00
store double %25, double* %3
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [6 x double], [6 x double]* @gammln.cof, i64 0, i64 %27
%29 = load double, double* %28
%30 = load double, double* %3
%31 = fdiv double %29, %30
%32 = load double, double* %5
%33 = fadd double %32, %31
store double %33, double* %5
br label %34
34: ; preds = %23
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %20
37: ; preds = %20
%38 = load double, double* %4
%39 = fneg double %38
%40 = load double, double* %5
%41 = fmul double 0x40040D931FF6CE25, %40
%42 = call double @log(double %41)
%43 = fadd double %39, %42
%44 = fptrunc double %43 to float
ret float %44
}

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