// File: /workspace/github_c_makefile_star2_O0/thegenemyers[P]DASCRUBBER/DASpatch.c
// Function: lowq_patch
static Patch *lowq_patch(Overlap *ovls, int novl, Interval *lblock, Interval *rblock)
{ static Patch patch;

  int j;
  int lft, rgt; 
  int lcv, rcv; 

  lft = lblock->end;
  rgt = rblock->beg;
  lcv = lft - COVER_LEN;
  rcv = rgt + COVER_LEN;
  if (lcv < lblock->beg)
    lcv = lblock->beg;
  if (rcv > rblock->end)
    rcv = rblock->end;

  patch.bread = -1;
  patch.anc   = TRACE_SPACING;
  patch.avg   = 100;
  for (j = 0; j < novl; j++)
    if (ovls[j].path.abpos <= lcv && ovls[j].path.aepos >= rcv)
      { Patch *can;

        can = compute_patch(lft,rgt,ovls+j,ovls+j);
            
        if (can == NULL) continue;

        if (unsuitable(can->bread,can->beg,can->end))
          continue;

        if (can->anc <= ANCHOR_THRESH && can->avg <= GOOD_QV && can->bad == 0 &&
            can->avg + can->anc < patch.anc + patch.avg)
          patch = *can;
      }

#ifdef DEBUG_GAP_FILL
  if (patch.bread >= 0)
    printf("    LOWQ  PATCH = %d%c[%d..%d]  %d (%d)\n",
           patch.bread,patch.comp?'c':'n',patch.beg,patch.end,patch.anc,patch.avg);
  else
    printf("    LOWQ PATCH FAIL\n");
#endif

  return (&patch);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
subl $0x190, %eax            # imm = 0x190
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
addl $0x190, %eax            # imm = 0x190
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x3a74
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x34(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jle 0x3a8a
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x34(%rbp)
movl $0xffffffff, 0x27a68(%rip) # imm = 0xFFFFFFFF
movl 0x279b6(%rip), %eax     # 0x2b450
movl %eax, 0x27a6c(%rip)     # 0x2b50c
movl $0x64, 0x27a6a(%rip)    # 0x2b514
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x3bd1
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
cmpl -0x30(%rbp), %eax
jg 0x3bc1
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
cmpl -0x34(%rbp), %eax
jl 0x3bc1
movl -0x28(%rbp), %edi
movl -0x2c(%rbp), %esi
movq -0x8(%rbp), %rdx
movslq -0x24(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdx
movq -0x8(%rbp), %rcx
movslq -0x24(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rcx
callq 0x3f90
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x3b2c
jmp 0x3bc3
movq -0x40(%rbp), %rax
movl (%rax), %edi
movq -0x40(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x40(%rbp), %rax
movl 0xc(%rax), %edx
callq 0x42d0
cmpl $0x0, %eax
je 0x3b4c
jmp 0x3bc3
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
cmpl 0x278fb(%rip), %eax     # 0x2b454
jg 0x3bbf
movq -0x40(%rbp), %rax
movl 0x18(%rax), %eax
cmpl 0x278bc(%rip), %eax     # 0x2b424
jg 0x3bbf
movq -0x40(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jne 0x3bbf
movq -0x40(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x40(%rbp), %rcx
addl 0x10(%rcx), %eax
movl 0x27984(%rip), %ecx     # 0x2b50c
addl 0x27986(%rip), %ecx     # 0x2b514
cmpl %ecx, %eax
jge 0x3bbf
movq -0x40(%rbp), %rax
movq (%rax), %rcx
movq %rcx, 0x2795c(%rip)     # 0x2b4fc
movq 0x8(%rax), %rcx
movq %rcx, 0x27959(%rip)     # 0x2b504
movq 0x10(%rax), %rcx
movq %rcx, 0x27956(%rip)     # 0x2b50c
movl 0x18(%rax), %eax
movl %eax, 0x27955(%rip)     # 0x2b514
jmp 0x3bc1
jmp 0x3bc3
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x3ab1
leaq 0x27924(%rip), %rax     # 0x2b4fc
addq $0x40, %rsp
popq %rbp
retq
nop