// File: /workspace/github_c_makefile_star2_O3/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 0x3adb9
movq %rdi, %r13
cmpb $0x0, 0x1e(%rdi)
jne 0x3adb9
cmpl $0x0, 0x50(%r13)
jne 0x3adb9
movq %r13, %rdi
callq 0x48791
testq %rax, %rax
je 0x3ad99
movq %rax, %rbp
movq %rax, %rdi
movl $0x16, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x487d8
movl 0x178(%r13), %eax
testl %eax, %eax
jle 0x3ad8a
decl %eax
movl 0x34(%rbp), %ecx
cmpl %eax, %ecx
jbe 0x3a9f4
movq 0x8(%rbp), %rdx
movl %eax, %eax
leaq (%rax,%rax,2), %rax
movl %ecx, 0x8(%rdx,%rax,8)
cmpl $0x0, 0x28(%r12)
jle 0x3aaaa
movl $0x1, %ebx
xorl %r14d, %r14d
xorl %r15d, %r15d
testl %ebx, 0x174(%r13)
je 0x3aa93
movl $0x1, %eax
movl %r15d, %ecx
shll %cl, %eax
orl %eax, 0xa0(%rbp)
cmpq $0x1, %r15
je 0x3aa43
movq (%rbp), %rcx
movq 0x20(%rcx), %rcx
movq 0x8(%rcx,%r14), %rcx
cmpb $0x0, 0x11(%rcx)
je 0x3aa43
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 0x487d8
cmpb $0x0, 0x99(%r12)
jne 0x3aa93
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 0x487d8
addl %ebx, %ebx
incq %r15
movslq 0x28(%r12), %rax
addq $0x20, %r14
cmpq %rax, %r15
jl 0x3aa0b
cmpl $0x0, 0x214(%r13)
jle 0x3ab0d
xorl %r14d, %r14d
movq 0x288(%r13), %rax
movq (%rax,%r14,8), %rax
movq 0x60(%rax), %rbx
testq %rbx, %rbx
je 0x3aad6
cmpq %r12, (%rbx)
je 0x3aad8
movq 0x28(%rbx), %rbx
jmp 0x3aac6
xorl %ebx, %ebx
movq %rbp, %rdi
movl $0x88, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x487d8
movq %rbp, %rdi
movl %eax, %esi
movq %rbx, %rdx
movl $0xfffffff6, %ecx       # imm = 0xFFFFFFF6
callq 0x12044
incq %r14
movslq 0x214(%r13), %rax
cmpq %rax, %r14
jl 0x3aab7
movq %rbp, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movl $0x0, 0x214(%r13)
movq %r13, %rdi
callq 0x48791
cmpl $0x0, 0x1c8(%r13)
jle 0x3ab8d
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 0x487d8
movq %r14, %rdi
movl %eax, %esi
movq %rbx, %rdx
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
callq 0x12044
incq %r12
movslq 0x1c8(%r13), %rax
addq $0x18, %r15
cmpq %rax, %r12
jl 0x3ab40
movq 0x1d8(%r13), %rbp
testq %rbp, %rbp
je 0x3ad1e
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 0x488b9
leal 0x1(%r12), %r8d
movq %r15, %rdi
movl $0x1a, %esi
xorl %edx, %edx
movl %r12d, %ecx
movl %r8d, 0x4(%rsp)
callq 0x487d8
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 0x487d8
movq %r15, %rdi
movl %eax, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x12044
leal 0x9(%r13), %r14d
movq %r15, %rdi
movl $0x67, %esi
xorl %edx, %edx
movl %r14d, %ecx
xorl %r8d, %r8d
callq 0x487d8
movq %r15, %rdi
movl $0x2b, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r12d, %r8d
callq 0x487d8
leal 0x7(%r13), %ecx
movq %r15, %rdi
movl $0x4c, %esi
movl %ebx, %edx
movl %r12d, %r8d
callq 0x487d8
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x3ac88
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 0x487d8
movq %r15, %rdi
movl $0x2b, %esi
xorl %edx, %edx
movl $0x1, %ecx
movl %r12d, %r8d
callq 0x487d8
movq %r15, %rdi
movl $0x10, %esi
xorl %edx, %edx
movl %r14d, %ecx
xorl %r8d, %r8d
callq 0x487d8
addl $0x2, %r13d
movq %r15, %rdi
movl $0x9, %esi
xorl %edx, %edx
movl %r13d, %ecx
xorl %r8d, %r8d
callq 0x487d8
movq %r15, %rdi
movl $0x17, %esi
xorl %edx, %edx
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0x487d8
movq %r15, %rdi
movl $0x38, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x487d8
movq (%rbp), %rbp
testq %rbp, %rbp
movq 0x20(%rsp), %r13
jne 0x3abaf
movl 0x178(%r13), %ebx
movq 0x168(%r13), %r14
testq %r14, %r14
je 0x3ad6c
movl $0x0, 0x178(%r13)
cmpl $0x0, (%r14)
jle 0x3ad6c
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x8(%r14), %rax
movq (%rax,%r15), %rsi
movl 0x1c(%rax,%r15), %edx
movq %r13, %rdi
callq 0x4885f
incq %r12
movslq (%r14), %rax
addq $0x20, %r15
cmpq %rax, %r12
jl 0x3ad48
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movl $0x10, %esi
xorl %edx, %edx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x487d8
movq 0x10(%rsp), %r12
cmpl $0x0, 0x50(%r13)
jne 0x3ad99
cmpb $0x0, 0x50(%r12)
je 0x3adc8
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 0x3ade1
cmpl $0x0, 0x54(%r13)
jne 0x3ade1
movl $0x1, 0x54(%r13)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x121d1
movl $0x65, 0x18(%r13)
movb $0x0, 0x1c(%r13)
jmp 0x3ada1