// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq (%rdi), %r12
cmpb $0x0, 0x50(%r12)
jne 0x39830
movq %rdi, %r13
cmpb $0x0, 0x1e(%rdi)
jne 0x39830
cmpl $0x0, 0x50(%r13)
jne 0x39830
movq %r13, %rdi
callq 0x45ece
testq %rax, %rax
je 0x39810
movq %rax, %rbx
movq %rax, %rdi
movl $0x14, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x45f15
movl 0x16c(%r13), %eax
testl %eax, %eax
jle 0x39801
decl %eax
movl 0x34(%rbx), %ecx
cmpl %eax, %ecx
jbe 0x394da
movq 0x8(%rbx), %rdx
movl %eax, %eax
leaq (%rax,%rax,2), %rax
movl %ecx, 0x8(%rdx,%rax,8)
movq %rbx, -0x30(%rbp)
cmpl $0x0, 0x28(%r12)
jle 0x39575
movl $0x1, %ebx
movl $0x18, %r15d
xorl %r14d, %r14d
testl %ebx, 0x168(%r13)
je 0x39562
movl $0x1, %eax
movl %r14d, %ecx
shll %cl, %eax
movq -0x30(%rbp), %rdi
orl %eax, 0xa0(%rdi)
xorl %ecx, %ecx
testl %ebx, 0x164(%r13)
setne %cl
movl $0x4, %esi
movl %r14d, %edx
xorl %r8d, %r8d
callq 0x45f15
cmpb $0x0, 0x99(%r12)
jne 0x39562
movl 0x170(%r13,%r14,4), %ecx
movq 0x20(%r12), %rax
movq (%rax,%r15), %rax
movl 0x4(%rax), %r8d
movq -0x30(%rbp), %rdi
movl $0x2f, %esi
movl %r14d, %edx
callq 0x45f15
addl %ebx, %ebx
incq %r14
movslq 0x28(%r12), %rax
addq $0x20, %r15
cmpq %rax, %r14
jl 0x394f8
cmpl $0x0, 0x204(%r13)
movq -0x30(%rbp), %r15
jle 0x395dc
xorl %r14d, %r14d
movq 0x280(%r13), %rax
movq (%rax,%r14,8), %rax
movq 0x58(%rax), %rbx
testq %rbx, %rbx
je 0x395a5
cmpq %r12, (%rbx)
je 0x395a7
movq 0x28(%rbx), %rbx
jmp 0x39595
xorl %ebx, %ebx
movq %r15, %rdi
movl $0x86, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x45f15
movq %r15, %rdi
movl %eax, %esi
movq %rbx, %rdx
movl $0xfffffff6, %ecx       # imm = 0xFFFFFFF6
callq 0x11a9f
incq %r14
movslq 0x204(%r13), %rax
cmpq %rax, %r14
jl 0x39586
movq %r12, -0x40(%rbp)
movl $0x0, 0x204(%r13)
movq %r13, %rdi
callq 0x45ece
cmpl $0x0, 0x1c0(%r13)
jle 0x39656
movq %rax, %rbx
movl $0x10, %r15d
xorl %r12d, %r12d
movq 0x1c8(%r13), %rax
movl -0x10(%rax,%r15), %edx
movl -0xc(%rax,%r15), %ecx
movzbl -0x8(%rax,%r15), %r8d
movq (%rax,%r15), %r14
movq %rbx, %rdi
movl $0x85, %esi
callq 0x45f15
movq %rbx, %rdi
movl %eax, %esi
movq %r14, %rdx
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
callq 0x11a9f
incq %r12
movslq 0x1c0(%r13), %rax
addq $0x18, %r15
cmpq %rax, %r12
jl 0x39609
movq 0x1d0(%r13), %r14
testq %r14, %r14
je 0x397e0
movq 0x10(%r13), %r15
movq (%r13), %rax
movq %rax, -0x48(%rbp)
movq %r13, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movslq 0x10(%r14), %rdx
movl 0x14(%r14), %r12d
movq %rdx, %rcx
shlq $0x5, %rcx
movq 0x18(%rax,%rcx), %rax
movq 0x68(%rax), %rcx
movq %r13, %rdi
xorl %esi, %esi
movl $0x30, %r8d
callq 0x45fa0
leal 0x1(%r12), %r8d
movq %r15, %rdi
movl $0x18, %esi
xorl %edx, %edx
movl %r12d, %ecx
movl %r8d, -0x38(%rbp)
callq 0x45f15
movl 0x34(%r15), %r13d
leal -0x1(%r12), %ecx
movl %ecx, -0x34(%rbp)
movq 0x8(%r14), %rax
movq (%rax), %rbx
movq %r15, %rdi
movl $0x5e, %esi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x45f15
movq %r15, %rdi
movl %eax, %esi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x11a9f
leal 0x9(%r13), %ebx
movq %r15, %rdi
movl $0x65, %esi
xorl %edx, %edx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x45f15
movq %r15, %rdi
movl $0x29, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r12d, %r8d
callq 0x45f15
leal 0x7(%r13), %ecx
movq %r15, %rdi
movl $0x4b, %esi
movl -0x34(%rbp), %edx
movl %r12d, %r8d
callq 0x45f15
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x3974e
movslq 0x34(%r15), %rcx
leaq (%rcx,%rcx,2), %rcx
movb $0x8, -0x15(%rax,%rcx,8)
movq %r15, %rdi
movl $0x60, %esi
xorl %edx, %edx
movl -0x38(%rbp), %ecx
xorl %r8d, %r8d
callq 0x45f15
movq %r15, %rdi
movl $0x29, %esi
xorl %edx, %edx
movl $0x1, %ecx
movl %r12d, %r8d
callq 0x45f15
movq %r15, %rdi
movl $0xe, %esi
xorl %edx, %edx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x45f15
addl $0x2, %r13d
movq %r15, %rdi
movl $0x7, %esi
xorl %edx, %edx
movl %r13d, %ecx
xorl %r8d, %r8d
callq 0x45f15
movq %r15, %rdi
movl $0x15, %esi
xorl %edx, %edx
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0x45f15
movq %r15, %rdi
movl $0x36, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x45f15
movq (%r14), %r14
testq %r14, %r14
movq -0x50(%rbp), %r13
jne 0x39676
movl 0x16c(%r13), %ecx
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
movl $0xe, %esi
xorl %edx, %edx
xorl %r8d, %r8d
callq 0x45f15
movq -0x40(%rbp), %r12
cmpl $0x0, 0x50(%r13)
jne 0x39810
cmpb $0x0, 0x50(%r12)
je 0x3983f
movl $0x1, 0x18(%r13)
xorl %eax, %eax
movq %rax, 0x54(%r13)
movl %eax, 0x5c(%r13)
movl %eax, 0x1f8(%r13)
movq %rax, 0x168(%r13)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x1d0(%r13)
je 0x39858
cmpl $0x0, 0x54(%r13)
jne 0x39858
movl $0x1, 0x54(%r13)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x11c84
movl $0x65, 0x18(%r13)
movb $0x0, 0x1c(%r13)
jmp 0x39818