// File: /workspace/github_c_makefile_star2_O2/thegenemyers[P]DASCRUBBER/DAStrim.c
// Function: analyze_gap_pairs
static int analyze_gap_pairs(int gsize, Spanner *gsort, Overlap *ovls,
                             int gcnt, int scnt, int test, int move)
{ int j, l, c, x, w;
  int bord, soft, keeper;
  int ncnt, biggest;

  (void) ovls;

  biggest = 0;
  ncnt = 0;
#ifdef SHOW_PAIRS
  if (move)
    printf("  Gsort: %d\n",gsize);
#endif
  if (gcnt > 0)
    c = gsize - gsort[0].delta;
  else
    c = gsize;
  w = 0;
  for (j = 0; j <= gcnt; j++)
    { l = c;
      if (j >= gcnt)
        bord = 1;
      else
        { c = gsize - gsort[j].delta;
          if (l < 0)
            bord = (l-c >= 20-.1*c);
          else
            bord = (l-c >= 20+.1*l);
        }
      if (bord)
        { soft = 0;
          for (x = w; x < j; x++)
            soft += (gsort[x].soft <= test);
          keeper = (j-w >= 4 && (soft < .4*(j-w) || (j-w)-soft >= 8));
          if (test == 0)
            { if (keeper && j-w > biggest)
                { biggest = j-w;
                  ncnt = 0;
                }
              else
                keeper = 0;
            }
#ifdef SHOW_PAIRS
          if (move)
            { printf("----\n");
              for (x = w; x < j; x++)
                { printf("  %3d: %5d %5d",x,gsort[x].delta,gsize-gsort[x].delta);
                  printf(" %5d",ovls[gsort[x].lidx].bread);
                  if (gsort[x].soft == 0)
                    printf(" @");
                  else if (gsort[x].soft == 1)
                    printf(" #");
                  else
                    printf("  ");
                  if (!keeper)
                    printf(" X");
                  printf("\n");
                }
            }
#endif
          if (keeper)
            { for (x = w; x < j; x++)
                if (gsort[x].soft > test)
                  break;
              for (w = j; gsort[w-1].soft <= test; w--)
                ;
              if (move)
                while (x < w)
                  gsort[ncnt++] = gsort[x++];
              else
                ncnt += w-x;
            }
          w = j;
        }
    }
  if (move)
    for (x = gcnt; x < gcnt+scnt; x++)
      gsort[ncnt++] = gsort[x];
  else
    ncnt += scnt;

  return (ncnt);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %r9d, -0x24(%rsp)
movl %ecx, -0x28(%rsp)
movl %edi, %r11d
testl %edx, %edx
jle 0x6a4c
movl %edi, %r11d
subl 0x8(%rsi), %r11d
movl %edi, -0xc(%rsp)
movabsq $0x100000000, %rbp      # imm = 0x100000000
leaq -0x4(%rsi), %r12
movl %edx, -0x10(%rsp)
movslq %edx, %r10
movq %rsi, -0x20(%rsp)
leaq 0xc(%rsi), %rax
movq %rax, -0x8(%rsp)
xorl %r15d, %r15d
movl $0x1, %eax
movsd 0x16605(%rip), %xmm0    # 0x1d088
movsd 0x165ad(%rip), %xmm1    # 0x1d038
movsd 0x165ed(%rip), %xmm2    # 0x1d080
movsd 0x165f5(%rip), %xmm3    # 0x1d090
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
movq %rbp, %rsi
movq %rax, %rbp
xorl %ecx, %ecx
xorl %eax, %eax
movl $0x0, -0x2c(%rsp)
cmpq %r10, %r15
jg 0x6c7b
jge 0x6af2
movq %r15, %r9
shlq $0x4, %r9
movl -0xc(%rsp), %edi
movq -0x20(%rsp), %rdx
subl 0x8(%rdx,%r9), %edi
movl %r11d, %r9d
subl %edi, %r9d
cvtsi2sd %r9d, %xmm4
testl %r11d, %r11d
js 0x6af7
cvtsi2sd %r11d, %xmm5
mulsd %xmm2, %xmm5
jmp 0x6aff
movl %r11d, %edi
jmp 0x6b0d
cvtsi2sd %edi, %xmm5
mulsd %xmm0, %xmm5
addsd %xmm1, %xmm5
ucomisd %xmm5, %xmm4
jb 0x6c5d
movq %rsi, -0x18(%rsp)
movq %r10, %rsi
movq %rbp, %r10
movq %r12, %rbp
movslq %ecx, %r9
movq %r9, %r14
shlq $0x4, %r14
addq -0x8(%rsp), %r14
xorl %r11d, %r11d
movq %r14, %rdx
movq %r9, %rbx
cmpq %r15, %rbx
jge 0x6b4e
xorl %r12d, %r12d
cmpl %r8d, (%rdx)
setle %r12b
addl %r12d, %r11d
incq %rbx
addq $0x10, %rdx
jmp 0x6b33
movl %r15d, %edx
subl %ecx, %edx
cmpl $0x4, %edx
jl 0x6b7d
cvtsi2sd %r11d, %xmm4
cvtsi2sd %edx, %xmm5
mulsd %xmm3, %xmm5
movb $0x1, %bl
ucomisd %xmm4, %xmm5
movq %rbp, %r12
ja 0x6b82
movl %edx, %ebx
subl %r11d, %ebx
cmpl $0x8, %ebx
setge %bl
jmp 0x6b82
xorl %ebx, %ebx
movq %rbp, %r12
testl %r8d, %r8d
je 0x6b90
movl %eax, %r11d
movl -0x2c(%rsp), %edx
jmp 0x6bab
cmpl -0x2c(%rsp), %edx
setg %r12b
andb %bl, %r12b
xorl %r11d, %r11d
cmpb $0x1, %r12b
movq %rbp, %r12
jne 0x6c46
testb %bl, %bl
movq %r10, %rbp
je 0x6bd4
cmpl %r15d, %ecx
cmovlel %r15d, %ecx
movq %rsi, %r10
movq -0x18(%rsp), %rsi
cmpq %r15, %r9
jge 0x6be3
cmpl %r8d, (%r14)
jg 0x6be0
incq %r9
addq $0x10, %r14
jmp 0x6bc1
movl %r15d, %ecx
movl %r11d, %eax
movl %edx, -0x2c(%rsp)
jmp 0x6c4c
movl %r9d, %ecx
leal (%r11,%rbp), %eax
subl %ecx, %eax
movq %r12, %rbx
movq %rsi, %r9
addq %r13, %r9
decl %eax
leaq -0x10(%rbx), %r14
cmpl %r8d, (%rbx)
movq %r14, %rbx
jle 0x6bef
cmpl $0x0, -0x24(%rsp)
je 0x6c56
movslq %ecx, %rax
sarq $0x20, %r9
movslq %r11d, %rcx
shlq $0x4, %rcx
movq %rax, %rbx
shlq $0x4, %rbx
movq -0x20(%rsp), %r14
cmpq %r9, %rax
jge 0x6c3e
incq %rax
movupd (%r14,%rbx), %xmm4
movupd %xmm4, (%r14,%rcx)
incl %r11d
addq $0x10, %r14
jmp 0x6c21
movl %r15d, %ecx
movl %r11d, %eax
jmp 0x6c59
movl %r15d, %ecx
movq %r10, %rbp
movq %rsi, %r10
movq -0x18(%rsp), %rsi
jmp 0x6c5d
movl %r15d, %ecx
movl %edx, -0x2c(%rsp)
incq %r15
movabsq $0x100000000, %rdx      # imm = 0x100000000
addq %rdx, %rsi
incl %ebp
addq $0x10, %r12
movl %edi, %r11d
jmp 0x6ab7
cmpl $0x0, -0x24(%rsp)
je 0x6cba
movl -0x28(%rsp), %ecx
addl -0x10(%rsp), %ecx
movslq %ecx, %rcx
movslq %eax, %rdx
shlq $0x4, %rdx
movq %r10, %rdi
shlq $0x4, %rdi
movq -0x20(%rsp), %rsi
cmpq %rcx, %r10
jge 0x6cbe
movupd (%rsi,%rdi), %xmm0
movupd %xmm0, (%rsi,%rdx)
incq %r10
incl %eax
addq $0x10, %rsi
jmp 0x6ca0
addl -0x28(%rsp), %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)