// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/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;

  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))
  ){
    pParse->nErr++;
    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 ){
    sqlite3VdbeAddOp3(v, OP_Function, 0, regArgs+3-pFunc->nArg, regArgs+3);
    assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg );
    sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg));
    sqlite3VdbeChangeP4(v, -1, (char *)pFunc, P4_FUNCDEF);

    /* 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
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x80(%rbp)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x8200
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x28(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x839e0
movl %eax, %ecx
movl %ecx, -0x34(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x82f01
movq -0x30(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x839e0
movl %eax, %ecx
movl %ecx, -0x34(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x82f01
movq 0x10(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x839e0
movl %eax, %ecx
movl %ecx, -0x34(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0x82f13
movq -0x8(%rbp), %rax
movl 0x50(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x50(%rax)
jmp 0x83047
cmpq $0x0, -0x20(%rbp)
je 0x82f6d
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x5e, %eax
jne 0x82f37
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
jmp 0x82f42
movq $0x0, -0x90(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x90(%rbp), %rdx
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rcx
callq 0x5e720
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x82f6b
jmp 0x83047
jmp 0x82f6d
movq -0x8(%rbp), %rdi
callq 0x5e000
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
movl $0x4, %esi
callq 0x67c30
movl %eax, -0x84(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x84(%rbp), %edx
callq 0x69c70
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x84(%rbp), %edx
addl $0x1, %edx
callq 0x69c70
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movl -0x84(%rbp), %edx
addl $0x2, %edx
callq 0x69c70
cmpq $0x0, -0x78(%rbp)
je 0x83045
movq -0x78(%rbp), %rdi
movl -0x84(%rbp), %ecx
addl $0x3, %ecx
movq -0x18(%rbp), %rax
movswl (%rax), %eax
subl %eax, %ecx
movl -0x84(%rbp), %r8d
addl $0x3, %r8d
movl $0x1, %esi
xorl %edx, %edx
callq 0x5e0f0
movq -0x78(%rbp), %rdi
movq -0x18(%rbp), %rax
movw (%rax), %ax
movzbl %al, %esi
callq 0x5e540
movq -0x78(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xfffffffb, %ecx       # imm = 0xFFFFFFFB
callq 0x13c20
movq -0x78(%rbp), %rdi
cmpl $0x18, -0xc(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %edx
movl $0x84, %esi
callq 0x5ecf0
jmp 0x83047
movq -0x80(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x47330
movq -0x80(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x47330
movq -0x80(%rbp), %rdi
movq 0x10(%rbp), %rsi
callq 0x47330
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)