#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 cos(double);
double f_BohachevskyNoDesplazamiento(double sol[], int DIM) {
  double sum = 0.0;
  int i;
  double currentGen;
  double nextGen;
  currentGen = sol[0];
  for (i = 1; i < DIM; i++) {
    nextGen = sol[i];
    sum += currentGen * currentGen + 2.0 * nextGen * nextGen;
    double c1 = cos(3.0 * 3.14159265 * currentGen);
    double c2 = cos(4.0 * 3.14159265 * nextGen);
    sum += 0.7 - (0.3 * c1 + 0.4 * c2);
    currentGen = nextGen;
  }
  return sum;
}


x86 assembly (clang, -O0):
<f_BohachevskyNoDesplazamiento>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1205 <f_BohachevskyNoDesplazamiento+0xf5>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  0xebd(%rip),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe91(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe72(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  0xe4e(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  0xe39(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe21(%rip),%xmm0
subsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113b <f_BohachevskyNoDesplazamiento+0x2b>
movsd  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_BohachevskyNoDesplazamiento>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
cmp    $0x2,%esi
jl     11d7 <f_BohachevskyNoDesplazamiento+0xc7>
mov    %rdi,%r14
movsd  (%rdi),%xmm1
mov    %esi,%r15d
xorpd  %xmm0,%xmm0
mov    $0x1,%ebx
nopl   0x0(%rax)
movsd  (%r14,%rbx,8),%xmm3
movsd  %xmm3,0x8(%rsp)
movapd %xmm3,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm3,%xmm2
movapd %xmm1,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
movsd  %xmm3,0x18(%rsp)
mulsd  0xe8a(%rip),%xmm1
movapd %xmm1,%xmm0
call   1030 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe75(%rip),%xmm0
call   1030 <cos@plt>
mulsd  0xe70(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0xe6a(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe66(%rip),%xmm0
subsd  %xmm1,%xmm0
addsd  0x18(%rsp),%xmm0
add    $0x1,%rbx
movsd  0x8(%rsp),%xmm1
cmp    %rbx,%r15
jne    1140 <f_BohachevskyNoDesplazamiento+0x30>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @f_BohachevskyNoDesplazamiento(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %5
%11 = load double*, double** %3
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
store double %13, double* %7
store i32 1, i32* %6
br label %14
14: ; preds = %47, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %50
18: ; preds = %14
%19 = load double*, double** %3
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
store double %23, double* %8
%24 = load double, double* %7
%25 = load double, double* %7
%26 = load double, double* %8
%27 = fmul double 2.000000e+00, %26
%28 = load double, double* %8
%29 = fmul double %27, %28
%30 = call double @llvm.fmuladd.f64(double %24, double %25, double %29)
%31 = load double, double* %5
%32 = fadd double %31, %30
store double %32, double* %5
%33 = load double, double* %7
%34 = fmul double 0x4022D97C7ED69FB5, %33
%35 = call double @cos(double %34)
store double %35, double* %9
%36 = load double, double* %8
%37 = fmul double 0x402921FB53C8D4F1, %36
%38 = call double @cos(double %37)
store double %38, double* %10
%39 = load double, double* %9
%40 = load double, double* %10
%41 = fmul double 4.000000e-01, %40
%42 = call double @llvm.fmuladd.f64(double 3.000000e-01, double %39, double %41)
%43 = fsub double 0x3FE6666666666666, %42
%44 = load double, double* %5
%45 = fadd double %44, %43
store double %45, double* %5
%46 = load double, double* %8
store double %46, double* %7
br label %47
47: ; preds = %18
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %14
50: ; preds = %14
%51 = load double, double* %5
ret double %51
}

LLVM IR (-O2):
define double @f_BohachevskyNoDesplazamiento(double* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %27
4: ; preds = %2
%5 = load double, double* %0
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ 1, %4 ], [ %25, %7 ]
%9 = phi double [ 0.000000e+00, %4 ], [ %24, %7 ]
%10 = phi double [ %5, %4 ], [ %12, %7 ]
%11 = getelementptr inbounds double, double* %0, i64 %8
%12 = load double, double* %11
%13 = fmul double %12, 2.000000e+00
%14 = fmul double %12, %13
%15 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %14)
%16 = fadd double %9, %15
%17 = fmul double %10, 0x4022D97C7ED69FB5
%18 = tail call double @cos(double %17)
%19 = fmul double %12, 0x402921FB53C8D4F1
%20 = tail call double @cos(double %19)
%21 = fmul double %20, 4.000000e-01
%22 = tail call double @llvm.fmuladd.f64(double %18, double 3.000000e-01, double %21)
%23 = fsub double 0x3FE6666666666666, %22
%24 = fadd double %16, %23
%25 = add nuw nsw i64 %8, 1
%26 = icmp eq i64 %25, %6
br i1 %26, label %27, label %7
27: ; preds = %7, %2
%28 = phi double [ 0.000000e+00, %2 ], [ %24, %7 ]
ret double %28
}