#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 cdflib_exparg(int const *);
double exp(double);
double fabs(double);
double log(double);
double cdflib_fpser(double *a, double *b, double *x, double *eps) {
  static const int K1 = 1;
  double fpser, an, c, s, t, tol;
  fpser = 1.0e0;
  if (*a <= 1.e-3 * *eps) {
    goto S10;
  }
  fpser = 0.0e0;
  t = *a * log(*x);
  if (t < cdflib_exparg(&K1)) {
    return fpser;
  }
  fpser = exp(t);
S10:
  fpser = *b / *a * fpser;
  tol = *eps / *a;
  an = *a + 1.0e0;
  t = *x;
  s = t / an;
S20:
  an += 1.0e0;
  t = *x * t;
  c = t / an;
  s += c;
  if (fabs(c) > tol) {
    goto S20;
  }
  fpser *= (1.0e0 + *a * s);
  return fpser;
}


x86 assembly (clang, -O0):
<cdflib_fpser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x28(%rbp),%rax
movsd  0xe97(%rip),%xmm0
mulsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jb     117c <cdflib_fpser+0x4c>
jmp    11f2 <cdflib_fpser+0xc2>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
lea    0xe60(%rip),%rdi
call   1050 <cdflib_exparg@plt>
movsd  -0x60(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e3 <cdflib_fpser+0xb3>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12e5 <cdflib_fpser+0x1b5>
movsd  -0x50(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
movsd  0xddb(%rip),%xmm0
addsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xdae(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movaps 0xd70(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    12b4 <cdflib_fpser+0x184>
jmp    1252 <cdflib_fpser+0x122>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd3b(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdflib_fpser>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
movsd  (%rdi),%xmm9
movsd  (%rcx),%xmm1
movsd  0xeb1(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xead(%rip),%xmm6
ucomisd %xmm9,%xmm0
jae    11c7 <cdflib_fpser+0x97>
mov    %rcx,%r12
mov    %rdi,%rbx
movsd  (%r15),%xmm0
movsd  %xmm9,(%rsp)
call   1040 <log@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
lea    0xe93(%rip),%rdi
call   1050 <cdflib_exparg@plt>
movsd  (%rsp),%xmm2
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm1
ja     124c <cdflib_fpser+0x11c>
movapd %xmm2,%xmm0
call   1030 <exp@plt>
movsd  (%rbx),%xmm9
movsd  (%r12),%xmm1
movsd  0xe43(%rip),%xmm6
jmp    11cb <cdflib_fpser+0x9b>
movapd %xmm6,%xmm0
movsd  (%r14),%xmm8
divsd  %xmm9,%xmm8
divsd  %xmm9,%xmm1
movsd  0xe26(%rip),%xmm4
addsd  %xmm9,%xmm4
movsd  (%r15),%xmm2
movapd %xmm2,%xmm3
divsd  %xmm4,%xmm3
movapd 0xe13(%rip),%xmm10
movapd %xmm2,%xmm5
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addsd  %xmm6,%xmm4
mulsd  %xmm2,%xmm5
movapd %xmm5,%xmm7
divsd  %xmm4,%xmm7
addsd  %xmm7,%xmm3
andpd  %xmm10,%xmm7
ucomisd %xmm1,%xmm7
ja     1210 <cdflib_fpser+0xe0>
mulsd  %xmm8,%xmm0
mulsd  %xmm3,%xmm9
addsd  0xdc6(%rip),%xmm9
mulsd  %xmm0,%xmm9
movapd %xmm9,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@cdflib_fpser.K1 = internal constant i32 1
define double @cdflib_fpser(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store double 1.000000e+00, double* %10
%16 = load double*, double** %6
%17 = load double, double* %16
%18 = load double*, double** %9
%19 = load double, double* %18
%20 = fmul double 1.000000e-03, %19
%21 = fcmp ole double %17, %20
br i1 %21, label %22, label %23
22: ; preds = %4
br label %38
23: ; preds = %4
store double 0.000000e+00, double* %10
%24 = load double*, double** %6
%25 = load double, double* %24
%26 = load double*, double** %8
%27 = load double, double* %26
%28 = call double @log(double %27)
%29 = fmul double %25, %28
store double %29, double* %14
%30 = load double, double* %14
%31 = call double @cdflib_exparg(i32* @cdflib_fpser.K1)
%32 = fcmp olt double %30, %31
br i1 %32, label %33, label %35
33: ; preds = %23
%34 = load double, double* %10
store double %34, double* %5
br label %85
35: ; preds = %23
%36 = load double, double* %14
%37 = call double @exp(double %36)
store double %37, double* %10
br label %38
38: ; preds = %35, %22
%39 = load double*, double** %7
%40 = load double, double* %39
%41 = load double*, double** %6
%42 = load double, double* %41
%43 = fdiv double %40, %42
%44 = load double, double* %10
%45 = fmul double %43, %44
store double %45, double* %10
%46 = load double*, double** %9
%47 = load double, double* %46
%48 = load double*, double** %6
%49 = load double, double* %48
%50 = fdiv double %47, %49
store double %50, double* %15
%51 = load double*, double** %6
%52 = load double, double* %51
%53 = fadd double %52, 1.000000e+00
store double %53, double* %11
%54 = load double*, double** %8
%55 = load double, double* %54
store double %55, double* %14
%56 = load double, double* %14
%57 = load double, double* %11
%58 = fdiv double %56, %57
store double %58, double* %13
br label %59
59: ; preds = %76, %38
%60 = load double, double* %11
%61 = fadd double %60, 1.000000e+00
store double %61, double* %11
%62 = load double*, double** %8
%63 = load double, double* %62
%64 = load double, double* %14
%65 = fmul double %63, %64
store double %65, double* %14
%66 = load double, double* %14
%67 = load double, double* %11
%68 = fdiv double %66, %67
store double %68, double* %12
%69 = load double, double* %12
%70 = load double, double* %13
%71 = fadd double %70, %69
store double %71, double* %13
%72 = load double, double* %12
%73 = call double @llvm.fabs.f64(double %72)
%74 = load double, double* %15
%75 = fcmp ogt double %73, %74
br i1 %75, label %76, label %77
76: ; preds = %59
br label %59
77: ; preds = %59
%78 = load double*, double** %6
%79 = load double, double* %78
%80 = load double, double* %13
%81 = call double @llvm.fmuladd.f64(double %79, double %80, double 1.000000e+00)
%82 = load double, double* %10
%83 = fmul double %82, %81
store double %83, double* %10
%84 = load double, double* %10
store double %84, double* %5
br label %85
85: ; preds = %77, %33
%86 = load double, double* %5
ret double %86
}

LLVM IR (-O2):
@cdflib_fpser.K1 = internal constant i32 1
define double @cdflib_fpser(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3) {
%5 = load double, double* %0
%6 = load double, double* %3
%7 = fmul double %6, 1.000000e-03
%8 = fcmp ugt double %5, %7
br i1 %8, label %9, label %19
9: ; preds = %4
%10 = load double, double* %2
%11 = tail call double @log(double %10)
%12 = fmul double %5, %11
%13 = tail call double @cdflib_exparg(i32* @cdflib_fpser.K1)
%14 = fcmp olt double %12, %13
br i1 %14, label %43, label %15
15: ; preds = %9
%16 = tail call double @exp(double %12)
%17 = load double, double* %0
%18 = load double, double* %3
br label %19
19: ; preds = %4, %15
%20 = phi double [ %6, %4 ], [ %18, %15 ]
%21 = phi double [ %5, %4 ], [ %17, %15 ]
%22 = phi double [ 1.000000e+00, %4 ], [ %16, %15 ]
%23 = load double, double* %1
%24 = fdiv double %23, %21
%25 = fdiv double %20, %21
%26 = fadd double %21, 1.000000e+00
%27 = load double, double* %2
%28 = fdiv double %27, %26
br label %29
29: ; preds = %29, %19
%30 = phi double [ %26, %19 ], [ %33, %29 ]
%31 = phi double [ %28, %19 ], [ %36, %29 ]
%32 = phi double [ %27, %19 ], [ %34, %29 ]
%33 = fadd double %30, 1.000000e+00
%34 = fmul double %27, %32
%35 = fdiv double %34, %33
%36 = fadd double %31, %35
%37 = tail call double @llvm.fabs.f64(double %35)
%38 = fcmp ogt double %37, %25
br i1 %38, label %29, label %39
39: ; preds = %29
%40 = fmul double %22, %24
%41 = tail call double @llvm.fmuladd.f64(double %21, double %36, double 1.000000e+00)
%42 = fmul double %40, %41
br label %43
43: ; preds = %9, %39
%44 = phi double [ %42, %39 ], [ 0.000000e+00, %9 ]
ret double %44
}