// File: /workspace/github_c_makefile_star2_O0/skeeto[P]flappy/sqlite3.c
// Function: sqlite3RefillIndex
static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
  Table *pTab = pIndex->pTable;  /* The table that is indexed */
  int iTab = pParse->nTab++;     /* Btree cursor used for pTab */
  int iIdx = pParse->nTab++;     /* Btree cursor used for pIndex */
  int iSorter;                   /* Cursor opened by OpenSorter (if in use) */
  int addr1;                     /* Address of top of loop */
  int addr2;                     /* Address to jump to for next iteration */
  int tnum;                      /* Root page of index */
  int iPartIdxLabel;             /* Jump to this label to skip a row */
  Vdbe *v;                       /* Generate code into this virtual machine */
  KeyInfo *pKey;                 /* KeyInfo for index */
  int regRecord;                 /* Register holding assemblied index record */
  sqlite3 *db = pParse->db;      /* The database connection */
  int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);

#ifndef SQLITE_OMIT_AUTHORIZATION
  if( sqlite3AuthCheck(pParse, SQLITE_REINDEX, pIndex->zName, 0,
      db->aDb[iDb].zName ) ){
    return;
  }
#endif

  /* Require a write-lock on the table to perform this operation */
  sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);

  v = sqlite3GetVdbe(pParse);
  if( v==0 ) return;
  if( memRootPage>=0 ){
    tnum = memRootPage;
  }else{
    tnum = pIndex->tnum;
  }
  pKey = sqlite3KeyInfoOfIndex(pParse, pIndex);

  /* Open the sorter cursor if we are to use one. */
  iSorter = pParse->nTab++;
  sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, 0, (char*)
                    sqlite3KeyInfoRef(pKey), P4_KEYINFO);

  /* Open the table. Loop through all rows of the table, inserting index
  ** records into the sorter. */
  sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
  addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
  regRecord = sqlite3GetTempReg(pParse);

  sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 0, &iPartIdxLabel);
  sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
  sqlite3VdbeResolveLabel(v, iPartIdxLabel);
  sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);
  sqlite3VdbeJumpHere(v, addr1);
  if( memRootPage<0 ) sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb);
  sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, 
                    (char *)pKey, P4_KEYINFO);
  sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0));

  addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0);
  assert( pKey!=0 || db->mallocFailed || pParse->nErr );
  if( pIndex->onError!=OE_None && pKey!=0 ){
    int j2 = sqlite3VdbeCurrentAddr(v) + 3;
    sqlite3VdbeAddOp2(v, OP_Goto, 0, j2);
    addr2 = sqlite3VdbeCurrentAddr(v);
    sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord,
                         pKey->nField - pIndex->nKeyCol);
    sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);
  }else{
    addr2 = sqlite3VdbeCurrentAddr(v);
  }
  sqlite3VdbeAddOp2(v, OP_SorterData, iSorter, regRecord);
  sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 1);
  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
  sqlite3ReleaseTempReg(pParse, regRecord);
  sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2);
  sqlite3VdbeJumpHere(v, addr1);

  sqlite3VdbeAddOp1(v, OP_Close, iTab);
  sqlite3VdbeAddOp1(v, OP_Close, iIdx);
  sqlite3VdbeAddOp1(v, OP_Close, iSorter);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rcx
movl 0x54(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x54(%rcx)
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rcx
movl 0x54(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x54(%rcx)
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0x16b60
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movq -0x60(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x64(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %r8
movl $0x1b, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x6a8a0
cmpl $0x0, %eax
je 0x717ce
jmp 0x71aac
movq -0x8(%rbp), %rdi
movl -0x64(%rbp), %esi
movq -0x20(%rbp), %rax
movl 0x3c(%rax), %edx
movq -0x20(%rbp), %rax
movq (%rax), %r8
movl $0x1, %ecx
callq 0x63f00
movq -0x8(%rbp), %rdi
callq 0x638c0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x71806
jmp 0x71aac
cmpl $0x0, -0x14(%rbp)
jl 0x71814
movl -0x14(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x7181e
movq -0x10(%rbp), %rax
movl 0x58(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x64150
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rcx
movl 0x54(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x54(%rcx)
movl %eax, -0x2c(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x50(%rbp), %rdi
callq 0x64440
movq -0x78(%rbp), %rdi
movl -0x6c(%rbp), %edx
movq %rax, %r9
movl $0x36, %esi
xorl %r8d, %r8d
movl %r8d, %ecx
movl $0xfffffffa, (%rsp)     # imm = 0xFFFFFFFA
callq 0x63a70
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x64(%rbp), %edx
movq -0x20(%rbp), %rcx
movl $0x32, %r8d
callq 0x63dd0
movq -0x48(%rbp), %rdi
movl -0x24(%rbp), %edx
movl $0x67, %esi
xorl %ecx, %ecx
callq 0x63980
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x67350
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x24(%rbp), %edx
movl -0x54(%rbp), %ecx
xorl %r8d, %r8d
leaq -0x3c(%rbp), %r9
callq 0x71db0
movq -0x48(%rbp), %rdi
movl -0x2c(%rbp), %edx
movl -0x54(%rbp), %ecx
movl $0x68, %esi
callq 0x63980
movq -0x48(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x66470
movq -0x48(%rbp), %rdi
movl -0x24(%rbp), %edx
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
movl $0x9, %esi
callq 0x63980
movq -0x48(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x63950
cmpl $0x0, -0x14(%rbp)
jge 0x7192b
movq -0x48(%rbp), %rdi
movl -0x38(%rbp), %edx
movl -0x64(%rbp), %ecx
movl $0x6f, %esi
callq 0x63980
movq -0x48(%rbp), %rdi
movl -0x28(%rbp), %edx
movl -0x38(%rbp), %ecx
movl -0x64(%rbp), %r8d
movq -0x50(%rbp), %r9
movl $0x33, %esi
movl $0xfffffffa, (%rsp)     # imm = 0xFFFFFFFA
callq 0x63a70
movq -0x48(%rbp), %rdi
movl -0x14(%rbp), %edx
xorl %eax, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovgel %ecx, %eax
orl $0x1, %eax
movzbl %al, %esi
callq 0x63ec0
movq -0x48(%rbp), %rdi
movl -0x2c(%rbp), %edx
movl $0x65, %esi
xorl %ecx, %ecx
callq 0x63980
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x62(%rax), %eax
cmpl $0x0, %eax
je 0x71a05
cmpq $0x0, -0x50(%rbp)
je 0x71a05
movq -0x48(%rbp), %rdi
callq 0x63ea0
addl $0x3, %eax
movl %eax, -0x68(%rbp)
movq -0x48(%rbp), %rdi
movl -0x68(%rbp), %ecx
movl $0x10, %esi
xorl %edx, %edx
callq 0x63980
movq -0x48(%rbp), %rdi
callq 0x63ea0
movl %eax, -0x34(%rbp)
movq -0x48(%rbp), %rdi
movl -0x2c(%rbp), %edx
movl -0x68(%rbp), %ecx
movl -0x54(%rbp), %r8d
movq -0x50(%rbp), %rax
movzwl 0x6(%rax), %r9d
movq -0x10(%rbp), %rax
movzwl 0x5e(%rax), %eax
subl %eax, %r9d
movl $0x52, %esi
callq 0x640a0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rdx
movl $0x2, %esi
callq 0x72000
jmp 0x71a11
movq -0x48(%rbp), %rdi
callq 0x63ea0
movl %eax, -0x34(%rbp)
movq -0x48(%rbp), %rdi
movl -0x2c(%rbp), %edx
movl -0x54(%rbp), %ecx
movl $0x5d, %esi
callq 0x63980
movq -0x48(%rbp), %rdi
movl -0x28(%rbp), %edx
movl -0x54(%rbp), %ecx
movl $0x69, %esi
movl $0x1, %r8d
callq 0x639b0
movq -0x48(%rbp), %rdi
movl $0x10, %esi
callq 0x63ec0
movq -0x8(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x673a0
movq -0x48(%rbp), %rdi
movl -0x2c(%rbp), %edx
movl -0x34(%rbp), %ecx
movl $0x5, %esi
callq 0x63980
movq -0x48(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x63950
movq -0x48(%rbp), %rdi
movl -0x24(%rbp), %edx
movl $0x38, %esi
callq 0x66020
movq -0x48(%rbp), %rdi
movl -0x28(%rbp), %edx
movl $0x38, %esi
callq 0x66020
movq -0x48(%rbp), %rdi
movl -0x2c(%rbp), %edx
movl $0x38, %esi
callq 0x66020
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)