// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3AutoincrementBegin
SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse){
  AutoincInfo *p;            /* Information about an AUTOINCREMENT */
  sqlite3 *db = pParse->db;  /* The database connection */
  Db *pDb;                   /* Database only autoinc table */
  int memId;                 /* Register holding max rowid */
  Vdbe *v = pParse->pVdbe;   /* VDBE under construction */

  /* This routine is never called during trigger-generation.  It is
  ** only called from the top-level */
  assert( pParse->pTriggerTab==0 );
  assert( sqlite3IsToplevel(pParse) );

  assert( v );   /* We failed long ago if this is not so */
  for(p = pParse->pAinc; p; p = p->pNext){
    static const int iLn = VDBE_OFFSET_LINENO(2);
    static const VdbeOpList autoInc[] = {
      /* 0  */ {OP_Null,    0,  0, 0},
      /* 1  */ {OP_Rewind,  0, 10, 0},
      /* 2  */ {OP_Column,  0,  0, 0},
      /* 3  */ {OP_Ne,      0,  9, 0},
      /* 4  */ {OP_Rowid,   0,  0, 0},
      /* 5  */ {OP_Column,  0,  1, 0},
      /* 6  */ {OP_AddImm,  0,  0, 0},
      /* 7  */ {OP_Copy,    0,  0, 0},
      /* 8  */ {OP_Goto,    0, 11, 0},
      /* 9  */ {OP_Next,    0,  2, 0},
      /* 10 */ {OP_Integer, 0,  0, 0},
      /* 11 */ {OP_Close,   0,  0, 0}
    };
    VdbeOp *aOp;
    pDb = &db->aDb[p->iDb];
    memId = p->regCtr;
    assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) );
    sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenRead);
    sqlite3VdbeLoadString(v, memId-1, p->pTab->zName);
    aOp = sqlite3VdbeAddOpList(v, ArraySize(autoInc), autoInc, iLn);
    if( aOp==0 ) break;
    aOp[0].p2 = memId;
    aOp[0].p3 = memId+2;
    aOp[2].p3 = memId;
    aOp[3].p1 = memId-1;
    aOp[3].p3 = memId;
    aOp[3].p5 = SQLITE_JUMPIFNULL;
    aOp[4].p2 = memId+1;
    aOp[5].p3 = memId;
    aOp[6].p1 = memId;
    aOp[7].p2 = memId+2;
    aOp[7].p1 = memId;
    aOp[10].p2 = memId;
    if( pParse->nTab==0 ) pParse->nTab = 1;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x98(%rdi), %r13
testq %r13, %r13
je 0x2bc7da
movq %rdi, %rbx
movq (%rdi), %rax
movq %rax, (%rsp)
movq 0x10(%rdi), %r14
movq (%rsp), %rax
movq 0x20(%rax), %rax
movslq 0x10(%r13), %rdx
movl 0x14(%r13), %r15d
movq %rdx, %rcx
shlq $0x5, %rcx
movq 0x18(%rax,%rcx), %rax
movq 0x68(%rax), %rcx
movq %rbx, %rdi
xorl %esi, %esi
movl $0x60, %r8d
callq 0x2bc82f
leal -0x1(%r15), %ebp
movq 0x8(%r13), %rax
movq (%rax), %r12
movq %r14, %rdi
movl $0x73, %esi
xorl %edx, %edx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x2a83e1
movq %r14, %rdi
movl %eax, %esi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x27b778
movq %r14, %rdi
movl $0xc, %esi
leaq 0x118a7f(%rip), %rdx    # 0x3d51f0
callq 0x27b673
testq %rax, %rax
je 0x2bc7da
movl %r15d, 0x8(%rax)
leal 0x2(%r15), %ecx
movl %ecx, 0xc(%rax)
movl %r15d, 0x3c(%rax)
movl %ebp, 0x4c(%rax)
movl %r15d, 0x54(%rax)
movw $0x10, 0x4a(%rax)
leal 0x1(%r15), %edx
movl %edx, 0x68(%rax)
movl %r15d, 0x84(%rax)
movl %r15d, 0x94(%rax)
movl %ecx, 0xb0(%rax)
movl %r15d, 0xac(%rax)
movl %r15d, 0xf8(%rax)
cmpl $0x0, 0x34(%rbx)
jne 0x2bc7cd
movl $0x1, 0x34(%rbx)
movq (%r13), %r13
testq %r13, %r13
jne 0x2bc704
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq