#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 exparg(int);
double fabs(double);
double log(double);
double fpser(double a, double b, double x, double eps) {
  double ret_val;
  double c__, s, t, an, tol;
  ret_val = 1.0;
  if (a <= eps * .001f) {
    goto L10;
  }
  ret_val = 0.0;
  t = a * log(x);
  if (t < exparg(1)) {
    return ret_val;
  }
  ret_val = exp(t);
L10:
  ret_val = b / a * ret_val;
  tol = eps / a;
  an = a + 1.0;
  t = x;
  s = t / an;
L20:
  an += 1.0;
  t = x * t;
  c__ = t / an;
  s += c__;
  if (fabs(c__) > tol) {
    goto L20;
  }
  ret_val *= a * s + 1.0;
  return ret_val;
}


x86 assembly (clang, -O0):
<fpser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  0xeb4(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  0xe9a(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     117a <fpser+0x4a>
jmp    11e8 <fpser+0xb8>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    $0x1,%edi
call   1050 <exparg@plt>
movsd  -0x60(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d9 <fpser+0xa9>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c3 <fpser+0x193>
movsd  -0x48(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xdf5(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdca(%rip),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movaps 0xd8f(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    1295 <fpser+0x165>
jmp    1236 <fpser+0x106>
movsd  -0x10(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd5d(%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):
<fpser>:
sub    $0x28,%rsp
movapd %xmm0,%xmm8
movsd  0xebf(%rip),%xmm0
mulsd  %xmm3,%xmm0
movsd  0xeba(%rip),%xmm10
ucomisd %xmm8,%xmm0
movapd %xmm10,%xmm0
jae    11d2 <fpser+0xa2>
movsd  %xmm3,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm0
movsd  %xmm8,(%rsp)
call   1040 <log@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    $0x1,%edi
call   1050 <exparg@plt>
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
movsd  0x20(%rsp),%xmm2
ucomisd %xmm2,%xmm1
ja     123c <fpser+0x10c>
movapd %xmm2,%xmm0
call   1030 <exp@plt>
movsd  0x18(%rsp),%xmm1
movsd  (%rsp),%xmm8
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
movsd  0xe36(%rip),%xmm10
divsd  %xmm8,%xmm1
divsd  %xmm8,%xmm3
movsd  0xe24(%rip),%xmm7
addsd  %xmm8,%xmm7
movapd %xmm2,%xmm6
divsd  %xmm7,%xmm6
movapd 0xe16(%rip),%xmm9
movapd %xmm2,%xmm4
xchg   %ax,%ax
addsd  %xmm10,%xmm7
mulsd  %xmm2,%xmm4
movapd %xmm4,%xmm5
divsd  %xmm7,%xmm5
addsd  %xmm5,%xmm6
andpd  %xmm9,%xmm5
ucomisd %xmm3,%xmm5
ja     1200 <fpser+0xd0>
mulsd  %xmm0,%xmm1
mulsd  %xmm6,%xmm8
addsd  0xdd6(%rip),%xmm8
mulsd  %xmm1,%xmm8
movapd %xmm8,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @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* %9
%18 = fmul double %17, 0x3F50624DE0000000
%19 = fcmp ole double %16, %18
br i1 %19, label %20, label %21
20: ; preds = %4
br label %34
21: ; preds = %4
store double 0.000000e+00, double* %10
%22 = load double, double* %6
%23 = load double, double* %8
%24 = call double @log(double %23)
%25 = fmul double %22, %24
store double %25, double* %13
%26 = load double, double* %13
%27 = call double @exparg(i32 1)
%28 = fcmp olt double %26, %27
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = load double, double* %10
store double %30, double* %5
br label %73
31: ; preds = %21
%32 = load double, double* %13
%33 = call double @exp(double %32)
store double %33, double* %10
br label %34
34: ; preds = %31, %20
%35 = load double, double* %7
%36 = load double, double* %6
%37 = fdiv double %35, %36
%38 = load double, double* %10
%39 = fmul double %37, %38
store double %39, double* %10
%40 = load double, double* %9
%41 = load double, double* %6
%42 = fdiv double %40, %41
store double %42, double* %15
%43 = load double, double* %6
%44 = fadd double %43, 1.000000e+00
store double %44, double* %14
%45 = load double, double* %8
store double %45, double* %13
%46 = load double, double* %13
%47 = load double, double* %14
%48 = fdiv double %46, %47
store double %48, double* %12
br label %49
49: ; preds = %65, %34
%50 = load double, double* %14
%51 = fadd double %50, 1.000000e+00
store double %51, double* %14
%52 = load double, double* %8
%53 = load double, double* %13
%54 = fmul double %52, %53
store double %54, double* %13
%55 = load double, double* %13
%56 = load double, double* %14
%57 = fdiv double %55, %56
store double %57, double* %11
%58 = load double, double* %11
%59 = load double, double* %12
%60 = fadd double %59, %58
store double %60, double* %12
%61 = load double, double* %11
%62 = call double @llvm.fabs.f64(double %61)
%63 = load double, double* %15
%64 = fcmp ogt double %62, %63
br i1 %64, label %65, label %66
65: ; preds = %49
br label %49
66: ; preds = %49
%67 = load double, double* %6
%68 = load double, double* %12
%69 = call double @llvm.fmuladd.f64(double %67, double %68, double 1.000000e+00)
%70 = load double, double* %10
%71 = fmul double %70, %69
store double %71, double* %10
%72 = load double, double* %10
store double %72, double* %5
br label %73
73: ; preds = %66, %29
%74 = load double, double* %5
ret double %74
}

LLVM IR (-O2):
define double @fpser(double %0, double %1, double %2, double %3) {
%5 = fmul double %3, 0x3F50624DE0000000
%6 = fcmp ult double %5, %0
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = tail call double @log(double %2)
%9 = fmul double %8, %0
%10 = tail call double @exparg(i32 1)
%11 = fcmp olt double %9, %10
br i1 %11, label %34, label %12
12: ; preds = %7
%13 = tail call double @exp(double %9)
br label %14
14: ; preds = %4, %12
%15 = phi double [ 1.000000e+00, %4 ], [ %13, %12 ]
%16 = fdiv double %1, %0
%17 = fdiv double %3, %0
%18 = fadd double %0, 1.000000e+00
%19 = fdiv double %2, %18
br label %20
20: ; preds = %20, %14
%21 = phi double [ %19, %14 ], [ %27, %20 ]
%22 = phi double [ %2, %14 ], [ %25, %20 ]
%23 = phi double [ %18, %14 ], [ %24, %20 ]
%24 = fadd double %23, 1.000000e+00
%25 = fmul double %22, %2
%26 = fdiv double %25, %24
%27 = fadd double %21, %26
%28 = tail call double @llvm.fabs.f64(double %26)
%29 = fcmp ogt double %28, %17
br i1 %29, label %20, label %30
30: ; preds = %20
%31 = fmul double %16, %15
%32 = tail call double @llvm.fmuladd.f64(double %0, double %27, double 1.000000e+00)
%33 = fmul double %31, %32
br label %34
34: ; preds = %7, %30
%35 = phi double [ %33, %30 ], [ 0.000000e+00, %7 ]
ret double %35
}