#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 */
typedef int /*<<< orphan*/ mpf_t;

/* Variables and functions */
scalar_t__ floor(double);
int /*<<< orphan*/ fp_poch_rising(int /*<<< orphan*/, int /*<<< orphan*/,
                                  unsigned int);
int /*<<< orphan*/ mpf_add_ui(int /*<<< orphan*/, int /*<<< orphan*/,
                              unsigned int);
int /*<<< orphan*/ mpf_clear(int /*<<< orphan*/);
double mpf_get_d(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set(int /*<<< orphan*/, int /*<<< orphan*/ const);
int /*<<< orphan*/ mpf_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_sub_ui(int /*<<< orphan*/, int /*<<< orphan*/,
                              unsigned int);
int /*<<< orphan*/ mpf_ui_div(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ reduced_gamma(int /*<<< orphan*/, int /*<<< orphan*/, int);
void fp_gamma(mpf_t gam, const mpf_t z, int prec) {
  mpf_t zee;
  mpf_init(zee);
  mpf_set(zee, z);
  double flo = mpf_get_d(zee);
  if (flo > 2.5) {
    unsigned int intpart = (unsigned int)floor(flo - 1.0);
    if (flo - intpart < 1.5)
      intpart--;
    mpf_sub_ui(zee, zee, intpart);
    fp_poch_rising(gam, zee, intpart);
  } else if (flo < 1.5) {
    unsigned int intpart = (unsigned int)floor(2.0 - flo);
    if (flo + intpart < 1.5)
      intpart++;
    fp_poch_rising(gam, zee, intpart);
    mpf_ui_div(gam, 1, gam);
    mpf_add_ui(zee, zee, intpart);
  } else {
    mpf_set_ui(gam, 1);
  }
  mpf_t rgamma;
  mpf_init(rgamma);
  reduced_gamma(rgamma, zee, prec);
  mpf_mul(gam, gam, rgamma);
  mpf_clear(zee);
  mpf_clear(rgamma);
}


x86 assembly (clang, -O0):
<fp_gamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x10(%rbp),%edi
call   1070 <mpf_init@plt>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1090 <mpf_set@plt>
mov    -0x10(%rbp),%edi
call   10d0 <mpf_get_d@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe02(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    126e <fp_gamma+0xae>
movsd  -0x18(%rbp),%xmm0
movsd  0xe03(%rip),%xmm1
addsd  %xmm1,%xmm0
call   10e0 <floor@plt>
mov    %eax,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm1
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
subsd  %xmm0,%xmm1
movsd  0xdce(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    124d <fp_gamma+0x8d>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <mpf_sub_ui@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <fp_poch_rising@plt>
jmp    1309 <fp_gamma+0x149>
movsd  0xd92(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    12f7 <fp_gamma+0x137>
movsd  -0x18(%rbp),%xmm1
movsd  0xd82(%rip),%xmm0
subsd  %xmm1,%xmm0
call   10e0 <floor@plt>
mov    %eax,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
mov    -0x20(%rbp),%eax
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm1
movsd  0xd55(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12c6 <fp_gamma+0x106>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1030 <fp_poch_rising@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%edx
mov    $0x1,%esi
call   1040 <mpf_ui_div@plt>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x20(%rbp),%edx
call   10c0 <mpf_add_ui@plt>
jmp    1304 <fp_gamma+0x144>
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
jmp    1309 <fp_gamma+0x149>
mov    -0x24(%rbp),%edi
call   1070 <mpf_init@plt>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1060 <reduced_gamma@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x24(%rbp),%edx
call   10b0 <mpf_mul@plt>
mov    -0x10(%rbp),%edi
call   1080 <mpf_clear@plt>
mov    -0x24(%rbp),%edi
call   1080 <mpf_clear@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fp_gamma>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1070 <mpf_init@plt>
mov    %ebp,%esi
call   1090 <mpf_set@plt>
call   10d0 <mpf_get_d@plt>
movapd %xmm0,%xmm1
ucomisd 0xe14(%rip),%xmm0
jbe    1241 <fp_gamma+0x81>
movsd  0xe22(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm1,0x8(%rsp)
call   10e0 <floor@plt>
mov    %rax,%rbp
mov    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0xde4(%rip),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
seta   %al
sub    %eax,%ebp
mov    %ebp,%edx
call   1050 <mpf_sub_ui@plt>
mov    %ebx,%edi
mov    %ebp,%edx
call   1030 <fp_poch_rising@plt>
jmp    12b6 <fp_gamma+0xf6>
movsd  0xdbf(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12aa <fp_gamma+0xea>
movsd  0xdb9(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm1,0x8(%rsp)
call   10e0 <floor@plt>
mov    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %rcx,%xmm0
addsd  0x8(%rsp),%xmm0
xor    %ebp,%ebp
movsd  0xd88(%rip),%xmm1
ucomisd %xmm0,%xmm1
seta   %bpl
add    %eax,%ebp
mov    %ebx,%edi
mov    %ebp,%edx
call   1030 <fp_poch_rising@plt>
mov    %ebx,%edi
mov    $0x1,%esi
mov    %ebx,%edx
call   1040 <mpf_ui_div@plt>
mov    %ebp,%edx
call   10c0 <mpf_add_ui@plt>
jmp    12b6 <fp_gamma+0xf6>
mov    %ebx,%edi
mov    $0x1,%esi
call   10a0 <mpf_set_ui@plt>
call   1070 <mpf_init@plt>
mov    %r14d,%edx
call   1060 <reduced_gamma@plt>
mov    %ebx,%edi
mov    %ebx,%esi
call   10b0 <mpf_mul@plt>
call   1080 <mpf_clear@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1080 <mpf_clear@plt>

LLVM IR (-O0):
define void @fp_gamma(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%12 = load i32, i32* %7
%13 = call i32 @mpf_init(i32 %12)
%14 = load i32, i32* %7
%15 = load i32, i32* %5
%16 = call i32 @mpf_set(i32 %14, i32 %15)
%17 = load i32, i32* %7
%18 = call double @mpf_get_d(i32 %17)
store double %18, double* %8
%19 = load double, double* %8
%20 = fcmp ogt double %19, 2.500000e+00
br i1 %20, label %21, label %43
21: ; preds = %3
%22 = load double, double* %8
%23 = fsub double %22, 1.000000e+00
%24 = call i64 @floor(double %23)
%25 = trunc i64 %24 to i32
store i32 %25, i32* %9
%26 = load double, double* %8
%27 = load i32, i32* %9
%28 = uitofp i32 %27 to double
%29 = fsub double %26, %28
%30 = fcmp olt double %29, 1.500000e+00
br i1 %30, label %31, label %34
31: ; preds = %21
%32 = load i32, i32* %9
%33 = add i32 %32, -1
store i32 %33, i32* %9
br label %34
34: ; preds = %31, %21
%35 = load i32, i32* %7
%36 = load i32, i32* %7
%37 = load i32, i32* %9
%38 = call i32 @mpf_sub_ui(i32 %35, i32 %36, i32 %37)
%39 = load i32, i32* %4
%40 = load i32, i32* %7
%41 = load i32, i32* %9
%42 = call i32 @fp_poch_rising(i32 %39, i32 %40, i32 %41)
br label %75
43: ; preds = %3
%44 = load double, double* %8
%45 = fcmp olt double %44, 1.500000e+00
br i1 %45, label %46, label %71
46: ; preds = %43
%47 = load double, double* %8
%48 = fsub double 2.000000e+00, %47
%49 = call i64 @floor(double %48)
%50 = trunc i64 %49 to i32
store i32 %50, i32* %10
%51 = load double, double* %8
%52 = load i32, i32* %10
%53 = uitofp i32 %52 to double
%54 = fadd double %51, %53
%55 = fcmp olt double %54, 1.500000e+00
br i1 %55, label %56, label %59
56: ; preds = %46
%57 = load i32, i32* %10
%58 = add i32 %57, 1
store i32 %58, i32* %10
br label %59
59: ; preds = %56, %46
%60 = load i32, i32* %4
%61 = load i32, i32* %7
%62 = load i32, i32* %10
%63 = call i32 @fp_poch_rising(i32 %60, i32 %61, i32 %62)
%64 = load i32, i32* %4
%65 = load i32, i32* %4
%66 = call i32 @mpf_ui_div(i32 %64, i32 1, i32 %65)
%67 = load i32, i32* %7
%68 = load i32, i32* %7
%69 = load i32, i32* %10
%70 = call i32 @mpf_add_ui(i32 %67, i32 %68, i32 %69)
br label %74
71: ; preds = %43
%72 = load i32, i32* %4
%73 = call i32 @mpf_set_ui(i32 %72, i32 1)
br label %74
74: ; preds = %71, %59
br label %75
75: ; preds = %74, %34
%76 = load i32, i32* %11
%77 = call i32 @mpf_init(i32 %76)
%78 = load i32, i32* %11
%79 = load i32, i32* %7
%80 = load i32, i32* %6
%81 = call i32 @reduced_gamma(i32 %78, i32 %79, i32 %80)
%82 = load i32, i32* %4
%83 = load i32, i32* %4
%84 = load i32, i32* %11
%85 = call i32 @mpf_mul(i32 %82, i32 %83, i32 %84)
%86 = load i32, i32* %7
%87 = call i32 @mpf_clear(i32 %86)
%88 = load i32, i32* %11
%89 = call i32 @mpf_clear(i32 %88)
ret void
}

LLVM IR (-O2):
define void @fp_gamma(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @mpf_init(i32 undef)
%5 = tail call i32 @mpf_set(i32 undef, i32 %1)
%6 = tail call double @mpf_get_d(i32 undef)
%7 = fcmp ogt double %6, 2.500000e+00
br i1 %7, label %8, label %19
8: ; preds = %3
%9 = fadd double %6, -1.000000e+00
%10 = tail call i64 @floor(double %9)
%11 = trunc i64 %10 to i32
%12 = uitofp i32 %11 to double
%13 = fsub double %6, %12
%14 = fcmp olt double %13, 1.500000e+00
%15 = sext i1 %14 to i32
%16 = add i32 %15, %11
%17 = tail call i32 @mpf_sub_ui(i32 undef, i32 undef, i32 %16)
%18 = tail call i32 @fp_poch_rising(i32 %0, i32 undef, i32 %16)
br label %35
19: ; preds = %3
%20 = fcmp olt double %6, 1.500000e+00
br i1 %20, label %21, label %33
21: ; preds = %19
%22 = fsub double 2.000000e+00, %6
%23 = tail call i64 @floor(double %22)
%24 = trunc i64 %23 to i32
%25 = uitofp i32 %24 to double
%26 = fadd double %6, %25
%27 = fcmp olt double %26, 1.500000e+00
%28 = zext i1 %27 to i32
%29 = add i32 %28, %24
%30 = tail call i32 @fp_poch_rising(i32 %0, i32 undef, i32 %29)
%31 = tail call i32 @mpf_ui_div(i32 %0, i32 1, i32 %0)
%32 = tail call i32 @mpf_add_ui(i32 undef, i32 undef, i32 %29)
br label %35
33: ; preds = %19
%34 = tail call i32 @mpf_set_ui(i32 %0, i32 1)
br label %35
35: ; preds = %21, %33, %8
%36 = tail call i32 @mpf_init(i32 undef)
%37 = tail call i32 @reduced_gamma(i32 undef, i32 undef, i32 %2)
%38 = tail call i32 @mpf_mul(i32 %0, i32 %0, i32 undef)
%39 = tail call i32 @mpf_clear(i32 undef)
%40 = tail call i32 @mpf_clear(i32 undef)
ret void
}