// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x44104d
jmp 0x4411b3
cmpq $0x0, -0x38(%rbp)
je 0x4411b3
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x38(%rax)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rdi
callq 0x4299d0
movq %rax, -0x20(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x43bf50
cmpl $0x0, %eax
je 0x441109
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %edx
movl -0x24(%rbp), %ecx
movl $0x45, %esi
callq 0x410100
cmpl $0x0, -0x2c(%rbp)
jne 0x4410ba
movq -0x20(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x429db0
jmp 0x441107
cmpl $0x0, -0x2c(%rbp)
jl 0x441105
movq -0x10(%rbp), %rax
movswl 0x2(%rax), %eax
movl %eax, -0x3c(%rbp)
movslq -0x2c(%rbp), %rdi
callq 0x3fcec0
movw %ax, %cx
movl -0x3c(%rbp), %eax
movswl %cx, %ecx
cmpl %ecx, %eax
jle 0x441105
movslq -0x2c(%rbp), %rdi
callq 0x3fcec0
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x2(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x4000, %ecx           # imm = 0x4000
movl %ecx, 0x4(%rax)
jmp 0x441107
jmp 0x441142
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
movl -0x24(%rbp), %edx
callq 0x429d30
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %edx
movl $0xf, %esi
callq 0x42ba70
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %edx
movl -0x14(%rbp), %ecx
movl $0x14, %esi
callq 0x410100
movq -0x38(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x4411b1
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x38(%rax)
movl %ecx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rax
movl 0x38(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x38(%rax)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rsi
movl -0x28(%rbp), %edx
callq 0x429d30
movq -0x20(%rbp), %rdi
movl -0x28(%rbp), %edx
movl $0xf, %esi
callq 0x42ba70
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
addl $0x1, %ecx
movl -0x28(%rbp), %r8d
movl $0x98, %esi
callq 0x410130
jmp 0x4411b3
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)