#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*/ 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_1(double a, double x, const char *prompt) {
  int i;
  double ap, del, gln, sum;
  static const double eps = 1e-20;
  gln = lngamma(a);
  ap = a;
  del = sum = 1 / a;
  for (i = 1; i <= 100; i++) {
    ap++;
    del *= x / ap;
    sum += del;
    if (fabs(del) < fabs(sum) * eps)
      return sum * exp(-x + a * log(x) - (gln));
  }
  fprintf(stderr,
          "%s: ERROR! Too many iterations in routine \"gamma_help_1\"!\n",
          prompt);
  exit(1);
  return 0;
}


x86 assembly (clang, -O0):
<gamma_help_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1060 <lngamma@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe69(%rip),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  %xmm0,-0x30(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jg     12a3 <gamma_help_1+0x143>
movsd  0xe41(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <fabs@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <fabs@plt>
movsd  -0x48(%rbp),%xmm1
movsd  0xdf6(%rip),%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    1290 <gamma_help_1+0x130>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <log@plt>
movsd  -0x60(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x38(%rbp),%xmm0
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x60,%rsp
pop    %rbp
ret
jmp    1295 <gamma_help_1+0x135>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ad <gamma_help_1+0x4d>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd61(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<gamma_help_1>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1050 <lngamma@plt>
movsd  0x8(%rsp),%xmm2
movaps %xmm0,%xmm9
movsd  0xe84(%rip),%xmm8
movapd %xmm8,%xmm7
movsd  0x10(%rsp),%xmm3
divsd  %xmm3,%xmm7
mov    $0x64,%eax
movapd 0xe78(%rip),%xmm1
movsd  0xe68(%rip),%xmm0
movapd %xmm7,%xmm4
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movapd %xmm4,%xmm5
addsd  %xmm8,%xmm3
movapd %xmm2,%xmm4
divsd  %xmm3,%xmm4
mulsd  %xmm5,%xmm4
addsd  %xmm4,%xmm7
movapd %xmm4,%xmm5
andpd  %xmm1,%xmm5
movapd %xmm7,%xmm6
andpd  %xmm1,%xmm6
mulsd  %xmm0,%xmm6
ucomisd %xmm5,%xmm6
ja     120a <gamma_help_1+0xba>
add    $0xffffffff,%eax
jne    11b0 <gamma_help_1+0x60>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
lea    0xe28(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movapd %xmm2,%xmm0
movapd %xmm7,0x20(%rsp)
movsd  %xmm9,0x18(%rsp)
call   1060 <log@plt>
mulsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
call   1040 <exp@plt>
mulsd  0x20(%rsp),%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@gamma_help_1.eps = internal constant double 0x3BC79CA10C924223
@stderr = global i32 0
@.str = [59 x i8] c"%s: ERROR! Too many iterations in routine \22gamma_help_1\22!\0A\00"
define double @gamma_help_1(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
store double %0, double* %4
store double %1, double* %5
store i8* %2, i8** %6
%12 = load double, double* %4
%13 = call double @lngamma(double %12)
store double %13, double* %10
%14 = load double, double* %4
store double %14, double* %8
%15 = load double, double* %4
%16 = fdiv double 1.000000e+00, %15
store double %16, double* %11
store double %16, double* %9
store i32 1, i32* %7
br label %17
17: ; preds = %50, %3
%18 = load i32, i32* %7
%19 = icmp sle i32 %18, 100
br i1 %19, label %20, label %53
20: ; preds = %17
%21 = load double, double* %8
%22 = fadd double %21, 1.000000e+00
store double %22, double* %8
%23 = load double, double* %5
%24 = load double, double* %8
%25 = fdiv double %23, %24
%26 = load double, double* %9
%27 = fmul double %26, %25
store double %27, double* %9
%28 = load double, double* %9
%29 = load double, double* %11
%30 = fadd double %29, %28
store double %30, double* %11
%31 = load double, double* %9
%32 = call double @fabs(double %31)
%33 = load double, double* %11
%34 = call double @fabs(double %33)
%35 = fmul double %34, 0x3BC79CA10C924223
%36 = fcmp olt double %32, %35
br i1 %36, label %37, label %49
37: ; preds = %20
%38 = load double, double* %11
%39 = load double, double* %5
%40 = fneg double %39
%41 = load double, double* %4
%42 = load double, double* %5
%43 = call double @log(double %42)
%44 = call double @llvm.fmuladd.f64(double %41, double %43, double %40)
%45 = load double, double* %10
%46 = fsub double %44, %45
%47 = call double @exp(double %46)
%48 = fmul double %38, %47
ret double %48
49: ; preds = %20
br label %50
50: ; preds = %49
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %17
53: ; preds = %17
%54 = load i32, i32* @stderr
%55 = load i8*, i8** %6
%56 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [59 x i8] c"%s: ERROR! Too many iterations in routine \22gamma_help_1\22!\0A\00"
define double @gamma_help_1(double %0, double %1, i8* %2) {
%4 = tail call double @lngamma(double %0)
%5 = fdiv double 1.000000e+00, %0
br label %9
6: ; preds = %9
%7 = add nuw nsw i32 %11, 1
%8 = icmp eq i32 %7, 101
br i1 %8, label %29, label %9
9: ; preds = %3, %6
%10 = phi double [ %5, %3 ], [ %17, %6 ]
%11 = phi i32 [ 1, %3 ], [ %7, %6 ]
%12 = phi double [ %5, %3 ], [ %16, %6 ]
%13 = phi double [ %0, %3 ], [ %14, %6 ]
%14 = fadd double %13, 1.000000e+00
%15 = fdiv double %1, %14
%16 = fmul double %12, %15
%17 = fadd double %10, %16
%18 = tail call double @llvm.fabs.f64(double %16)
%19 = tail call double @llvm.fabs.f64(double %17)
%20 = fmul double %19, 0x3BC79CA10C924223
%21 = fcmp olt double %18, %20
br i1 %21, label %22, label %6
22: ; preds = %9
%23 = fneg double %1
%24 = tail call double @log(double %1)
%25 = tail call double @llvm.fmuladd.f64(double %0, double %24, double %23)
%26 = fsub double %25, %4
%27 = tail call double @exp(double %26)
%28 = fmul double %17, %27
ret double %28
29: ; preds = %6
%30 = load i32, i32* @stderr
%31 = tail call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %2)
%32 = tail call i32 @exit(i32 1)
unreachable
}