#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);
int /*<<< orphan*/ printf(char *, ...);
void gser(float *gamser, float a, float x, float *gln) {
  float gammln(float xx);
  int n;
  float sum, del, ap;
  *gln = gammln(a);
  if (x <= 0.0) {
    if (x < 0.0)
      printf("Error(gser):x less than 0\n");
    *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;
      }
    }
    printf("Error(gser):a=%f too large, x=%f, ITMAX too small\n", a, x);
    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     11c6 <gser+0x76>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11b6 <gser+0x66>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
jmp    1310 <gser+0x1c0>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe1f(%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     12f0 <gser+0x1a0>
movss  0xe04(%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  0xda9(%rip),%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    12dd <gser+0x18d>
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    1310 <gser+0x1c0>
jmp    12e2 <gser+0x192>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11fa <gser+0xaa>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd26(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gser>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
movss  %xmm1,0x8(%rsp)
mov    %rdi,%r14
movss  %xmm0,0x14(%rsp)
call   1080 <gammln@plt>
movss  0x8(%rsp),%xmm1
movss  %xmm0,(%rbx)
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
jae    12d5 <gser+0x175>
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  %xmm0,0x28(%rsp)
movss  0x14(%rsp),%xmm4
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
movsd  %xmm0,0x20(%rsp)
movss  0xe43(%rip),%xmm3
movaps %xmm3,%xmm0
divss  %xmm4,%xmm0
mov    $0x64,%ebp
movaps %xmm0,%xmm2
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   1050 <fabs@plt>
movsd  %xmm0,0x18(%rsp)
movss  0x4(%rsp),%xmm0
call   1050 <fabs@plt>
mulsd  0xdf2(%rip),%xmm0
ucomisd 0x18(%rsp),%xmm0
ja     12ec <gser+0x18c>
movss  0x10(%rsp),%xmm0
addss  0xdd0(%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   1050 <fabs@plt>
movsd  %xmm0,0x18(%rsp)
movss  0x4(%rsp),%xmm0
call   1050 <fabs@plt>
movsd  0xd8a(%rip),%xmm1
mulsd  %xmm1,%xmm0
ucomisd 0x18(%rsp),%xmm0
ja     12ec <gser+0x18c>
add    $0xfffffffe,%ebp
movss  0x8(%rsp),%xmm1
movss  0x4(%rsp),%xmm2
movss  0xd5f(%rip),%xmm3
movss  0x10(%rsp),%xmm4
movss  0xc(%rsp),%xmm0
jne    11d0 <gser+0x70>
lea    0xd56(%rip),%rdi
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mov    $0x2,%al
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>
jbe    12e3 <gser+0x183>
lea    0xd65(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,(%r14)
jmp    1317 <gser+0x1b7>
movss  0x8(%rsp),%xmm0
call   1070 <log@plt>
mulss  0x14(%rsp),%xmm0
subss  0x8(%rsp),%xmm0
subss  (%rbx),%xmm0
call   1060 <exp@plt>
mulss  0x4(%rsp),%xmm0
movss  %xmm0,(%r14)
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Error(gser):x less than 0\0A\00"
@.str.1 = [51 x i8] c"Error(gser):a=%f too large, x=%f, ITMAX too small\0A\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 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 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 %77
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 %77
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 = load float, float* %6
%73 = fpext float %72 to double
%74 = load float, float* %7
%75 = fpext float %74 to double
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), double %73, double %75)
br label %77
77: ; preds = %71, %53, %25
ret void
}

LLVM IR (-O2):
@.str.1 = [51 x i8] c"Error(gser):a=%f too large, x=%f, ITMAX too small\0A\00"
@str = [26 x i8] c"Error(gser):x less than 0\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 = fpext float %2 to double
%7 = fcmp ugt float %2, 0.000000e+00
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = fcmp olt float %2, 0.000000e+00
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
store float 0.000000e+00, float* %0
br label %52
13: ; preds = %4
%14 = fpext float %1 to double
%15 = fdiv float 1.000000e+00, %1
br label %28
16: ; preds = %28
%17 = fadd float %33, 1.000000e+00
%18 = fdiv float %2, %17
%19 = fmul float %35, %18
%20 = fadd float %36, %19
%21 = tail call double @fabs(float %19)
%22 = tail call double @fabs(float %20)
%23 = fmul double %22, 3.000000e-07
%24 = fcmp olt double %21, %23
br i1 %24, label %41, label %25
25: ; preds = %16
%26 = add nuw nsw i32 %32, 2
%27 = icmp eq i32 %26, 101
br i1 %27, label %50, label %28
28: ; preds = %25, %13
%29 = phi float [ %1, %13 ], [ %17, %25 ]
%30 = phi float [ %15, %13 ], [ %19, %25 ]
%31 = phi float [ %15, %13 ], [ %20, %25 ]
%32 = phi i32 [ 1, %13 ], [ %26, %25 ]
%33 = fadd float %29, 1.000000e+00
%34 = fdiv float %2, %33
%35 = fmul float %30, %34
%36 = fadd float %31, %35
%37 = tail call double @fabs(float %35)
%38 = tail call double @fabs(float %36)
%39 = fmul double %38, 3.000000e-07
%40 = fcmp olt double %37, %39
br i1 %40, label %41, label %16
41: ; preds = %16, %28
%42 = phi float [ %36, %28 ], [ %20, %16 ]
%43 = fneg float %2
%44 = tail call float @log(float %2)
%45 = tail call float @llvm.fmuladd.f32(float %1, float %44, float %43)
%46 = load float, float* %3
%47 = fsub float %45, %46
%48 = tail call float @exp(float %47)
%49 = fmul float %42, %48
store float %49, float* %0
br label %52
50: ; preds = %25
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), double %14, double %6)
br label %52
52: ; preds = %50, %41, %12
ret void
}