// File: /workspace/github_c_makefile_star2_O0/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: sqlite3CreateFunc
SQLITE_PRIVATE int sqlite3CreateFunc(
  sqlite3 *db,
  const char *zFunctionName,
  int nArg,
  int enc,
  void *pUserData,
  void (*xFunc)(sqlite3_context*,int,sqlite3_value **),
  void (*xStep)(sqlite3_context*,int,sqlite3_value **),
  void (*xFinal)(sqlite3_context*),
  FuncDestructor *pDestructor
){
  FuncDef *p;
  int nName;
  int extraFlags;

  assert( sqlite3_mutex_held(db->mutex) );
  if( zFunctionName==0 ||
      (xFunc && (xFinal || xStep)) || 
      (!xFunc && (xFinal && !xStep)) ||
      (!xFunc && (!xFinal && xStep)) ||
      (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) ||
      (255<(nName = sqlite3Strlen30( zFunctionName))) ){
    return SQLITE_MISUSE_BKPT;
  }

  assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );
  extraFlags = enc &  SQLITE_DETERMINISTIC;
  enc &= (SQLITE_FUNC_ENCMASK|SQLITE_ANY);
  
#ifndef SQLITE_OMIT_UTF16
  /* If SQLITE_UTF16 is specified as the encoding type, transform this
  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the
  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.
  **
  ** If SQLITE_ANY is specified, add three versions of the function
  ** to the hash table.
  */
  if( enc==SQLITE_UTF16 ){
    enc = SQLITE_UTF16NATIVE;
  }else if( enc==SQLITE_ANY ){
    int rc;
    rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8|extraFlags,
         pUserData, xFunc, xStep, xFinal, pDestructor);
    if( rc==SQLITE_OK ){
      rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE|extraFlags,
          pUserData, xFunc, xStep, xFinal, pDestructor);
    }
    if( rc!=SQLITE_OK ){
      return rc;
    }
    enc = SQLITE_UTF16BE;
  }
#else
  enc = SQLITE_UTF8;
#endif
  
  /* Check if an existing function is being overridden or deleted. If so,
  ** and there are active VMs, then return SQLITE_BUSY. If a function
  ** is being overridden/deleted but there are no active VMs, allow the
  ** operation to continue but invalidate all precompiled statements.
  */
  p = sqlite3FindFunction(db, zFunctionName, nName, nArg, (u8)enc, 0);
  if( p && (p->funcFlags & SQLITE_FUNC_ENCMASK)==enc && p->nArg==nArg ){
    if( db->nVdbeActive ){
      sqlite3ErrorWithMsg(db, SQLITE_BUSY, 
        "unable to delete/modify user-function due to active statements");
      assert( !db->mallocFailed );
      return SQLITE_BUSY;
    }else{
      sqlite3ExpirePreparedStatements(db);
    }
  }

  p = sqlite3FindFunction(db, zFunctionName, nName, nArg, (u8)enc, 1);
  assert(p || db->mallocFailed);
  if( !p ){
    return SQLITE_NOMEM;
  }

  /* If an older version of the function with a configured destructor is
  ** being replaced invoke the destructor function here. */
  functionDestroy(db, p);

  if( pDestructor ){
    pDestructor->nRef++;
  }
  p->pDestructor = pDestructor;
  p->funcFlags = (p->funcFlags & SQLITE_FUNC_ENCMASK) | extraFlags;
  testcase( p->funcFlags & SQLITE_DETERMINISTIC );
  p->xFunc = xFunc;
  p->xStep = xStep;
  p->xFinalize = xFinal;
  p->pUserData = pUserData;
  p->nArg = (u16)nArg;
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1d793
cmpq $0x0, -0x30(%rbp)
je 0x1d746
cmpq $0x0, 0x18(%rbp)
jne 0x1d793
cmpq $0x0, 0x10(%rbp)
jne 0x1d793
cmpq $0x0, -0x30(%rbp)
jne 0x1d75b
cmpq $0x0, 0x18(%rbp)
je 0x1d75b
cmpq $0x0, 0x10(%rbp)
je 0x1d793
cmpq $0x0, -0x30(%rbp)
jne 0x1d770
cmpq $0x0, 0x18(%rbp)
jne 0x1d770
cmpq $0x0, 0x10(%rbp)
jne 0x1d793
cmpl $-0x1, -0x1c(%rbp)
jl 0x1d793
cmpl $0x7f, -0x1c(%rbp)
jg 0x1d793
movq -0x18(%rbp), %rdi
callq 0xc6c0
movl %eax, %ecx
movl %ecx, -0x3c(%rbp)
movl $0xff, %eax
cmpl %ecx, %eax
jge 0x1d7a5
movl $0x20a16, %edi          # imm = 0x20A16
callq 0xc850
movl %eax, -0x4(%rbp)
jmp 0x1d9a9
movl -0x20(%rbp), %eax
andl $0x800, %eax            # imm = 0x800
movl %eax, -0x40(%rbp)
movl -0x20(%rbp), %eax
andl $0x7, %eax
movl %eax, -0x20(%rbp)
cmpl $0x4, -0x20(%rbp)
jne 0x1d7cb
movl $0x2, -0x20(%rbp)
jmp 0x1d86b
cmpl $0x5, -0x20(%rbp)
jne 0x1d869
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x40(%rbp), %ecx
orl $0x1, %ecx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movq 0x10(%rbp), %r11
movq 0x18(%rbp), %r10
movq 0x20(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x1d700
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x1d851
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl -0x40(%rbp), %ecx
orl $0x2, %ecx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movq 0x10(%rbp), %r11
movq 0x18(%rbp), %r10
movq 0x20(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x1d700
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x1d862
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1d9a9
movl $0x3, -0x20(%rbp)
jmp 0x1d86b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x3c(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %eax
xorl %r9d, %r9d
movzbl %al, %r8d
callq 0x1dbc0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x1d8ea
movq -0x38(%rbp), %rax
movzwl 0x2(%rax), %eax
andl $0x3, %eax
cmpl -0x20(%rbp), %eax
jne 0x1d8ea
movq -0x38(%rbp), %rax
movswl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jne 0x1d8ea
movq -0x10(%rbp), %rax
cmpl $0x0, 0xa4(%rax)
je 0x1d8df
movq -0x10(%rbp), %rdi
movl $0x5, %esi
leaq 0x8c42b(%rip), %rdx     # 0xa9cf7
movb $0x0, %al
callq 0x11390
movl $0x5, -0x4(%rbp)
jmp 0x1d9a9
movq -0x10(%rbp), %rdi
callq 0x18ba0
jmp 0x1d8ea
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x3c(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %eax
movl $0x1, %r9d
movzbl %al, %r8d
callq 0x1dbc0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x1d921
movl $0x7, -0x4(%rbp)
jmp 0x1d9a9
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x9f800
cmpq $0x0, 0x20(%rbp)
je 0x1d940
movq 0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq 0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x38(%rbp), %rax
movzwl 0x2(%rax), %eax
andl $0x3, %eax
orl -0x40(%rbp), %eax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x2(%rax)
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movq 0x10(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
movq 0x18(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x1c(%rbp), %eax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)