// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3CreateFunc
SQLITE_PRIVATE int sqlite3CreateFunc(
  sqlite3 *db,
  const char *zFunctionName,
  int nArg,
  int enc,
  void *pUserData,
  void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),
  void (*xStep)(sqlite3_context*,int,sqlite3_value **),
  void (*xFinal)(sqlite3_context*),
  void (*xValue)(sqlite3_context*),
  void (*xInverse)(sqlite3_context*,int,sqlite3_value **),
  FuncDestructor *pDestructor
){
  FuncDef *p;
  int nName;
  int extraFlags;

  assert( sqlite3_mutex_held(db->mutex) );
  assert( xValue==0 || xSFunc==0 );
  if( zFunctionName==0                /* Must have a valid name */
   || (xSFunc!=0 && xFinal!=0)        /* Not both xSFunc and xFinal */
   || ((xFinal==0)!=(xStep==0))       /* Both or neither of xFinal and xStep */
   || ((xValue==0)!=(xInverse==0))    /* Both or neither of xValue, xInverse */
   || (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG)
   || (255<(nName = sqlite3Strlen30( zFunctionName)))
  ){
    return SQLITE_MISUSE_BKPT;
  }

  assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );
  assert( SQLITE_FUNC_DIRECT==SQLITE_DIRECTONLY );
  extraFlags = enc &  (SQLITE_DETERMINISTIC|SQLITE_DIRECTONLY|
                       SQLITE_SUBTYPE|SQLITE_INNOCUOUS);
  enc &= (SQLITE_FUNC_ENCMASK|SQLITE_ANY);

  /* The SQLITE_INNOCUOUS flag is the same bit as SQLITE_FUNC_UNSAFE.  But
  ** the meaning is inverted.  So flip the bit. */
  assert( SQLITE_FUNC_UNSAFE==SQLITE_INNOCUOUS );
  extraFlags ^= SQLITE_FUNC_UNSAFE;


#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)^SQLITE_FUNC_UNSAFE,
         pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
    if( rc==SQLITE_OK ){
      rc = sqlite3CreateFunc(db, zFunctionName, nArg,
           (SQLITE_UTF16LE|extraFlags)^SQLITE_FUNC_UNSAFE,
           pUserData, xSFunc, xStep, xFinal, xValue, xInverse, 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, nArg, (u8)enc, 0);
  if( p && (p->funcFlags & SQLITE_FUNC_ENCMASK)==(u32)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, 0);
    }
  }

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

  /* 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->u.pDestructor = pDestructor;
  p->funcFlags = (p->funcFlags & SQLITE_FUNC_ENCMASK) | extraFlags;
  testcase( p->funcFlags & SQLITE_DETERMINISTIC );
  testcase( p->funcFlags & SQLITE_DIRECTONLY );
  p->xSFunc = xSFunc ? xSFunc : xStep;
  p->xFinalize = xFinal;
  p->xValue = xValue;
  p->xInverse = xInverse;
  p->pUserData = pUserData;
  p->nArg = (u16)nArg;
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x80, %rsp
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movl %edx, -0x2c(%rbp)
movl %ecx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x3d198e
cmpq $0x0, -0x40(%rbp)
je 0x3d192d
cmpq $0x0, 0x18(%rbp)
jne 0x3d198e
cmpq $0x0, 0x18(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
cmpq $0x0, 0x10(%rbp)
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x3d198e
cmpq $0x0, 0x20(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
cmpq $0x0, 0x28(%rbp)
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x3d198e
cmpl $-0x1, -0x2c(%rbp)
jl 0x3d198e
cmpl $0x7f, -0x2c(%rbp)
jg 0x3d198e
movq -0x28(%rbp), %rdi
callq 0x3c3400
movl %eax, %ecx
movl %ecx, -0x4c(%rbp)
movl $0xff, %eax
cmpl %ecx, %eax
jge 0x3d19a0
movl $0x27bed, %edi          # imm = 0x27BED
callq 0x3bf6a0
movl %eax, -0x14(%rbp)
jmp 0x3d1bf6
movl -0x30(%rbp), %eax
andl $0x380800, %eax         # imm = 0x380800
movl %eax, -0x50(%rbp)
movl -0x30(%rbp), %eax
andl $0x7, %eax
movl %eax, -0x30(%rbp)
movl -0x50(%rbp), %eax
xorl $0x200000, %eax         # imm = 0x200000
movl %eax, -0x50(%rbp)
cmpl $0x4, -0x30(%rbp)
jne 0x3d19d1
movl $0x2, -0x30(%rbp)
jmp 0x3d1aa1
cmpl $0x5, -0x30(%rbp)
jne 0x3d1a9f
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl -0x50(%rbp), %ecx
orl $0x1, %ecx
xorl $0x200000, %ecx         # imm = 0x200000
movq -0x38(%rbp), %r8
movq -0x40(%rbp), %r9
movq 0x10(%rbp), %r14
movq 0x18(%rbp), %rbx
movq 0x20(%rbp), %r11
movq 0x28(%rbp), %r10
movq 0x30(%rbp), %rax
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x3d18e0
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x3d1a87
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl -0x50(%rbp), %ecx
orl $0x2, %ecx
xorl $0x200000, %ecx         # imm = 0x200000
movq -0x38(%rbp), %r8
movq -0x40(%rbp), %r9
movq 0x10(%rbp), %r14
movq 0x18(%rbp), %rbx
movq 0x20(%rbp), %r11
movq 0x28(%rbp), %r10
movq 0x30(%rbp), %rax
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x3d18e0
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0x3d1a98
movl -0x54(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x3d1bf6
movl $0x3, -0x30(%rbp)
jmp 0x3d1aa1
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %eax
xorl %r8d, %r8d
movzbl %al, %ecx
callq 0x3d1cd0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x3d1b1d
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl -0x30(%rbp), %eax
jne 0x3d1b1d
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
cmpl -0x2c(%rbp), %eax
jne 0x3d1b1d
movq -0x20(%rbp), %rax
cmpl $0x0, 0xc0(%rax)
je 0x3d1b10
movq -0x20(%rbp), %rdi
movl $0x5, %esi
leaq 0x1ddea3(%rip), %rdx    # 0x5af9a0
movb $0x0, %al
callq 0x3c50b0
movl $0x5, -0x14(%rbp)
jmp 0x3d1bf6
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x3cc920
jmp 0x3d1b1d
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %eax
movl $0x1, %r8d
movzbl %al, %ecx
callq 0x3d1cd0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x3d1b50
movl $0x7, -0x14(%rbp)
jmp 0x3d1bf6
movq -0x20(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x46e650
cmpq $0x0, 0x30(%rbp)
je 0x3d1b6f
movq 0x30(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq 0x30(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x48(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0x3, %ecx
orl -0x50(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x4(%rax)
cmpq $0x0, -0x40(%rbp)
je 0x3d1ba0
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x3d1ba8
movq 0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x18(%rax)
movq 0x18(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x20(%rax)
movq 0x20(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x28(%rax)
movq 0x28(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x38(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x2c(%rbp), %eax
movb %al, %cl
movq -0x48(%rbp), %rax
movb %cl, (%rax)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
addq $0x80, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopw %cs:(%rax,%rax)