// File: mateuz[P]MTS-LS1/source/Benchmarks.cpp
// Function: Benchmarks::rot_ackley(double*, int, int)
double Benchmarks::rot_ackley(double *x,int dim,int k)
{
  double result=0.0;
  double sum1=0.0;
  double sum2=0.0;

  int i,j;
  for(i=dim-1;i>=0;i--)
    {
      anotherz1[i]=0;
      for(j=dim-1;j>=0;j--)
        {
          anotherz1[i]+=x[Pvector[(k-1)*dim+j]]*RotMatrix[dim*j+i];
        }
    }
  for(i=dim-1;i>=0;i--)
    {
      sum1+=anotherz1[i]*anotherz1[i];
      sum2+=cos(2.0*PI*anotherz1[i]);
    }
  result=-20.0*exp(-0.2*sqrt(sum1/dim))-exp(sum2/dim)+20.0+E;
  return(result);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x6cec
movq -0x40(%rbp), %rax
movq 0x78(%rax), %rax
movslq -0x34(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jl 0x6cdc
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x58(%rax), %rdx
movl -0x18(%rbp), %esi
subl $0x1, %esi
imull -0x14(%rbp), %esi
addl -0x38(%rbp), %esi
movslq %esi, %rsi
movslq (%rdx,%rsi,4), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x60(%rax), %rcx
movl -0x14(%rbp), %edx
imull -0x38(%rbp), %edx
addl -0x34(%rbp), %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm2
movq 0x78(%rax), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x6c76
jmp 0x6cde
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x6c4f
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x6d5a
movq -0x40(%rbp), %rax
movq 0x78(%rax), %rcx
movslq -0x34(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x78(%rax), %rcx
movslq -0x34(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm2
movsd -0x28(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movq 0x78(%rax), %rax
movslq -0x34(%rbp), %rcx
movsd 0xc32d(%rip), %xmm0     # 0x13068
mulsd (%rax,%rcx,8), %xmm0
callq 0x3350
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x6cf5
movsd -0x28(%rbp), %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x3160
movaps %xmm0, %xmm1
movsd 0xc310(%rip), %xmm0     # 0x13088
mulsd %xmm1, %xmm0
callq 0x3330
movsd %xmm0, -0x48(%rbp)
movsd -0x30(%rbp), %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x3330
movaps %xmm0, %xmm1
movsd -0x48(%rbp), %xmm0
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0xc2c0(%rip), %xmm2     # 0x13080
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0xc2a8(%rip), %xmm1     # 0x13078
addsd %xmm1, %xmm0
movsd 0xc294(%rip), %xmm1     # 0x13070
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
addq $0x50, %rsp
popq %rbp
retq