// File: /workspace/github_cpp_makefile_star2_O3/mateuz[P]MTS-LS1/source/main.cpp
// Function: mts_ls1_improve_dim(Benchmarks*, std::vector<double, std::allocator<double>>&, double, unsigned int, std::vector<double, std::allocator<double>>&)
LSresult mts_ls1_improve_dim(Benchmarks * bench, vector<double>& sol, double best_fitness, unsigned i, vector<double> & SR ){
  vector<double> newsol = sol;
  newsol[i] -= SR[i];

  double initial_fit = best_fitness;

  newsol[i] = min(newsol[i], (double)bench->getMaxX());
  newsol[i] = max(newsol[i], (double)bench->getMinX());

  double fitness_newsol = bench->compute(newsol.data());

  unsigned evals = 1;

  if( fitness_newsol < best_fitness ){
    best_fitness = fitness_newsol;
    sol = newsol;
  } else if( fitness_newsol > best_fitness ){
    newsol[i] = sol[i];
    newsol[i] += 0.5 * SR[i];

    newsol[i] = min(newsol[i], (double)bench->getMaxX());
    newsol[i] = max(newsol[i], (double)bench->getMinX());

    fitness_newsol = bench->compute(newsol.data());
    evals++;

    if( fitness_newsol < best_fitness ){
      best_fitness = fitness_newsol;
      sol = newsol;
    }
  }
  //printf("%1.20E -> %1.20E\n", initial_fit, best_fitness);
  return LSresult{sol, best_fitness, evals};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r12
movl %ecx, %r13d
movsd %xmm0, -0x30(%rbp)
movq %rsi, %r15
movq %rdi, %rbx
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movq %rdx, -0x38(%rbp)
movq %rdx, %rsi
callq 0xa5e0
movl %r13d, %r13d
movq (%r12), %rax
movq (%r14), %r14
movsd (%r14,%r13,8), %xmm0
subsd (%rax,%r13,8), %xmm0
movsd %xmm0, (%r14,%r13,8)
movq %r15, %rdi
callq 0x674e
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
minsd (%r14,%r13,8), %xmm0
movq -0x50(%rbp), %r14
movsd %xmm0, (%r14,%r13,8)
movq %r15, %rdi
callq 0x6742
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
maxsd (%r14,%r13,8), %xmm0
movq -0x50(%rbp), %rsi
movsd %xmm0, (%rsi,%r13,8)
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
movsd -0x30(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x9153
movsd %xmm0, -0x30(%rbp)
leaq -0x50(%rbp), %rsi
movq -0x38(%rbp), %r15
movq %r15, %rdi
callq 0xa660
movl $0x1, %r14d
jmp 0x920d
movl $0x1, %r14d
ucomisd %xmm1, %xmm0
jbe 0x9209
movq -0x38(%rbp), %rax
movq (%rax), %rax
movsd (%rax,%r13,8), %xmm0
movq -0x50(%rbp), %r14
movsd %xmm0, (%r14,%r13,8)
movq (%r12), %rax
movsd (%rax,%r13,8), %xmm1
mulsd 0x1e9c(%rip), %xmm1     # 0xb028
addsd %xmm0, %xmm1
movsd %xmm1, (%r14,%r13,8)
movq %r15, %rdi
callq 0x674e
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
minsd (%r14,%r13,8), %xmm0
movq -0x50(%rbp), %r14
movsd %xmm0, (%r14,%r13,8)
movq %r15, %rdi
callq 0x6742
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
maxsd (%r14,%r13,8), %xmm0
movq -0x50(%rbp), %rsi
movsd %xmm0, (%rsi,%r13,8)
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq -0x38(%rbp), %r15
movapd %xmm0, %xmm1
movl $0x2, %r14d
movsd -0x30(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x920d
leaq -0x50(%rbp), %rsi
movq %r15, %rdi
movsd %xmm1, -0x30(%rbp)
callq 0xa660
jmp 0x920d
movq -0x38(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xa5e0
movsd -0x30(%rbp), %xmm0
movsd %xmm0, 0x18(%rbx)
movl %r14d, 0x20(%rbx)
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x9234
callq 0x31f0
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9250
jmp 0x9250
jmp 0x9250
jmp 0x9250
jmp 0x9250
movq %rax, %rbx
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x9261
callq 0x31f0
movq %rbx, %rdi
callq 0x3320