// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
xorl %eax, %eax
movq %rax, -0x38(%rbp)
movq %rax, -0x30(%rbp)
testq %rcx, %rcx
je 0x4e74c
cmpb $-0x68, (%rcx)
jne 0x4e74c
movq 0x40(%rcx), %rax
testq %rax, %rax
je 0x4e74c
testb $0x10, 0x46(%rax)
je 0x4e74c
movl %edx, %r15d
movq %rdi, %r14
movq 0x58(%rax), %rax
testq %rax, %rax
je 0x4e636
cmpq %r14, (%rax)
je 0x4e636
movq 0x28(%rax), %rax
jmp 0x4e626
movq 0x10(%rax), %r12
movq (%r12), %rax
cmpq $0x0, 0x90(%rax)
je 0x4e74c
movq %rax, -0x40(%rbp)
movq 0x30(%rbx), %rsi
movq %r14, %rdi
callq 0x1010d
testq %rax, %rax
je 0x4e74c
movq %rax, %r13
movb (%rax), %al
testb %al, %al
je 0x4e68d
movq %r13, %rcx
incq %rcx
leaq 0x279e5(%rip), %rdx     # 0x76060
movzbl %al, %eax
movb (%rax,%rdx), %al
movb %al, -0x1(%rcx)
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x4e67b
leaq -0x38(%rbp), %rcx
leaq -0x30(%rbp), %r8
movq %r12, %rdi
movl %r15d, %esi
movq %r13, %rdx
movq -0x40(%rbp), %rax
callq *0x90(%rax)
movl %eax, %r15d
movq %r14, %rdi
movq %r13, %rsi
callq 0x9c3a
testl %r15d, %r15d
je 0x4e74c
movq 0x30(%rbx), %rax
testq %rax, %rax
je 0x4e6e7
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
incl %r15d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0x4e6ce
andl $0x3fffffff, %r15d      # imm = 0x3FFFFFFF
addl $0x49, %r15d
jmp 0x4e6ed
movl $0x49, %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x115e9
testq %rax, %rax
je 0x4e74c
movq %rax, %r14
movl %r15d, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0x8200
movl $0x9, %ecx
movq %r14, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
addq $0x48, %rdi
movq %rdi, 0x30(%r14)
movq 0x30(%rbx), %rsi
testq %rsi, %rsi
je 0x4e761
movq $-0x1, %rdx
cmpb $0x0, 0x1(%rsi,%rdx)
leaq 0x1(%rdx), %rdx
jne 0x4e736
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
incq %rdx
jmp 0x4e766
movq %rbx, %r14
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edx
callq 0x82f0
movq -0x38(%rbp), %rax
movq %rax, 0x18(%r14)
movq -0x30(%rbp), %rax
movq %rax, 0x8(%r14)
orb $0x4, 0x3(%r14)
jmp 0x4e74f