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


x86 assembly (clang, -O0):
<f_chan_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xeca(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  0xe94(%rip),%xmm3
subsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    118b <f_chan_prime+0x5b>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a4 <f_chan_prime+0x174>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x2e4e(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe55(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  0xe34(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1280 <f_chan_prime+0x150>
movsd  -0x30(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <F_ha@plt>
cvttsd2si -0x20(%rbp),%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x24(%rbp),%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  0xddf(%rip),%xmm1
mov    0x2db0(%rip),%rax
mulsd  (%rax),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11c7 <f_chan_prime+0x97>
movsd  -0x38(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xd6e(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_chan_prime>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
movapd %xmm0,%xmm6
movapd 0xebc(%rip),%xmm5
andpd  %xmm0,%xmm5
movsd  0xec0(%rip),%xmm4
addsd  %xmm1,%xmm4
movapd %xmm2,%xmm3
divsd  %xmm4,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm3,%xmm5
ja     1287 <f_chan_prime+0x157>
mov    0x2e77(%rip),%r14
movsd  (%r14),%xmm0
movsd  %xmm4,0x28(%rsp)
mulsd  %xmm4,%xmm0
movsd  %xmm2,0x18(%rsp)
divsd  %xmm2,%xmm0
movsd  0xe86(%rip),%xmm2
mulsd  %xmm0,%xmm2
xorpd  %xmm3,%xmm3
movsd  %xmm0,0x20(%rsp)
ucomisd %xmm0,%xmm2
movapd %xmm6,0x50(%rsp)
jb     1277 <f_chan_prime+0x147>
mov    %edi,%ebx
cvttsd2si 0x18(%rsp),%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
movsd  %xmm0,0x30(%rsp)
xorpd  %xmm3,%xmm3
movsd  0x20(%rsp),%xmm0
movsd  %xmm1,0x40(%rsp)
movsd  %xmm2,0x38(%rsp)
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  %xmm3,0x48(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <F_ha@plt>
mov    %ebp,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mov    %ebx,%edi
call   1040 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%r14),%xmm1
mulsd  0xdf6(%rip),%xmm1
mulsd  0x30(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  0x50(%rsp),%xmm0
addsd  %xmm1,%xmm0
call   1030 <cos@plt>
movsd  0x48(%rsp),%xmm3
movsd  0x38(%rsp),%xmm2
movsd  0x40(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm3
movsd  0x8(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
ucomisd %xmm0,%xmm2
jae    11e0 <f_chan_prime+0xb0>
movsd  0x28(%rsp),%xmm0
mulsd  %xmm3,%xmm0
divsd  0x18(%rsp),%xmm0
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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