// File: /workspace/github_c_makefile_star2_O2/josch[P]stride/measure.c
// Function: Sov
int Sov(char *Asn1, int L1, char *Asn2, int L2, char SecStr, float Threshold, float *Q2)
{
  int Bound1[MAX_ASSIGN][2], Bound2[MAX_ASSIGN][2], Length1[MAX_ASSIGN], 
      Length2[MAX_ASSIGN], NSeg1, NSeg2;
  int Overlap, MaxOverlap, TP=0, FN=0;
  register int i, j;

  NSeg1 = Boundaries(Asn1,L1,SecStr,Bound1);
  NSeg2 = Boundaries(Asn2,L2,SecStr,Bound2);
  

  for(i=0; i<NSeg1; i++)
    Length1[i] = Bound1[i][1]-Bound1[i][0]+1;

  for(j=0; j<NSeg2; j++)
    Length2[j] = Bound2[j][1]-Bound2[j][0]+1;
									    
  for(i=0; i<NSeg1; i++) {
    MaxOverlap = 0;
    for(j=0; j<NSeg2; j++) {
      
      if( Bound1[i][0] > Bound2[j][1] || Bound1[i][1] < Bound2[j][0] ) /*No overlap */
	Overlap = 0;
      else if ( Bound2[j][0] >= Bound1[i][0] && Bound2[j][1] <= Bound1[i][1] ) /* j inside i */
	Overlap = Length2[j];
      else if ( Bound1[i][0] <= Bound2[j][0] ) /* j shifted to the right with respect to i */ 
	Overlap = Minimum(Bound2[j][1]-Bound2[j][0],Bound1[i][1]-Bound2[j][0])+1;
      else if( Bound1[i][0] >= Bound2[j][0] ) /* i shifted to the right with respect to j */
	Overlap = Minimum(Bound2[j][1]-Bound2[j][0],Bound2[j][1]-Bound1[i][0])+1;
      else
	Overlap = Length1[i]; /* i inside j */
      if( Overlap > MaxOverlap ) MaxOverlap = Overlap;
    }
    if( (float)MaxOverlap/(float)Length1[i] >= Threshold ) 
      TP++;
    else
      FN++;
  }
  if( TP+FN != 0 )
    *Q2 = (float)TP/((float)TP+(float)FN);
  else
    *Q2 = -1.0;
/*  O  = (float)TP/((float)TP+(float)FN);*/
  return(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x2ef0, %rsp           # imm = 0x2EF0
movq %r9, %rbx
movss %xmm0, 0xc(%rsp)
movl %r8d, %ebp
movl %ecx, %r15d
movq %rdx, %r12
leaq 0xfb0(%rsp), %rcx
movl %r8d, %edx
callq 0x47d8
movl %eax, %r14d
leaq 0x10(%rsp), %rcx
movq %r12, %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0x47d8
xorl %ecx, %ecx
testl %r14d, %r14d
cmovlel %ecx, %r14d
cmpq %rcx, %r14
je 0x172e8
movl 0xfb4(%rsp,%rcx,8), %edx
subl 0xfb0(%rsp,%rcx,8), %edx
incl %edx
movl %edx, 0x2720(%rsp,%rcx,4)
incq %rcx
jmp 0x172c7
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movss 0xc(%rsp), %xmm2
cmpq %rcx, %rax
je 0x17310
movl 0x14(%rsp,%rcx,8), %edx
subl 0x10(%rsp,%rcx,8), %edx
incl %edx
movl %edx, 0x1f50(%rsp,%rcx,4)
incq %rcx
jmp 0x172f5
xorl %esi, %esi
xorl %ecx, %ecx
xorl %edx, %edx
cmpq %r14, %rsi
je 0x173b4
xorl %edi, %edi
xorl %r8d, %r8d
cmpq %rdi, %rax
je 0x1738e
movl 0xfb0(%rsp,%rsi,8), %r15d
movl 0x14(%rsp,%rdi,8), %r9d
xorl %ebp, %ebp
movl %r9d, %r11d
subl %r15d, %r11d
jl 0x17382
movl 0xfb4(%rsp,%rsi,8), %r10d
movl 0x10(%rsp,%rdi,8), %r12d
cmpl %r12d, %r10d
jl 0x17382
cmpl %r10d, %r9d
jg 0x17365
cmpl %r15d, %r12d
jl 0x17365
movl 0x1f50(%rsp,%rdi,4), %ebp
jmp 0x17382
cmpl %r15d, %r12d
jge 0x17372
incl %r11d
movl %r11d, %ebp
jmp 0x17382
cmpl %r10d, %r9d
cmovll %r9d, %r10d
subl %r12d, %r10d
incl %r10d
movl %r10d, %ebp
cmpl %r8d, %ebp
cmovgl %ebp, %r8d
incq %rdi
jmp 0x17324
cvtsi2ss %r8d, %xmm0
cvtsi2ssl 0x2720(%rsp,%rsi,4), %xmm1
divss %xmm1, %xmm0
ucomiss %xmm2, %xmm0
sbbl $-0x1, %ecx
ucomiss %xmm2, %xmm0
adcl $0x0, %edx
incq %rsi
jmp 0x17316
movl %ecx, %eax
addl %edx, %eax
je 0x173cc
cvtsi2ss %ecx, %xmm0
cvtsi2ss %edx, %xmm1
addss %xmm0, %xmm1
divss %xmm1, %xmm0
jmp 0x173d4
movss 0x2b10(%rip), %xmm0     # 0x19ee4
movss %xmm0, (%rbx)
pushq $0x1
popq %rax
addq $0x2ef0, %rsp           # imm = 0x2EF0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop