// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: computeLimitRegisters
static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){
  Vdbe *v = 0;
  int iLimit = 0;
  int iOffset;
  int n;
  Expr *pLimit = p->pLimit;

  if( p->iLimit ) return;

  /*
  ** "LIMIT -1" always shows all rows.  There is some
  ** controversy about what the correct behavior should be.
  ** The current implementation interprets "LIMIT 0" to mean
  ** no rows.
  */
  if( pLimit ){
    assert( pLimit->op==TK_LIMIT );
    assert( pLimit->pLeft!=0 );
    p->iLimit = iLimit = ++pParse->nMem;
    v = sqlite3GetVdbe(pParse);
    assert( v!=0 );
    if( sqlite3ExprIsInteger(pLimit->pLeft, &n) ){
      sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit);
      VdbeComment((v, "LIMIT counter"));
      if( n==0 ){
        sqlite3VdbeGoto(v, iBreak);
      }else if( n>=0 && p->nSelectRow>sqlite3LogEst((u64)n) ){
        p->nSelectRow = sqlite3LogEst((u64)n);
        p->selFlags |= SF_FixedLimit;
      }
    }else{
      sqlite3ExprCode(pParse, pLimit->pLeft, iLimit);
      sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit); VdbeCoverage(v);
      VdbeComment((v, "LIMIT counter"));
      sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, iBreak); VdbeCoverage(v);
    }
    if( pLimit->pRight ){
      p->iOffset = iOffset = ++pParse->nMem;
      pParse->nMem++;   /* Allocate an extra register for limit+offset */
      sqlite3ExprCode(pParse, pLimit->pRight, iOffset);
      sqlite3VdbeAddOp1(v, OP_MustBeInt, iOffset); VdbeCoverage(v);
      VdbeComment((v, "OFFSET counter"));
      sqlite3VdbeAddOp3(v, OP_OffsetLimit, iLimit, iOffset+1, iOffset);
      VdbeComment((v, "LIMIT+OFFSET"));
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x60(%rsi), %rbp
cmpl $0x0, 0x8(%rsi)
setne %al
testq %rbp, %rbp
sete %cl
orb %al, %cl
jne 0x270b28
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, %r14
movl 0x38(%rdi), %ebx
incl %ebx
movl %ebx, 0x38(%rdi)
movl %ebx, 0x8(%rsi)
callq 0x2645be
movq %rax, %r12
movq 0x10(%rbp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x26f334
testl %eax, %eax
je 0x270a99
movl %r13d, (%rsp)
movl 0x4(%rsp), %r13d
pushq $0x45
popq %rsi
movq %r12, %rdi
movl %r13d, %edx
movl %ebx, %ecx
callq 0x24d51a
testq %r13, %r13
je 0x270ac6
testl %r13d, %r13d
js 0x270ad1
movzwl 0x2(%r15), %eax
movw %ax, (%rsp)
movq %r13, %rdi
callq 0x243f7b
cmpw %ax, (%rsp)
jle 0x270ad1
movw %ax, 0x2(%r15)
orb $0x40, 0x5(%r15)
jmp 0x270ad1
movq 0x10(%rbp), %rsi
movq %r14, %rdi
movl %ebx, %edx
callq 0x26463f
pushq $0xf
popq %rsi
movq %r12, %rdi
movl %ebx, %edx
callq 0x265d5c
pushq $0x14
popq %rsi
movq %r12, %rdi
movl %ebx, %edx
movl %r13d, %ecx
callq 0x24d51a
jmp 0x270ad1
movq %r12, %rdi
movl (%rsp), %esi
callq 0x264680
movq 0x18(%rbp), %rsi
testq %rsi, %rsi
je 0x270b28
movl 0x38(%r14), %r13d
leal 0x1(%r13), %ebp
movl %ebp, 0xc(%r15)
addl $0x2, %r13d
movl %r13d, 0x38(%r14)
movq %r14, %rdi
movl %ebp, %edx
callq 0x26463f
pushq $0xf
popq %rsi
movq %r12, %rdi
movl %ebp, %edx
callq 0x265d5c
movq %r12, %rdi
movl $0x98, %esi
movl %ebx, %edx
movl %r13d, %ecx
movl %ebp, %r8d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x24d51f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq