// File: /workspace/github_c_makefile_star2_O3/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 0x40a56
movq %rsi, %r13
movq %rdi, %r14
movq (%rdi), %rbx
movq 0x8(%rsi), %r15
cmpb $0x0, 0x1(%r15)
je 0x408c1
movq %rbx, -0x40(%rbp)
leaq 0x1(%r15), %rdi
movq $-0x1, %r12
cmpb $0x0, 0x1(%r15,%r12)
leaq 0x1(%r12), %r12
jne 0x40825
movl %r12d, %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
cmpb $0x3f, (%r15)
movq %r14, -0x38(%rbp)
movq %rax, -0x48(%rbp)
jne 0x408db
leal -0x1(%rax), %edx
leaq -0x50(%rbp), %rbx
movq %rbx, %rsi
movl $0x1, %ecx
callq 0x16fda
testl %eax, %eax
setne %al
movq (%rbx), %rbx
movw %bx, 0x30(%r13)
testq %rbx, %rbx
setle %cl
orb %al, %cl
movq -0x40(%rbp), %rax
movl 0x8c(%rax), %edx
movslq %edx, %rax
cmpq %rax, %rbx
setg %al
orb %cl, %al
movl %ebx, %r13d
cmpb $0x1, %al
jne 0x408a5
leaq 0x3b646(%rip), %rsi     # 0x7bede
xorl %r13d, %r13d
movq %r14, %rdi
xorl %eax, %eax
callq 0x11842
movslq 0x1f8(%r14), %rax
cmpq %rax, %rbx
jle 0x40944
movl %ebx, 0x1f8(%r14)
jmp 0x40944
movl 0x1f8(%r14), %eax
incl %eax
movl %eax, 0x1f8(%r14)
movw %ax, 0x30(%r13)
jmp 0x40a21
movq %r13, -0x30(%rbp)
movl 0x1fc(%r14), %ebx
testl %ebx, %ebx
jle 0x40926
movq -0x38(%rbp), %rax
movq 0x218(%rax), %r14
movw $0x1, %r13w
leal -0x1(%r13), %eax
movswq %ax, %rax
movq (%r14,%rax,8), %rdi
testq %rdi, %rdi
je 0x4091b
movq %r15, %rsi
callq 0x8530
testl %eax, %eax
je 0x40a65
movswl %r13w, %eax
incl %r13d
cmpl %eax, %ebx
jg 0x408fa
movq -0x38(%rbp), %rax
movl 0x1f8(%rax), %r13d
incl %r13d
movl %r13d, 0x1f8(%rax)
movq -0x30(%rbp), %rax
movw %r13w, 0x30(%rax)
testw %r13w, %r13w
movq -0x38(%rbp), %r14
movq -0x40(%rbp), %rbx
jle 0x40a21
movswl %r13w, %edi
cmpl %edi, 0x1fc(%r14)
jge 0x409b5
movq 0x218(%r14), %rsi
leal (,%rdi,8), %edx
movq %rdi, -0x30(%rbp)
movq %rbx, %rdi
callq 0x174d6
testq %rax, %rax
je 0x40a56
movq %rax, 0x218(%r14)
movslq 0x1fc(%r14), %rcx
leaq (%rax,%rcx,8), %rdi
movslq -0x30(%rbp), %rdx
subq %rcx, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x8200
movq -0x30(%rbp), %rdi
movl %edi, 0x1fc(%r14)
cmpb $0x3f, (%r15)
movq 0x218(%r14), %rax
jne 0x409ce
movzwl %r13w, %ecx
cmpq $0x0, -0x8(%rax,%rcx,8)
jne 0x40a21
decl %edi
movq %rdi, %r13
movq (%rax,%rdi,8), %rsi
movq %rbx, %rdi
callq 0x9ca4
movq -0x48(%rbp), %rsi
incl %esi
movq %rbx, %rdi
callq 0x11721
movq %rax, %r14
testq %rax, %rax
je 0x40a0f
andl $0x3fffffff, %r12d      # imm = 0x3FFFFFFF
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x82f0
movb $0x0, (%r14,%r12)
movq -0x38(%rbp), %rcx
movq 0x218(%rcx), %rax
movq %r14, (%rax,%r13,8)
movq %rcx, %r14
cmpl $0x0, 0x50(%r14)
jne 0x40a56
movl 0x1f8(%r14), %eax
cmpl 0x8c(%rbx), %eax
jle 0x40a56
leaq 0x3b4cb(%rip), %rsi     # 0x7bf09
movq %r14, %rdi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11842
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x30(%rbp), %rax
movw %r13w, 0x30(%rax)
testw %r13w, %r13w
jne 0x40944
jmp 0x40926