#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 calc(int, float);
double fabs(float);
float fOfX(int a, float x, int t) {
  if (fabs(calc(a + 1, x)) < 0.0001 || t < 0)
    return 0;
  float ans = calc(a, x);
  ans += fOfX(a + 1, x, t - 1);
  return ans;
}


x86 assembly (clang, -O0):
<fOfX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
movss  -0xc(%rbp),%xmm0
call   1040 <calc@plt>
call   1050 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xe9d(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     1177 <fOfX+0x47>
cmpl   $0x0,-0x10(%rbp)
jge    1184 <fOfX+0x54>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c0 <fOfX+0x90>
mov    -0x8(%rbp),%edi
movss  -0xc(%rbp),%xmm0
call   1040 <calc@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
movss  -0xc(%rbp),%xmm0
mov    -0x10(%rbp),%esi
sub    $0x1,%esi
call   1030 <fOfX@plt>
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fOfX>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
lea    0x1(%rbp),%r14d
mov    %r14d,%edi
movss  %xmm0,0x8(%rsp)
call   1040 <calc@plt>
call   1050 <fabs@plt>
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
test   %ebx,%ebx
js     1199 <fOfX+0x69>
movsd  0xe99(%rip),%xmm2
ucomisd %xmm1,%xmm2
ja     1199 <fOfX+0x69>
mov    %ebp,%edi
movss  0x8(%rsp),%xmm0
call   1040 <calc@plt>
movss  %xmm0,0xc(%rsp)
add    $0xffffffff,%ebx
mov    %r14d,%edi
movss  0x8(%rsp),%xmm0
mov    %ebx,%esi
call   1030 <fOfX@plt>
addss  0xc(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define float @fOfX(i32 %0, float %1, i32 %2) {
%4 = alloca float
%5 = alloca i32
%6 = alloca float
%7 = alloca i32
%8 = alloca float
store i32 %0, i32* %5
store float %1, float* %6
store i32 %2, i32* %7
%9 = load i32, i32* %5
%10 = add nsw i32 %9, 1
%11 = load float, float* %6
%12 = call float @calc(i32 %10, float %11)
%13 = call double @fabs(float %12)
%14 = fcmp olt double %13, 1.000000e-04
br i1 %14, label %18, label %15
15: ; preds = %3
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15, %3
store float 0.000000e+00, float* %4
br label %32
19: ; preds = %15
%20 = load i32, i32* %5
%21 = load float, float* %6
%22 = call float @calc(i32 %20, float %21)
store float %22, float* %8
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
%25 = load float, float* %6
%26 = load i32, i32* %7
%27 = sub nsw i32 %26, 1
%28 = call float @fOfX(i32 %24, float %25, i32 %27)
%29 = load float, float* %8
%30 = fadd float %29, %28
store float %30, float* %8
%31 = load float, float* %8
store float %31, float* %4
br label %32
32: ; preds = %19, %18
%33 = load float, float* %4
ret float %33
}

LLVM IR (-O2):
define float @fOfX(i32 %0, float %1, i32 %2) {
%4 = add nsw i32 %0, 1
%5 = tail call float @calc(i32 %4, float %1)
%6 = tail call double @fabs(float %5)
%7 = fcmp olt double %6, 1.000000e-04
%8 = icmp slt i32 %2, 0
%9 = or i1 %8, %7
br i1 %9, label %10, label %12
10: ; preds = %3, %12
%11 = phi float [ %16, %12 ], [ 0.000000e+00, %3 ]
ret float %11
12: ; preds = %3
%13 = tail call float @calc(i32 %0, float %1)
%14 = add nsw i32 %2, -1
%15 = tail call float @fOfX(i32 %4, float %1, i32 %14)
%16 = fadd float %13, %15
br label %10
}