#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_up(double);
int M_PI;
double cos(double);
int fabs(double);
double pow(double, int);
double f_cup_prime(double x, int k) {
  if (fabs(x) > 2.)
    return 0.;
  double pik, y = 0.0;
  for (pik = M_PI; pik <= M_PI * 50; pik += M_PI) {
    y += pow(F_up(pik * 0.5), 2) * pow(pik * 0.5, k) *
         cos(pik * x * 0.5 + M_PI * 0.5 * k);
  }
  return y * 0.5;
}


x86 assembly (clang, -O0):
<f_cup_prime>:
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,%xmm0
movsd  0xe9a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    117d <f_cup_prime+0x3d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    127e <f_cup_prime+0x13e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0x2e5c(%rip),%rax
cvtsi2sdl (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
mov    0x2e47(%rip),%rax
imul   $0x32,(%rax),%eax
cvtsi2sd %eax,%xmm0
ucomisd %xmm1,%xmm0
jb     126c <f_cup_prime+0x12c>
movsd  0xe4e(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <F_up@plt>
mov    $0x2,%edi
call   1060 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe2d(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x14(%rbp),%edi
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mov    0x2dde(%rip),%rax
cvtsi2sdl (%rax),%xmm1
movsd  0xdf2(%rip),%xmm2
mulsd  %xmm2,%xmm1
cvtsi2sdl -0x14(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xddd(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0x2d8f(%rip),%rax
cvtsi2sdl (%rax),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1195 <f_cup_prime+0x55>
movsd  0xd94(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_cup_prime>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %edi,%ebp
movsd  %xmm0,0x20(%rsp)
call   1040 <fabs@plt>
xorpd  %xmm1,%xmm1
cmp    $0x2,%eax
jg     1261 <f_cup_prime+0x121>
mov    0x2e81(%rip),%rbx
mov    (%rbx),%eax
cvtsi2sd %eax,%xmm2
imul   $0x32,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
ucomisd %xmm2,%xmm0
jb     1261 <f_cup_prime+0x121>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x18(%rsp)
xorpd  %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x30(%rsp)
movsd  0xe4c(%rip),%xmm0
mulsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm0
call   1030 <F_up@plt>
mov    $0x2,%edi
call   1060 <pow@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x8(%rsp),%xmm0
mov    %ebp,%edi
call   1060 <pow@plt>
mulsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl (%rbx),%xmm1
movsd  0xdf5(%rip),%xmm2
mulsd  %xmm2,%xmm1
mulsd  0x18(%rsp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <cos@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x30(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm1
mov    (%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm2
imul   $0x32,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
ucomisd %xmm2,%xmm0
jae    11a0 <f_cup_prime+0x60>
mulsd  0xd9f(%rip),%xmm1
movapd %xmm1,%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

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

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