#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_ha(double, double);
double M_PI;
double cos(double);
int fabs(double);
double f_ha(double x, double a) {
  if (fabs(x) > 1. / (a - 1.))
    return 0.;
  double pik, y = 0.5, h = M_PI * (a - 1.);
  for (pik = h; pik <= h * 50; pik += h) {
    y += F_ha(pik, a) * cos(pik * x);
  }
  return y * (a - 1.);
}


x86 assembly (clang, -O0):
<f_ha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xea3(%rip),%xmm1
subsd  %xmm1,%xmm2
movsd  0xe97(%rip),%xmm1
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1184 <f_ha+0x54>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124c <f_ha+0x11c>
movsd  0xe7c(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0x2e50(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe57(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xe43(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     122d <f_ha+0xfd>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <F_ha@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <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    11c0 <f_ha+0x90>
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xdc1(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_ha>:
sub    $0x48,%rsp
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x30(%rsp)
call   1030 <fabs@plt>
movsd  0x18(%rsp),%xmm1
cvtsi2sd %eax,%xmm4
movsd  0xea9(%rip),%xmm3
addsd  %xmm1,%xmm3
movsd  0xea5(%rip),%xmm2
divsd  %xmm3,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm4
ja     1226 <f_ha+0xf6>
mov    0x2e6c(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm3,0x20(%rsp)
mulsd  %xmm3,%xmm0
movsd  0xe7e(%rip),%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm0,0x10(%rsp)
movsd  0xe74(%rip),%xmm3
ucomisd %xmm0,%xmm2
jb     121c <f_ha+0xec>
movsd  0x10(%rsp),%xmm0
movsd  %xmm2,0x28(%rsp)
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  %xmm3,0x40(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <F_ha@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0x30(%rsp),%xmm0
call   1040 <cos@plt>
movsd  0x40(%rsp),%xmm3
movsd  0x28(%rsp),%xmm2
movsd  0x18(%rsp),%xmm1
mulsd  0x38(%rsp),%xmm0
addsd  %xmm0,%xmm3
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
ucomisd %xmm0,%xmm2
jae    11c0 <f_ha+0x90>
movsd  0x20(%rsp),%xmm0
mulsd  %xmm3,%xmm0
add    $0x48,%rsp
ret

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

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @f_ha(double %0, double %1) {
%3 = tail call i32 @fabs(double %0)
%4 = sitofp i32 %3 to double
%5 = fadd double %1, -1.000000e+00
%6 = fdiv double 1.000000e+00, %5
%7 = fcmp olt double %6, %4
br i1 %7, label %25, label %8
8: ; preds = %2
%9 = load double, double* @M_PI
%10 = fmul double %5, %9
%11 = fmul double %10, 5.000000e+01
%12 = fcmp ugt double %10, %11
br i1 %12, label %22, label %13
13: ; preds = %8, %13
%14 = phi double [ %19, %13 ], [ 5.000000e-01, %8 ]
%15 = phi double [ %20, %13 ], [ %10, %8 ]
%16 = tail call double @F_ha(double %15, double %1)
%17 = fmul double %15, %0
%18 = tail call double @cos(double %17)
%19 = tail call double @llvm.fmuladd.f64(double %16, double %18, double %14)
%20 = fadd double %10, %15
%21 = fcmp ugt double %20, %11
br i1 %21, label %22, label %13
22: ; preds = %13, %8
%23 = phi double [ 5.000000e-01, %8 ], [ %19, %13 ]
%24 = fmul double %5, %23
br label %25
25: ; preds = %2, %22
%26 = phi double [ %24, %22 ], [ 0.000000e+00, %2 ]
ret double %26
}