// File: /workspace/github_c_makefile_star2_O3/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 0x2e83da
testq %r12, %r12
je 0x2e83ab
movq %r14, %rdi
movq %r12, %rsi
callq 0x2a6164
testq %r15, %r15
je 0x2e83bb
movq %r14, %rdi
movq %r15, %rsi
callq 0x2a6164
testq %rbx, %rbx
je 0x2e83cb
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2a6164
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
movups %xmm0, 0x48(%rsp)
movups %xmm0, 0x38(%rsp)
movups %xmm0, 0x28(%rsp)
movq %rdi, 0x20(%rsp)
testq %r12, %r12
movq %rdx, 0x18(%rsp)
je 0x2e8420
cmpb $0x3b, (%r12)
jne 0x2e840f
movb $0x73, (%r12)
jmp 0x2e8420
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x2c496c
testl %eax, %eax
jne 0x2e83a0
testq %r15, %r15
je 0x2e8446
cmpb $0x3b, (%r15)
jne 0x2e8431
movb $0x73, (%r15)
jmp 0x2e8446
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x2c496c
testl %eax, %eax
jne 0x2e839b
testq %rbx, %rbx
je 0x2e846a
cmpb $0x3b, (%rbx)
jne 0x2e8455
movb $0x73, (%rbx)
jmp 0x2e846a
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x2c496c
testl %eax, %eax
jne 0x2e839b
testq %rbp, %rbp
je 0x2e8496
cmpb $0x73, (%rbp)
jne 0x2e847b
movq 0x8(%rbp), %rdx
jmp 0x2e847d
xorl %edx, %edx
movq %r13, %rdi
movl 0xc(%rsp), %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2c37ba
testl %eax, %eax
jne 0x2e839b
movq %r13, %rdi
callq 0x2bc630
movq %rax, 0x10(%rsp)
movl 0x28(%r13), %eax
cmpl $0x4, %eax
jge 0x2e84bc
movl 0x38(%r13), %eax
leal 0x1(%rax), %ebp
addl $0x4, %eax
movl %eax, 0x38(%r13)
jmp 0x2e84ce
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 0x2bc7e9
leal 0x1(%rbp), %edx
movq %r13, %rdi
movq %r15, %rsi
callq 0x2bc7e9
leal 0x2(%rbp), %edx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2bc7e9
movq 0x10(%rsp), %rax
testq %rax, %rax
movq 0x18(%rsp), %r9
je 0x2e839b
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 0x2bee54
xorl %edx, %edx
cmpl $0x18, 0xc(%rsp)
sete %dl
movq %r13, %rdi
movl $0x9e, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2a83e1
jmp 0x2e839b