// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: whereLoopFindLesser
static WhereLoop **whereLoopFindLesser(
  WhereLoop **ppPrev,
  const WhereLoop *pTemplate
){
  WhereLoop *p;
  for(p=(*ppPrev); p; ppPrev=&p->pNextLoop, p=*ppPrev){
    if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ){
      /* If either the iTab or iSortIdx values for two WhereLoop are different
      ** then those WhereLoops need to be considered separately.  Neither is
      ** a candidate to replace the other. */
      continue;
    }
    /* In the current implementation, the rSetup value is either zero
    ** or the cost of building an automatic index (NlogN) and the NlogN
    ** is the same for compatible WhereLoops. */
    assert( p->rSetup==0 || pTemplate->rSetup==0
                 || p->rSetup==pTemplate->rSetup );

    /* whereLoopAddBtree() always generates and inserts the automatic index
    ** case first.  Hence compatible candidate WhereLoops never have a larger
    ** rSetup. Call this SETUP-INVARIANT */
    assert( p->rSetup>=pTemplate->rSetup );

    /* Any loop using an appliation-defined index (or PRIMARY KEY or
    ** UNIQUE constraint) with one or more == constraints is better
    ** than an automatic index. Unless it is a skip-scan. */
    if( (p->wsFlags & WHERE_AUTO_INDEX)!=0
     && (pTemplate->nSkip)==0
     && (pTemplate->wsFlags & WHERE_INDEXED)!=0
     && (pTemplate->wsFlags & WHERE_COLUMN_EQ)!=0
     && (p->prereq & pTemplate->prereq)==pTemplate->prereq
    ){
      break;
    }

    /* If existing WhereLoop p is better than pTemplate, pTemplate can be
    ** discarded.  WhereLoop p is better if:
    **   (1)  p has no more dependencies than pTemplate, and
    **   (2)  p has an equal or lower cost than pTemplate
    */
    if( (p->prereq & pTemplate->prereq)==p->prereq    /* (1)  */
     && p->rSetup<=pTemplate->rSetup                  /* (2a) */
     && p->rRun<=pTemplate->rRun                      /* (2b) */
     && p->nOut<=pTemplate->nOut                      /* (2c) */
    ){
      return 0;  /* Discard pTemplate */
    }

    /* If pTemplate is always better than p, then cause p to be overwritten
    ** with pTemplate.  pTemplate is better than p if:
    **   (1)  pTemplate has no more dependences than p, and
    **   (2)  pTemplate has an equal or lower cost than p.
    */
    if( (p->prereq & pTemplate->prereq)==pTemplate->prereq   /* (1)  */
     && p->rRun>=pTemplate->rRun                             /* (2a) */
     && p->nOut>=pTemplate->nOut                             /* (2b) */
    ){
      assert( p->rSetup>=pTemplate->rSetup ); /* SETUP-INVARIANT above */
      break;   /* Cause p to be overwritten by pTemplate */
    }
  }
  return ppPrev;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x453575
movq -0x20(%rbp), %rax
movzbl 0x10(%rax), %eax
movq -0x18(%rbp), %rcx
movzbl 0x10(%rcx), %ecx
cmpl %ecx, %eax
jne 0x45345a
movq -0x20(%rbp), %rax
movzbl 0x11(%rax), %eax
movq -0x18(%rbp), %rcx
movzbl 0x11(%rcx), %ecx
cmpl %ecx, %eax
je 0x45345f
jmp 0x453559
movq -0x20(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x4534b9
movq -0x18(%rbp), %rax
movzwl 0x2e(%rax), %eax
cmpl $0x0, %eax
jne 0x4534b9
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x4534b9
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x4534b9
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
andq (%rcx), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x4534b9
jmp 0x453575
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
andq (%rcx), %rax
movq -0x20(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x453516
movq -0x20(%rbp), %rax
movswl 0x12(%rax), %eax
movq -0x18(%rbp), %rcx
movswl 0x12(%rcx), %ecx
cmpl %ecx, %eax
jg 0x453516
movq -0x20(%rbp), %rax
movswl 0x14(%rax), %eax
movq -0x18(%rbp), %rcx
movswl 0x14(%rcx), %ecx
cmpl %ecx, %eax
jg 0x453516
movq -0x20(%rbp), %rax
movswl 0x16(%rax), %eax
movq -0x18(%rbp), %rcx
movswl 0x16(%rcx), %ecx
cmpl %ecx, %eax
jg 0x453516
movq $0x0, -0x8(%rbp)
jmp 0x45357d
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
andq (%rcx), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x453557
movq -0x20(%rbp), %rax
movswl 0x14(%rax), %eax
movq -0x18(%rbp), %rcx
movswl 0x14(%rcx), %ecx
cmpl %ecx, %eax
jl 0x453557
movq -0x20(%rbp), %rax
movswl 0x16(%rax), %eax
movq -0x18(%rbp), %rcx
movswl 0x16(%rcx), %ecx
cmpl %ecx, %eax
jl 0x453557
jmp 0x453575
jmp 0x453559
movq -0x20(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x453427
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)