// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VtabOverloadFunction
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(
  sqlite3 *db,    /* Database connection for reporting malloc problems */
  FuncDef *pDef,  /* Function to possibly overload */
  int nArg,       /* Number of arguments to the function */
  Expr *pExpr     /* First argument to the function */
){
  Table *pTab;
  sqlite3_vtab *pVtab;
  sqlite3_module *pMod;
  void (*xFunc)(sqlite3_context*,int,sqlite3_value**) = 0;
  void *pArg = 0;
  FuncDef *pNew;
  int rc = 0;
  char *zLowerName;
  unsigned char *z;


  /* Check to see the left operand is a column in a virtual table */
  if( NEVER(pExpr==0) ) return pDef;
  if( pExpr->op!=TK_COLUMN ) return pDef;
  pTab = pExpr->pTab;
  if( NEVER(pTab==0) ) return pDef;
  if( (pTab->tabFlags & TF_Virtual)==0 ) return pDef;
  pVtab = sqlite3GetVTable(db, pTab)->pVtab;
  assert( pVtab!=0 );
  assert( pVtab->pModule!=0 );
  pMod = (sqlite3_module *)pVtab->pModule;
  if( pMod->xFindFunction==0 ) return pDef;
 
  /* Call the xFindFunction method on the virtual table implementation
  ** to see if the implementation wants to overload this function 
  */
  zLowerName = sqlite3DbStrDup(db, pDef->zName);
  if( zLowerName ){
    for(z=(unsigned char*)zLowerName; *z; z++){
      *z = sqlite3UpperToLower[*z];
    }
    rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xFunc, &pArg);
    sqlite3DbFree(db, zLowerName);
  }
  if( rc==0 ){
    return pDef;
  }

  /* Create a new ephemeral function definition for the overloaded
  ** function */
  pNew = sqlite3DbMallocZero(db, sizeof(*pNew)
                             + sqlite3Strlen30(pDef->zName) + 1);
  if( pNew==0 ){
    return pDef;
  }
  *pNew = *pDef;
  pNew->zName = (char *)&pNew[1];
  memcpy(pNew->zName, pDef->zName, sqlite3Strlen30(pDef->zName)+1);
  pNew->xFunc = xFunc;
  pNew->pUserData = pArg;
  pNew->flags |= SQLITE_FUNC_EPHEM;
  return pNew;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movl $0x0, -0x5c(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x69e95
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6a08f
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x98, %eax
je 0x69eb0
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6a08f
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x69ed0
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6a08f
movq -0x30(%rbp), %rax
movzbl 0x46(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x69eed
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6a08f
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x49880
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x90(%rax)
jne 0x69f28
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6a08f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0x11720
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x69fac
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpb $0x0, (%rax)
je 0x69f7c
movq -0x70(%rbp), %rax
movzbl (%rax), %eax
movl %eax, %ecx
leaq 0x40bdb(%rip), %rax     # 0xaab40
movb (%rax,%rcx), %cl
movq -0x70(%rbp), %rax
movb %cl, (%rax)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x69f4c
movq -0x40(%rbp), %rax
movq 0x90(%rax), %rax
movq -0x38(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x68(%rbp), %rdx
leaq -0x48(%rbp), %rcx
leaq -0x50(%rbp), %r8
callq *%rax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x9cd0
cmpl $0x0, -0x5c(%rbp)
jne 0x69fbf
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6a08f
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x92f0
movq -0x78(%rbp), %rdi
cltq
addq $0x48, %rax
addq $0x1, %rax
movl %eax, %esi
callq 0x11ca0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x6a001
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6a08f
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x48, %edx
callq 0x82f0
movq -0x58(%rbp), %rcx
addq $0x48, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x58(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x92f0
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
addl $0x1, %eax
movslq %eax, %rdx
callq 0x82f0
movq -0x48(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x58(%rbp), %rax
movzbl 0x3(%rax), %ecx
orl $0x4, %ecx
movb %cl, 0x3(%rax)
movq -0x58(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)