#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
double gammaf(double x) {
  int i;
  double w, w1;
  static double a[8] = {1.0,         -0.577191652, 0.988205891, -0.897056937,
                        0.918206857, -0.756704078, 0.482199394, -0.193527818};
  if (x <= 0.) {
    fprintf(stderr, "Error : x <= 0  in gammaf()\n");
    return 0.;
  }
  if (x >= 34.) {
    fprintf(stderr, "Error : x >= 34  (Overflow) in gammaf()\n");
    return 0.;
  }
  w1 = 1.;
  if (x > 1.) {
    do {
      x -= 1.;
      w1 *= x;
    } while (x > 1.);
  }
  w = 0.035868343;
  for (i = 7; i >= 0; i--)
    w = w * x + a[i];
  return w1 * w / x;
}


x86 assembly (clang, -O0):
<gammaf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     114d <gammaf+0x3d>
mov    0x2eae(%rip),%rax
mov    (%rax),%edi
lea    0xedd(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1257 <gammaf+0x147>
movsd  -0x10(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1186 <gammaf+0x76>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1257 <gammaf+0x147>
movsd  0xe7a(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe68(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11f0 <gammaf+0xe0>
jmp    11af <gammaf+0x9f>
movsd  -0x10(%rbp),%xmm0
movsd  0xe4c(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe27(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11af <gammaf+0x9f>
jmp    11f0 <gammaf+0xe0>
movsd  0xe18(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x7,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1243 <gammaf+0x133>
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2e0d(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1204 <gammaf+0xf4>
movsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammaf>:
push   %rax
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    11d0 <gammaf+0xc0>
ucomisd 0xed9(%rip),%xmm0
jae    11e2 <gammaf+0xd2>
movsd  0xed3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    115e <gammaf+0x4e>
movsd  0xec5(%rip),%xmm2
movsd  0xec5(%rip),%xmm3
movapd %xmm2,%xmm1
nop
addsd  %xmm3,%xmm0
mulsd  %xmm0,%xmm1
ucomisd %xmm2,%xmm0
ja     1150 <gammaf+0x40>
movsd  0xeb2(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xeae(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xeaa(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xea6(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xea2(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe9e(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe9a(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe96(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xe42(%rip),%xmm2
mulsd  %xmm1,%xmm2
divsd  %xmm0,%xmm2
jmp    11fb <gammaf+0xeb>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
jmp    11f2 <gammaf+0xe2>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm2,%xmm2
movapd %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@gammaf.a = internal global [8 x double] [double 1.000000e+00, double 0xBFE2785AA09BA7A2, double 0x3FEF9F61F5F1E7C2, double 0xBFECB4B0BFE213ED, double 0x3FED61F358B8E4F5, double 0xBFE836EB7878508D, double 0x3FDEDC5AD8D8629C, double 0xBFC8C58500968F09]
@stderr = global i32 0
@.str = [29 x i8] c"Error : x <= 0 in gammaf()\0A\00"
@.str.1 = [41 x i8] c"Error : x >= 34 (Overflow) in gammaf()\0A\00"
define double @gammaf(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
store double %0, double* %3
%7 = load double, double* %3
%8 = fcmp ole double %7, 0.000000e+00
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %2
br label %53
12: ; preds = %1
%13 = load double, double* %3
%14 = fcmp oge double %13, 3.400000e+01
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
store double 0.000000e+00, double* %2
br label %53
18: ; preds = %12
store double 1.000000e+00, double* %6
%19 = load double, double* %3
%20 = fcmp ogt double %19, 1.000000e+00
br i1 %20, label %21, label %32
21: ; preds = %18
br label %22
22: ; preds = %28, %21
%23 = load double, double* %3
%24 = fsub double %23, 1.000000e+00
store double %24, double* %3
%25 = load double, double* %3
%26 = load double, double* %6
%27 = fmul double %26, %25
store double %27, double* %6
br label %28
28: ; preds = %22
%29 = load double, double* %3
%30 = fcmp ogt double %29, 1.000000e+00
br i1 %30, label %22, label %31
31: ; preds = %28
br label %32
32: ; preds = %31, %18
store double 0x3FA25D55E04B1DA4, double* %5
store i32 7, i32* %4
br label %33
33: ; preds = %44, %32
%34 = load i32, i32* %4
%35 = icmp sge i32 %34, 0
br i1 %35, label %36, label %47
36: ; preds = %33
%37 = load double, double* %5
%38 = load double, double* %3
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [8 x double], [8 x double]* @gammaf.a, i64 0, i64 %40
%42 = load double, double* %41
%43 = call double @llvm.fmuladd.f64(double %37, double %38, double %42)
store double %43, double* %5
br label %44
44: ; preds = %36
%45 = load i32, i32* %4
%46 = add nsw i32 %45, -1
store i32 %46, i32* %4
br label %33
47: ; preds = %33
%48 = load double, double* %6
%49 = load double, double* %5
%50 = fmul double %48, %49
%51 = load double, double* %3
%52 = fdiv double %50, %51
store double %52, double* %2
br label %53
53: ; preds = %47, %15, %9
%54 = load double, double* %2
ret double %54
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Error : x <= 0 in gammaf()\0A\00"
@.str.1 = [41 x i8] c"Error : x >= 34 (Overflow) in gammaf()\0A\00"
define double @gammaf(double %0) {
%2 = fcmp ugt double %0, 0.000000e+00
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %32
6: ; preds = %1
%7 = fcmp ult double %0, 3.400000e+01
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %32
11: ; preds = %6
%12 = fcmp ogt double %0, 1.000000e+00
br i1 %12, label %13, label %19
13: ; preds = %11, %13
%14 = phi double [ %16, %13 ], [ %0, %11 ]
%15 = phi double [ %17, %13 ], [ 1.000000e+00, %11 ]
%16 = fadd double %14, -1.000000e+00
%17 = fmul double %15, %16
%18 = fcmp ogt double %16, 1.000000e+00
br i1 %18, label %13, label %19
19: ; preds = %13, %11
%20 = phi double [ %0, %11 ], [ %16, %13 ]
%21 = phi double [ 1.000000e+00, %11 ], [ %17, %13 ]
%22 = tail call double @llvm.fmuladd.f64(double %20, double 0x3FA25D55E04B1DA4, double 0xBFC8C58500968F09)
%23 = tail call double @llvm.fmuladd.f64(double %22, double %20, double 0x3FDEDC5AD8D8629C)
%24 = tail call double @llvm.fmuladd.f64(double %23, double %20, double 0xBFE836EB7878508D)
%25 = tail call double @llvm.fmuladd.f64(double %24, double %20, double 0x3FED61F358B8E4F5)
%26 = tail call double @llvm.fmuladd.f64(double %25, double %20, double 0xBFECB4B0BFE213ED)
%27 = tail call double @llvm.fmuladd.f64(double %26, double %20, double 0x3FEF9F61F5F1E7C2)
%28 = tail call double @llvm.fmuladd.f64(double %27, double %20, double 0xBFE2785AA09BA7A2)
%29 = tail call double @llvm.fmuladd.f64(double %28, double %20, double 1.000000e+00)
%30 = fmul double %21, %29
%31 = fdiv double %30, %20
br label %32
32: ; preds = %19, %8, %3
%33 = phi double [ 0.000000e+00, %3 ], [ 0.000000e+00, %8 ], [ %31, %19 ]
ret double %33
}