#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 M_PI;
double cos(double);
int fabs(double);
double pow(double, int);
double ff_up(double x) {
  int k, m, mmax, kmax, number;
  double y, psin, k2, psin1, t, pi, epspsin, epsintegr;
  if (fabs(x) > 1)
    return 0;
  pi = M_PI;
  number = 3;
  mmax = 10;
  kmax = 20;
  y = 0.5;
  for (k = 1; k < 20; k++) {
    psin = 1;
    t = (pi * k) / 2;
    for (m = 1; m < 10; m++) {
      t = t / 2;
      psin = psin * pow(cos(t), m);
    }
    psin = psin * cos((pi * k) * x);
    y = y + psin;
  }
  return y;
}


x86 assembly (clang, -O0):
<ff_up>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
cmp    $0x1,%eax
jle    1160 <ff_up+0x30>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128b <ff_up+0x15b>
mov    0x2e81(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x3,-0x24(%rbp)
movl   $0xa,-0x1c(%rbp)
movl   $0x14,-0x20(%rbp)
movsd  0xe73(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    1281 <ff_up+0x151>
movsd  0xe65(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x58(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe42(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    1231 <ff_up+0x101>
movsd  -0x50(%rbp),%xmm0
movsd  0xe1b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1040 <cos@plt>
mov    -0x18(%rbp),%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d6 <ff_up+0xa6>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x58(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1199 <ff_up+0x69>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ff_up>:
push   %rbx
sub    $0x40,%rsp
movsd  %xmm0,0x28(%rsp)
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cmp    $0x1,%eax
jg     1385 <ff_up+0x255>
mov    0x2e95(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0xe9b(%rip),%xmm0
movsd  0xe9b(%rip),%xmm1
mov    $0x13,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm1,0x38(%rsp)
movsd  %xmm0,0x18(%rsp)
movsd  0x20(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%rsp)
movapd %xmm0,%xmm1
movsd  0xe58(%rip),%xmm0
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1040 <cos@plt>
mov    $0x1,%edi
call   1050 <pow@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe23(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
mov    $0x2,%edi
call   1050 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xdf4(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
mov    $0x3,%edi
call   1050 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xdc5(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
mov    $0x4,%edi
call   1050 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xd96(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
mov    $0x5,%edi
call   1050 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xd67(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
mov    $0x6,%edi
call   1050 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xd38(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
mov    $0x7,%edi
call   1050 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xd09(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
mov    $0x8,%edi
call   1050 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xcda(%rip),%xmm0
call   1040 <cos@plt>
mov    $0x9,%edi
call   1050 <pow@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x30(%rsp),%xmm0
mulsd  0x28(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x38(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
addsd  0xc8c(%rip),%xmm1
add    $0xffffffff,%ebx
jne    1180 <ff_up+0x50>
add    $0x40,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @ff_up(double %0) {
%2 = tail call i32 @fabs(double %0)
%3 = icmp sgt i32 %2, 1
br i1 %3, label %53, label %4
4: ; preds = %1
%5 = load double, double* @M_PI
br label %6
6: ; preds = %4, %6
%7 = phi i32 [ 1, %4 ], [ %51, %6 ]
%8 = phi double [ 5.000000e-01, %4 ], [ %50, %6 ]
%9 = sitofp i32 %7 to double
%10 = fmul double %5, %9
%11 = fmul double %10, 5.000000e-01
%12 = fmul double %11, 5.000000e-01
%13 = tail call double @cos(double %12)
%14 = tail call double @pow(double %13, i32 1)
%15 = fmul double %12, 5.000000e-01
%16 = tail call double @cos(double %15)
%17 = tail call double @pow(double %16, i32 2)
%18 = fmul double %14, %17
%19 = fmul double %15, 5.000000e-01
%20 = tail call double @cos(double %19)
%21 = tail call double @pow(double %20, i32 3)
%22 = fmul double %18, %21
%23 = fmul double %19, 5.000000e-01
%24 = tail call double @cos(double %23)
%25 = tail call double @pow(double %24, i32 4)
%26 = fmul double %22, %25
%27 = fmul double %23, 5.000000e-01
%28 = tail call double @cos(double %27)
%29 = tail call double @pow(double %28, i32 5)
%30 = fmul double %26, %29
%31 = fmul double %27, 5.000000e-01
%32 = tail call double @cos(double %31)
%33 = tail call double @pow(double %32, i32 6)
%34 = fmul double %30, %33
%35 = fmul double %31, 5.000000e-01
%36 = tail call double @cos(double %35)
%37 = tail call double @pow(double %36, i32 7)
%38 = fmul double %34, %37
%39 = fmul double %35, 5.000000e-01
%40 = tail call double @cos(double %39)
%41 = tail call double @pow(double %40, i32 8)
%42 = fmul double %38, %41
%43 = fmul double %39, 5.000000e-01
%44 = tail call double @cos(double %43)
%45 = tail call double @pow(double %44, i32 9)
%46 = fmul double %42, %45
%47 = fmul double %10, %0
%48 = tail call double @cos(double %47)
%49 = fmul double %46, %48
%50 = fadd double %8, %49
%51 = add nuw nsw i32 %7, 1
%52 = icmp eq i32 %51, 20
br i1 %52, label %53, label %6
53: ; preds = %6, %1
%54 = phi double [ 0.000000e+00, %1 ], [ %50, %6 ]
ret double %54
}