#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 */
float exp(float);
double fabs(float);
float log(float);
void gser(float *gamser, float a, float x, float *gln) {
  float gammln(float xx);
  void nrerror(char error_text[]);
  int n;
  float 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    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
call   1070 <gammln@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     11c4 <gser+0x74>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11b4 <gser+0x64>
lea    0xe65(%rip),%rdi
call   1030 <nrerror@plt>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
jmp    12fa <gser+0x1aa>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe21(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  %xmm0,-0x24(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jg     12ee <gser+0x19e>
movss  0xe06(%rip),%xmm0
addss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x10(%rbp),%xmm0
divss  -0x28(%rbp),%xmm0
mulss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x24(%rbp),%xmm0
call   1040 <fabs@plt>
movsd  %xmm0,-0x30(%rbp)
movss  -0x20(%rbp),%xmm0
call   1040 <fabs@plt>
movsd  -0x30(%rbp),%xmm1
movsd  0xdab(%rip),%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    12db <gser+0x18b>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x10(%rbp),%xmm0
call   1060 <log@plt>
movss  -0x3c(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x38(%rbp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
subss  (%rax),%xmm0
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
jmp    12fa <gser+0x1aa>
jmp    12e0 <gser+0x190>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f8 <gser+0xa8>
lea    0xd3d(%rip),%rdi
call   1030 <nrerror@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gser>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
movss  %xmm1,0x8(%rsp)
mov    %rdi,%r14
movss  %xmm0,0x14(%rsp)
call   1070 <gammln@plt>
movss  0x8(%rsp),%xmm1
movss  %xmm0,(%rbx)
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
jae    12a7 <gser+0x157>
movss  0xe73(%rip),%xmm3
movaps %xmm3,%xmm0
movss  0x14(%rsp),%xmm4
divss  %xmm4,%xmm0
mov    $0x64,%ebp
movaps %xmm0,%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movaps %xmm0,%xmm5
addss  %xmm3,%xmm4
movss  %xmm4,0x10(%rsp)
movaps %xmm1,%xmm0
divss  %xmm4,%xmm0
mulss  %xmm5,%xmm0
addss  %xmm0,%xmm2
movss  %xmm2,0x4(%rsp)
movss  %xmm0,0xc(%rsp)
call   1040 <fabs@plt>
movsd  %xmm0,0x18(%rsp)
movss  0x4(%rsp),%xmm0
call   1040 <fabs@plt>
mulsd  0xe12(%rip),%xmm0
ucomisd 0x18(%rsp),%xmm0
ja     12be <gser+0x16e>
movss  0x10(%rsp),%xmm0
addss  0xdf0(%rip),%xmm0
movss  0x8(%rsp),%xmm1
movss  %xmm0,0x10(%rsp)
divss  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
mulss  %xmm1,%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  %xmm0,0xc(%rsp)
call   1040 <fabs@plt>
movsd  %xmm0,0x18(%rsp)
movss  0x4(%rsp),%xmm0
call   1040 <fabs@plt>
movsd  0xdaa(%rip),%xmm1
mulsd  %xmm1,%xmm0
ucomisd 0x18(%rsp),%xmm0
ja     12be <gser+0x16e>
add    $0xfffffffe,%ebp
movss  0x8(%rsp),%xmm1
movss  0x4(%rsp),%xmm2
movss  0xd7f(%rip),%xmm3
movss  0x10(%rsp),%xmm4
movss  0xc(%rsp),%xmm0
jne    11b0 <gser+0x60>
lea    0xd94(%rip),%rdi
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <nrerror@plt>
jbe    12b5 <gser+0x165>
lea    0xd60(%rip),%rdi
call   1030 <nrerror@plt>
movl   $0x0,(%r14)
jmp    12e9 <gser+0x199>
movss  0x8(%rsp),%xmm0
call   1060 <log@plt>
mulss  0x14(%rsp),%xmm0
subss  0x8(%rsp),%xmm0
subss  (%rbx),%xmm0
call   1050 <exp@plt>
mulss  0x4(%rsp),%xmm0
movss  %xmm0,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
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(float* %0, float %1, float %2, float* %3) {
%5 = alloca float*
%6 = alloca float
%7 = alloca float
%8 = alloca float*
%9 = alloca i32
%10 = alloca float
%11 = alloca float
%12 = alloca float
store float* %0, float** %5
store float %1, float* %6
store float %2, float* %7
store float* %3, float** %8
%13 = load float, float* %6
%14 = call float @gammln(float %13)
%15 = load float*, float** %8
store float %14, float* %15
%16 = load float, float* %7
%17 = fpext float %16 to double
%18 = fcmp ole double %17, 0.000000e+00
br i1 %18, label %19, label %26
19: ; preds = %4
%20 = load float, float* %7
%21 = fpext float %20 to double
%22 = fcmp olt double %21, 0.000000e+00
br i1 %22, label %23, label %24
23: ; preds = %19
br label %24
24: ; preds = %23, %19
%25 = load float*, float** %5
store float 0.000000e+00, float* %25
br label %71
26: ; preds = %4
%27 = load float, float* %6
store float %27, float* %12
%28 = load float, float* %6
%29 = fpext float %28 to double
%30 = fdiv double 1.000000e+00, %29
%31 = fptrunc double %30 to float
store float %31, float* %10
store float %31, float* %11
store i32 1, i32* %9
br label %32
32: ; preds = %67, %26
%33 = load i32, i32* %9
%34 = icmp sle i32 %33, 100
br i1 %34, label %35, label %70
35: ; preds = %32
%36 = load float, float* %12
%37 = fadd float %36, 1.000000e+00
store float %37, float* %12
%38 = load float, float* %7
%39 = load float, float* %12
%40 = fdiv float %38, %39
%41 = load float, float* %11
%42 = fmul float %41, %40
store float %42, float* %11
%43 = load float, float* %11
%44 = load float, float* %10
%45 = fadd float %44, %43
store float %45, float* %10
%46 = load float, float* %11
%47 = call double @fabs(float %46)
%48 = load float, float* %10
%49 = call double @fabs(float %48)
%50 = fmul double %49, 3.000000e-07
%51 = fcmp olt double %47, %50
br i1 %51, label %52, label %66
52: ; preds = %35
%53 = load float, float* %10
%54 = load float, float* %7
%55 = fneg float %54
%56 = load float, float* %6
%57 = load float, float* %7
%58 = call float @log(float %57)
%59 = call float @llvm.fmuladd.f32(float %56, float %58, float %55)
%60 = load float*, float** %8
%61 = load float, float* %60
%62 = fsub float %59, %61
%63 = call float @exp(float %62)
%64 = fmul float %53, %63
%65 = load float*, float** %5
store float %64, float* %65
br label %71
66: ; preds = %35
br label %67
67: ; preds = %66
%68 = load i32, i32* %9
%69 = add nsw i32 %68, 1
store i32 %69, i32* %9
br label %32
70: ; preds = %32
br label %71
71: ; preds = %70, %52, %24
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(float* nocapture writeonly %0, float %1, float %2, float* nocapture %3) {
%5 = tail call float @gammln(float %1)
store float %5, float* %3
%6 = fcmp ugt float %2, 0.000000e+00
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = fcmp olt float %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 float 0.000000e+00, float* %0
br label %48
11: ; preds = %4
%12 = fdiv float 1.000000e+00, %1
br label %25
13: ; preds = %25
%14 = fadd float %30, 1.000000e+00
%15 = fdiv float %2, %14
%16 = fmul float %32, %15
%17 = fadd float %33, %16
%18 = tail call double @fabs(float %16)
%19 = tail call double @fabs(float %17)
%20 = fmul double %19, 3.000000e-07
%21 = fcmp olt double %18, %20
br i1 %21, label %38, label %22
22: ; preds = %13
%23 = add nuw nsw i32 %29, 2
%24 = icmp eq i32 %23, 101
br i1 %24, label %47, label %25
25: ; preds = %22, %11
%26 = phi float [ %1, %11 ], [ %14, %22 ]
%27 = phi float [ %12, %11 ], [ %16, %22 ]
%28 = phi float [ %12, %11 ], [ %17, %22 ]
%29 = phi i32 [ 1, %11 ], [ %23, %22 ]
%30 = fadd float %26, 1.000000e+00
%31 = fdiv float %2, %30
%32 = fmul float %27, %31
%33 = fadd float %28, %32
%34 = tail call double @fabs(float %32)
%35 = tail call double @fabs(float %33)
%36 = fmul double %35, 3.000000e-07
%37 = fcmp olt double %34, %36
br i1 %37, label %38, label %13
38: ; preds = %13, %25
%39 = phi float [ %33, %25 ], [ %17, %13 ]
%40 = fneg float %2
%41 = tail call float @log(float %2)
%42 = tail call float @llvm.fmuladd.f32(float %1, float %41, float %40)
%43 = load float, float* %3
%44 = fsub float %42, %43
%45 = tail call float @exp(float %44)
%46 = fmul float %39, %45
store float %46, float* %0
br label %48
47: ; preds = %22
tail call void @nrerror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %47, %38, %10
ret void
}