// File: /workspace/github_cpp_makefile_star2_O2/ncbi[P]amr/alignment.cpp
// Function: Alignment_sp::SeqChange::setNeighborhoodMismatch(unsigned long)
void SeqChange::setNeighborhoodMismatch (size_t flankingLen) 
{ 
  ASSERT (al);
  ASSERT (start < al->targetSeq. size ())
  

  neighborhoodMismatch = 0.0;
  if (! flankingLen)
    return;
  
    
  // PD-2001
  size_t span = 0;
  size_t mismatches = 0; 
  
  size_t j = 0;  // auxiliary

  // Left flank
  if (start)
  {
    j = start - 1; 
    while (start - j <= flankingLen)
    { 
      span++;
      if (al->targetSeq [j] != al->refSeq [j])
        mismatches++;
      if (j == 0)
        break;
      j--;
    }
  }
  ASSERT (start >= j);
  const size_t missed_left = min (min (al->targetTail (true), al->refStart), flankingLen + 1 - (start - j)); 
  span       += missed_left;
  mismatches += missed_left; 
  if (verbose ())
    cout << "missed_left: " << start  << ' ' << j << ' ' << missed_left << endl;

  // Right flank
  const size_t stop = getStop ();
  for (j = stop + 1; j < al->targetSeq. size () && j - stop <= flankingLen; j++)
  { 
    span++;
    if (al->targetSeq [j] != al->refSeq [j])
      mismatches++;
  }
  ASSERT (j >= stop);
  const size_t missed_right = min (min (al->targetTail (false), al->refLen - al->refEnd), flankingLen + 1 - (j - stop));
  span       += missed_right;
  mismatches += missed_right;     
  if (verbose ())
    cout << "missed_right: " << j << ' ' << missed_right << ' ' << mismatches << ' ' << span << endl;  
    
  ASSERT (mismatches <= span);
  
  neighborhoodMismatch = (double) mismatches / (double) span;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rsi, %r12
movq %rdi, %rbx
callq 0xc070
andl $0x0, (%rax)
movq 0x8(%rbx), %rcx
testq %rcx, %rcx
je 0x40b3d
movq 0x18(%rbx), %r8
cmpq 0x38(%rcx), %r8
jae 0x40c11
andq $0x0, 0x80(%rbx)
testq %r12, %r12
je 0x40b2b
testq %r8, %r8
je 0x408e4
pushq $0x1
popq %r14
leaq -0x1(%r8), %r13
xorl %ebp, %ebp
cmpq %r12, %r14
ja 0x408f1
movq 0x30(%rcx), %rdx
movq 0x98(%rcx), %rsi
movb (%rdx,%r13), %dl
xorl %edi, %edi
cmpb (%rsi,%r13), %dl
setne %dil
addq %rdi, %rbp
incq %r14
addq $-0x1, %r13
jb 0x408b8
jmp 0x408e6
xorl %ebp, %ebp
andl $0x0, (%rax)
xorl %r13d, %r13d
movq %r8, %r14
jmp 0x40900
andl $0x0, (%rax)
cmpq %r13, %r8
jb 0x40e8d
decq %r14
movq 0xb8(%rcx), %rdx
cmpb $0x0, 0x68(%rcx)
movq %rax, 0x110(%rsp)
je 0x4091b
movq 0x50(%rcx), %r15
jmp 0x40923
movq 0x60(%rcx), %r15
subq 0x58(%rcx), %r15
movq %r12, %rcx
subq %r8, %rcx
leaq (%rcx,%r13), %rax
incq %rax
cmpq %r15, %rdx
cmovbq %rdx, %r15
cmpq %r15, %rax
cmovbq %rax, %r15
addq %r15, %r14
xorl %edi, %edi
callq 0x15d77
testb %al, %al
je 0x4099f
movq 0x4863d(%rip), %rdi     # 0x88f90
leaq 0x21cc9(%rip), %rsi     # 0x62623
callq 0xc5a0
movq 0x18(%rbx), %rsi
movq %rax, %rdi
callq 0xc410
pushq $0x20
popq %rsi
movq %rax, %rdi
callq 0xc690
movq %rax, %rdi
movq %r13, %rsi
callq 0xc410
movq %rax, %rdi
pushq $0x20
popq %rsi
callq 0xc690
movq %rax, %rdi
movq %r15, %rsi
callq 0xc410
movq %rax, %rdi
callq 0xc300
addq %rbp, %r15
movq 0x8(%rbx), %rax
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdi
leaq (%rdi,%rsi), %rcx
movq 0x38(%rax), %rdx
leaq (%rdi,%rsi), %rbp
incq %rbp
negq %r14
pushq $0x1
popq %rsi
movq %r12, %r13
cmpq %r12, %rsi
ja 0x409fb
cmpq %rdx, %rbp
jae 0x409fb
movq 0x30(%rax), %rdi
movq 0x98(%rax), %r8
movb (%rdi,%rbp), %dil
xorl %r9d, %r9d
cmpb (%r8,%rbp), %dil
setne %r9b
addq %r9, %r15
decq %r13
incq %rbp
incq %rsi
decq %r14
jmp 0x409c6
movq 0x110(%rsp), %rdx
andl $0x0, (%rdx)
cmpq %rcx, %rbp
jb 0x40ce5
movq 0xc8(%rax), %rcx
cmpb $0x0, 0x68(%rax)
jne 0x40a22
movq 0x50(%rax), %rdx
jmp 0x40a2a
movq 0x60(%rax), %rdx
subq 0x58(%rax), %rdx
subq 0xc0(%rax), %rcx
cmpq %rdx, %rcx
movq %rdx, %r12
cmovbq %rcx, %r12
cmpq %r12, %r13
cmovbq %r13, %r12
cmpq %r13, %rdx
cmovbq %rdx, %r13
cmpq %rcx, %r13
cmovaeq %rcx, %r13
subq %r14, %r13
addq %r12, %r15
xorl %edi, %edi
callq 0x15d77
testb %al, %al
je 0x40ac9
movq 0x48528(%rip), %rdi     # 0x88f90
leaq 0x21bcc(%rip), %rsi     # 0x6263b
callq 0xc5a0
movq %rax, %rdi
movq %rbp, %rsi
callq 0xc410
pushq $0x20
popq %rbp
movq %rax, %rdi
movl %ebp, %esi
callq 0xc690
movq %rax, %rdi
movq %r12, %rsi
callq 0xc410
movq %rax, %rdi
movl %ebp, %esi
callq 0xc690
movq %rax, %rdi
movq %r15, %rsi
callq 0xc410
movq %rax, %rdi
movl %ebp, %esi
callq 0xc690
movq %rax, %rdi
movq %r13, %rsi
callq 0xc410
movq %rax, %rdi
callq 0xc300
movq 0x110(%rsp), %rax
andl $0x0, (%rax)
cmpq %r13, %r15
ja 0x40db9
movq %r15, %xmm0
movq 0x214d6(%rip), %xmm1    # 0x61fc0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x214da(%rip), %xmm2    # 0x61fd0
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq %r13, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm3
movsd %xmm3, 0x80(%rbx)
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xc6d0
testl %eax, %eax
jne 0x40f61
leaq 0x21497(%rip), %rsi     # 0x61fe8
leaq 0x70(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xdbbe
leaq 0x50(%rsp), %rdi
movl $0x16e, %esi            # imm = 0x16E
callq 0xe2d5
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0xe26e
leaq 0x1d644(%rip), %rdx     # 0x5e1d1
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0xe24f
leaq 0x21a31(%rip), %rsi     # 0x625da
leaq 0x10(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0xdbbe
leaq 0x1dd0d(%rip), %rdx     # 0x5e8cc
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xe24f
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xe26e
leaq 0x21dfc(%rip), %rdx     # 0x629eb
leaq 0xf0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xe24f
leaq 0xf0(%rsp), %rdi
callq 0x101d0
callq 0xc6d0
testl %eax, %eax
jne 0x40f61
leaq 0x213c3(%rip), %rsi     # 0x61fe8
leaq 0x70(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xdbbe
leaq 0x50(%rsp), %rdi
movl $0x16f, %esi            # imm = 0x16F
callq 0xe2d5
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0xe26e
leaq 0x1d570(%rip), %rdx     # 0x5e1d1
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0xe24f
leaq 0x2195d(%rip), %rsi     # 0x625da
leaq 0x10(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0xdbbe
leaq 0x1dc39(%rip), %rdx     # 0x5e8cc
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xe24f
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xe26e
leaq 0x218f8(%rip), %rdx     # 0x625bb
leaq 0xf0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xe24f
leaq 0xf0(%rsp), %rdi
callq 0x101d0
callq 0xc6d0
testl %eax, %eax
jne 0x40f61
leaq 0x212ef(%rip), %rsi     # 0x61fe8
leaq 0x70(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xdbbe
leaq 0x50(%rsp), %rdi
movl $0x19a, %esi            # imm = 0x19A
callq 0xe2d5
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0xe26e
leaq 0x1d49c(%rip), %rdx     # 0x5e1d1
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0xe24f
leaq 0x21889(%rip), %rsi     # 0x625da
leaq 0x10(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0xdbbe
leaq 0x1db65(%rip), %rdx     # 0x5e8cc
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xe24f
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xe26e
leaq 0x2189a(%rip), %rdx     # 0x62631
leaq 0xf0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xe24f
leaq 0xf0(%rsp), %rdi
callq 0x101d0
callq 0xc6d0
testl %eax, %eax
jne 0x40f61
leaq 0x2121b(%rip), %rsi     # 0x61fe8
leaq 0x70(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xdbbe
leaq 0x50(%rsp), %rdi
movl $0x1a1, %esi            # imm = 0x1A1
callq 0xe2d5
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0xe26e
leaq 0x1d3c8(%rip), %rdx     # 0x5e1d1
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0xe24f
leaq 0x217b5(%rip), %rsi     # 0x625da
leaq 0x10(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0xdbbe
leaq 0x1da91(%rip), %rdx     # 0x5e8cc
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xe24f
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xe26e
leaq 0x217df(%rip), %rdx     # 0x6264a
leaq 0xf0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xe24f
leaq 0xf0(%rsp), %rdi
callq 0x101d0
callq 0xc6d0
testl %eax, %eax
jne 0x40f61
leaq 0x21147(%rip), %rsi     # 0x61fe8
leaq 0x70(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xdbbe
leaq 0x50(%rsp), %rdi
movl $0x18b, %esi            # imm = 0x18B
callq 0xe2d5
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0xe26e
leaq 0x1d2f4(%rip), %rdx     # 0x5e1d1
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0xe24f
leaq 0x216e1(%rip), %rsi     # 0x625da
leaq 0x10(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0xdbbe
leaq 0x1d9bd(%rip), %rdx     # 0x5e8cc
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xe24f
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xe26e
leaq 0x216d9(%rip), %rdx     # 0x62618
leaq 0xf0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xe24f
leaq 0xf0(%rsp), %rdi
callq 0x101d0
pushq $0x1
popq %rdi
callq 0xc6f0
jmp 0x40f7d
jmp 0x40f8f
jmp 0x40fa9
jmp 0x40f7d
jmp 0x40f8f
jmp 0x40f7d
jmp 0x40f8f
jmp 0x40fc0
jmp 0x40f7d
jmp 0x40f8f
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0xcbe8
jmp 0x40f92
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0xcbe8
jmp 0x40fac
jmp 0x40fa9
jmp 0x40fa9
jmp 0x40fd7
jmp 0x40fa9
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xcbe8
jmp 0x40fc3
jmp 0x40fc0
jmp 0x40fc0
jmp 0x40ff1
jmp 0x40fc0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xcbe8
jmp 0x40fda
jmp 0x40fd7
jmp 0x40fd7
jmp 0x4100b
jmp 0x40fd7
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0xcbe8
jmp 0x40ff4
jmp 0x40ff1
jmp 0x40ff1
jmp 0x41020
jmp 0x40ff1
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0xcbe8
jmp 0x4100e
jmp 0x4100b
jmp 0x4100b
jmp 0x41035
jmp 0x4100b
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xcbe8
jmp 0x41023
jmp 0x41020
jmp 0x41020
jmp 0x41020
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xcbe8
jmp 0x41038
jmp 0x41035
jmp 0x41035
jmp 0x41035
movq %rax, %rbx
movq %rbx, %rdi
callq 0xcaa0