#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 exp(double);
double fabs(double);
double log(double);
void gser(double *gamser, double a, double x, double *gln) {
  double gammln(double xx);
  void nrerror(char error_text[]);
  int n;
  double sum, del, ap;
  *gln = gammln(a);
  if (x <= 0.0) {
    if (x < 0.0)
      nrerror("x less than 0 in routine gser");
    *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) * 3.0e-7) {
        *gamser = sum * exp(-x + a * log(x) - (*gln));
        return;
      }
    }
    nrerror("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 <gammln@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11a4 <gser+0x64>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1194 <gser+0x54>
lea    0xe91(%rip),%rdi
call   1030 <nrerror@plt>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    12da <gser+0x19a>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe4a(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jg     12ce <gser+0x18e>
movsd  0xe22(%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 0xdf9(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movaps 0xde9(%rip),%xmm2
pand   %xmm2,%xmm0
movsd  0xdd5(%rip),%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    12bb <gser+0x17b>
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   1050 <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   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12da <gser+0x19a>
jmp    12c0 <gser+0x180>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11cc <gser+0x8c>
lea    0xd69(%rip),%rdi
call   1030 <nrerror@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 <gammln@plt>
movsd  0x8(%rsp),%xmm7
movsd  %xmm0,(%rbx)
xorpd  %xmm0,%xmm0
ucomisd %xmm7,%xmm0
jae    11fb <gser+0xbb>
movsd  0xe82(%rip),%xmm9
movapd %xmm9,%xmm3
movsd  (%rsp),%xmm8
divsd  %xmm8,%xmm3
mov    $0x64,%eax
movapd 0xe75(%rip),%xmm1
movsd  0xe65(%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     1212 <gser+0xd2>
add    $0xffffffff,%eax
jne    11b0 <gser+0x70>
lea    0xe4f(%rip),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r14
jmp    1030 <nrerror@plt>
jbe    1209 <gser+0xc9>
lea    0xe1c(%rip),%rdi
call   1030 <nrerror@plt>
movq   $0x0,(%r14)
jmp    1244 <gser+0x104>
movapd %xmm7,%xmm0
movapd %xmm2,0x10(%rsp)
call   1050 <log@plt>
mulsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
subsd  (%rbx),%xmm0
call   1040 <exp@plt>
movapd 0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [30 x i8] c"x less than 0 in routine gser\00"
@.str.1 = [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 @gammln(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 olt double %19, 0.000000e+00
br i1 %20, label %21, label %22
21: ; preds = %18
br label %22
22: ; preds = %21, %18
%23 = load double*, double** %5
store double 0.000000e+00, double* %23
br label %67
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, 3.000000e-07
%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 %67
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
br label %67
67: ; preds = %66, %48, %22
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"x less than 0 in routine gser\00"
@.str.1 = [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 @gammln(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 olt double %2, 0.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %7
tail call void @nrerror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %9, %7
store double 0.000000e+00, double* %0
br label %38
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, 3.000000e-07
%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 %38
37: ; preds = %13
tail call void @nrerror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %38
38: ; preds = %37, %29, %10
ret void
}