#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 DBL_MIN;
int /*<<< orphan*/ exit(int);
double exp(double);
double const fabs(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
double lngamma(double);
double log(double);
int /*<<< orphan*/ stderr;
double gamma_help_2(double a, double x, const char *prompt) {
  int i;
  double an, b, c, d, del, gln, h;
  double const very_small = 1000 * DBL_MIN;
  static const double eps = 1e-20;
  gln = lngamma(a);
  b = x + 1 - a;
  c = 1 / very_small;
  d = 1 / b;
  h = d;
  for (i = 1; i <= 100; i++) {
    an = -i * (i - a);
    b += 2;
    d = an * d + b;
    if (fabs(d) < very_small)
      d = very_small;
    c = b + an / c;
    if (fabs(c) < very_small)
      c = very_small;
    d = 1 / d;
    del = d * c;
    h *= del;
    if (fabs(del - 1) < eps)
      return exp(-x + a * log(x) - gln) * h;
  }
  fprintf(stderr,
          "%s: ERROR! Too many iterations in routine \"gamma_help_2\"!\n",
          prompt);
  exit(1);
  return -1;
}


x86 assembly (clang, -O0):
<gamma_help_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    0x2e5b(%rip),%rax
imul   $0x3e8,(%rax),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1060 <lngamma@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  0xe5d(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe46(%rip),%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe34(%rip),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jg     136c <gamma_help_2+0x20c>
xor    %eax,%eax
sub    -0x1c(%rbp),%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdf3(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <fabs@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1261 <gamma_help_2+0x101>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
divsd  -0x38(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <fabs@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    129f <gamma_help_2+0x13f>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd59(%rip),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xd24(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xd20(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1359 <gamma_help_2+0x1f9>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <log@plt>
movsd  -0x70(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x50(%rbp),%xmm0
call   1050 <exp@plt>
mulsd  -0x58(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret
jmp    135e <gamma_help_2+0x1fe>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e7 <gamma_help_2+0x87>
mov    0x2c6d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xca0(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<gamma_help_2>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
mov    0x2e6e(%rip),%rax
imul   $0x3e8,(%rax),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd %xmm1,0x10(%rsp)
call   1050 <lngamma@plt>
movapd 0x10(%rsp),%xmm4
movsd  (%rsp),%xmm14
movapd %xmm0,%xmm13
movsd  0xe64(%rip),%xmm8
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm11
addsd  %xmm8,%xmm1
subsd  %xmm14,%xmm1
movapd %xmm8,%xmm2
divsd  %xmm4,%xmm2
movapd %xmm8,%xmm6
divsd  %xmm1,%xmm6
mov    $0x1,%eax
mov    $0xffffffff,%ecx
movsd  0xe32(%rip),%xmm9
movapd 0xe41(%rip),%xmm15
movsd  0xe28(%rip),%xmm10
movsd  0xe27(%rip),%xmm12
movapd %xmm6,%xmm7
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
subsd  %xmm14,%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm9,%xmm1
mulsd  %xmm3,%xmm7
addsd  %xmm1,%xmm7
movapd %xmm7,%xmm0
andpd  %xmm15,%xmm0
cmpltsd %xmm4,%xmm0
movapd %xmm0,%xmm5
andnpd %xmm7,%xmm5
andpd  %xmm4,%xmm0
orpd   %xmm5,%xmm0
divsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
movapd %xmm3,%xmm2
andpd  %xmm15,%xmm2
cmpltsd %xmm4,%xmm2
movapd %xmm2,%xmm5
andnpd %xmm3,%xmm5
andpd  %xmm4,%xmm2
orpd   %xmm5,%xmm2
movapd %xmm8,%xmm7
divsd  %xmm0,%xmm7
movapd %xmm7,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm6
addsd  %xmm10,%xmm0
andpd  %xmm15,%xmm0
ucomisd %xmm0,%xmm12
ja     12bf <gamma_help_2+0x16f>
add    $0x1,%eax
add    $0xffffffff,%ecx
cmp    $0xffffff9b,%ecx
jne    1200 <gamma_help_2+0xb0>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movapd %xmm11,%xmm0
movsd  %xmm13,0x28(%rsp)
movsd  %xmm6,0x10(%rsp)
call   1060 <log@plt>
mulsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
subsd  0x28(%rsp),%xmm0
call   1040 <exp@plt>
mulsd  0x10(%rsp),%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@DBL_MIN = global i32 0
@gamma_help_2.eps = internal constant double 0x3BC79CA10C924223
@stderr = global i32 0
@.str = [59 x i8] c"%s: ERROR! Too many iterations in routine \22gamma_help_2\22!\0A\00"
define double @gamma_help_2(double %0, double %1, i8* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i8*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double %0, double* %4
store double %1, double* %5
store i8* %2, i8** %6
%16 = load i32, i32* @DBL_MIN
%17 = mul nsw i32 1000, %16
%18 = sitofp i32 %17 to double
store double %18, double* %15
%19 = load double, double* %4
%20 = call double @lngamma(double %19)
store double %20, double* %13
%21 = load double, double* %5
%22 = fadd double %21, 1.000000e+00
%23 = load double, double* %4
%24 = fsub double %22, %23
store double %24, double* %9
%25 = load double, double* %15
%26 = fdiv double 1.000000e+00, %25
store double %26, double* %10
%27 = load double, double* %9
%28 = fdiv double 1.000000e+00, %27
store double %28, double* %11
%29 = load double, double* %11
store double %29, double* %14
store i32 1, i32* %7
br label %30
30: ; preds = %92, %3
%31 = load i32, i32* %7
%32 = icmp sle i32 %31, 100
br i1 %32, label %33, label %95
33: ; preds = %30
%34 = load i32, i32* %7
%35 = sub nsw i32 0, %34
%36 = sitofp i32 %35 to double
%37 = load i32, i32* %7
%38 = sitofp i32 %37 to double
%39 = load double, double* %4
%40 = fsub double %38, %39
%41 = fmul double %36, %40
store double %41, double* %8
%42 = load double, double* %9
%43 = fadd double %42, 2.000000e+00
store double %43, double* %9
%44 = load double, double* %8
%45 = load double, double* %11
%46 = load double, double* %9
%47 = call double @llvm.fmuladd.f64(double %44, double %45, double %46)
store double %47, double* %11
%48 = load double, double* %11
%49 = call double @fabs(double %48)
%50 = load double, double* %15
%51 = fcmp olt double %49, %50
br i1 %51, label %52, label %54
52: ; preds = %33
%53 = load double, double* %15
store double %53, double* %11
br label %54
54: ; preds = %52, %33
%55 = load double, double* %9
%56 = load double, double* %8
%57 = load double, double* %10
%58 = fdiv double %56, %57
%59 = fadd double %55, %58
store double %59, double* %10
%60 = load double, double* %10
%61 = call double @fabs(double %60)
%62 = load double, double* %15
%63 = fcmp olt double %61, %62
br i1 %63, label %64, label %66
64: ; preds = %54
%65 = load double, double* %15
store double %65, double* %10
br label %66
66: ; preds = %64, %54
%67 = load double, double* %11
%68 = fdiv double 1.000000e+00, %67
store double %68, double* %11
%69 = load double, double* %11
%70 = load double, double* %10
%71 = fmul double %69, %70
store double %71, double* %12
%72 = load double, double* %12
%73 = load double, double* %14
%74 = fmul double %73, %72
store double %74, double* %14
%75 = load double, double* %12
%76 = fsub double %75, 1.000000e+00
%77 = call double @fabs(double %76)
%78 = fcmp olt double %77, 0x3BC79CA10C924223
br i1 %78, label %79, label %91
79: ; preds = %66
%80 = load double, double* %5
%81 = fneg double %80
%82 = load double, double* %4
%83 = load double, double* %5
%84 = call double @log(double %83)
%85 = call double @llvm.fmuladd.f64(double %82, double %84, double %81)
%86 = load double, double* %13
%87 = fsub double %85, %86
%88 = call double @exp(double %87)
%89 = load double, double* %14
%90 = fmul double %88, %89
ret double %90
91: ; preds = %66
br label %92
92: ; preds = %91
%93 = load i32, i32* %7
%94 = add nsw i32 %93, 1
store i32 %94, i32* %7
br label %30
95: ; preds = %30
%96 = load i32, i32* @stderr
%97 = load i8*, i8** %6
%98 = call i32 @fprintf(i32 %96, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %97)
%99 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@DBL_MIN = global i32 0
@stderr = global i32 0
@.str = [59 x i8] c"%s: ERROR! Too many iterations in routine \22gamma_help_2\22!\0A\00"
define double @gamma_help_2(double %0, double %1, i8* %2) {
%4 = load i32, i32* @DBL_MIN
%5 = mul nsw i32 %4, 1000
%6 = sitofp i32 %5 to double
%7 = tail call double @lngamma(double %0)
%8 = fadd double %1, 1.000000e+00
%9 = fsub double %8, %0
%10 = fdiv double 1.000000e+00, %6
%11 = fdiv double 1.000000e+00, %9
br label %15
12: ; preds = %15
%13 = add nuw nsw i32 %16, 1
%14 = icmp eq i32 %13, 101
br i1 %14, label %49, label %15
15: ; preds = %3, %12
%16 = phi i32 [ 1, %3 ], [ %13, %12 ]
%17 = phi double [ %11, %3 ], [ %38, %12 ]
%18 = phi double [ %9, %3 ], [ %26, %12 ]
%19 = phi double [ %10, %3 ], [ %35, %12 ]
%20 = phi double [ %11, %3 ], [ %36, %12 ]
%21 = sub nsw i32 0, %16
%22 = sitofp i32 %21 to double
%23 = sitofp i32 %16 to double
%24 = fsub double %23, %0
%25 = fmul double %24, %22
%26 = fadd double %18, 2.000000e+00
%27 = tail call double @llvm.fmuladd.f64(double %25, double %20, double %26)
%28 = tail call double @llvm.fabs.f64(double %27)
%29 = fcmp olt double %28, %6
%30 = select i1 %29, double %6, double %27
%31 = fdiv double %25, %19
%32 = fadd double %26, %31
%33 = tail call double @llvm.fabs.f64(double %32)
%34 = fcmp olt double %33, %6
%35 = select i1 %34, double %6, double %32
%36 = fdiv double 1.000000e+00, %30
%37 = fmul double %36, %35
%38 = fmul double %17, %37
%39 = fadd double %37, -1.000000e+00
%40 = tail call double @llvm.fabs.f64(double %39)
%41 = fcmp olt double %40, 0x3BC79CA10C924223
br i1 %41, label %42, label %12
42: ; preds = %15
%43 = fneg double %1
%44 = tail call double @log(double %1)
%45 = tail call double @llvm.fmuladd.f64(double %0, double %44, double %43)
%46 = fsub double %45, %7
%47 = tail call double @exp(double %46)
%48 = fmul double %38, %47
ret double %48
49: ; preds = %12
%50 = load i32, i32* @stderr
%51 = tail call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %2)
%52 = tail call i32 @exit(i32 1)
unreachable
}