// File: /workspace/github_cpp_makefile_star2_O2/Kingsford-Group[P]ghost2/src/localImprove.hpp
// Function: localImprove(Graph&, Graph&, boost::unordered::unordered_map<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, double, boost::hash<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::equal_to<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::allocator<std::pair<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>> const, double>>>*, boost::bimaps::bimap<boost::bimaps::unordered_set_of<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, boost::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, boost::bimaps::unordered_set_of<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, boost::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, mpl_::na, mpl_::na, mpl_::na>*, int, double, int)
int localImprove(Graph& G, Graph& H, blastmap *dists, bmap *f, int iters, double ratio, int numP)
{
  if(iters == 0) return 0;
  vector<double> ratios;
  double sum = 0;
  int ri = iters;
  if(iters == -1) ri = 10;
  for(int i=0; i < ri; i++){
    double d = exp(-i);
    sum += d;
    ratios.push_back(d);
  }
  sum = ratio/sum;
  int totalDelt = 0;
  for(int i=0; i < iters || iters == -1; i++){
    ptime t = bclock::local_time();
    double unconstrained;
    if(i < ri) unconstrained = ratios[i] * sum;
    else unconstrained = ratios[ri-1] * sum;
    if(unconstrained > 1) unconstrained = 1;
    cout << "running PISWAP iteration, " << (unconstrained * 100) << "\% unconstrained\n";
    int d = searchIter(G, H, dists, f, unconstrained, numP);
    cout << "\nadded " << d << " edges in " << (bclock::local_time() - t).total_milliseconds() << "ms\n";
    totalDelt += d;
    if(d == 0) break;
  }
  return totalDelt;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, 0x2c(%rsp)
movsd %xmm0, 0x8(%rsp)
movq %rcx, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, 0x38(%rsp)
testl %r8d, %r8d
je 0x173f6
movl %r8d, %r13d
xorpd %xmm0, %xmm0
leaq 0x60(%rsp), %rbx
andq $0x0, 0x10(%rbx)
cmpl $-0x1, %r8d
pushq $0xa
popq %rbp
cmovnel %r8d, %ebp
xorl %r14d, %r14d
testl %ebp, %ebp
movl $0x0, %r12d
cmovgl %ebp, %r12d
movapd %xmm0, (%rbx)
negl %r12d
xorpd %xmm1, %xmm1
leaq 0x20(%rsp), %r15
cmpl %r14d, %r12d
je 0x17296
movsd %xmm1, 0x18(%rsp)
movl %r14d, %edi
callq 0x1ad38
movsd %xmm0, 0x10(%rsp)
movsd %xmm0, 0x20(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x18f0c
movsd 0x18(%rsp), %xmm1
addsd 0x10(%rsp), %xmm1
decl %r14d
jmp 0x1725b
movsd 0x8(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movl %r13d, %eax
movslq %ebp, %r13
movl %eax, 0x10(%rsp)
cltq
movq %rax, 0x30(%rsp)
xorl %r14d, %r14d
xorl %ebp, %ebp
xorl %ebx, %ebx
cmpl $-0x1, 0x10(%rsp)
setne %al
cmpq 0x30(%rsp), %rbp
setge %cl
testb %cl, %al
jne 0x173ea
callq 0x1889e
movq %rax, 0x20(%rsp)
movq 0x60(%rsp), %rax
leaq (%rax,%r14), %rcx
cmpq %r13, %rbp
leaq -0x8(%rax,%r13,8), %rax
cmovlq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x65c92(%rip), %rdi     # 0x7cf98
leaq 0x296ed(%rip), %rsi     # 0x409fa
callq 0xe540
movsd 0x18(%rsp), %xmm1
mulsd 0x8(%rsp), %xmm1
movsd 0x28d4a(%rip), %xmm0    # 0x40070
minsd %xmm1, %xmm0
mulsd 0x28d26(%rip), %xmm0    # 0x40058
movq %rax, %rdi
callq 0xe940
movq %rax, %rdi
leaq 0x296d1(%rip), %rsi     # 0x40a15
callq 0xe540
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x50(%rsp), %rcx
movl 0x2c(%rsp), %r8d
callq 0x16b43
movl %eax, %r15d
movq 0x65c27(%rip), %rdi     # 0x7cf98
leaq 0x296ae(%rip), %rsi     # 0x40a26
callq 0xe540
movq %rax, %rdi
movl %r15d, %esi
callq 0xe9d0
movq %rax, %rdi
leaq 0x2969c(%rip), %rsi     # 0x40a2e
callq 0xe540
movq %rax, %r12
callq 0x1889e
movq %rax, 0x58(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1c4fa
cqto
movl $0x3e8, %ecx            # imm = 0x3E8
idivq %rcx
movq %r12, %rdi
movq %rax, %rsi
callq 0xe500
movq %rax, %rdi
leaq 0x29521(%rip), %rsi     # 0x408f3
callq 0xe540
addl %r15d, %ebx
incq %rbp
addq $0x8, %r14
testl %r15d, %r15d
jne 0x172be
leaq 0x60(%rsp), %rdi
callq 0x29310
jmp 0x173f8
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x17411
jmp 0x17411
jmp 0x17411
jmp 0x17411
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x29310
movq %rbx, %rdi
callq 0xe9f0