// File: /workspace/github_c_makefile_star2_O3/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, -0x34(%rsp)
movl %ecx, -0x38(%rsp)
testl %edx, %edx
movq %rsi, -0x30(%rsp)
movq %rdx, -0x18(%rsp)
movl %edi, %eax
jle 0x80aa
subl 0x8(%rsi), %eax
jmp 0x80b0
js 0x831d
movl %edi, -0x24(%rsp)
movabsq $0x100000000, %r10      # imm = 0x100000000
leaq -0x4(%rsi), %r11
movl %edx, %ecx
movq %rcx, -0x8(%rsp)
leal 0x1(%rdx), %ecx
movq %rcx, -0x10(%rsp)
leaq 0xc(%rsi), %rcx
movq %rcx, -0x20(%rsp)
xorl %r12d, %r12d
movl $0x1, %ebp
movsd 0x16f96(%rip), %xmm0    # 0x1f080
movsd 0x16f26(%rip), %xmm1    # 0x1f018
movsd 0x16f7e(%rip), %xmm2    # 0x1f078
movsd 0x16f86(%rip), %xmm3    # 0x1f088
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
xorl %ecx, %ecx
xorl %r15d, %r15d
xorl %edx, %edx
cmpq -0x8(%rsp), %r12
jae 0x814e
movq %r12, %r9
shlq $0x4, %r9
movl -0x24(%rsp), %esi
movq -0x30(%rsp), %rdi
subl 0x8(%rdi,%r9), %esi
movl %eax, %r9d
subl %esi, %r9d
xorps %xmm4, %xmm4
cvtsi2sd %r9d, %xmm4
testl %eax, %eax
js 0x8152
xorps %xmm5, %xmm5
cvtsi2sd %eax, %xmm5
mulsd %xmm2, %xmm5
jmp 0x815d
movl %eax, %esi
jmp 0x816b
xorps %xmm5, %xmm5
cvtsi2sd %esi, %xmm5
mulsd %xmm0, %xmm5
addsd %xmm1, %xmm5
ucomisd %xmm5, %xmm4
jb 0x828b
movslq %edx, %rbx
xorl %eax, %eax
cmpq %rbx, %r12
jle 0x819d
movq %rbx, %r9
shlq $0x4, %r9
addq -0x20(%rsp), %r9
xorl %eax, %eax
movq %rbx, %r14
xorl %edi, %edi
cmpl %r8d, (%r9)
setle %dil
addl %edi, %eax
incq %r14
addq $0x10, %r9
cmpq %r14, %r12
jne 0x8186
movl %r12d, %r9d
subl %edx, %r9d
cmpl $0x4, %r9d
jl 0x81d3
xorps %xmm4, %xmm4
cvtsi2sd %eax, %xmm4
xorps %xmm5, %xmm5
cvtsi2sd %r9d, %xmm5
mulsd %xmm3, %xmm5
movb $0x1, %r14b
ucomisd %xmm4, %xmm5
ja 0x81d6
movl %r9d, %edi
subl %eax, %edi
cmpl $0x8, %edi
setge %r14b
jmp 0x81d6
xorl %r14d, %r14d
testl %r8d, %r8d
je 0x81e3
movl %r15d, %eax
movl %ecx, %r9d
jmp 0x81f9
cmpl %ecx, %r9d
setg %dil
andb %r14b, %dil
xorl %eax, %eax
cmpb $0x1, %dil
jne 0x8288
testb %r14b, %r14b
je 0x8294
cmpq %rbx, %r12
jle 0x822e
movq %rbx, %rcx
shlq $0x4, %rcx
addq -0x20(%rsp), %rcx
incq %rbx
cmpl %r8d, (%rcx)
jg 0x822e
movl %ebx, %edi
incl %edx
addq $0x10, %rcx
incq %rbx
cmpq %r12, %rdi
jne 0x8216
movl %r12d, %edx
movq %r11, %r14
movl %ebp, %ebx
movq %r10, %rcx
addq %r13, %rcx
decl %ebx
leaq -0x10(%r14), %rdi
cmpl %r8d, (%r14)
movq %rdi, %r14
jle 0x8236
cmpl $0x0, -0x34(%rsp)
je 0x8290
cmpl %ebx, %edx
jge 0x8294
movslq %eax, %rbx
movslq %edx, %rdx
sarq $0x20, %rcx
movq %rdx, %r14
shlq $0x4, %r14
shlq $0x4, %rbx
movq -0x30(%rsp), %r15
incq %rdx
movupd (%r15,%r14), %xmm4
movupd %xmm4, (%r15,%rbx)
addq $0x10, %r15
incl %eax
cmpq %rcx, %rdx
jl 0x826c
jmp 0x8294
movl %r12d, %edx
movl %ecx, %r9d
jmp 0x829a
subl %edx, %eax
addl %ebx, %eax
movl %r12d, %edx
movl %eax, %r15d
incq %r12
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r10
incl %ebp
addq $0x10, %r11
movl %r9d, %ecx
movl %esi, %eax
cmpq -0x10(%rsp), %r12
jne 0x8113
cmpl $0x0, -0x34(%rsp)
je 0x830a
movl -0x38(%rsp), %edx
testl %edx, %edx
jle 0x830f
movq -0x18(%rsp), %rcx
addl %ecx, %edx
movslq %r15d, %rax
movslq %ecx, %rcx
movslq %edx, %rdx
movq %rcx, %rdi
shlq $0x4, %rdi
shlq $0x4, %rax
movq -0x30(%rsp), %rsi
movupd (%rsi,%rdi), %xmm0
movupd %xmm0, (%rsi,%rax)
incq %rcx
addq $0x10, %rsi
incl %r15d
cmpq %rdx, %rcx
jl 0x82ef
jmp 0x830f
addl -0x38(%rsp), %r15d
movl %r15d, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
jmp 0x82c0
nop