// File: 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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movsd %xmm0, -0x38(%rbp)
movl %r9d, -0x3c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x2084a
movl $0x0, -0x4(%rbp)
jmp 0x20b73
leaq -0x58(%rbp), %rdi
callq 0x251f0
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x64(%rbp)
cmpl $-0x1, -0x2c(%rbp)
jne 0x2086e
movl $0xa, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x208e7
movl -0x68(%rbp), %edi
negl %edi
callq 0x2b1c0
movsd %xmm0, -0xb8(%rbp)
jmp 0x20891
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm1
movsd -0x60(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x253d0
jmp 0x208c0
jmp 0x208c2
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x20875
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x25480
jmp 0x20b7f
movsd -0x38(%rbp), %xmm0
divsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movl $0x0, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %ecx
movb $0x1, %al
cmpl -0x2c(%rbp), %ecx
movb %al, -0xb9(%rbp)
jl 0x20927
cmpl $-0x1, -0x2c(%rbp)
sete %al
movb %al, -0xb9(%rbp)
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x20936
jmp 0x20b64
callq 0x23b20
movq %rax, -0xc8(%rbp)
jmp 0x20944
movq -0xc8(%rbp), %rax
movq %rax, -0x90(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x20980
movslq -0x84(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x25500
movsd (%rax), %xmm0
mulsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
jmp 0x209a3
movl -0x64(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x58(%rbp), %rdi
callq 0x25500
movsd (%rax), %xmm0
mulsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
movsd 0x9b6bd(%rip), %xmm1    # 0xbc070
ucomisd %xmm1, %xmm0
jbe 0x209c9
movsd 0x9b6af(%rip), %xmm0    # 0xbc070
movsd %xmm0, -0x98(%rbp)
movq 0x1105c8(%rip), %rdi    # 0x130f98
leaq 0x9bfe7(%rip), %rsi     # 0xbc9be
callq 0x106c0
movq %rax, -0xd0(%rbp)
jmp 0x209e5
movq -0xd0(%rbp), %rdi
movsd -0x98(%rbp), %xmm0
movsd 0x9b65c(%rip), %xmm1    # 0xbc058
mulsd %xmm1, %xmm0
callq 0x10dc0
movq %rax, -0xd8(%rbp)
jmp 0x20a0e
movq -0xd8(%rbp), %rdi
leaq 0x9bfbd(%rip), %rsi     # 0xbc9d9
callq 0x106c0
jmp 0x20a23
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movsd -0x98(%rbp), %xmm0
movl -0x3c(%rbp), %r8d
callq 0x1fb80
movl %eax, -0xdc(%rbp)
jmp 0x20a4c
movl -0xdc(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq 0x110539(%rip), %rdi    # 0x130f98
leaq 0x9bf84(%rip), %rsi     # 0xbc9ea
callq 0x106c0
movq %rax, -0xe8(%rbp)
jmp 0x20a74
movq -0xe8(%rbp), %rdi
movl -0x9c(%rbp), %esi
callq 0x10ca0
movq %rax, -0xf0(%rbp)
jmp 0x20a8f
movq -0xf0(%rbp), %rdi
leaq 0x9bf55(%rip), %rsi     # 0xbc9f2
callq 0x106c0
movq %rax, -0xf8(%rbp)
jmp 0x20aab
callq 0x23b20
movq %rax, -0x100(%rbp)
jmp 0x20ab9
movq -0x100(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x23cc0
movq %rax, -0x108(%rbp)
jmp 0x20ae3
movq -0x108(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x23cf0
movq %rax, -0x110(%rbp)
jmp 0x20b06
movq -0x110(%rbp), %rsi
movq -0xf8(%rbp), %rdi
callq 0x10d40
movq %rax, -0x118(%rbp)
jmp 0x20b22
movq -0x118(%rbp), %rdi
leaq 0x9bd87(%rip), %rsi     # 0xbc8b7
callq 0x106c0
jmp 0x20b37
movl -0x9c(%rbp), %eax
addl -0x80(%rbp), %eax
movl %eax, -0x80(%rbp)
cmpl $0x0, -0x9c(%rbp)
jne 0x20b4e
jmp 0x20b64
jmp 0x20b50
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x20907
movl -0x80(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x25480
movl -0x4(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x10cc0
nopl (%rax,%rax)