// File: /workspace/github_c_makefile_star2_O2/shifengbin[P]bishe/Output/../Persistence/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 assembled 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, pIndex->nKeyCol, (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); VdbeCoverage(v);
  regRecord = sqlite3GetTempReg(pParse);

  sqlite3GenerateIndexKey(pParse,pIndex,iTab,regRecord,0,&iPartIdxLabel,0,0);
  sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);
  sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel);
  sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); VdbeCoverage(v);
  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); VdbeCoverage(v);
  assert( pKey!=0 || db->mallocFailed || pParse->nErr );
  if( IsUniqueIndex(pIndex) && pKey!=0 ){
    int j2 = sqlite3VdbeCurrentAddr(v) + 3;
    sqlite3VdbeGoto(v, j2);
    addr2 = sqlite3VdbeCurrentAddr(v);
    sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord,
                         pIndex->nKeyCol); VdbeCoverage(v);
    sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);
  }else{
    addr2 = sqlite3VdbeCurrentAddr(v);
  }
  sqlite3VdbeAddOp3(v, OP_SorterData, iSorter, regRecord, iIdx);
  sqlite3VdbeAddOp3(v, OP_Last, iIdx, 0, -1);
  sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 0);
  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
  sqlite3ReleaseTempReg(pParse, regRecord);
  sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2); VdbeCoverage(v);
  sqlite3VdbeJumpHere(v, addr1);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edx, -0x30(%rbp)
movq %rsi, %r13
movq %rdi, %r14
movq 0x18(%rsi), %r12
movl 0x50(%rdi), %eax
movq %rax, -0x58(%rbp)
addl $0x2, %eax
movl %eax, 0x50(%rdi)
movq (%rdi), %r15
movq 0x30(%rsi), %rsi
movq %r15, %rdi
callq 0x136fb
movl %eax, %ebx
movq (%r13), %rdx
movq 0x20(%r15), %rax
movslq %ebx, %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %r8
pushq $0x1b
popq %rsi
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x4e772
testl %eax, %eax
jne 0x52f5e
movl 0x38(%r12), %edx
movq (%r12), %r8
pushq $0x1
popq %rcx
movq %r14, %rdi
movl %ebx, %esi
callq 0x4a1b8
movq %r14, %rdi
callq 0x49f90
testq %rax, %rax
je 0x52f5e
movq %rax, %r15
movq %r12, -0x40(%rbp)
movl %ebx, -0x4c(%rbp)
movl -0x30(%rbp), %r12d
movl %r12d, -0x2c(%rbp)
testl %r12d, %r12d
jns 0x52d14
movl 0x58(%r13), %eax
movl %eax, -0x2c(%rbp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x4a2b3
movl 0x50(%r14), %ecx
movq %rcx, -0x48(%rbp)
incl %ecx
movl %ecx, 0x50(%r14)
movzwl 0x5e(%r13), %r8d
testq %rax, %rax
je 0x52d39
incl (%rax)
movq -0x58(%rbp), %rbx
leal 0x1(%rbx), %ecx
movl %ecx, -0x50(%rbp)
movl $0xfffffffa, (%rsp)     # imm = 0xFFFFFFFA
pushq $0x3b
popq %rsi
movq %r15, %rdi
movq -0x48(%rbp), %rdx
xorl %ecx, %ecx
movq %rax, %r9
movq %rax, -0x38(%rbp)
callq 0x4a044
pushq $0x37
popq %r8
movq %r14, %rdi
movl %ebx, %esi
movl -0x4c(%rbp), %edx
movq -0x40(%rbp), %rcx
callq 0x4a0e1
pushq $0x6e
popq %rsi
movq %r15, %rdi
movl %ebx, %edx
xorl %ecx, %ecx
callq 0x4a1ab
movq %rax, -0x68(%rbp)
movq %r14, %rdi
callq 0x4c550
movl %eax, %ebx
andl $0x0, 0x8(%rsp)
andq $0x0, (%rsp)
leaq -0x5c(%rbp), %r9
movq %r14, %rdi
movq %r13, %rsi
movq -0x58(%rbp), %rdx
movl %eax, %ecx
xorl %r8d, %r8d
callq 0x53109
pushq $0x6f
popq %rsi
movq %r15, %rdi
movq -0x48(%rbp), %rdx
movl %ebx, -0x40(%rbp)
movl %ebx, %ecx
callq 0x4a1ab
leaq -0x5c(%rbp), %rax
movl (%rax), %esi
movq %r14, %rdi
callq 0x53290
movq -0x68(%rbp), %rbx
leal 0x1(%rbx), %ecx
pushq $0x8
popq %rsi
movq %r15, %rdi
movq -0x58(%rbp), %rdx
callq 0x4a1ab
movq %r15, %rdi
movl %ebx, %esi
movl -0x4c(%rbp), %ebx
callq 0x4a022
testl %r12d, %r12d
jns 0x52e10
pushq $0x78
popq %rsi
movq %r15, %rdi
movl -0x2c(%rbp), %edx
movl %ebx, %ecx
callq 0x4a1ab
movl $0xfffffffa, (%rsp)     # imm = 0xFFFFFFFA
pushq $0x38
popq %rsi
movq %r15, %rdi
movl -0x50(%rbp), %edx
movl -0x2c(%rbp), %ecx
movl %ebx, %r8d
movq -0x38(%rbp), %r9
callq 0x4a044
notl %r12d
shrl $0x1b, %r12d
andl $-0x10, %r12d
incl %r12d
movq %r15, %rdi
movl %r12d, %esi
callq 0x13770
pushq $0x6c
popq %rsi
movq %r15, %rdi
movq -0x48(%rbp), %rbx
movl %ebx, %edx
xorl %ecx, %ecx
callq 0x4a1ab
movl %eax, -0x30(%rbp)
movl 0x3c(%r15), %r12d
cmpq $0x0, -0x38(%rbp)
je 0x52eb8
cmpb $0x0, 0x62(%r13)
je 0x52eb8
addl $0x3, %r12d
movq %r15, %rdi
movl %r12d, %esi
callq 0x4a0cb
movl 0x3c(%r15), %ebx
movzwl 0x5e(%r13), %r9d
pushq $0x65
popq %rsi
movq %r15, %rdi
movq -0x48(%rbp), %rdx
movl %r12d, %ecx
movl -0x40(%rbp), %r12d
movl %r12d, %r8d
callq 0x1373a
pushq $0x2
popq %rsi
movq %r14, %rdi
movq %r13, %rdx
callq 0x532b5
movl %ebx, -0x38(%rbp)
movq -0x48(%rbp), %rbx
jmp 0x52ec0
movl %r12d, -0x38(%rbp)
movl -0x40(%rbp), %r12d
pushq $0x66
popq %rsi
movq %r15, %rdi
movl %ebx, %edx
movl %r12d, %ecx
movl -0x50(%rbp), %r13d
movl %r13d, %r8d
callq 0x385b6
pushq $0x6b
popq %rsi
pushq $-0x1
popq %r8
movq %r15, %rdi
movl %r13d, %edx
xorl %ecx, %ecx
callq 0x385b6
pushq $0x70
popq %rsi
movq %r15, %rdi
movl %r13d, %edx
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0x385b6
pushq $0x10
popq %rsi
movq %r15, %rdi
callq 0x13770
movq %r14, %rdi
movl %r12d, %esi
callq 0x4c573
pushq $0x4
popq %rsi
movq %r15, %rdi
movl %ebx, %edx
movl -0x38(%rbp), %ecx
callq 0x4a1ab
movq %r15, %rdi
movl -0x30(%rbp), %esi
callq 0x4a022
movq %rbx, %r14
pushq $0x3e
popq %rbx
movq %r15, %rdi
movl %ebx, %esi
movq -0x58(%rbp), %rdx
callq 0x4b9b3
movq %r15, %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x4b9b3
movq %r15, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x4b9b3
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq