// File: /workspace/github_c_makefile_star2_O1/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 0x2d77f8
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, %r14
movl 0x38(%rdi), %ebx
incl %ebx
movl %ebx, 0x38(%rdi)
movl %ebx, 0x8(%rsi)
callq 0x2c5ddf
movq %rax, %r12
movq 0x10(%rbp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x2d2e59
testl %eax, %eax
je 0x2d7750
movl %r13d, (%rsp)
movl 0x4(%rsp), %r13d
movq %r12, %rdi
movl $0x45, %esi
movl %r13d, %edx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x2b200c
testq %r13, %r13
je 0x2d7781
testl %r13d, %r13d
js 0x2d7796
movzwl 0x2(%r15), %eax
movw %ax, (%rsp)
movq %r13, %rdi
callq 0x2a680d
cmpw %ax, (%rsp)
jle 0x2d7796
movq %r13, %rdi
callq 0x2a680d
movw %ax, 0x2(%r15)
orb $0x40, 0x5(%r15)
jmp 0x2d7796
movq 0x10(%rbp), %rsi
movq %r14, %rdi
movl %ebx, %edx
callq 0x2c5f97
movq %r12, %rdi
movl $0xf, %esi
movl %ebx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2b200c
movq %r12, %rdi
movl $0x14, %esi
movl %ebx, %edx
movl %r13d, %ecx
jmp 0x2d778e
movq %r12, %rdi
movl $0xb, %esi
xorl %edx, %edx
movl (%rsp), %ecx
xorl %r8d, %r8d
callq 0x2b200c
movq 0x18(%rbp), %rsi
testq %rsi, %rsi
je 0x2d77f8
movl 0x38(%r14), %r13d
leal 0x1(%r13), %ebp
movl %ebp, 0x38(%r14)
movl %ebp, 0xc(%r15)
addl $0x2, %r13d
movl %r13d, 0x38(%r14)
movq %r14, %rdi
movl %ebp, %edx
callq 0x2c5f97
movq %r12, %rdi
movl $0xf, %esi
movl %ebp, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2b200c
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 0x2b200c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq