#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 alogam(double *x, int *ifault) {
  static double a1 = .918938533204673;
  static double a2 = 5.95238095238e-4;
  static double a3 = 7.93650793651e-4;
  static double a4 = .002777777777778;
  static double a5 = .083333333333333;
  static double f, y, z;
  *ifault = 1;
  if (*x < 0.) {
    return (0.);
  }
  *ifault = 0;
  y = *x;
  f = 0.;
  if (y >= 7.) {
    goto L30;
  }
  f = y;
L10:
  y += 1.;
  if (y >= 7.) {
    goto L20;
  }
  f *= y;
  goto L10;
L20:
  f = -log(f);
L30:
  z = 1. / (y * y);
  return (f + (y - .5) * log(y) - y + a1 +
          (((-a2 * z + a3) * z - a4) * z + a5) / y);
}


x86 assembly (clang, -O0):
<alogam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    1148 <alogam+0x38>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1327 <alogam+0x217>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x2efe(%rip)
xorps  %xmm0,%xmm0
movsd  %xmm0,0x2eeb(%rip)
movsd  0x2eeb(%rip),%xmm0
movsd  0xe83(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     118c <alogam+0x7c>
jmp    121c <alogam+0x10c>
movsd  0x2ecc(%rip),%xmm0
movsd  %xmm0,0x2ebc(%rip)
movsd  0xe64(%rip),%xmm0
addsd  0x2eb4(%rip),%xmm0
movsd  %xmm0,0x2eac(%rip)
movsd  0x2ea4(%rip),%xmm0
movsd  0xe3c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11d3 <alogam+0xc3>
jmp    11f0 <alogam+0xe0>
movsd  0x2e85(%rip),%xmm0
mulsd  0x2e75(%rip),%xmm0
movsd  %xmm0,0x2e6d(%rip)
jmp    119c <alogam+0x8c>
movsd  0x2e60(%rip),%xmm0
call   1030 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,0x2e3c(%rip)
movsd  0x2e3c(%rip),%xmm1
mulsd  0x2e34(%rip),%xmm1
movsd  0xdd4(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2e28(%rip)
movsd  0x2e10(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0x2e0b(%rip),%xmm0
movsd  0xdb3(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0x2df2(%rip),%xmm0
call   1030 <log@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  0x2dd0(%rip),%xmm0
addsd  0x2d90(%rip),%xmm0
movsd  0x2d90(%rip),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0x2da9(%rip),%xmm3
movsd  0x2d71(%rip),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0x2d91(%rip),%xmm3
movsd  0x2d61(%rip),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0x2d62(%rip),%xmm3
movsd  0x2d3a(%rip),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  0x2d42(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alogam>:
sub    $0x28,%rsp
movl   $0x1,(%rsi)
movsd  (%rdi),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     123c <alogam+0x12c>
movl   $0x0,(%rsi)
movsd  %xmm0,0x2ef6(%rip)
ucomisd 0xebe(%rip),%xmm0
jae    11a3 <alogam+0x93>
movsd  0xebc(%rip),%xmm1
addsd  %xmm0,%xmm1
ucomisd 0xea8(%rip),%xmm1
jae    117e <alogam+0x6e>
movsd  0xea6(%rip),%xmm2
movsd  0xe96(%rip),%xmm3
nopw   0x0(%rax,%rax,1)
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm1
ucomisd %xmm3,%xmm1
jb     1170 <alogam+0x60>
movsd  %xmm1,0x2eaa(%rip)
call   1030 <log@plt>
xorpd  0xead(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x2e8f(%rip),%xmm0
jmp    11ad <alogam+0x9d>
xorpd  %xmm1,%xmm1
movapd %xmm1,0x10(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe4b(%rip),%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,0x2e6f(%rip)
movsd  0xe3f(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1030 <log@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  0x2e3c(%rip),%xmm2
subsd  %xmm2,%xmm0
addsd  0xe18(%rip),%xmm0
movsd  0x2e30(%rip),%xmm3
movsd  0xe10(%rip),%xmm1
mulsd  %xmm3,%xmm1
addsd  0xe0c(%rip),%xmm1
mulsd  %xmm3,%xmm1
addsd  0xe08(%rip),%xmm1
mulsd  %xmm3,%xmm1
addsd  0xe04(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@alogam.a1 = internal global double 0x3FED67F1C864BEB7
@alogam.a2 = internal global double 0x3F438138138134A5
@alogam.a3 = internal global double 0x3F4A01A01A01A789
@alogam.a4 = internal global double 0x3F66C16C16C16E17
@alogam.a5 = internal global double 0x3FB555555555553D
@alogam.f = internal global double 0.000000e+00
@alogam.y = internal global double 0.000000e+00
@alogam.z = internal global double 0.000000e+00
define double @alogam(double* %0, i32* %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca i32*
store double* %0, double** %4
store i32* %1, i32** %5
%6 = load i32*, i32** %5
store i32 1, i32* %6
%7 = load double*, double** %4
%8 = load double, double* %7
%9 = fcmp olt double %8, 0.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %2
store double 0.000000e+00, double* %3
br label %64
11: ; preds = %2
%12 = load i32*, i32** %5
store i32 0, i32* %12
%13 = load double*, double** %4
%14 = load double, double* %13
store double %14, double* @alogam.y
store double 0.000000e+00, double* @alogam.f
%15 = load double, double* @alogam.y
%16 = fcmp oge double %15, 7.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %11
br label %34
18: ; preds = %11
%19 = load double, double* @alogam.y
store double %19, double* @alogam.f
br label %20
20: ; preds = %26, %18
%21 = load double, double* @alogam.y
%22 = fadd double %21, 1.000000e+00
store double %22, double* @alogam.y
%23 = load double, double* @alogam.y
%24 = fcmp oge double %23, 7.000000e+00
br i1 %24, label %25, label %26
25: ; preds = %20
br label %30
26: ; preds = %20
%27 = load double, double* @alogam.y
%28 = load double, double* @alogam.f
%29 = fmul double %28, %27
store double %29, double* @alogam.f
br label %20
30: ; preds = %25
%31 = load double, double* @alogam.f
%32 = call double @log(double %31)
%33 = fneg double %32
store double %33, double* @alogam.f
br label %34
34: ; preds = %30, %17
%35 = load double, double* @alogam.y
%36 = load double, double* @alogam.y
%37 = fmul double %35, %36
%38 = fdiv double 1.000000e+00, %37
store double %38, double* @alogam.z
%39 = load double, double* @alogam.f
%40 = load double, double* @alogam.y
%41 = fsub double %40, 5.000000e-01
%42 = load double, double* @alogam.y
%43 = call double @log(double %42)
%44 = call double @llvm.fmuladd.f64(double %41, double %43, double %39)
%45 = load double, double* @alogam.y
%46 = fsub double %44, %45
%47 = load double, double* @alogam.a1
%48 = fadd double %46, %47
%49 = load double, double* @alogam.a2
%50 = fneg double %49
%51 = load double, double* @alogam.z
%52 = load double, double* @alogam.a3
%53 = call double @llvm.fmuladd.f64(double %50, double %51, double %52)
%54 = load double, double* @alogam.z
%55 = load double, double* @alogam.a4
%56 = fneg double %55
%57 = call double @llvm.fmuladd.f64(double %53, double %54, double %56)
%58 = load double, double* @alogam.z
%59 = load double, double* @alogam.a5
%60 = call double @llvm.fmuladd.f64(double %57, double %58, double %59)
%61 = load double, double* @alogam.y
%62 = fdiv double %60, %61
%63 = fadd double %48, %62
store double %63, double* %3
br label %64
64: ; preds = %34, %10
%65 = load double, double* %3
ret double %65
}

LLVM IR (-O2):
@alogam.y = internal unnamed_addr global double 0.000000e+00
@alogam.z = internal unnamed_addr global double 0.000000e+00
define double @alogam(double* nocapture %0, i32* nocapture writeonly %1) {
store i32 1, i32* %1
%3 = load double, double* %0
%4 = fcmp olt double %3, 0.000000e+00
br i1 %4, label %39, label %5
5: ; preds = %2
store i32 0, i32* %1
store double %3, double* @alogam.y
%6 = fcmp ult double %3, 7.000000e+00
br i1 %6, label %7, label %22
7: ; preds = %5
%8 = fadd double %3, 1.000000e+00
%9 = fcmp ult double %8, 7.000000e+00
br i1 %9, label %10, label %16
10: ; preds = %7, %10
%11 = phi double [ %14, %10 ], [ %8, %7 ]
%12 = phi double [ %13, %10 ], [ %3, %7 ]
%13 = fmul double %12, %11
%14 = fadd double %11, 1.000000e+00
%15 = fcmp ult double %14, 7.000000e+00
br i1 %15, label %10, label %16
16: ; preds = %10, %7
%17 = phi double [ %8, %7 ], [ %14, %10 ]
%18 = phi double [ %3, %7 ], [ %13, %10 ]
store double %17, double* @alogam.y
%19 = tail call double @log(double %18)
%20 = fneg double %19
%21 = load double, double* @alogam.y
br label %22
22: ; preds = %5, %16
%23 = phi double [ 0.000000e+00, %5 ], [ %20, %16 ]
%24 = phi double [ %3, %5 ], [ %21, %16 ]
%25 = fmul double %24, %24
%26 = fdiv double 1.000000e+00, %25
store double %26, double* @alogam.z
%27 = fadd double %24, -5.000000e-01
%28 = tail call double @log(double %24)
%29 = tail call double @llvm.fmuladd.f64(double %27, double %28, double %23)
%30 = load double, double* @alogam.y
%31 = fsub double %29, %30
%32 = fadd double %31, 0x3FED67F1C864BEB7
%33 = load double, double* @alogam.z
%34 = tail call double @llvm.fmuladd.f64(double %33, double 0xBF438138138134A5, double 0x3F4A01A01A01A789)
%35 = tail call double @llvm.fmuladd.f64(double %34, double %33, double 0xBF66C16C16C16E17)
%36 = tail call double @llvm.fmuladd.f64(double %35, double %33, double 0x3FB555555555553D)
%37 = fdiv double %36, %30
%38 = fadd double %32, %37
br label %39
39: ; preds = %2, %22
%40 = phi double [ %38, %22 ], [ 0.000000e+00, %2 ]
ret double %40
}