#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 exp(double);
double log(double);
int /*<<< orphan*/ printf(char *);
double const sin(double const);
double th_Gamma(double x) {
  double Recxs, sum, term, x10;
  const double EulerG = 0.577215664902, hlfLn2Pi = 0.918938533205;
  const double b[] = {0.0,
                      0.0833333333333,
                      -0.00277777777778,
                      0.000793650793651,
                      -0.000595238095238,
                      0.000841750841751};
  const double Pi = 3.14159265359;
  int xInt, k, x11;
  if (x > 10.0) {
    Recxs = 1.0 / (x * x);
    term = x;
    sum = (x - 0.5) * log(x) - x + hlfLn2Pi;
    for (k = 1; k <= 5; k++) {
      term *= Recxs;
      sum += b[k] * term;
    }
    return exp(sum);
  }
  if (x > 0) {
    x -= 1.0;
    x11 = (int)11.0 - x;
    x10 = x + (double)x11;
    xInt = (int)x;
    sum = 0.0;
    for (k = 1; k <= x11 - 1; k++) {
      sum -= log(x10 - (double)k);
    }
    return exp(sum) * th_Gamma(x10);
  }
  if (x == 0.0) {
    printf("\n!!x=0 in th_Gamma; zero returned");
    return 0.0;
  };
  return Pi / (sin(Pi * x) * th_Gamma(1.0 - x));
}


x86 assembly (clang, -O0):
<th_Gamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xec8(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xeb3(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
movsd  0xe8e(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe79(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe64(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe4f(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe3a(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe25(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe0b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12ea <th_Gamma+0x18a>
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xe37(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe27(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1080 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdba(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x80(%rbp)
cmpl   $0x5,-0x80(%rbp)
jg     12d6 <th_Gamma+0x176>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movslq -0x80(%rbp),%rax
movsd  -0x70(%rbp,%rax,8),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    128e <th_Gamma+0x12e>
movsd  -0x20(%rbp),%xmm0
call   1070 <exp@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    144b <th_Gamma+0x2eb>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    13d1 <th_Gamma+0x271>
movsd  -0x10(%rbp),%xmm0
movsd  0xd3f(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xd36(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x84(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x84(%rbp),%xmm1
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x7c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x80(%rbp)
mov    -0x80(%rbp),%eax
mov    -0x84(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     139c <th_Gamma+0x23c>
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x80(%rbp),%xmm1
subsd  %xmm1,%xmm0
call   1080 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    1356 <th_Gamma+0x1f6>
movsd  -0x20(%rbp),%xmm0
call   1070 <exp@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
call   1060 <th_Gamma@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    144b <th_Gamma+0x2eb>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1402 <th_Gamma+0x2a2>
jp     1402 <th_Gamma+0x2a2>
lea    0xc70(%rip),%rdi
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    144b <th_Gamma+0x2eb>
movsd  0xbfe(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  0xc24(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1060 <th_Gamma@plt>
movsd  -0xa0(%rbp),%xmm1
ff
mulsd  %xmm0,%xmm1
movsd  0xbc6(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<th_Gamma>:
push   %rbx
sub    $0x20,%rsp
movapd %xmm0,%xmm1
ucomisd 0xe9f(%rip),%xmm0
jbe    1224 <th_Gamma+0xd4>
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe99(%rip),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xe9f(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
movapd %xmm1,%xmm0
movsd  %xmm1,(%rsp)
call   1070 <log@plt>
mulsd  0x10(%rsp),%xmm0
movsd  (%rsp),%xmm2
subsd  %xmm2,%xmm0
addsd  0xe78(%rip),%xmm0
movsd  0x8(%rsp),%xmm3
mulsd  %xmm3,%xmm2
movapd %xmm3,%xmm1
mulsd  %xmm2,%xmm1
mulsd  0xe66(%rip),%xmm2
addsd  %xmm2,%xmm0
movapd %xmm3,%xmm2
mulsd  %xmm1,%xmm2
mulsd  0xe5a(%rip),%xmm1
addsd  %xmm1,%xmm0
movapd %xmm3,%xmm1
mulsd  %xmm2,%xmm1
mulsd  0xe4e(%rip),%xmm2
addsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm3
mulsd  0xe46(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  0xe42(%rip),%xmm3
addsd  %xmm3,%xmm0
add    $0x20,%rsp
pop    %rbx
jmp    1060 <exp@plt>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jbe    12c6 <th_Gamma+0x176>
addsd  0xdde(%rip),%xmm1
movsd  0xdde(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ebx
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
cmp    $0x2,%ebx
jl     12a6 <th_Gamma+0x156>
add    $0xffffffff,%ebx
xorpd  %xmm2,%xmm2
movsd  0xda0(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  %xmm2,(%rsp)
movapd 0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
call   1070 <log@plt>
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm2
subsd  %xmm0,%xmm2
addsd  0xd6f(%rip),%xmm1
add    $0xffffffff,%ebx
jne    1270 <th_Gamma+0x120>
movapd %xmm2,%xmm0
call   1060 <exp@plt>
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
call   1050 <th_Gamma@plt>
mulsd  (%rsp),%xmm0
jmp    1320 <th_Gamma+0x1d0>
jne    12dc <th_Gamma+0x18c>
jp     12dc <th_Gamma+0x18c>
lea    0xd8f(%rip),%rdi
call   1030 <printf@plt>
xorpd  %xmm0,%xmm0
jmp    1320 <th_Gamma+0x1d0>
movapd %xmm1,%xmm0
mulsd  0xd20(%rip),%xmm0
movsd  %xmm1,(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xd10(%rip),%xmm0
subsd  (%rsp),%xmm0
call   1050 <th_Gamma@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0xcf0(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"\0A!!x=0 in th_Gamma; zero returned\00"
define double @th_Gamma(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca [6 x double]
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store double %0, double* %3
store double 0x3FE2788CFC6FC689, double* %8
store double 0x3FED67F1C864CA38, double* %9
%15 = bitcast [6 x double]* %10 to i8*
%16 = bitcast i8* %15 to [6 x double]*
%17 = getelementptr inbounds [6 x double], [6 x double]* %16, i32 0, i32 1
store double 0x3FB5555555554BF3, double* %17
%18 = getelementptr inbounds [6 x double], [6 x double]* %16, i32 0, i32 2
store double 0xBF66C16C16C1801B, double* %18
%19 = getelementptr inbounds [6 x double], [6 x double]* %16, i32 0, i32 3
store double 0x3F4A01A01A01A789, double* %19
%20 = getelementptr inbounds [6 x double], [6 x double]* %16, i32 0, i32 4
store double 0xBF438138138134A5, double* %20
%21 = getelementptr inbounds [6 x double], [6 x double]* %16, i32 0, i32 5
store double 0x3F4B951E2B1904D7, double* %21
store double 0x400921FB54442EEA, double* %11
%22 = load double, double* %3
%23 = fcmp ogt double %22, 1.000000e+01
br i1 %23, label %24, label %58
24: ; preds = %1
%25 = load double, double* %3
%26 = load double, double* %3
%27 = fmul double %25, %26
%28 = fdiv double 1.000000e+00, %27
store double %28, double* %4
%29 = load double, double* %3
store double %29, double* %6
%30 = load double, double* %3
%31 = fsub double %30, 5.000000e-01
%32 = load double, double* %3
%33 = call double @log(double %32)
%34 = load double, double* %3
%35 = fneg double %34
%36 = call double @llvm.fmuladd.f64(double %31, double %33, double %35)
%37 = fadd double %36, 0x3FED67F1C864CA38
store double %37, double* %5
store i32 1, i32* %13
br label %38
38: ; preds = %52, %24
%39 = load i32, i32* %13
%40 = icmp sle i32 %39, 5
br i1 %40, label %41, label %55
41: ; preds = %38
%42 = load double, double* %4
%43 = load double, double* %6
%44 = fmul double %43, %42
store double %44, double* %6
%45 = load i32, i32* %13
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [6 x double], [6 x double]* %10, i64 0, i64 %46
%48 = load double, double* %47
%49 = load double, double* %6
%50 = load double, double* %5
%51 = call double @llvm.fmuladd.f64(double %48, double %49, double %50)
store double %51, double* %5
br label %52
52: ; preds = %41
%53 = load i32, i32* %13
%54 = add nsw i32 %53, 1
store i32 %54, i32* %13
br label %38
55: ; preds = %38
%56 = load double, double* %5
%57 = call double @exp(double %56)
store double %57, double* %2
br label %109
58: ; preds = %1
%59 = load double, double* %3
%60 = fcmp ogt double %59, 0.000000e+00
br i1 %60, label %61, label %95
61: ; preds = %58
%62 = load double, double* %3
%63 = fsub double %62, 1.000000e+00
store double %63, double* %3
%64 = load double, double* %3
%65 = fsub double 1.100000e+01, %64
%66 = fptosi double %65 to i32
store i32 %66, i32* %14
%67 = load double, double* %3
%68 = load i32, i32* %14
%69 = sitofp i32 %68 to double
%70 = fadd double %67, %69
store double %70, double* %7
%71 = load double, double* %3
%72 = fptosi double %71 to i32
store i32 %72, i32* %12
store double 0.000000e+00, double* %5
store i32 1, i32* %13
br label %73
73: ; preds = %86, %61
%74 = load i32, i32* %13
%75 = load i32, i32* %14
%76 = sub nsw i32 %75, 1
%77 = icmp sle i32 %74, %76
br i1 %77, label %78, label %89
78: ; preds = %73
%79 = load double, double* %7
%80 = load i32, i32* %13
%81 = sitofp i32 %80 to double
%82 = fsub double %79, %81
%83 = call double @log(double %82)
%84 = load double, double* %5
%85 = fsub double %84, %83
store double %85, double* %5
br label %86
86: ; preds = %78
%87 = load i32, i32* %13
%88 = add nsw i32 %87, 1
store i32 %88, i32* %13
br label %73
89: ; preds = %73
%90 = load double, double* %5
%91 = call double @exp(double %90)
%92 = load double, double* %7
%93 = call double @th_Gamma(double %92)
%94 = fmul double %91, %93
store double %94, double* %2
br label %109
95: ; preds = %58
%96 = load double, double* %3
%97 = fcmp oeq double %96, 0.000000e+00
br i1 %97, label %98, label %100
98: ; preds = %95
%99 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %2
br label %109
100: ; preds = %95
%101 = load double, double* %3
%102 = fmul double 0x400921FB54442EEA, %101
%103 = call double @sin(double %102)
%104 = load double, double* %3
%105 = fsub double 1.000000e+00, %104
%106 = call double @th_Gamma(double %105)
%107 = fmul double %103, %106
%108 = fdiv double 0x400921FB54442EEA, %107
store double %108, double* %2
br label %109
109: ; preds = %100, %98, %89, %55
%110 = load double, double* %2
ret double %110
}

LLVM IR (-O2):
@.str = [34 x i8] c"\0A!!x=0 in th_Gamma; zero returned\00"
define double @th_Gamma(double %0) {
%2 = fcmp ogt double %0, 1.000000e+01
br i1 %2, label %3, label %22
3: ; preds = %1
%4 = fmul double %0, %0
%5 = fdiv double 1.000000e+00, %4
%6 = fadd double %0, -5.000000e-01
%7 = tail call double @log(double %0)
%8 = fneg double %0
%9 = tail call double @llvm.fmuladd.f64(double %6, double %7, double %8)
%10 = fadd double %9, 0x3FED67F1C864CA38
%11 = fmul double %5, %0
%12 = tail call double @llvm.fmuladd.f64(double %11, double 0x3FB5555555554BF3, double %10)
%13 = fmul double %5, %11
%14 = tail call double @llvm.fmuladd.f64(double %13, double 0xBF66C16C16C1801B, double %12)
%15 = fmul double %5, %13
%16 = tail call double @llvm.fmuladd.f64(double %15, double 0x3F4A01A01A01A789, double %14)
%17 = fmul double %5, %15
%18 = tail call double @llvm.fmuladd.f64(double %17, double 0xBF438138138134A5, double %16)
%19 = fmul double %5, %17
%20 = tail call double @llvm.fmuladd.f64(double %19, double 0x3F4B951E2B1904D7, double %18)
%21 = tail call double @exp(double %20)
br label %56
22: ; preds = %1
%23 = fcmp ogt double %0, 0.000000e+00
br i1 %23, label %24, label %45
24: ; preds = %22
%25 = fadd double %0, -1.000000e+00
%26 = fsub double 1.100000e+01, %25
%27 = fptosi double %26 to i32
%28 = sitofp i32 %27 to double
%29 = fadd double %25, %28
%30 = icmp sgt i32 %27, 1
br i1 %30, label %31, label %40
31: ; preds = %24, %31
%32 = phi i32 [ %38, %31 ], [ 1, %24 ]
%33 = phi double [ %37, %31 ], [ 0.000000e+00, %24 ]
%34 = sitofp i32 %32 to double
%35 = fsub double %29, %34
%36 = tail call double @log(double %35)
%37 = fsub double %33, %36
%38 = add nuw nsw i32 %32, 1
%39 = icmp eq i32 %38, %27
br i1 %39, label %40, label %31
40: ; preds = %31, %24
%41 = phi double [ 0.000000e+00, %24 ], [ %37, %31 ]
%42 = tail call double @exp(double %41)
%43 = tail call double @th_Gamma(double %29)
%44 = fmul double %42, %43
br label %56
45: ; preds = %22
%46 = fcmp oeq double %0, 0.000000e+00
br i1 %46, label %47, label %49
47: ; preds = %45
%48 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %56
49: ; preds = %45
%50 = fmul double %0, 0x400921FB54442EEA
%51 = tail call double @sin(double %50)
%52 = fsub double 1.000000e+00, %0
%53 = tail call double @th_Gamma(double %52)
%54 = fmul double %51, %53
%55 = fdiv double 0x400921FB54442EEA, %54
br label %56
56: ; preds = %49, %47, %40, %3
%57 = phi double [ %21, %3 ], [ %44, %40 ], [ 0.000000e+00, %47 ], [ %55, %49 ]
ret double %57
}