// File: /workspace/github_c_makefile_star2_O1/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, -0x2c(%rsp)
movl %ecx, -0x30(%rsp)
movl %edi, %ebp
testl %edx, %edx
jle 0x81fc
movl %edi, %ebp
subl 0x8(%rsi), %ebp
testl %edx, %edx
movq %rdx, -0x10(%rsp)
js 0x8432
movl %edi, %ecx
movabsq $0x100000000, %r14      # imm = 0x100000000
leaq -0x4(%rsi), %r11
movl %edx, %r12d
leal 0x1(%rdx), %eax
movq %rax, -0x8(%rsp)
leaq 0xc(%rsi), %rax
movq %rax, -0x18(%rsp)
xorl %ebx, %ebx
movl $0x1, %r13d
movsd 0x16e4b(%rip), %xmm0    # 0x1f088
movsd 0x16dd3(%rip), %xmm1    # 0x1f018
movsd 0x16e33(%rip), %xmm2    # 0x1f080
movsd 0x16e3b(%rip), %xmm3    # 0x1f090
movq %r14, %r10
xorl %r9d, %r9d
xorl %r15d, %r15d
xorl %edi, %edi
movl %ecx, %edx
movq %r12, -0x28(%rsp)
movl %ecx, -0x34(%rsp)
movb $0x1, %cl
cmpq %r12, %rbx
jae 0x82b3
movq %rbx, %rcx
shlq $0x4, %rcx
movl %edx, %eax
subl 0x8(%rsi,%rcx), %eax
movl %ebp, %ecx
subl %eax, %ecx
xorps %xmm4, %xmm4
cvtsi2sd %ecx, %xmm4
testl %ebp, %ebp
js 0x829b
xorps %xmm5, %xmm5
cvtsi2sd %ebp, %xmm5
mulsd %xmm2, %xmm5
jmp 0x82a6
xorps %xmm5, %xmm5
cvtsi2sd %eax, %xmm5
mulsd %xmm0, %xmm5
addsd %xmm1, %xmm5
ucomisd %xmm5, %xmm4
setae %cl
movl %eax, %ebp
testb %cl, %cl
je 0x831e
movl %ebp, -0x1c(%rsp)
movslq %edi, %r12
xorl %eax, %eax
cmpq %r12, %rbx
jle 0x82ed
movslq %edi, %rcx
movq %rcx, %r14
shlq $0x4, %r14
addq -0x18(%rsp), %r14
xorl %eax, %eax
xorl %ebp, %ebp
cmpl %r8d, (%r14)
setle %bpl
addl %ebp, %eax
incq %rcx
addq $0x10, %r14
cmpq %rcx, %rbx
jne 0x82d6
movl %ebx, %ecx
subl %edi, %ecx
cmpl $0x4, %ecx
jl 0x8326
xorps %xmm4, %xmm4
cvtsi2sd %eax, %xmm4
xorps %xmm5, %xmm5
cvtsi2sd %ecx, %xmm5
mulsd %xmm3, %xmm5
movb $0x1, %r14b
ucomisd %xmm4, %xmm5
ja 0x8329
movl %ecx, %ebp
subl %eax, %ebp
cmpl $0x8, %ebp
setge %r14b
jmp 0x8329
movl %r9d, %ecx
jmp 0x8415
xorl %r14d, %r14d
testl %r8d, %r8d
jne 0x833f
cmpl %r9d, %ecx
setg %bpl
xorl %eax, %eax
testb %bpl, %r14b
jne 0x8345
xorl %r14d, %r14d
movl %r15d, %eax
movl %r9d, %ecx
testb %r14b, %r14b
movl -0x1c(%rsp), %ebp
je 0x83e2
cmpq %r12, %rbx
jle 0x837d
movq %r12, %rdx
shlq $0x4, %rdx
addq -0x18(%rsp), %rdx
cmpl %r8d, (%rdx)
jg 0x837a
incq %r12
movl %r12d, %r9d
addq $0x10, %rdx
cmpq %rbx, %r9
jne 0x8363
movq %rbx, %r12
movl %r12d, %edi
movq %r11, %r14
movl %r13d, %r9d
movq %r10, %r15
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
addq %rdx, %r15
decl %r9d
leaq -0x10(%r14), %r12
cmpl %r8d, (%r14)
movq %r12, %r14
jle 0x8390
cmpl $0x0, -0x2c(%rsp)
je 0x83f8
cmpl %r9d, %edi
jge 0x83fd
movslq %eax, %r9
movslq %edi, %rdx
sarq $0x20, %r15
movq %rdx, %r14
shlq $0x4, %r14
shlq $0x4, %r9
movq %rsi, %r12
incq %rdx
movupd (%r12,%r14), %xmm4
movupd %xmm4, (%r12,%r9)
addq $0x10, %r12
incl %eax
cmpq %r15, %rdx
jl 0x83c6
jmp 0x83fd
movl %ebx, %edi
movl %eax, %r15d
movabsq $0x100000000, %r14      # imm = 0x100000000
movq -0x28(%rsp), %r12
jmp 0x8415
subl %edi, %eax
addl %r9d, %eax
movl %ebx, %edi
movl %eax, %r15d
movabsq $0x100000000, %r14      # imm = 0x100000000
movq -0x28(%rsp), %r12
movl -0x34(%rsp), %edx
incq %rbx
addq %r14, %r10
incl %r13d
addq $0x10, %r11
movl %ecx, %r9d
cmpq -0x8(%rsp), %rbx
jne 0x826b
jmp 0x8435
xorl %r15d, %r15d
cmpl $0x0, -0x2c(%rsp)
je 0x847b
movl -0x30(%rsp), %edx
testl %edx, %edx
jle 0x8480
movq -0x10(%rsp), %rcx
addl %ecx, %edx
movslq %r15d, %rax
movslq %ecx, %rcx
movslq %edx, %rdx
movq %rcx, %r8
shlq $0x4, %r8
shlq $0x4, %rax
movupd (%rsi,%r8), %xmm0
movupd %xmm0, (%rsi,%rax)
incq %rcx
addq $0x10, %rsi
incl %r15d
cmpq %rdx, %rcx
jl 0x845f
jmp 0x8480
addl -0x30(%rsp), %r15d
movl %r15d, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop