#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 gammln(float);
float log(float);
int /*<<< orphan*/ nrerror(char *);
void gser(float *gamser, float a, float x, float *gln) {
  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 %27
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 %25
23: ; preds = %19
%24 = call i32 @nrerror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23, %19
%26 = load float*, float** %5
store float 0.000000e+00, float* %26
br label %73
27: ; preds = %4
%28 = load float, float* %6
store float %28, float* %12
%29 = load float, float* %6
%30 = fpext float %29 to double
%31 = fdiv double 1.000000e+00, %30
%32 = fptrunc double %31 to float
store float %32, float* %10
store float %32, float* %11
store i32 1, i32* %9
br label %33
33: ; preds = %68, %27
%34 = load i32, i32* %9
%35 = icmp sle i32 %34, 100
br i1 %35, label %36, label %71
36: ; preds = %33
%37 = load float, float* %12
%38 = fadd float %37, 1.000000e+00
store float %38, float* %12
%39 = load float, float* %7
%40 = load float, float* %12
%41 = fdiv float %39, %40
%42 = load float, float* %11
%43 = fmul float %42, %41
store float %43, float* %11
%44 = load float, float* %11
%45 = load float, float* %10
%46 = fadd float %45, %44
store float %46, float* %10
%47 = load float, float* %11
%48 = call double @fabs(float %47)
%49 = load float, float* %10
%50 = call double @fabs(float %49)
%51 = fmul double %50, 3.000000e-07
%52 = fcmp olt double %48, %51
br i1 %52, label %53, label %67
53: ; preds = %36
%54 = load float, float* %10
%55 = load float, float* %7
%56 = fneg float %55
%57 = load float, float* %6
%58 = load float, float* %7
%59 = call float @log(float %58)
%60 = call float @llvm.fmuladd.f32(float %57, float %59, float %56)
%61 = load float*, float** %8
%62 = load float, float* %61
%63 = fsub float %60, %62
%64 = call float @exp(float %63)
%65 = fmul float %54, %64
%66 = load float*, float** %5
store float %65, float* %66
br label %73
67: ; preds = %36
br label %68
68: ; preds = %67
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 1
store i32 %70, i32* %9
br label %33
71: ; preds = %33
%72 = call i32 @nrerror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %73
73: ; preds = %71, %53, %25
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 %12, label %7
7: ; preds = %4
%8 = fcmp olt float %2, 0.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 @nrerror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %7
store float 0.000000e+00, float* %0
br label %50
12: ; preds = %4
%13 = fdiv float 1.000000e+00, %1
br label %26
14: ; preds = %26
%15 = fadd float %31, 1.000000e+00
%16 = fdiv float %2, %15
%17 = fmul float %33, %16
%18 = fadd float %34, %17
%19 = tail call double @fabs(float %17)
%20 = tail call double @fabs(float %18)
%21 = fmul double %20, 3.000000e-07
%22 = fcmp olt double %19, %21
br i1 %22, label %39, label %23
23: ; preds = %14
%24 = add nuw nsw i32 %30, 2
%25 = icmp eq i32 %24, 101
br i1 %25, label %48, label %26
26: ; preds = %23, %12
%27 = phi float [ %1, %12 ], [ %15, %23 ]
%28 = phi float [ %13, %12 ], [ %17, %23 ]
%29 = phi float [ %13, %12 ], [ %18, %23 ]
%30 = phi i32 [ 1, %12 ], [ %24, %23 ]
%31 = fadd float %27, 1.000000e+00
%32 = fdiv float %2, %31
%33 = fmul float %28, %32
%34 = fadd float %29, %33
%35 = tail call double @fabs(float %33)
%36 = tail call double @fabs(float %34)
%37 = fmul double %36, 3.000000e-07
%38 = fcmp olt double %35, %37
br i1 %38, label %39, label %14
39: ; preds = %14, %26
%40 = phi float [ %34, %26 ], [ %18, %14 ]
%41 = fneg float %2
%42 = tail call float @log(float %2)
%43 = tail call float @llvm.fmuladd.f32(float %1, float %42, float %41)
%44 = load float, float* %3
%45 = fsub float %43, %44
%46 = tail call float @exp(float %45)
%47 = fmul float %40, %46
store float %47, float* %0
br label %50
48: ; preds = %23
%49 = tail call i32 @nrerror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %50
50: ; preds = %48, %39, %11
ret void
}