#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 DBL_EPSILON;
double exp(double);
double fabs(double);
double gammaln(double);
double log(double);
int /*<<< orphan*/ puts(char *);
void gammaser(double *gser, double a, double x) {
  int n, ITMAX = 100;
  double sum, del, ap, gln, eps = DBL_EPSILON;
  gln = gammaln(a);
  if (x <= 0.0) {
    if (x < 0.0)
      puts("uwerr: x less than 0 in gammaser.");
    *gser = 0.0;
    return;
  } else {
    ap = a;
    del = sum = 1.0 / a;
    for (n = 0; n < ITMAX; ++n) {
      ++ap;
      del *= x / ap;
      sum += del;
      if (fabs(del) < fabs(sum) * eps) {
        *gser = sum * exp(-x + a * log(x) - gln);
        return;
      }
    }
    puts("uwerr: a too large, ITMAX too small in gammaser.");
  }
}


x86 assembly (clang, -O0):
<gammaser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movl   $0x64,-0x20(%rbp)
mov    0x2e84(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <gammaln@plt>
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11b4 <gammaser+0x74>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11a4 <gammaser+0x64>
lea    0xe81(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    12e2 <gammaser+0x1a2>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe3a(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    12d6 <gammaser+0x196>
movsd  0xe10(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm1
movaps 0xde7(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movaps 0xdd7(%rip),%xmm2
pand   %xmm2,%xmm0
mulsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12c3 <gammaser+0x183>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <log@plt>
movsd  -0x60(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x40(%rbp),%xmm0
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12e2 <gammaser+0x1a2>
jmp    12c8 <gammaser+0x188>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11dc <gammaser+0x9c>
lea    0xd65(%rip),%rdi
call   1040 <puts@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammaser>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,%xmm1
mov    %rdi,%rbx
mov    0x2e8f(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1030 <gammaln@plt>
movsd  0x8(%rsp),%xmm6
xorpd  %xmm1,%xmm1
ucomisd %xmm6,%xmm1
jae    1209 <gammaser+0xc9>
movsd  %xmm0,0x28(%rsp)
movsd  0xe6c(%rip),%xmm9
movapd %xmm9,%xmm7
movsd  (%rsp),%xmm8
divsd  %xmm8,%xmm7
mov    $0x64,%eax
movapd 0xe5f(%rip),%xmm1
movapd %xmm8,%xmm2
movapd %xmm7,%xmm3
movsd  0x10(%rsp),%xmm0
movapd %xmm3,%xmm4
addsd  %xmm9,%xmm2
movapd %xmm6,%xmm3
divsd  %xmm2,%xmm3
mulsd  %xmm4,%xmm3
addsd  %xmm3,%xmm7
movapd %xmm3,%xmm4
andpd  %xmm1,%xmm4
movapd %xmm7,%xmm5
andpd  %xmm1,%xmm5
mulsd  %xmm0,%xmm5
ucomisd %xmm4,%xmm5
ja     1220 <gammaser+0xe0>
add    $0xffffffff,%eax
jne    11c0 <gammaser+0x80>
lea    0xe43(%rip),%rdi
add    $0x30,%rsp
pop    %rbx
jmp    1040 <puts@plt>
jbe    1217 <gammaser+0xd7>
lea    0xe0e(%rip),%rdi
call   1040 <puts@plt>
movq   $0x0,(%rbx)
jmp    1253 <gammaser+0x113>
movapd %xmm6,%xmm0
movapd %xmm7,0x10(%rsp)
call   1060 <log@plt>
mulsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
subsd  0x28(%rsp),%xmm0
call   1050 <exp@plt>
movapd 0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@DBL_EPSILON = global double 0.000000e+00
@.str = [34 x i8] c"uwerr: x less than 0 in gammaser.\00"
@.str.1 = [49 x i8] c"uwerr: a too large, ITMAX too small in gammaser.\00"
define void @gammaser(double* %0, double %1, double %2) {
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double* %0, double** %4
store double %1, double* %5
store double %2, double* %6
store i32 100, i32* %8
%14 = load double, double* @DBL_EPSILON
store double %14, double* %13
%15 = load double, double* %5
%16 = call double @gammaln(double %15)
store double %16, double* %12
%17 = load double, double* %6
%18 = fcmp ole double %17, 0.000000e+00
br i1 %18, label %19, label %26
19: ; preds = %3
%20 = load double, double* %6
%21 = fcmp olt double %20, 0.000000e+00
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
%25 = load double*, double** %4
store double 0.000000e+00, double* %25
br label %71
26: ; preds = %3
%27 = load double, double* %5
store double %27, double* %11
%28 = load double, double* %5
%29 = fdiv double 1.000000e+00, %28
store double %29, double* %9
store double %29, double* %10
store i32 0, i32* %7
br label %30
30: ; preds = %66, %26
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %69
34: ; preds = %30
%35 = load double, double* %11
%36 = fadd double %35, 1.000000e+00
store double %36, double* %11
%37 = load double, double* %6
%38 = load double, double* %11
%39 = fdiv double %37, %38
%40 = load double, double* %10
%41 = fmul double %40, %39
store double %41, double* %10
%42 = load double, double* %10
%43 = load double, double* %9
%44 = fadd double %43, %42
store double %44, double* %9
%45 = load double, double* %10
%46 = call double @llvm.fabs.f64(double %45)
%47 = load double, double* %9
%48 = call double @llvm.fabs.f64(double %47)
%49 = load double, double* %13
%50 = fmul double %48, %49
%51 = fcmp olt double %46, %50
br i1 %51, label %52, label %65
52: ; preds = %34
%53 = load double, double* %9
%54 = load double, double* %6
%55 = fneg double %54
%56 = load double, double* %5
%57 = load double, double* %6
%58 = call double @log(double %57)
%59 = call double @llvm.fmuladd.f64(double %56, double %58, double %55)
%60 = load double, double* %12
%61 = fsub double %59, %60
%62 = call double @exp(double %61)
%63 = fmul double %53, %62
%64 = load double*, double** %4
store double %63, double* %64
br label %71
65: ; preds = %34
br label %66
66: ; preds = %65
%67 = load i32, i32* %7
%68 = add nsw i32 %67, 1
store i32 %68, i32* %7
br label %30
69: ; preds = %30
%70 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
br label %71
71: ; preds = %24, %52, %69
ret void
}

LLVM IR (-O2):
@DBL_EPSILON = global double 0.000000e+00
@.str = [34 x i8] c"uwerr: x less than 0 in gammaser.\00"
@.str.1 = [49 x i8] c"uwerr: a too large, ITMAX too small in gammaser.\00"
define void @gammaser(double* nocapture writeonly %0, double %1, double %2) {
%4 = load double, double* @DBL_EPSILON
%5 = tail call double @gammaln(double %1)
%6 = fcmp ugt double %2, 0.000000e+00
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = fcmp olt double %2, 0.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %7
store double 0.000000e+00, double* %0
br label %39
12: ; preds = %3
%13 = fdiv double 1.000000e+00, %1
br label %17
14: ; preds = %17
%15 = add nuw nsw i32 %18, 1
%16 = icmp eq i32 %15, 100
br i1 %16, label %37, label %17
17: ; preds = %12, %14
%18 = phi i32 [ 0, %12 ], [ %15, %14 ]
%19 = phi double [ %13, %12 ], [ %25, %14 ]
%20 = phi double [ %1, %12 ], [ %22, %14 ]
%21 = phi double [ %13, %12 ], [ %24, %14 ]
%22 = fadd double %20, 1.000000e+00
%23 = fdiv double %2, %22
%24 = fmul double %21, %23
%25 = fadd double %19, %24
%26 = tail call double @llvm.fabs.f64(double %24)
%27 = tail call double @llvm.fabs.f64(double %25)
%28 = fmul double %4, %27
%29 = fcmp olt double %26, %28
br i1 %29, label %30, label %14
30: ; preds = %17
%31 = fneg double %2
%32 = tail call double @log(double %2)
%33 = tail call double @llvm.fmuladd.f64(double %1, double %32, double %31)
%34 = fsub double %33, %5
%35 = tail call double @exp(double %34)
%36 = fmul double %25, %35
store double %36, double* %0
br label %39
37: ; preds = %14
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %30, %11
ret void
}