// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movl %edx, %r12d
movq %rsi, %r13
movq %rdi, %r14
movq 0x18(%rsi), %rax
movq %rax, -0x38(%rbp)
movl 0x50(%rdi), %eax
movq %rax, -0x48(%rbp)
addl $0x2, %eax
movl %eax, 0x50(%rdi)
movq (%rdi), %rax
movq 0x30(%rsi), %rcx
testq %rcx, %rcx
je 0x5b1e2
movl 0x28(%rax), %edx
testl %edx, %edx
jle 0x5b1e9
movq 0x20(%rax), %rsi
addq $0x18, %rsi
xorl %ebx, %ebx
cmpq %rcx, (%rsi)
je 0x5b1eb
incq %rbx
addq $0x20, %rsi
cmpq %rbx, %rdx
jne 0x5b1cd
movl %edx, %ebx
jmp 0x5b1eb
movl $0xfff0bdc0, %ebx       # imm = 0xFFF0BDC0
jmp 0x5b1eb
xorl %ebx, %ebx
movq (%r13), %rdx
movq 0x20(%rax), %rax
movslq %ebx, %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %r8
movq %r14, %rdi
movl $0x1b, %esi
xorl %ecx, %ecx
callq 0x5605b
testl %eax, %eax
jne 0x5b613
movq -0x38(%rbp), %rax
movl 0x38(%rax), %edx
movq (%rax), %r8
movq %r14, %rdi
movl %ebx, %esi
movl $0x1, %ecx
callq 0x50be4
movq %r14, %rdi
callq 0x507bf
testq %rax, %rax
je 0x5b613
movq %rax, %r15
movl %r12d, -0x2c(%rbp)
testl %r12d, %r12d
jns 0x5b252
movl 0x58(%r13), %eax
movl %eax, -0x2c(%rbp)
movl %r12d, -0x30(%rbp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x50ceb
movq %rax, %r12
movl 0x50(%r14), %edx
leal 0x1(%rdx), %eax
movl %eax, 0x50(%r14)
movzwl 0x5e(%r13), %r8d
testq %r12, %r12
je 0x5b27d
incl (%r12)
movq %r15, %rdi
movl $0x3b, %esi
movq %rdx, -0x40(%rbp)
xorl %ecx, %ecx
callq 0x3fa9e
movq %r15, %rdi
movl %eax, %esi
movq %r12, -0x50(%rbp)
movq %r12, %rdx
movl $0xfffffffa, %ecx       # imm = 0xFFFFFFFA
callq 0x14ab9
movq %r14, %rdi
movq -0x48(%rbp), %r12
movl %r12d, %esi
movl %ebx, %edx
movq -0x38(%rbp), %rcx
movl $0x37, %r8d
callq 0x50ae2
movq %r15, %rdi
movl $0x6e, %esi
movl %r12d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movq %rax, -0x58(%rbp)
movb 0x1f(%r14), %al
testb %al, %al
je 0x5b2f2
decb %al
movb %al, 0x1f(%r14)
movzbl %al, %eax
movl 0x24(%r14,%rax,4), %r12d
jmp 0x5b2fd
movl 0x54(%r14), %r12d
incl %r12d
movl %r12d, 0x54(%r14)
leaq -0x5c(%rbp), %r9
movq %r14, %rdi
movq %r13, %rsi
movq -0x48(%rbp), %rdx
movl %r12d, %ecx
xorl %r8d, %r8d
pushq $0x0
pushq $0x0
callq 0x5b7c2
addq $0x10, %rsp
movq %r15, %rdi
movl $0x6f, %esi
movq -0x40(%rbp), %rdx
movl %r12d, -0x38(%rbp)
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
leaq -0x5c(%rbp), %rax
movl (%rax), %esi
movq %r14, %rdi
callq 0x5b96e
movq -0x58(%rbp), %r12
leal 0x1(%r12), %ecx
movq %r15, %rdi
movl $0x8, %esi
movq -0x48(%rbp), %rdx
xorl %r8d, %r8d
callq 0x3fa9e
movl 0x3c(%r15), %eax
leal -0x1(%rax), %ecx
movq 0x30(%r15), %rdx
movl %ecx, 0x68(%rdx)
movq (%r15), %rdx
cmpb $0x0, 0x51(%rdx)
movq %r13, -0x68(%rbp)
je 0x5b388
leaq 0x3a162(%rip), %rcx     # 0x954e8
jmp 0x5b39e
testl %r12d, %r12d
cmovnsl %r12d, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x8(%r15), %rcx
movl -0x30(%rbp), %r12d
movq -0x48(%rbp), %rdx
leal 0x1(%rdx), %r13d
movl %eax, 0x8(%rcx)
testl %r12d, %r12d
jns 0x5b3c7
movq %r15, %rdi
movl $0x78, %esi
movl -0x2c(%rbp), %edx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
testl %r12d, %r12d
setns %r12b
movq %r15, %rdi
movl $0x38, %esi
movl %r13d, -0x30(%rbp)
movl %r13d, %edx
movl -0x2c(%rbp), %ecx
movl %ebx, %r8d
callq 0x3fa9e
movq %r15, %rdi
movl %eax, %esi
movq -0x50(%rbp), %rdx
movl $0xfffffffa, %ecx       # imm = 0xFFFFFFFA
callq 0x14ab9
shlb $0x4, %r12b
incb %r12b
movq (%r15), %rax
cmpb $0x0, 0x51(%rax)
je 0x5b414
leaq 0x3a0d6(%rip), %rax     # 0x954e8
jmp 0x5b428
movslq 0x3c(%r15), %rax
movq 0x8(%r15), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rax
addq $-0x18, %rax
movq -0x68(%rbp), %r13
movb %r12b, 0x3(%rax)
movq %r15, %rdi
movl $0x6c, %esi
movq -0x40(%rbp), %r12
movl %r12d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movl %eax, -0x2c(%rbp)
movl 0x3c(%r15), %ebx
cmpq $0x0, -0x50(%rbp)
je 0x5b4cb
cmpb $0x0, 0x62(%r13)
je 0x5b4cb
addl $0x3, %ebx
movq %r15, %rdi
movl $0xe, %esi
xorl %edx, %edx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movl 0x3c(%r15), %eax
movl %eax, -0x50(%rbp)
movzwl 0x5e(%r13), %eax
movq %rax, -0x58(%rbp)
movq %r15, %rdi
movl $0x65, %esi
movq -0x40(%rbp), %rdx
movl %ebx, %ecx
movl -0x38(%rbp), %r12d
movl %r12d, %r8d
callq 0x3fa9e
movq %r15, %rdi
movl %eax, %esi
movq -0x58(%rbp), %rdx
movl $0xfffffff2, %ecx       # imm = 0xFFFFFFF2
callq 0x14ab9
movq %r14, %rdi
movl $0x2, %esi
movq %r13, %rdx
callq 0x5b9a7
movl -0x50(%rbp), %ebx
movq -0x40(%rbp), %rdx
jmp 0x5b4d2
movq %r12, %rdx
movl -0x38(%rbp), %r12d
movq %r15, %rdi
movl $0x66, %esi
movl %r12d, %ecx
movl -0x30(%rbp), %r13d
movl %r13d, %r8d
callq 0x3fa9e
movq %r15, %rdi
movl $0x6b, %esi
movl %r13d, %edx
xorl %ecx, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x3fa9e
movq %r15, %rdi
movl $0x70, %esi
movl %r13d, %edx
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movq (%r15), %rax
cmpb $0x0, 0x51(%rax)
je 0x5b529
leaq 0x39fc1(%rip), %rax     # 0x954e8
jmp 0x5b53d
movslq 0x3c(%r15), %rax
movq 0x8(%r15), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rax
addq $-0x18, %rax
movb $0x10, 0x3(%rax)
testl %r12d, %r12d
je 0x5b580
movzbl 0x1f(%r14), %eax
cmpq $0x7, %rax
ja 0x5b580
xorl %ecx, %ecx
cmpl %r12d, 0x94(%r14,%rcx)
je 0x5b577
addq $0x14, %rcx
cmpl $0xc8, %ecx
jne 0x5b553
leal 0x1(%rax), %ecx
movb %cl, 0x1f(%r14)
movl %r12d, 0x24(%r14,%rax,4)
jmp 0x5b580
movb $0x1, 0x8e(%r14,%rcx)
movq %r15, %rdi
movl $0x4, %esi
movq -0x40(%rbp), %r14
movl %r14d, %edx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movl 0x3c(%r15), %eax
leal -0x1(%rax), %ecx
movq 0x30(%r15), %rdx
movl %ecx, 0x68(%rdx)
movq (%r15), %rdx
cmpb $0x0, 0x51(%rdx)
je 0x5b5b9
leaq 0x39f31(%rip), %rcx     # 0x954e8
jmp 0x5b5d0
movl -0x2c(%rbp), %edx
testl %edx, %edx
cmovnsl %edx, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x8(%r15), %rcx
movl %eax, 0x8(%rcx)
movq %r15, %rdi
movl $0x3e, %esi
movq -0x48(%rbp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movq %r15, %rdi
movl $0x3e, %esi
movl %r13d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movq %r15, %rdi
movl $0x3e, %esi
movl %r14d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq