// File: /workspace/github_c_makefile_star2_O0/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
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 0x53de6
jmp 0x540f8
movq -0x8(%rbp), %rax
cmpb $0x0, 0x1e(%rax)
je 0x53df5
jmp 0x540f8
movq -0x8(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x53e04
jmp 0x540f8
movq -0x8(%rbp), %rdi
callq 0x638c0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x54042
movq -0x18(%rbp), %rdi
movl $0x16, %esi
callq 0x63920
movq -0x8(%rbp), %rax
cmpl $0x0, 0x178(%rax)
jle 0x54040
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x178(%rax), %esi
subl $0x1, %esi
callq 0x63950
movl $0x0, -0x20(%rbp)
movl $0x1, -0x1c(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x53f1e
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
andl 0x174(%rcx), %eax
cmpl $0x0, %eax
jne 0x53e86
jmp 0x53f08
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x16dc0
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %edx
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
andl 0x170(%rcx), %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %ecx
movl $0x4, %esi
callq 0x63980
movq -0x10(%rbp), %rax
movzbl 0x99(%rax), %eax
cmpl $0x0, %eax
jne 0x53f06
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %edx
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl 0x17c(%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 $0x31, %esi
callq 0x639b0
jmp 0x53f08
movl -0x1c(%rbp), %eax
shll %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x53e5f
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x214(%rcx), %eax
jge 0x53f81
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x288(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x4dec0
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %r9
movl $0x88, %esi
xorl %r8d, %r8d
movl %r8d, %edx
movl %r8d, %ecx
movl $0xfffffff6, (%rsp)     # imm = 0xFFFFFFF6
callq 0x63a70
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x53f25
movq -0x8(%rbp), %rax
movl $0x0, 0x214(%rax)
movq -0x8(%rbp), %rdi
callq 0x63ad0
movq -0x8(%rbp), %rdi
callq 0x63b70
movq -0x8(%rbp), %rax
movl 0x178(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x168(%rax)
je 0x5402d
movq -0x8(%rbp), %rax
movq 0x168(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl $0x0, 0x178(%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x5402b
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %edx
callq 0x63d40
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x53fe0
jmp 0x5402d
movq -0x18(%rbp), %rdi
movl -0x28(%rbp), %ecx
movl $0x10, %esi
xorl %edx, %edx
callq 0x63980
jmp 0x54042
cmpq $0x0, -0x18(%rbp)
je 0x540a2
movq -0x8(%rbp), %rax
cmpl $0x0, 0x50(%rax)
jne 0x540a2
movq -0x10(%rbp), %rax
cmpb $0x0, 0x50(%rax)
jne 0x540a2
movq -0x8(%rbp), %rax
cmpq $0x0, 0x1d8(%rax)
je 0x54080
movq -0x8(%rbp), %rax
cmpl $0x0, 0x54(%rax)
jne 0x54080
movq -0x8(%rbp), %rax
movl $0x1, 0x54(%rax)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x17070
movq -0x8(%rbp), %rax
movl $0x65, 0x18(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x1c(%rax)
jmp 0x540ad
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, 0x208(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x174(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x178(%rax)
addq $0x40, %rsp
popq %rbp
retq
nop