#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(const double xx) {
  int j;
  double x, tmp, y, ser;
  static const double cof[14] = {
      57.1562356658629235,      -59.5979603554754912,
      14.1360979747417471,      -0.491913816097620199,
      0.339946499848118887e-4,  0.465236289270485756e-4,
      -0.983744753048795646e-4, 0.0158088703224912494e-3,
      -0.210264441724104883e-3, 0.217439618115212643e-3,
      -0.164318106536763890e-3, 0.888182239838527433e-4,
      -0.261908384015814087e-4, 0.368991826595316234e-5};
  if (xx <= 0.0) {
  }
  y = xx;
  x = xx;
  tmp = x + 5.24218750000000000;
  tmp = (x + 0.5) * log(tmp) - tmp;
  ser = 0.999999999999997092;
  for (j = 0; j < 14; 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
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     1130 <gammln+0x20>
jmp    1130 <gammln+0x20>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xec4(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeaa(%rip),%xmm0
addsd  -0x18(%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   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe55(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xe,-0xc(%rbp)
jge    11ff <gammln+0xef>
movslq -0xc(%rbp),%rcx
lea    0xe64(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe47(%rip),%xmm1
addsd  -0x28(%rbp),%xmm1
movsd  %xmm1,-0x28(%rbp)
divsd  %xmm1,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b7 <gammln+0xa7>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe07(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammln>:
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
movsd  0xede(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1030 <log@plt>
movsd  0xecb(%rip),%xmm1
movsd  0x10(%rsp),%xmm6
movapd %xmm6,%xmm2
addsd  %xmm1,%xmm2
movsd  0xebd(%rip),%xmm3
divsd  %xmm2,%xmm3
addsd  0xeb9(%rip),%xmm3
movapd %xmm0,%xmm5
addsd  %xmm1,%xmm2
movsd  0xeb1(%rip),%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
addsd  %xmm1,%xmm2
movsd  0xea5(%rip),%xmm3
divsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
addsd  %xmm1,%xmm2
movsd  0xe99(%rip),%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
addsd  %xmm1,%xmm2
movsd  0xe8d(%rip),%xmm3
divsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
addsd  %xmm1,%xmm2
movsd  0xe81(%rip),%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
addsd  %xmm1,%xmm2
movapd %xmm2,%xmm3
addsd  %xmm1,%xmm3
unpcklpd %xmm3,%xmm2
movapd 0xe81(%rip),%xmm4
divpd  %xmm2,%xmm4
addsd  %xmm4,%xmm0
unpckhpd %xmm4,%xmm4
addsd  %xmm0,%xmm4
addsd  %xmm1,%xmm3
movapd %xmm3,%xmm0
addsd  %xmm1,%xmm0
unpcklpd %xmm0,%xmm3
movapd 0xe69(%rip),%xmm2
divpd  %xmm3,%xmm2
addsd  %xmm2,%xmm4
unpckhpd %xmm2,%xmm2
addsd  %xmm4,%xmm2
addsd  %xmm1,%xmm0
movapd %xmm0,%xmm3
addsd  %xmm1,%xmm3
unpcklpd %xmm3,%xmm0
movapd 0xe51(%rip),%xmm4
divpd  %xmm0,%xmm4
addsd  %xmm4,%xmm2
unpckhpd %xmm4,%xmm4
addsd  %xmm2,%xmm4
addsd  %xmm1,%xmm3
addsd  %xmm3,%xmm1
unpcklpd %xmm1,%xmm3
movapd 0xe3d(%rip),%xmm0
divpd  %xmm3,%xmm0
addsd  %xmm0,%xmm4
unpckhpd %xmm0,%xmm0
addsd  %xmm4,%xmm0
movsd  0xddd(%rip),%xmm1
addsd  %xmm6,%xmm1
mulsd  %xmm1,%xmm5
subsd  0x8(%rsp),%xmm5
movsd  %xmm5,0x8(%rsp)
mulsd  0xdc9(%rip),%xmm0
divsd  %xmm6,%xmm0
call   1030 <log@plt>
addsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@gammln.cof = internal constant [14 x double] [double 0x404C93FF87C1ACCE, double 0xC04DCC89F7058930, double 0x402C45AEA23D22A1, double 0xBFDF7B841625BFE4, double 0x3F01D2AF4786183A, double 0x3F08644BB7C5E3BD, double 0xBF19C9CC9DE574B7, double 0x3EF093A94BDD8524, double 0xBF2B8F4DCD2ABE36, double 0x3F2C801018E9E826, double 0xBF258999C9952640, double 0x3F17487D781D58DD, double 0xBEFB768CB5D1E206, double 0x3ECEF40A04FC9810]
define double @gammln(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %2
%8 = load double, double* %2
%9 = fcmp ole double %8, 0.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %1
br label %11
11: ; preds = %10, %1
%12 = load double, double* %2
store double %12, double* %6
%13 = load double, double* %2
store double %13, double* %4
%14 = load double, double* %4
%15 = fadd double %14, 0x4014F80000000000
store double %15, double* %5
%16 = load double, double* %4
%17 = fadd double %16, 5.000000e-01
%18 = load double, double* %5
%19 = call double @log(double %18)
%20 = load double, double* %5
%21 = fneg double %20
%22 = call double @llvm.fmuladd.f64(double %17, double %19, double %21)
store double %22, double* %5
store double 0x3FEFFFFFFFFFFFE6, double* %7
store i32 0, i32* %3
br label %23
23: ; preds = %36, %11
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 14
br i1 %25, label %26, label %39
26: ; preds = %23
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [14 x double], [14 x double]* @gammln.cof, i64 0, i64 %28
%30 = load double, double* %29
%31 = load double, double* %6
%32 = fadd double %31, 1.000000e+00
store double %32, double* %6
%33 = fdiv double %30, %32
%34 = load double, double* %7
%35 = fadd double %34, %33
store double %35, double* %7
br label %36
36: ; preds = %26
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %23
39: ; preds = %23
%40 = load double, double* %5
%41 = load double, double* %7
%42 = fmul double 0x40040D931FF62706, %41
%43 = load double, double* %4
%44 = fdiv double %42, %43
%45 = call double @log(double %44)
%46 = fadd double %40, %45
ret double %46
}

LLVM IR (-O2):
define double @gammln(double %0) {
%2 = fadd double %0, 0x4014F80000000000
%3 = tail call double @log(double %2)
%4 = fadd double %0, 1.000000e+00
%5 = fdiv double 0x404C93FF87C1ACCE, %4
%6 = fadd double %5, 0x3FEFFFFFFFFFFFE6
%7 = fadd double %4, 1.000000e+00
%8 = fdiv double 0xC04DCC89F7058930, %7
%9 = fadd double %6, %8
%10 = fadd double %7, 1.000000e+00
%11 = fdiv double 0x402C45AEA23D22A1, %10
%12 = fadd double %9, %11
%13 = fadd double %10, 1.000000e+00
%14 = fdiv double 0xBFDF7B841625BFE4, %13
%15 = fadd double %12, %14
%16 = fadd double %13, 1.000000e+00
%17 = fdiv double 0x3F01D2AF4786183A, %16
%18 = fadd double %15, %17
%19 = fadd double %16, 1.000000e+00
%20 = fdiv double 0x3F08644BB7C5E3BD, %19
%21 = fadd double %18, %20
%22 = fadd double %19, 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 0xBF19C9CC9DE574B7, double 0x3EF093A94BDD8524>, %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 %23, 1.000000e+00
%32 = fadd double %31, 1.000000e+00
%33 = insertelement <2 x double> poison, double %31, i64 0
%34 = insertelement <2 x double> %33, double %32, i64 1
%35 = fdiv <2 x double> <double 0xBF2B8F4DCD2ABE36, double 0x3F2C801018E9E826>, %34
%36 = extractelement <2 x double> %35, i64 0
%37 = fadd double %30, %36
%38 = extractelement <2 x double> %35, i64 1
%39 = fadd double %37, %38
%40 = fadd double %32, 1.000000e+00
%41 = fadd double %40, 1.000000e+00
%42 = insertelement <2 x double> poison, double %40, i64 0
%43 = insertelement <2 x double> %42, double %41, i64 1
%44 = fdiv <2 x double> <double 0xBF258999C9952640, double 0x3F17487D781D58DD>, %43
%45 = extractelement <2 x double> %44, i64 0
%46 = fadd double %39, %45
%47 = extractelement <2 x double> %44, i64 1
%48 = fadd double %46, %47
%49 = fadd double %41, 1.000000e+00
%50 = fadd double %49, 1.000000e+00
%51 = insertelement <2 x double> poison, double %49, i64 0
%52 = insertelement <2 x double> %51, double %50, i64 1
%53 = fdiv <2 x double> <double 0xBEFB768CB5D1E206, double 0x3ECEF40A04FC9810>, %52
%54 = extractelement <2 x double> %53, i64 0
%55 = fadd double %48, %54
%56 = extractelement <2 x double> %53, i64 1
%57 = fadd double %55, %56
%58 = fadd double %0, 5.000000e-01
%59 = fneg double %2
%60 = tail call double @llvm.fmuladd.f64(double %58, double %3, double %59)
%61 = fmul double %57, 0x40040D931FF62706
%62 = fdiv double %61, %0
%63 = tail call double @log(double %62)
%64 = fadd double %60, %63
ret double %64
}