#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*/ assert(int);
double exp(double);
double fabs(double);
double lgamma(double);
double log(double);
int /*<<< orphan*/ printf(char *);
void gser(double *gamser, double a, double x, double *gln) {
  int n;
  double sum, del, ap;
  *gln = lgamma(a);
  if (x <= 0.0) {
    assert(x >= 0.);
    *gamser = 0.0;
    return;
  } else {
    ap = a;
    del = sum = 1.0 / a;
    for (n = 1; n <= 100; n++) {
      ++ap;
      del *= x / ap;
      sum += del;
      if (fabs(del) < fabs(sum) * 1.0e-9) {
        *gamser = sum * exp(-x + a * log(x) - (*gln));
        return;
      }
    }
    printf("a too large, ITMAX too small in routine gser");
    return;
  }
}


x86 assembly (clang, -O0):
<gser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <lgamma@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11b3 <gser+0x63>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    12e9 <gser+0x199>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe3b(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jg     12dd <gser+0x18d>
movsd  0xe13(%rip),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm1
movaps 0xdea(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movaps 0xdda(%rip),%xmm2
pand   %xmm2,%xmm0
movsd  0xdc6(%rip),%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    12ca <gser+0x17a>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1070 <log@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
subsd  (%rax),%xmm0
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12e9 <gser+0x199>
jmp    12cf <gser+0x17f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11db <gser+0x8b>
lea    0xd3c(%rip),%rdi
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gser>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
movsd  %xmm1,0x8(%rsp)
mov    %rdi,%r14
movsd  %xmm0,(%rsp)
call   1060 <lgamma@plt>
movsd  0x8(%rsp),%xmm7
movsd  %xmm0,(%rbx)
xorpd  %xmm0,%xmm0
ucomisd %xmm7,%xmm0
jae    120b <gser+0xbb>
movsd  0xe72(%rip),%xmm9
movapd %xmm9,%xmm3
movsd  (%rsp),%xmm8
divsd  %xmm8,%xmm3
mov    $0x64,%eax
movapd 0xe65(%rip),%xmm1
movsd  0xe55(%rip),%xmm0
movapd %xmm8,%xmm4
movapd %xmm3,%xmm2
nopl   0x0(%rax)
movapd %xmm3,%xmm5
addsd  %xmm9,%xmm4
movapd %xmm7,%xmm3
divsd  %xmm4,%xmm3
mulsd  %xmm5,%xmm3
addsd  %xmm3,%xmm2
movapd %xmm3,%xmm5
andpd  %xmm1,%xmm5
movapd %xmm2,%xmm6
andpd  %xmm1,%xmm6
mulsd  %xmm0,%xmm6
ucomisd %xmm5,%xmm6
ja     1223 <gser+0xd3>
add    $0xffffffff,%eax
jne    11c0 <gser+0x70>
lea    0xe21(%rip),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>
xor    %edi,%edi
ucomisd %xmm0,%xmm7
setae  %dil
call   1040 <assert@plt>
movq   $0x0,(%r14)
jmp    1255 <gser+0x105>
movapd %xmm7,%xmm0
movapd %xmm2,0x10(%rsp)
call   1070 <log@plt>
mulsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
subsd  (%rbx),%xmm0
call   1050 <exp@plt>
movapd 0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

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