// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: codeAttach
static void codeAttach(
  Parse *pParse,       /* The parser context */
  int type,            /* Either SQLITE_ATTACH or SQLITE_DETACH */
  FuncDef const *pFunc,/* FuncDef wrapper for detachFunc() or attachFunc() */
  Expr *pAuthArg,      /* Expression to pass to authorization callback */
  Expr *pFilename,     /* Name of database file */
  Expr *pDbname,       /* Name of the database to use internally */
  Expr *pKey           /* Database key for encryption extension */
){
  int rc;
  NameContext sName;
  Vdbe *v;
  sqlite3* db = pParse->db;
  int regArgs;

  if( pParse->nErr ) goto attach_end;
  memset(&sName, 0, sizeof(NameContext));
  sName.pParse = pParse;

  if(
      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||
      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||
      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))
  ){
    goto attach_end;
  }

#ifndef SQLITE_OMIT_AUTHORIZATION
  if( pAuthArg ){
    char *zAuthArg;
    if( pAuthArg->op==TK_STRING ){
      zAuthArg = pAuthArg->u.zToken;
    }else{
      zAuthArg = 0;
    }
    rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0);
    if(rc!=SQLITE_OK ){
      goto attach_end;
    }
  }
#endif /* SQLITE_OMIT_AUTHORIZATION */


  v = sqlite3GetVdbe(pParse);
  regArgs = sqlite3GetTempRange(pParse, 4);
  sqlite3ExprCode(pParse, pFilename, regArgs);
  sqlite3ExprCode(pParse, pDbname, regArgs+1);
  sqlite3ExprCode(pParse, pKey, regArgs+2);

  assert( v || db->mallocFailed );
  if( v ){
    sqlite3VdbeAddFunctionCall(pParse, 0, regArgs+3-pFunc->nArg, regArgs+3,
                               pFunc->nArg, pFunc, 0);
    /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this
    ** statement only). For DETACH, set it to false (expire all existing
    ** statements).
    */
    sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));
  }

attach_end:
  sqlite3ExprDelete(db, pFilename);
  sqlite3ExprDelete(db, pDbname);
  sqlite3ExprDelete(db, pKey);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %r15
movq %r8, %r12
movl %esi, 0xc(%rsp)
movq 0x90(%rsp), %rbx
movq (%rdi), %r14
cmpl $0x0, 0x30(%rdi)
je 0x2f1663
testq %r12, %r12
je 0x2f1634
movq %r14, %rdi
movq %r12, %rsi
callq 0x2afd54
testq %r15, %r15
je 0x2f1644
movq %r14, %rdi
movq %r15, %rsi
callq 0x2afd54
testq %rbx, %rbx
je 0x2f1654
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2afd54
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %rbp
movq %rdi, %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x50(%rsp)
movq %rdi, 0x20(%rsp)
testq %r12, %r12
movq %rdx, 0x18(%rsp)
je 0x2f16b6
cmpb $0x3b, (%r12)
jne 0x2f16a1
movb $0x73, (%r12)
jmp 0x2f16b6
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x2ce0ea
testl %eax, %eax
jne 0x2f1624
testq %r15, %r15
je 0x2f16dc
cmpb $0x3b, (%r15)
jne 0x2f16c7
movb $0x73, (%r15)
jmp 0x2f16dc
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x2ce0ea
testl %eax, %eax
jne 0x2f1624
testq %rbx, %rbx
je 0x2f1700
cmpb $0x3b, (%rbx)
jne 0x2f16eb
movb $0x73, (%rbx)
jmp 0x2f1700
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x2ce0ea
testl %eax, %eax
jne 0x2f1624
testq %rbp, %rbp
je 0x2f172c
cmpb $0x73, (%rbp)
jne 0x2f1711
movq 0x8(%rbp), %rdx
jmp 0x2f1713
xorl %edx, %edx
movq %r13, %rdi
movl 0xc(%rsp), %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2cceea
testl %eax, %eax
jne 0x2f1624
movq %r13, %rdi
callq 0x2c5ddf
movq %rax, 0x10(%rsp)
movl 0x28(%r13), %eax
cmpl $0x4, %eax
jge 0x2f1752
movl 0x38(%r13), %eax
leal 0x1(%rax), %ebp
addl $0x4, %eax
movl %eax, 0x38(%r13)
jmp 0x2f1764
movl 0x2c(%r13), %ebp
leal 0x4(%rbp), %ecx
movl %ecx, 0x2c(%r13)
addl $-0x4, %eax
movl %eax, 0x28(%r13)
movq %r13, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x2c5f97
leal 0x1(%rbp), %edx
movq %r13, %rdi
movq %r15, %rsi
callq 0x2c5f97
leal 0x2(%rbp), %edx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2c5f97
movq 0x10(%rsp), %rax
testq %rax, %rax
movq 0x18(%rsp), %r9
je 0x2f1624
addl $0x3, %ebp
movsbl (%r9), %r8d
movl %ebp, %edx
subl %r8d, %edx
movl $0x0, (%rsp)
movq %r13, %rdi
xorl %esi, %esi
movl %ebp, %ecx
movq %rax, %r13
callq 0x2c85ae
xorl %edx, %edx
cmpl $0x18, 0xc(%rsp)
sete %dl
movq %r13, %rdi
movl $0x9e, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2b200c
jmp 0x2f1624