#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 F_fup(double, int);
int M_PI;
double cos(double);
int fabs(double);
double f_fup(double x, int n) {
  if ((2. * fabs(x)) > n + 2)
    return 0.;
  double pik, y = 0.5, h = 2. * M_PI / ((double)n + 2.);
  for (pik = h; pik <= h * 50; pik += h) {
    y += F_fup(pik, n) * cos(pik * x);
  }
  return y * 2. / ((double)n + 2.);
}


x86 assembly (clang, -O0):
<f_fup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xeaa(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x14(%rbp),%eax
add    $0x2,%eax
cvtsi2sd %eax,%xmm1
ucomisd %xmm1,%xmm0
jbe    117b <f_fup+0x4b>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1255 <f_fup+0x125>
movsd  0xe85(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0x2e59(%rip),%rax
cvtsi2sdl (%rax),%xmm1
movsd  0xe65(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe54(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xe40(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     122e <f_fup+0xfe>
movsd  -0x20(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1030 <F_fup@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11c3 <f_fup+0x93>
movsd  0xdca(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xdb8(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_fup>:
push   %rbx
sub    $0x40,%rsp
mov    %edi,%ebx
movsd  %xmm0,0x28(%rsp)
call   1040 <fabs@plt>
cltq
add    %rax,%rax
lea    0x2(%rbx),%ecx
movslq %ecx,%rcx
xorpd  %xmm1,%xmm1
cmp    %rcx,%rax
jg     1226 <f_fup+0xf6>
mov    0x2e87(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2sdl (%rax),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
addsd  %xmm1,%xmm1
addsd  0xe85(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe81(%rip),%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm1,0x10(%rsp)
ucomisd %xmm1,%xmm2
jae    11a4 <f_fup+0x74>
movsd  0xe71(%rip),%xmm1
jmp    1222 <f_fup+0xf2>
movsd  %xmm0,0x18(%rsp)
movsd  0xe66(%rip),%xmm1
movsd  0x10(%rsp),%xmm0
movsd  %xmm2,0x20(%rsp)
xchg   %ax,%ax
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x38(%rsp)
movsd  0x8(%rsp),%xmm0
mov    %ebx,%edi
call   1030 <F_fup@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0x28(%rsp),%xmm0
call   1050 <cos@plt>
movsd  0x20(%rsp),%xmm2
movsd  0x38(%rsp),%xmm1
mulsd  0x30(%rsp),%xmm0
addsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
ucomisd %xmm0,%xmm2
jae    11c0 <f_fup+0x90>
addsd  %xmm1,%xmm1
movsd  0x18(%rsp),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @f_fup(double %0, i32 %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store i32 %1, i32* %5
%9 = load double, double* %4
%10 = call i32 @fabs(double %9)
%11 = sitofp i32 %10 to double
%12 = fmul double 2.000000e+00, %11
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 2
%15 = sitofp i32 %14 to double
%16 = fcmp ogt double %12, %15
br i1 %16, label %17, label %18
17: ; preds = %2
store double 0.000000e+00, double* %3
br label %53
18: ; preds = %2
store double 5.000000e-01, double* %7
%19 = load i32, i32* @M_PI
%20 = sitofp i32 %19 to double
%21 = fmul double 2.000000e+00, %20
%22 = load i32, i32* %5
%23 = sitofp i32 %22 to double
%24 = fadd double %23, 2.000000e+00
%25 = fdiv double %21, %24
store double %25, double* %8
%26 = load double, double* %8
store double %26, double* %6
br label %27
27: ; preds = %42, %18
%28 = load double, double* %6
%29 = load double, double* %8
%30 = fmul double %29, 5.000000e+01
%31 = fcmp ole double %28, %30
br i1 %31, label %32, label %46
32: ; preds = %27
%33 = load double, double* %6
%34 = load i32, i32* %5
%35 = call double @F_fup(double %33, i32 %34)
%36 = load double, double* %6
%37 = load double, double* %4
%38 = fmul double %36, %37
%39 = call double @cos(double %38)
%40 = load double, double* %7
%41 = call double @llvm.fmuladd.f64(double %35, double %39, double %40)
store double %41, double* %7
br label %42
42: ; preds = %32
%43 = load double, double* %8
%44 = load double, double* %6
%45 = fadd double %44, %43
store double %45, double* %6
br label %27
46: ; preds = %27
%47 = load double, double* %7
%48 = fmul double %47, 2.000000e+00
%49 = load i32, i32* %5
%50 = sitofp i32 %49 to double
%51 = fadd double %50, 2.000000e+00
%52 = fdiv double %48, %51
store double %52, double* %3
br label %53
53: ; preds = %46, %17
%54 = load double, double* %3
ret double %54
}

LLVM IR (-O2):
@M_PI = global i32 0
define double @f_fup(double %0, i32 %1) {
%3 = tail call i32 @fabs(double %0)
%4 = sext i32 %3 to i64
%5 = shl nsw i64 %4, 1
%6 = add nsw i32 %1, 2
%7 = sext i32 %6 to i64
%8 = icmp sgt i64 %5, %7
br i1 %8, label %32, label %9
9: ; preds = %2
%10 = load i32, i32* @M_PI
%11 = sitofp i32 %10 to double
%12 = fmul double %11, 2.000000e+00
%13 = sitofp i32 %1 to double
%14 = fadd double %13, 2.000000e+00
%15 = fdiv double %12, %14
%16 = fmul double %15, 5.000000e+01
%17 = fcmp ugt double %15, %16
br i1 %17, label %29, label %18
18: ; preds = %9, %18
%19 = phi double [ %24, %18 ], [ 5.000000e-01, %9 ]
%20 = phi double [ %25, %18 ], [ %15, %9 ]
%21 = tail call double @F_fup(double %20, i32 %1)
%22 = fmul double %20, %0
%23 = tail call double @cos(double %22)
%24 = tail call double @llvm.fmuladd.f64(double %21, double %23, double %19)
%25 = fadd double %15, %20
%26 = fcmp ugt double %25, %16
br i1 %26, label %27, label %18
27: ; preds = %18
%28 = fmul double %24, 2.000000e+00
br label %29
29: ; preds = %27, %9
%30 = phi double [ 1.000000e+00, %9 ], [ %28, %27 ]
%31 = fdiv double %30, %14
br label %32
32: ; preds = %2, %29
%33 = phi double [ %31, %29 ], [ 0.000000e+00, %2 ]
ret double %33
}