// File: mateuz[P]MTS-LS1/source/F6.cpp
// Function: F6::compute(double*)
double F6::compute(double*x){
  int    i;
  double result = 0.0;

  if(Ovector == NULL) {
    Ovector = readOvector();
    Pvector = readPermVector();
    r25 = readR(25);
    r50 = readR(50);
    r100 = readR(100);
    s = readS(s_size);
    w = readW(s_size);
  }

  for(i = 0; i < dimension; i++) {
    anotherz[i] = x[i] - Ovector[i];
  }

  // cout<<"non"<<endl;
  
  // s_size non-separable part with rotation
  int c = 0;
  for (i = 0; i < s_size; i++)
    {
      // cout<<"c="<<c<<", i="<<i<<endl;
      anotherz1 = rotateVector(i, c);
      // cout<<"done rot"<<endl;
      result += w[i] * ackley(anotherz1, s[i]);
      delete []anotherz1;
      // cout<<result<<endl;
    }
  
  // one separable part without rotation
  double* z = new double[dimension-c];
  for (i = c; i < dimension; i++)
    {
      // cout<<i-c<<" "<<Pvector[i]<<" "<<anotherz[Pvector[i]]<<endl;
      z[i-c] = anotherz[Pvector[i]];
    }
  result += ackley(z, dimension-c);
  delete []z;
  
  return(result);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
cmpq $0x0, 0x48(%rax)
jne 0xb4c1
movq -0x38(%rbp), %rdi
callq 0x3e10
movq -0x38(%rbp), %rdi
movq %rax, 0x48(%rdi)
callq 0x4ad0
movq -0x38(%rbp), %rdi
movq %rax, 0x58(%rdi)
movl $0x19, %esi
callq 0x51e0
movq -0x38(%rbp), %rdi
movq %rax, 0xd8(%rdi)
movl $0x32, %esi
callq 0x51e0
movq -0x38(%rbp), %rdi
movq %rax, 0xe0(%rdi)
movl $0x64, %esi
callq 0x51e0
movq -0x38(%rbp), %rdi
movq %rax, 0xe8(%rdi)
movl 0x3c(%rdi), %esi
callq 0x5640
movq -0x38(%rbp), %rdi
movq %rax, 0xf0(%rdi)
movl 0x3c(%rdi), %esi
callq 0x58e0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0xf8(%rax)
movl $0x0, -0x14(%rbp)
movq -0x38(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0xb8(%rcx), %eax
jge 0xb50d
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq 0x48(%rax), %rcx
movslq -0x14(%rbp), %rdx
subsd (%rcx,%rdx,8), %xmm0
movq 0x70(%rax), %rax
movslq -0x14(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xb4c8
movl $0x0, -0x24(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x38(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x3c(%rcx), %eax
jge 0xb5b4
movq -0x38(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x24(%rbp), %rdx
callq 0x5b80
movq -0x38(%rbp), %rdi
movq %rax, 0x78(%rdi)
movq 0xf8(%rdi), %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x48(%rbp)
movq 0x78(%rdi), %rsi
movq 0xf0(%rdi), %rax
movslq -0x14(%rbp), %rcx
movl (%rax,%rcx,4), %edx
callq 0x65b0
movq -0x38(%rbp), %rax
movaps %xmm0, %xmm2
movsd -0x48(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movq 0x78(%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0xb5a4
movq -0x40(%rbp), %rdi
callq 0x3230
jmp 0xb5a6
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xb51b
movq -0x38(%rbp), %rax
movl 0xb8(%rax), %eax
subl -0x24(%rbp), %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x14(%rbp)
movq -0x38(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0xb8(%rcx), %eax
jge 0xb633
movq -0x38(%rbp), %rcx
movq 0x70(%rcx), %rax
movq 0x58(%rcx), %rcx
movslq -0x14(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movl -0x14(%rbp), %ecx
subl -0x24(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xb5ee
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl 0xb8(%rdi), %edx
subl -0x24(%rbp), %edx
callq 0x65b0
addsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0xb66a
movq -0x50(%rbp), %rdi
callq 0x3230
movsd -0x20(%rbp), %xmm0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop