// File: /workspace/github_cpp_makefile_star2_O1/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 0xa6dd(%rip), %al       # 0xd290
testb %al, %al
je 0x2ce0
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 0x2c2b
fldt 0x6454(%rip)            # 0x9030
fucompi %st(1), %st
jbe 0x2bea
fstp %st(0)
movl 0xa6a0(%rip), %eax      # 0xd288
jmp 0x2c29
fstpt (%rsp)
callq 0x2160
fmuls 0x6410(%rip)            # 0x9008
fadds 0x6406(%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 0x2c71
movq 0x20(%rbx), %r9
movq %rsi, %rcx
cmpb $0x1, 0x38(%rcx)
jne 0x2c74
addq $0x40, %rcx
cmpq %r9, %rcx
jne 0x2c6a
movq 0x8(%rdx), %rcx
addq $0x8, %rdx
leaq 0x200(%rcx), %r9
movq %rcx, %rdi
cmpq %r8, %rcx
jne 0x2c49
jmp 0x2c74
movq %rsi, %rcx
cmpq %rcx, %r8
je 0x2cea
fldt (%r14)
fstpt 0x10(%rcx)
movl %eax, 0x34(%rcx)
movb $0x1, 0x38(%rcx)
cmpq %rsi, %rcx
je 0x2cd8
movq %rcx, %rsi
cmpq %rdi, %rcx
jne 0x2c9c
movl $0x200, %esi            # imm = 0x200
addq -0x8(%rdx), %rsi
movq -0x40(%rsi), %rdx
cmpq (%rcx), %rdx
jne 0x2cc1
movq -0x18(%rsi), %rdx
incq %rdx
cmpq 0x28(%rcx), %rdx
jne 0x2cc1
cmpl %eax, -0xc(%rsi)
jne 0x2cc1
movq -0x20(%rsi), %rax
movq %rax, 0x20(%rcx)
jmp 0x2cc9
movq %rbx, %rdi
callq 0x6ba4
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r14
jmp 0x6cbc
addq $0x18, %rsp
popq %rbx
popq %r14
retq
callq 0x2400
jmp 0x2bbb
movq 0xa2ff(%rip), %rdi      # 0xcff0
leaq 0x667b(%rip), %rsi      # 0x9373
callq 0x2210
movq %rax, %rdi
movl $0xda, %esi
callq 0x2390
leaq 0x6670(%rip), %rsi      # 0x9381
movq %rax, %rdi
callq 0x2210
movq %rax, %rdi
callq 0x20e0
movq %rax, %rdi
callq 0x20e0
movl $0x2, %edi
callq 0x22c0
nop