// File: /workspace/github_cpp_makefile_star2_O3/Altius[P]hotspot2/src/hotspot2_part1.cpp
// Function: SiteManager::processPvalue(long double const&)
void SiteManager::processPvalue(const long double& pval
#ifdef DEBUG
				, const bool& sampled
#endif
				)
{
  static const int MAX_VALUE = static_cast<int>(floor(-log10(numeric_limits<long double>::min()) * CHANGE_OF_SCALE + 0.5));
  int negLog10P_scaled;
  if (pval < 0 || pval > 1)
    negLog10P_scaled = 0;
  else
    {
      if (pval < numeric_limits<long double>::min())
      	negLog10P_scaled = MAX_VALUE;
      else
	negLog10P_scaled = static_cast<int>(floor(-log10(pval) * CHANGE_OF_SCALE + 0.5));
    }
  deque<SiteRange>::iterator itCurSiteNeedingPval(m_sites.begin());
  while (itCurSiteNeedingPval != m_sites.end() && itCurSiteNeedingPval->hasPval)
    itCurSiteNeedingPval++;
  if (m_sites.end() == itCurSiteNeedingPval)
    {
      cerr << "Error:  line " << __LINE__ << ", m_sites is empty or already filled with P-values"
	   << endl << endl;
      exit(2);
    }

  itCurSiteNeedingPval->pval = pval;
  itCurSiteNeedingPval->negLog10P_scaled = negLog10P_scaled;
  itCurSiteNeedingPval->hasPval = true;
#ifdef DEBUG
  itCurSiteNeedingPval->sampled = sampled;
#endif

  if (itCurSiteNeedingPval != m_sites.begin())
    {
      deque<SiteRange>::iterator it_prev = itCurSiteNeedingPval;
      it_prev--;
      if (it_prev->chrom == itCurSiteNeedingPval->chrom && it_prev->endPos + 1 == itCurSiteNeedingPval->endPos &&
#ifdef DEBUG
	  it_prev->sampled == itCurSiteNeedingPval->sampled &&
#endif
	  it_prev->negLog10P_scaled == itCurSiteNeedingPval->negLog10P_scaled)
	itCurSiteNeedingPval->begPos = it_prev->begPos;
      else
	writeLastUnreportedSite();
      m_sites.pop_front();
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movb 0xa6f3(%rip), %al       # 0xd290
testb %al, %al
je 0x2cca
fldt (%r14)
fldz
fucompi %st(1), %st
seta %cl
fld1
fxch %st(1)
fucomi %st(1), %st
fstp %st(1)
seta %dl
xorl %eax, %eax
orb %cl, %dl
jne 0x2c15
fldt 0x646a(%rip)            # 0x9030
fucompi %st(1), %st
jbe 0x2bd4
fstp %st(0)
movl 0xa6b6(%rip), %eax      # 0xd288
jmp 0x2c13
fstpt (%rsp)
callq 0x2160
fmuls 0x6426(%rip)            # 0x9008
fadds 0x641c(%rip)            # 0x9004
fstpt (%rsp)
callq 0x20f0
fnstcw 0x10(%rsp)
movzwl 0x10(%rsp), %eax
orl $0xc00, %eax            # imm = 0xC00
movw %ax, 0x12(%rsp)
fldcw 0x12(%rsp)
fistpl 0x14(%rsp)
fldcw 0x10(%rsp)
movl 0x14(%rsp), %eax
fldz
fstp %st(0)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdi
movq 0x28(%rbx), %rdx
movq 0x30(%rbx), %r8
cmpq %r8, %rsi
je 0x2c5b
movq 0x20(%rbx), %r9
movq %rsi, %rcx
cmpb $0x1, 0x38(%rcx)
jne 0x2c5e
addq $0x40, %rcx
cmpq %r9, %rcx
jne 0x2c54
movq 0x8(%rdx), %rcx
addq $0x8, %rdx
leaq 0x200(%rcx), %r9
movq %rcx, %rdi
cmpq %r8, %rcx
jne 0x2c33
jmp 0x2c5e
movq %rsi, %rcx
cmpq %rcx, %r8
je 0x2cd4
fldt (%r14)
fstpt 0x10(%rcx)
movl %eax, 0x34(%rcx)
movb $0x1, 0x38(%rcx)
cmpq %rsi, %rcx
je 0x2cc2
movq %rcx, %rsi
cmpq %rdi, %rcx
jne 0x2c86
movl $0x200, %esi            # imm = 0x200
addq -0x8(%rdx), %rsi
movq -0x40(%rsi), %rdx
cmpq (%rcx), %rdx
jne 0x2cab
movq -0x18(%rsi), %rdx
incq %rdx
cmpq 0x28(%rcx), %rdx
jne 0x2cab
cmpl %eax, -0xc(%rsi)
jne 0x2cab
movq -0x20(%rsi), %rax
movq %rax, 0x20(%rcx)
jmp 0x2cb3
movq %rbx, %rdi
callq 0x6ed2
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r14
jmp 0x6fea
addq $0x18, %rsp
popq %rbx
popq %r14
retq
callq 0x2400
jmp 0x2ba5
movq 0xa315(%rip), %rdi      # 0xcff0
leaq 0x66c1(%rip), %rsi      # 0x93a3
callq 0x2210
movq %rax, %rdi
movl $0xda, %esi
callq 0x2390
leaq 0x66b6(%rip), %rsi      # 0x93b1
movq %rax, %rdi
callq 0x2210
movq %rax, %rdi
callq 0x20e0
movq %rax, %rdi
callq 0x20e0
movl $0x2, %edi
callq 0x22c0
nop