// File: /workspace/github_c_makefile_star2_O2/josch[P]stride/measure.c
// Function: Presnell
int Presnell(char *Asn1, int L1, char *Asn2, int L2, char SecStr, float Threshold, 
	     float *Q2, float *O)
{
  int Boundaries(char *Asn, int L, char SecondStr, int (*Bound)[2]);
  int Bound1[MAX_ASSIGN][2], Bound2[MAX_ASSIGN][2], Length1[MAX_ASSIGN], 
      Length2[MAX_ASSIGN], NSeg1, NSeg2;
  int Overlap, MaxOverlap, TP=0, FP=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++) {
      Overlap = Minimum(Bound1[i][1],Bound2[j][1])-Maximum(Bound1[i][0],Bound2[j][0])+1;
      if( Overlap > MaxOverlap ) MaxOverlap = Overlap;
    }
    if( (float)MaxOverlap/(float)Length1[i] >= Threshold ) 
      TP++;
    else
      FN++;
  }

  for(i=0; i<NSeg2; i++) {
    MaxOverlap = 0;
    for(j=0; j<NSeg1; j++) {
      Overlap = Minimum(Bound2[i][1],Bound1[j][1])-Maximum(Bound2[i][0],Bound1[j][0])+1;
      if( Overlap > MaxOverlap ) MaxOverlap = Overlap;
    }
    if( (float)MaxOverlap/(float)Length2[i] < Threshold ) 
      FP++;
  }

  if( TP+FN != 0 ) {
    *Q2 = (float)TP/((float)TP+(float)FN);
    *O = (float)FP/((float)TP+(float)FN);
  }
  else {
    *Q2 = -1.0;
    *O = -1.0;
  }

  return(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2ef8, %rsp           # imm = 0x2EF8
movq %r9, %rbx
movss %xmm0, 0xc(%rsp)
movl %r8d, %ebp
movl %ecx, %r15d
movq %rdx, %r12
movq 0x2f30(%rsp), %r13
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 0x1711c
movl 0xfb4(%rsp,%rcx,8), %edx
subl 0xfb0(%rsp,%rcx,8), %edx
incl %edx
movl %edx, 0x2720(%rsp,%rcx,4)
incq %rcx
jmp 0x170fb
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movss 0xc(%rsp), %xmm2
cmpq %rcx, %rax
je 0x17144
movl 0x14(%rsp,%rcx,8), %edx
subl 0x10(%rsp,%rcx,8), %edx
incl %edx
movl %edx, 0x1f50(%rsp,%rcx,4)
incq %rcx
jmp 0x17129
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %edi, %edi
cmpq %r14, %rsi
je 0x171b7
xorl %r8d, %r8d
cmpq %rdi, %rax
je 0x17194
movl 0xfb0(%rsp,%rsi,8), %r9d
movl 0xfb4(%rsp,%rsi,8), %r10d
movl 0x10(%rsp,%rdi,8), %r11d
movl 0x14(%rsp,%rdi,8), %r15d
cmpl %r15d, %r10d
cmovll %r10d, %r15d
cmpl %r11d, %r9d
cmovgl %r9d, %r11d
subl %r11d, %r15d
leal 0x1(%r15), %r9d
cmpl %r8d, %r15d
cmovgel %r9d, %r8d
incq %rdi
jmp 0x17154
cvtsi2ss %r8d, %xmm0
cvtsi2ssl 0x2720(%rsp,%rsi,4), %xmm1
divss %xmm1, %xmm0
ucomiss %xmm2, %xmm0
sbbl $-0x1, %edx
ucomiss %xmm2, %xmm0
adcl $0x0, %ecx
incq %rsi
jmp 0x1714a
xorl %esi, %esi
cmpq %rax, %rdi
je 0x17228
xorl %r8d, %r8d
xorl %r9d, %r9d
cmpq %r8, %r14
je 0x17204
movl 0x10(%rsp,%rdi,8), %r10d
movl 0x14(%rsp,%rdi,8), %r11d
movl 0xfb0(%rsp,%r8,8), %ebp
movl 0xfb4(%rsp,%r8,8), %r15d
cmpl %r15d, %r11d
cmovll %r11d, %r15d
cmpl %ebp, %r10d
cmovgl %r10d, %ebp
subl %ebp, %r15d
leal 0x1(%r15), %r10d
cmpl %r9d, %r15d
cmovgel %r10d, %r9d
incq %r8
jmp 0x171c4
cvtsi2ss %r9d, %xmm0
cvtsi2ssl 0x1f50(%rsp,%rdi,4), %xmm1
divss %xmm1, %xmm0
xorl %r8d, %r8d
ucomiss %xmm0, %xmm2
seta %r8b
addl %r8d, %esi
incq %rdi
jmp 0x171b9
movl %edx, %eax
addl %ecx, %eax
jne 0x17237
movaps 0x2cbb(%rip), %xmm0     # 0x19ef0
jmp 0x17255
movd %esi, %xmm0
movd %edx, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtsi2ss %ecx, %xmm2
cvtdq2ps %xmm1, %xmm0
addss %xmm0, %xmm2
shufps $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
divps %xmm2, %xmm0
movss %xmm0, (%rbx)
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movss %xmm0, (%r13)
pushq $0x1
popq %rax
addq $0x2ef8, %rsp           # imm = 0x2EF8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq