// File: /workspace/github_c_makefile_star2_O1/skeeto[P]flappy/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, i, addr;
      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
      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);

      /* Code constant expressions that where factored out of inner loops */
      addr = pParse->cookieGoto;
      if( pParse->pConstExpr ){
        ExprList *pEL = pParse->pConstExpr;
        pParse->cookieGoto = 0;
        for(i=0; i<pEL->nExpr; i++){
          sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg);
        }
      }

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


  /* Get the VDBE program ready for execution
  */
  if( v && ALWAYS(pParse->nErr==0) && !db->mallocFailed ){
    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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq (%rdi), %r12
cmpb $0x0, 0x50(%r12)
jne 0x3a9ae
movq %rdi, %r13
cmpb $0x0, 0x1e(%rdi)
jne 0x3a9ae
cmpl $0x0, 0x50(%r13)
jne 0x3a9ae
movq %r13, %rdi
callq 0x47f6a
testq %rax, %rax
je 0x3a98e
movq %rax, %rbp
movq %rax, %rdi
movl $0x16, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x47fb1
movl 0x178(%r13), %eax
testl %eax, %eax
jle 0x3a97f
decl %eax
movl 0x34(%rbp), %ecx
cmpl %eax, %ecx
jbe 0x3a5eb
movq 0x8(%rbp), %rdx
movl %eax, %eax
leaq (%rax,%rax,2), %rax
movl %ecx, 0x8(%rdx,%rax,8)
cmpl $0x0, 0x28(%r12)
jle 0x3a6a1
movl $0x1, %ebx
xorl %r14d, %r14d
xorl %r15d, %r15d
testl %ebx, 0x174(%r13)
je 0x3a68a
movl $0x1, %eax
movl %r15d, %ecx
shll %cl, %eax
orl %eax, 0xa0(%rbp)
cmpq $0x1, %r15
je 0x3a63a
movq (%rbp), %rcx
movq 0x20(%rcx), %rcx
movq 0x8(%rcx,%r14), %rcx
cmpb $0x0, 0x11(%rcx)
je 0x3a63a
orl %eax, 0xa4(%rbp)
xorl %ecx, %ecx
testl %ebx, 0x170(%r13)
setne %cl
movq %rbp, %rdi
movl $0x4, %esi
movl %r15d, %edx
xorl %r8d, %r8d
callq 0x47fb1
cmpb $0x0, 0x99(%r12)
jne 0x3a68a
movl 0x17c(%r13,%r15,4), %ecx
movq 0x20(%r12), %rax
movq 0x18(%rax,%r14), %rax
movl 0x4(%rax), %r8d
movq %rbp, %rdi
movl $0x31, %esi
movl %r15d, %edx
callq 0x47fb1
addl %ebx, %ebx
incq %r15
movslq 0x28(%r12), %rax
addq $0x20, %r14
cmpq %rax, %r15
jl 0x3a602
cmpl $0x0, 0x214(%r13)
jle 0x3a702
xorl %r14d, %r14d
movq 0x288(%r13), %rax
movq (%rax,%r14,8), %rax
movq 0x60(%rax), %rbx
testq %rbx, %rbx
je 0x3a6cd
cmpq %r12, (%rbx)
je 0x3a6cd
movq 0x28(%rbx), %rbx
jmp 0x3a6bd
movq %rbp, %rdi
movl $0x88, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x47fb1
movq %rbp, %rdi
movl %eax, %esi
movq %rbx, %rdx
movl $0xfffffff6, %ecx       # imm = 0xFFFFFFF6
callq 0x11ea3
incq %r14
movslq 0x214(%r13), %rax
cmpq %rax, %r14
jl 0x3a6ae
movq %rbp, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movl $0x0, 0x214(%r13)
movq %r13, %rdi
callq 0x47f6a
cmpl $0x0, 0x1c8(%r13)
jle 0x3a782
movq %rax, %r14
movl $0x10, %r15d
xorl %r12d, %r12d
movq 0x1d0(%r13), %rax
movl -0x10(%rax,%r15), %edx
movl -0xc(%rax,%r15), %ecx
movzbl -0x8(%rax,%r15), %r8d
movq (%rax,%r15), %rbx
movq %r14, %rdi
movl $0x87, %esi
callq 0x47fb1
movq %r14, %rdi
movl %eax, %esi
movq %rbx, %rdx
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
callq 0x11ea3
incq %r12
movslq 0x1c8(%r13), %rax
addq $0x18, %r15
cmpq %rax, %r12
jl 0x3a735
movq 0x1d8(%r13), %rbp
testq %rbp, %rbp
je 0x3a913
movq 0x10(%r13), %r15
movq (%r13), %rax
movq %rax, 0x18(%rsp)
movq %r13, 0x20(%rsp)
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0x10(%rbp), %rdx
movl 0x14(%rbp), %r12d
movq %rdx, %rcx
shlq $0x5, %rcx
movq 0x18(%rax,%rcx), %rax
movq 0x68(%rax), %rcx
movq %r13, %rdi
xorl %esi, %esi
movl $0x32, %r8d
callq 0x48081
leal 0x1(%r12), %r8d
movq %r15, %rdi
movl $0x1a, %esi
xorl %edx, %edx
movl %r12d, %ecx
movl %r8d, 0x4(%rsp)
callq 0x47fb1
movl 0x34(%r15), %r13d
leal -0x1(%r12), %ebx
movq 0x8(%rbp), %rax
movq (%rax), %r14
movq %r15, %rdi
movl $0x5f, %esi
xorl %edx, %edx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x47fb1
movq %r15, %rdi
movl %eax, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x11ea3
leal 0x9(%r13), %r14d
movq %r15, %rdi
movl $0x67, %esi
xorl %edx, %edx
movl %r14d, %ecx
xorl %r8d, %r8d
callq 0x47fb1
movq %r15, %rdi
movl $0x2b, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r12d, %r8d
callq 0x47fb1
leal 0x7(%r13), %ecx
movq %r15, %rdi
movl $0x4c, %esi
movl %ebx, %edx
movl %r12d, %r8d
callq 0x47fb1
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x3a87d
movslq 0x34(%r15), %rcx
leaq (%rcx,%rcx,2), %rcx
movb $0x8, -0x15(%rax,%rcx,8)
movq %r15, %rdi
movl $0x62, %esi
xorl %edx, %edx
movl 0x4(%rsp), %ecx
xorl %r8d, %r8d
callq 0x47fb1
movq %r15, %rdi
movl $0x2b, %esi
xorl %edx, %edx
movl $0x1, %ecx
movl %r12d, %r8d
callq 0x47fb1
movq %r15, %rdi
movl $0x10, %esi
xorl %edx, %edx
movl %r14d, %ecx
xorl %r8d, %r8d
callq 0x47fb1
addl $0x2, %r13d
movq %r15, %rdi
movl $0x9, %esi
xorl %edx, %edx
movl %r13d, %ecx
xorl %r8d, %r8d
callq 0x47fb1
movq %r15, %rdi
movl $0x17, %esi
xorl %edx, %edx
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0x47fb1
movq %r15, %rdi
movl $0x38, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x47fb1
movq (%rbp), %rbp
testq %rbp, %rbp
movq 0x20(%rsp), %r13
jne 0x3a7a4
movl 0x178(%r13), %ebx
movq 0x168(%r13), %r14
testq %r14, %r14
je 0x3a961
movl $0x0, 0x178(%r13)
cmpl $0x0, (%r14)
jle 0x3a961
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x8(%r14), %rax
movq (%rax,%r15), %rsi
movl 0x1c(%rax,%r15), %edx
movq %r13, %rdi
callq 0x4802e
incq %r12
movslq (%r14), %rax
addq $0x20, %r15
cmpq %rax, %r12
jl 0x3a93d
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movl $0x10, %esi
xorl %edx, %edx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x47fb1
movq 0x10(%rsp), %r12
cmpl $0x0, 0x50(%r13)
jne 0x3a98e
cmpb $0x0, 0x50(%r12)
je 0x3a9bd
movl $0x1, 0x18(%r13)
xorl %eax, %eax
movq %rax, 0x54(%r13)
movl %eax, 0x5c(%r13)
movl %eax, 0x208(%r13)
movq %rax, 0x174(%r13)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x1d8(%r13)
je 0x3a9d6
cmpl $0x0, 0x54(%r13)
jne 0x3a9d6
movl $0x1, 0x54(%r13)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x12039
movl $0x65, 0x18(%r13)
movb $0x0, 0x1c(%r13)
jmp 0x3a996