// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3ExprAssignVarNumber
SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
  sqlite3 *db = pParse->db;
  const char *z;

  if( pExpr==0 ) return;
  assert( !ExprHasAnyProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) );
  z = pExpr->u.zToken;
  assert( z!=0 );
  assert( z[0]!=0 );
  if( z[1]==0 ){
    /* Wildcard of the form "?".  Assign the next variable number */
    assert( z[0]=='?' );
    pExpr->iColumn = (ynVar)(++pParse->nVar);
  }else{
    ynVar x = 0;
    u32 n = sqlite3Strlen30(z);
    if( z[0]=='?' ){
      /* Wildcard of the form "?nnn".  Convert "nnn" to an integer and
      ** use it as the variable number */
      i64 i;
      int bOk = 0==sqlite3Atoi64(&z[1], &i, n-1, SQLITE_UTF8);
      pExpr->iColumn = x = (ynVar)i;
      testcase( i==0 );
      testcase( i==1 );
      testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 );
      testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] );
      if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
        sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d",
            db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]);
        x = 0;
      }
      if( i>pParse->nVar ){
        pParse->nVar = (int)i;
      }
    }else{
      /* Wildcards like ":aaa", "$aaa" or "@aaa".  Reuse the same variable
      ** number as the prior appearance of the same name, or if the name
      ** has never appeared before, reuse the same variable number
      */
      ynVar i;
      for(i=0; i<pParse->nzVar; i++){
        if( pParse->azVar[i] && strcmp(pParse->azVar[i],z)==0 ){
          pExpr->iColumn = x = (ynVar)i+1;
          break;
        }
      }
      if( x==0 ) x = pExpr->iColumn = (ynVar)(++pParse->nVar);
    }
    if( x>0 ){
      if( x>pParse->nzVar ){
        char **a;
        a = sqlite3DbRealloc(db, pParse->azVar, x*sizeof(a[0]));
        if( a==0 ) return;  /* Error reported through db->mallocFailed */
        pParse->azVar = a;
        memset(&a[pParse->nzVar], 0, (x-pParse->nzVar)*sizeof(a[0]));
        pParse->nzVar = x;
      }
      if( z[0]!='?' || pParse->azVar[x-1]==0 ){
        sqlite3DbFree(db, pParse->azVar[x-1]);
        pParse->azVar[x-1] = sqlite3DbStrNDup(db, z, n);
      }
    }
  } 
  if( !pParse->nErr && pParse->nVar>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
    sqlite3ErrorMsg(pParse, "too many SQL variables");
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rsi, %rsi
je 0x40685
movq %rsi, %r12
movq %rdi, %rbx
movq (%rdi), %r15
movq 0x8(%rsi), %rcx
cmpb $0x0, 0x1(%rcx)
je 0x40454
testq %rcx, %rcx
je 0x4046d
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq %rcx, %rax
incl %r14d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x4043f
andl $0x3fffffff, %r14d      # imm = 0x3FFFFFFF
jmp 0x40470
movl 0x1f8(%rbx), %eax
incl %eax
movl %eax, 0x1f8(%rbx)
movw %ax, 0x30(%r12)
jmp 0x40651
xorl %r14d, %r14d
movq %r15, -0x30(%rbp)
cmpb $0x3f, (%rcx)
movq %rcx, -0x38(%rbp)
jne 0x40501
leaq 0x1(%rcx), %rdi
leal -0x1(%r14), %edx
leaq -0x48(%rbp), %r13
movq %r13, %rsi
movl $0x1, %ecx
callq 0x16f9b
testl %eax, %eax
setne %al
movq (%r13), %r15
movw %r15w, 0x30(%r12)
testq %r15, %r15
setle %cl
orb %al, %cl
jne 0x404c6
movq -0x30(%rbp), %rax
movslq 0x8c(%rax), %rax
movl %r15d, %r13d
cmpq %rax, %r15
jle 0x404e4
movq -0x30(%rbp), %rax
movl 0x8c(%rax), %edx
leaq 0x3ba07(%rip), %rsi     # 0x7bede
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11724
movslq 0x1f8(%rbx), %rax
cmpq %rax, %r15
jle 0x404f7
movl %r15d, 0x1f8(%rbx)
movq -0x30(%rbp), %r15
movq -0x38(%rbp), %rcx
jmp 0x40580
movl 0x1fc(%rbx), %r15d
testl %r15d, %r15d
jle 0x40550
movq %rbx, -0x40(%rbp)
movq 0x218(%rbx), %rbx
movw $0x1, %r13w
leal -0x1(%r13), %eax
movswq %ax, %rax
movq (%rbx,%rax,8), %rdi
testq %rdi, %rdi
je 0x4053f
movq -0x38(%rbp), %rsi
callq 0x8530
movq -0x38(%rbp), %rcx
testl %eax, %eax
je 0x40555
movswl %r13w, %eax
incl %r13d
cmpl %eax, %r15d
jg 0x4051d
xorl %r13d, %r13d
jmp 0x4055b
xorl %r13d, %r13d
jmp 0x4055f
movw %r13w, 0x30(%r12)
movq -0x40(%rbp), %rbx
testw %r13w, %r13w
movq -0x30(%rbp), %r15
jne 0x40580
movl 0x1f8(%rbx), %r13d
incl %r13d
movl %r13d, 0x1f8(%rbx)
movw %r13w, 0x30(%r12)
testw %r13w, %r13w
jle 0x40651
movswl %r13w, %r12d
cmpl %r12d, 0x1fc(%rbx)
jge 0x405e5
movq 0x218(%rbx), %rsi
leal (,%r12,8), %edx
movq %r15, %rdi
callq 0x174d4
testq %rax, %rax
je 0x40685
movq %rax, 0x218(%rbx)
movslq 0x1fc(%rbx), %rcx
leaq (%rax,%rcx,8), %rdi
movslq %r12d, %rdx
subq %rcx, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x8200
movl %r12d, 0x1fc(%rbx)
movq -0x38(%rbp), %rcx
cmpb $0x3f, (%rcx)
jne 0x405fd
movq 0x218(%rbx), %rax
movzwl %r13w, %ecx
cmpq $0x0, -0x8(%rax,%rcx,8)
jne 0x40651
movq 0x218(%rbx), %rax
decl %r12d
movq %r12, -0x30(%rbp)
movq (%rax,%r12,8), %rsi
movq %r15, %rdi
callq 0x9c3a
leal 0x1(%r14), %esi
movq %r15, %rdi
callq 0x115e9
movq %rax, %r12
testq %rax, %rax
je 0x40642
movl %r14d, %r13d
movq %r12, %rdi
movq -0x38(%rbp), %rsi
movq %r13, %rdx
callq 0x82f0
movb $0x0, (%r12,%r13)
movq 0x218(%rbx), %rax
movq -0x30(%rbp), %rcx
movq %r12, (%rax,%rcx,8)
cmpl $0x0, 0x50(%rbx)
jne 0x40685
movl 0x1f8(%rbx), %eax
cmpl 0x8c(%r15), %eax
jle 0x40685
leaq 0x3b89c(%rip), %rsi     # 0x7bf09
movq %rbx, %rdi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11724
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq