// File: /workspace/github_cpp_makefile_star2_O3/Kingsford-Group[P]ghost2/src/spectralToDistance.hpp
// Function: applyAlpha(double, double, std::vector<D_alpha, std::allocator<D_alpha>>*, 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>>>*)
void applyAlpha(double a, double b, vector<D_alpha> *scores, blastmap* blastscores)
{
  if(!blastscores) return;

  if(a == -1){
    vector<double> maxheap;
    for(auto it = scores->begin(); it != scores->end(); it++){
      if(it->get_da() != 0) maxheap.push_back(it->get_da());
      push_heap(maxheap.begin(), maxheap.end());
      if(maxheap.size() > (int)(.0005 * scores->size())){
        pop_heap(maxheap.begin(), maxheap.end());
        maxheap.pop_back();
      }
    }
    double structval = maxheap.front();

    maxheap.clear();
    for(auto it = scores->begin(); it != scores->end(); it++){
      auto sc = blastscores->find(make_pair(it->get_n1(), it->get_n2()));
      if(sc == blastscores->end()) continue;
      double score = sc->second;
      if(score != 0) maxheap.push_back(score);
      push_heap(maxheap.begin(), maxheap.end());
      if(maxheap.size() > (int)(.0005 * blastscores->size())){
        pop_heap(maxheap.begin(), maxheap.end());
        maxheap.pop_back();
      }
    }
    if(maxheap.size() == 0) a = 1;
    else {
      double seqval = maxheap.front();
      a = seqval / (seqval + structval);
    }
  }

  double maxScore = -1;
  for(auto it = scores->begin(); it != scores->end(); it++){
    double seq;
    auto d = blastscores->find(make_pair(it->get_n1(), it->get_n2()));
    if(d != blastscores->end()){
      seq = d->second;
      if(seq > b) seq = b;
      if(seq > maxScore) maxScore = seq;
    }else seq = b;
    it->set_seq(seq);
  }

  for(auto it = scores->begin(); it != scores->end(); it++){
    double seq = it->get_ds();
    if(seq < b) it->set_seq(seq/maxScore);
    else it->set_seq(1.1);
    it->update_da(a);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
testq %rsi, %rsi
je 0x13907
movq %rsi, %rbx
movq %rdi, %r14
movsd %xmm1, 0xb0(%rsp)
ucomisd 0x34e1e(%rip), %xmm0    # 0x48078
movq (%rdi), %r15
jne 0x13676
jp 0x13676
movq %rbx, %rbp
xorpd %xmm0, %xmm0
movq %rsp, %r13
movapd %xmm0, (%r13)
movq $0x0, 0x10(%r13)
xorl %edx, %edx
leaq 0x68(%rsp), %r12
movabsq $-0x3333333333333333, %rbx # imm = 0xCCCCCCCCCCCCCCCD
movsd 0x40(%r15), %xmm0
ucomisd 0x34dc8(%rip), %xmm0    # 0x48068
jne 0x132a4
jnp 0x132ce
movsd %xmm0, 0x68(%rsp)
cmpq 0x10(%rsp), %rdx
je 0x132c0
movsd %xmm0, (%rdx)
addq $0x8, %rdx
movq %rdx, 0x8(%rsp)
jmp 0x132ce
movq %r13, %rdi
movq %rdx, %rsi
movq %r12, %rdx
callq 0x3e326
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
movsd -0x8(%rdx), %xmm0
movq %rdx, %rcx
subq %rdi, %rcx
movq %rcx, %rsi
sarq $0x3, %rsi
leaq -0x1(%rsi), %rax
cmpq $0x2, %rsi
jl 0x13319
leaq -0x1(%rax), %r8
movq %r8, %r9
shrq %r9
movsd (%rdi,%r9,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x13319
movsd %xmm1, (%rdi,%rax,8)
movq %r9, %rax
cmpq $0x1, %r8
ja 0x132f3
xorl %eax, %eax
movsd %xmm0, (%rdi,%rax,8)
movq 0x8(%r14), %rax
movq %rax, %r8
subq (%r14), %r8
sarq $0x4, %r8
imulq %rbx, %r8
movq %r8, %xmm0
punpckldq 0x34e23(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x34e2b(%rip), %xmm0    # 0x48170
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x34d8f(%rip), %xmm1    # 0x480e8
cvttsd2si %xmm1, %r8d
movslq %r8d, %r8
cmpq %r8, %rsi
jbe 0x1339c
cmpq $0x9, %rcx
jl 0x1338e
addq $-0x8, %rdx
movsd (%rdx), %xmm0
movsd (%rdi), %xmm1
movsd %xmm1, (%rdx)
subq %rdi, %rdx
sarq $0x3, %rdx
xorl %esi, %esi
callq 0x3f1d8
movq 0x8(%r14), %rax
movq 0x8(%rsp), %rdx
addq $-0x8, %rdx
movq %rdx, 0x8(%rsp)
addq $0x50, %r15
cmpq %rax, %r15
jne 0x13292
movq (%rsp), %rdi
movsd (%rdi), %xmm0
cmpq %rdi, %rdx
je 0x133be
movq %rdi, 0x8(%rsp)
movq %rdi, %rdx
movq (%r14), %r13
cmpq %rax, %r13
movq %rbp, %rbx
je 0x1365a
movsd %xmm0, 0x60(%rsp)
leaq 0x50(%rsp), %r15
leaq 0x30(%rsp), %r12
leaq 0x78(%rsp), %rbp
movq %r15, 0x40(%rsp)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0x27846
movq %r12, 0x20(%rsp)
movq 0x20(%r13), %rsi
movq 0x28(%r13), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0x27846
movq %rbp, 0x68(%rsp)
movq 0x40(%rsp), %rax
cmpq %r15, %rax
je 0x13436
movq %rax, 0x68(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x78(%rsp)
jmp 0x13440
movupd (%r15), %xmm0
movupd %xmm0, (%rbp)
movq 0x48(%rsp), %rax
movq %rax, 0x70(%rsp)
movq %r15, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
movb $0x0, 0x50(%rsp)
leaq 0x98(%rsp), %rcx
movq %rcx, 0x88(%rsp)
movq 0x20(%rsp), %rax
cmpq %r12, %rax
je 0x1348e
movq %rax, 0x88(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x98(%rsp)
jmp 0x13498
movupd (%r12), %xmm0
movupd %xmm0, (%rcx)
movq 0x28(%rsp), %rax
movq %rax, 0x90(%rsp)
movq %r12, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movq %rbx, %rdi
leaq 0x68(%rsp), %rsi
callq 0x3f28e
movq %rax, %rbp
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x134ed
movq 0x98(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x13509
movq 0x78(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x13520
movq 0x30(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x13537
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xc550
testq %rbp, %rbp
je 0x13638
movsd 0x50(%rbp), %xmm0
movsd %xmm0, 0x68(%rsp)
ucomisd 0x34b15(%rip), %xmm0    # 0x48068
movq 0x8(%rsp), %rdx
jne 0x1355c
jnp 0x13587
cmpq 0x10(%rsp), %rdx
je 0x13572
movsd %xmm0, (%rdx)
addq $0x8, %rdx
movq %rdx, 0x8(%rsp)
jmp 0x13587
movq %rsp, %rdi
movq %rdx, %rsi
leaq 0x68(%rsp), %rdx
callq 0x3365e
movq 0x8(%rsp), %rdx
movq (%rsp), %rdi
movsd -0x8(%rdx), %xmm0
movq %rdx, %rax
subq %rdi, %rax
movq %rax, %rcx
sarq $0x3, %rcx
leaq -0x1(%rcx), %rsi
cmpq $0x2, %rcx
jl 0x135cd
leaq -0x1(%rsi), %r8
movq %r8, %r9
shrq %r9
movsd (%rdi,%r9,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x135cd
movsd %xmm1, (%rdi,%rsi,8)
movq %r9, %rsi
cmpq $0x1, %r8
ja 0x135a7
xorl %esi, %esi
movsd %xmm0, (%rdi,%rsi,8)
movsd 0x10(%rbx), %xmm0
unpcklps 0x34b82(%rip), %xmm0    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x34b8a(%rip), %xmm0    # 0x48170
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x34aee(%rip), %xmm1    # 0x480e8
cvttsd2si %xmm1, %esi
movslq %esi, %rsi
cmpq %rsi, %rcx
jbe 0x13638
cmpq $0x9, %rax
jl 0x1362f
addq $-0x8, %rdx
movsd (%rdx), %xmm0
movsd (%rdi), %xmm1
movsd %xmm1, (%rdx)
subq %rdi, %rdx
sarq $0x3, %rdx
xorl %esi, %esi
callq 0x3f1d8
movq 0x8(%rsp), %rdx
addq $-0x8, %rdx
movq %rdx, 0x8(%rsp)
addq $0x50, %r13
cmpq 0x8(%r14), %r13
leaq 0x78(%rsp), %rbp
jne 0x133e2
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
movsd 0x60(%rsp), %xmm0
cmpq %rdi, %rdx
je 0x13681
movsd (%rdi), %xmm1
addsd %xmm1, %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, 0xa8(%rsp)
jmp 0x13697
movsd %xmm0, 0xa8(%rsp)
jmp 0x136a7
movsd 0x349d7(%rip), %xmm0    # 0x48060
movsd %xmm0, 0xa8(%rsp)
testq %rdi, %rdi
je 0x136a4
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0xc550
movq (%r14), %r15
cmpq 0x8(%r14), %r15
je 0x13907
movq %rbx, 0xc0(%rsp)
movq %r14, 0xb8(%rsp)
leaq 0x50(%rsp), %r12
leaq 0x30(%rsp), %r13
leaq 0x78(%rsp), %r14
movsd 0x349a0(%rip), %xmm6    # 0x48078
leaq 0x98(%rsp), %rbx
movsd %xmm6, 0x60(%rsp)
movq %r12, 0x40(%rsp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0x27846
movq %r13, 0x20(%rsp)
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0x27846
movq %r14, 0x68(%rsp)
movq 0x40(%rsp), %rax
cmpq %r12, %rax
je 0x13739
movq %rax, 0x68(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x78(%rsp)
jmp 0x13744
movupd (%r12), %xmm0
movupd %xmm0, (%r14)
movq 0x48(%rsp), %rax
movq %rax, 0x70(%rsp)
movq %r12, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
movb $0x0, 0x50(%rsp)
movq %rbx, 0x88(%rsp)
movq 0x20(%rsp), %rax
cmpq %r13, %rax
je 0x1378a
movq %rax, 0x88(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x98(%rsp)
jmp 0x13794
movupd (%r13), %xmm0
movupd %xmm0, (%rbx)
movq 0x28(%rsp), %rax
movq %rax, 0x90(%rsp)
movq %r13, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movq 0xc0(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3f28e
movq %rax, %rbp
movq 0x88(%rsp), %rdi
cmpq %rbx, %rdi
je 0x137e6
movq 0x98(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x137fd
movq 0x78(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x13814
movq 0x30(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x1382b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xc550
testq %rbp, %rbp
je 0x13850
movsd 0xb0(%rsp), %xmm0
minsd 0x50(%rbp), %xmm0
movsd 0x60(%rsp), %xmm6
ucomisd %xmm6, %xmm0
jbe 0x1385f
movapd %xmm0, %xmm6
jmp 0x1385f
movsd 0xb0(%rsp), %xmm0
movsd 0x60(%rsp), %xmm6
movsd %xmm0, 0x48(%r15)
addq $0x50, %r15
movq 0xb8(%rsp), %rax
cmpq 0x8(%rax), %r15
jne 0x136e0
movq 0xb8(%rsp), %rax
movq (%rax), %rax
cmpq %rax, %r15
movsd 0xb0(%rsp), %xmm4
movsd 0xa8(%rsp), %xmm5
je 0x13907
addq $-0x50, %r15
movsd 0x347b7(%rip), %xmm0    # 0x48060
subsd %xmm5, %xmm0
addq $-0x50, %rax
movsd 0x34837(%rip), %xmm1    # 0x480f0
movsd 0x98(%rax), %xmm2
movapd %xmm2, %xmm3
divsd %xmm6, %xmm3
cmpltsd %xmm4, %xmm2
andpd %xmm2, %xmm3
andnpd %xmm1, %xmm2
orpd %xmm3, %xmm2
movlpd %xmm2, 0x98(%rax)
mulsd %xmm0, %xmm2
movsd 0x90(%rax), %xmm3
mulsd %xmm5, %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, 0x90(%rax)
addq $0x50, %rax
cmpq %rax, %r15
jne 0x138b9
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1391f
jmp 0x1391f
jmp 0x1391f
movq %rax, %rbx
jmp 0x13964
movq %rax, %rbx
jmp 0x1394d
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x1d33e
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x1394d
movq 0x30(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x13964
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xc550
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x139b7
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
jmp 0x139b2
movq %rax, %rbx
jmp 0x139a0
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x1d33e
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x139a0
movq 0x30(%rsp), %rsi
incq %rsi
callq 0xc550
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x139b7
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xc550
movq %rbx, %rdi
callq 0xc9c0