// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x48(%rdi)
jne 0x8588
movq %rbx, %rdi
callq 0x3bbc
movq %rax, 0x48(%rbx)
movq %rbx, %rdi
callq 0x4728
movq %rax, 0x58(%rbx)
movq %rbx, %rdi
movl $0x19, %esi
callq 0x4c40
movq %rax, 0xd8(%rbx)
movq %rbx, %rdi
movl $0x32, %esi
callq 0x4c40
movq %rax, 0xe0(%rbx)
movq %rbx, %rdi
movl $0x64, %esi
callq 0x4c40
movq %rax, 0xe8(%rbx)
movl 0x3c(%rbx), %esi
movq %rbx, %rdi
callq 0x503c
movq %rax, 0xf0(%rbx)
movl 0x3c(%rbx), %esi
movq %rbx, %rdi
callq 0x52be
movq %rax, 0xf8(%rbx)
movslq 0xb8(%rbx), %r15
testq %r15, %r15
jle 0x85b6
movq 0x48(%rbx), %rax
movq 0x70(%rbx), %rcx
xorl %edx, %edx
movsd (%r14,%rdx,8), %xmm0
subsd (%rax,%rdx,8), %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %r15
jne 0x859e
movl $0x0, -0x24(%rbp)
cmpl $0x0, 0x3c(%rbx)
jle 0x8659
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorl %r14d, %r14d
leaq -0x24(%rbp), %r15
movq %rbx, %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x553e
movq %rax, 0x78(%rbx)
movq 0xf0(%rbx), %rcx
movq 0xf8(%rbx), %rdx
movsd (%rdx,%r14,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movl (%rcx,%r14,4), %edx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5e12
movq 0x78(%rbx), %rdi
testq %rdi, %rdi
je 0x8629
movsd %xmm0, -0x40(%rbp)
callq 0x3260
movsd -0x40(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd -0x30(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
incq %r14
movslq 0x3c(%rbx), %rax
cmpq %rax, %r14
jl 0x85d7
movl 0xb8(%rbx), %r15d
movl -0x24(%rbp), %r12d
jmp 0x8665
xorpd %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorl %r12d, %r12d
movl %r15d, %eax
subl %r12d, %eax
cltq
leaq (,%rax,8), %rcx
testl %eax, %eax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x3030
movq %rax, %r14
movl %r15d, %edx
subl %r12d, %edx
jle 0x86c5
movq 0x70(%rbx), %rax
movslq %r12d, %rdi
movslq %r15d, %rcx
leaq (,%rdi,4), %rsi
addq 0x58(%rbx), %rsi
subq %rdi, %rcx
xorl %edi, %edi
movslq (%rsi,%rdi,4), %r8
movsd (%rax,%r8,8), %xmm0
movsd %xmm0, (%r14,%rdi,8)
incq %rdi
cmpq %rdi, %rcx
jne 0x86ad
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5e12
movsd %xmm0, -0x38(%rbp)
movq %r14, %rdi
callq 0x3260
movsd -0x30(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq