// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/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 (*xSFunc)(sqlite3_context*,int,sqlite3_value**) = 0;
  void *pArg = 0;
  FuncDef *pNew;
  int rc = 0;

  /* 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->y.pTab;
  if( pTab==0 ) return pDef;
  if( !IsVirtual(pTab) ) 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.
  **
  ** Though undocumented, we have historically always invoked xFindFunction
  ** with an all lower-case function name.  Continue in this tradition to
  ** avoid any chance of an incompatibility.
  */
#ifdef SQLITE_DEBUG
  {
    int i;
    for(i=0; pDef->zName[i]; i++){
      unsigned char x = (unsigned char)pDef->zName[i];
      assert( x==sqlite3UpperToLower[x] );
    }
  }
#endif
  rc = pMod->xFindFunction(pVtab, nArg, pDef->zName, &xSFunc, &pArg);
  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 = (const char*)&pNew[1];
  memcpy((char*)&pNew[1], pDef->zName, sqlite3Strlen30(pDef->zName)+1);
  pNew->xSFunc = xSFunc;
  pNew->pUserData = pArg;
  pNew->funcFlags |= SQLITE_FUNC_EPHEM;
  return pNew;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movq %rax, (%rsp)
testq %rcx, %rcx
je 0x2c8576
cmpb $-0x5c, (%rcx)
jne 0x2c8576
movq 0x40(%rcx), %rax
testq %rax, %rax
je 0x2c8576
cmpl $0x0, 0x54(%rax)
je 0x2c8576
movq %rdi, %r14
movq 0x60(%rax), %rax
testq %rax, %rax
je 0x2c84dd
cmpq %r14, (%rax)
je 0x2c84dd
movq 0x28(%rax), %rax
jmp 0x2c84cd
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq 0x90(%rax), %r9
testq %r9, %r9
je 0x2c8576
movq 0x38(%rbx), %rax
leaq 0x8(%rsp), %rcx
movq %rsp, %r8
movl %edx, %esi
movq %rax, %rdx
callq *%r9
testl %eax, %eax
je 0x2c8576
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x2c8529
callq 0x172f0
movq %rax, %rsi
andl $0x3fffffff, %esi       # imm = 0x3FFFFFFF
addq $0x49, %rsi
jmp 0x2c852e
movl $0x49, %esi
movq %r14, %rdi
callq 0x283569
testq %rax, %rax
je 0x2c8576
movq %rax, %r14
movl $0x9, %ecx
movq %rax, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %r15
addq $0x48, %r15
movq %r15, 0x38(%rax)
movq 0x38(%rbx), %rbx
testq %rbx, %rbx
je 0x2c8586
movq %rbx, %rdi
callq 0x172f0
movq %rax, %rdx
andl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
incq %rdx
jmp 0x2c858b
movq %rbx, %r14
movq %r14, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x17660
movq 0x8(%rsp), %rax
movq %rax, 0x18(%r14)
movq (%rsp), %rax
movq %rax, 0x8(%r14)
orb $0x10, 0x4(%r14)
jmp 0x2c8579