// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3FinishCoding
SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
  sqlite3 *db;
  Vdbe *v;

  assert( pParse->pToplevel==0 );
  db = pParse->db;
  if( db->mallocFailed ) return;
  if( pParse->nested ) return;
  if( pParse->nErr ) return;

  /* Begin by generating some termination code at the end of the
  ** vdbe program
  */
  v = sqlite3GetVdbe(pParse);
  assert( !pParse->isMultiWrite 
       || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));
  if( v ){
    sqlite3VdbeAddOp0(v, OP_Halt);

    /* The cookie mask contains one bit for each database file open.
    ** (Bit 0 is for main, bit 1 is for temp, and so forth.)  Bits are
    ** set for each database that is used.  Generate code to start a
    ** transaction on each used database and to verify the schema cookie
    ** on each used database.
    */
    if( pParse->cookieGoto>0 ){
      yDbMask mask;
      int iDb;
      sqlite3VdbeJumpHere(v, pParse->cookieGoto-1);
      for(iDb=0, mask=1; iDb<db->nDb; mask<<=1, iDb++){
        if( (mask & pParse->cookieMask)==0 ) continue;
        sqlite3VdbeUsesBtree(v, iDb);
        sqlite3VdbeAddOp2(v,OP_Transaction, iDb, (mask & pParse->writeMask)!=0);
        if( db->init.busy==0 ){
          assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
          sqlite3VdbeAddOp3(v, OP_VerifyCookie,
                            iDb, pParse->cookieValue[iDb],
                            db->aDb[iDb].pSchema->iGeneration);
        }
      }
#ifndef SQLITE_OMIT_VIRTUALTABLE
      {
        int i;
        for(i=0; i<pParse->nVtabLock; i++){
          char *vtab = (char *)sqlite3GetVTable(db, pParse->apVtabLock[i]);
          sqlite3VdbeAddOp4(v, OP_VBegin, 0, 0, 0, vtab, P4_VTAB);
        }
        pParse->nVtabLock = 0;
      }
#endif

      /* Once all the cookies have been verified and transactions opened, 
      ** obtain the required table-locks. This is a no-op unless the 
      ** shared-cache feature is enabled.
      */
      codeTableLocks(pParse);

      /* Initialize any AUTOINCREMENT data structures required.
      */
      sqlite3AutoincrementBegin(pParse);

      /* Finally, jump back to the beginning of the executable code. */
      sqlite3VdbeAddOp2(v, OP_Goto, 0, pParse->cookieGoto);
    }
  }


  /* Get the VDBE program ready for execution
  */
  if( v && ALWAYS(pParse->nErr==0) && !db->mallocFailed ){
#ifdef SQLITE_DEBUG
    FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0;
    sqlite3VdbeTrace(v, trace);
#endif
    assert( pParse->iCacheLevel==0 );  /* Disables and re-enables match */
    /* A minimum of one cursor is required if autoincrement is used
    *  See ticket [a696379c1f08866] */
    if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
    sqlite3VdbeMakeReady(v, pParse);
    pParse->rc = SQLITE_DONE;
    pParse->colNamesSet = 0;
  }else{
    pParse->rc = SQLITE_ERROR;
  }
  pParse->nTab = 0;
  pParse->nMem = 0;
  pParse->nSet = 0;
  pParse->nVar = 0;
  pParse->cookieMask = 0;
  pParse->cookieGoto = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x50(%rax)
je 0x4f646
jmp 0x4f8d3
movq -0x8(%rbp), %rax
cmpb $0x0, 0x1e(%rax)
je 0x4f655
jmp 0x4f8d3
movq -0x8(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x4f664
jmp 0x4f8d3
movq -0x8(%rbp), %rdi
callq 0x5e000
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x4f81d
movq -0x18(%rbp), %rdi
movl $0x14, %esi
callq 0x5e060
movq -0x8(%rbp), %rax
cmpl $0x0, 0x16c(%rax)
jle 0x4f81b
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x16c(%rax), %esi
subl $0x1, %esi
callq 0x5e090
movl $0x0, -0x20(%rbp)
movl $0x1, -0x1c(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x4f77e
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
andl 0x168(%rcx), %eax
cmpl $0x0, %eax
jne 0x4f6e6
jmp 0x4f768
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x13bc0
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %edx
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
andl 0x164(%rcx), %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %ecx
movl $0x4, %esi
callq 0x5e0c0
movq -0x10(%rbp), %rax
movzbl 0x99(%rax), %eax
cmpl $0x0, %eax
jne 0x4f766
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %edx
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl 0x170(%rax,%rcx,4), %ecx
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x20(%rbp), %rsi
shlq $0x5, %rsi
addq %rsi, %rax
movq 0x18(%rax), %rax
movl 0x4(%rax), %r8d
movl $0x2f, %esi
callq 0x5e0f0
jmp 0x4f768
movl -0x1c(%rbp), %eax
shll %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x4f6bf
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x204(%rcx), %eax
jge 0x4f7e1
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x280(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x49880
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %r9
movl $0x86, %esi
xorl %r8d, %r8d
movl %r8d, %edx
movl %r8d, %ecx
movl $0xfffffff6, (%rsp)     # imm = 0xFFFFFFF6
callq 0x5e1b0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x4f785
movq -0x8(%rbp), %rax
movl $0x0, 0x204(%rax)
movq -0x8(%rbp), %rdi
callq 0x5e210
movq -0x8(%rbp), %rdi
callq 0x5e2b0
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x16c(%rax), %ecx
movl $0xe, %esi
xorl %edx, %edx
callq 0x5e0c0
jmp 0x4f81d
cmpq $0x0, -0x18(%rbp)
je 0x4f87d
movq -0x8(%rbp), %rax
cmpl $0x0, 0x50(%rax)
jne 0x4f87d
movq -0x10(%rbp), %rax
cmpb $0x0, 0x50(%rax)
jne 0x4f87d
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1d0(%rax)
je 0x4f85b
movq -0x8(%rbp), %rax
cmpl $0x0, 0x54(%rax)
jne 0x4f85b
movq -0x8(%rbp), %rax
movl $0x1, 0x54(%rax)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x13ee0
movq -0x8(%rbp), %rax
movl $0x65, 0x18(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x1c(%rax)
jmp 0x4f888
movq -0x8(%rbp), %rax
movl $0x1, 0x18(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x54(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x58(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x5c(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x1f8(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x168(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x16c(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)