// File: /workspace/github_c_makefile_star2_O2/ukontainer[P]sqlite-bench/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].zDbSName ) ){
    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);
  assert( pKey!=0 || db->mallocFailed || pParse->nErr );

  /* 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);
  sqlite3MultiWrite(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);
  if( IsUniqueIndex(pIndex) ){
    int j2 = sqlite3VdbeGoto(v, 1);
    addr2 = sqlite3VdbeCurrentAddr(v);
    sqlite3VdbeVerifyAbortable(v, OE_Abort);
    sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord,
                         pIndex->nKeyCol); VdbeCoverage(v);
    sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);
    sqlite3VdbeJumpHere(v, j2);
  }else{
    addr2 = sqlite3VdbeCurrentAddr(v);
  }
  sqlite3VdbeAddOp3(v, OP_SorterData, iSorter, regRecord, iIdx);
  sqlite3VdbeAddOp1(v, OP_SeekEnd, iIdx);
  sqlite3VdbeAddOp2(v, OP_IdxInsert, iIdx, regRecord);
  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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, 0x1c(%rsp)
movq %rsi, %r13
movq %rdi, %r14
movq 0x18(%rsi), %rbp
movl 0x34(%rdi), %ebx
leal 0x2(%rbx), %eax
movl %eax, 0x34(%rdi)
movq (%rdi), %r15
movq 0x30(%rsi), %rsi
movq %r15, %rdi
callq 0x40c73a
movl %eax, %r12d
movq (%r13), %rdx
movq 0x20(%r15), %rax
movslq %r12d, %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %r8
pushq $0x1b
popq %rsi
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x44d86d
testl %eax, %eax
jne 0x4522cd
movl 0x38(%rbp), %edx
movq (%rbp), %r8
pushq $0x1
popq %rcx
movq %r14, %rdi
movl %r12d, %esi
callq 0x448732
movq %r14, %rdi
callq 0x44856b
testq %rax, %rax
je 0x4522cd
movq %rax, %r15
movl 0x1c(%rsp), %eax
movl %eax, 0x18(%rsp)
testl %eax, %eax
jns 0x452034
movl 0x58(%r13), %eax
movl %eax, 0x18(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x44884c
movl 0x34(%r14), %ecx
movq %rcx, 0x30(%rsp)
incl %ecx
movl %ecx, 0x34(%r14)
movzwl 0x5e(%r13), %r8d
testq %rax, %rax
je 0x45205a
incl (%rax)
leal 0x1(%rbx), %ecx
movl %ecx, 0x24(%rsp)
movl $0xfffffff7, (%rsp)     # imm = 0xFFFFFFF7
pushq $0x72
popq %rsi
movq %r15, %rdi
movq 0x30(%rsp), %rdx
xorl %ecx, %ecx
movq %rax, %r9
movq %rax, 0x28(%rsp)
callq 0x4485b6
pushq $0x6d
popq %r8
movq %r14, %rdi
movl %ebx, %esi
movl %r12d, %edx
movq %rbp, %rcx
callq 0x448675
pushq $0x24
popq %rsi
movq %r15, %rdi
movl %ebx, %edx
xorl %ecx, %ecx
callq 0x432a3f
movq %rax, 0x40(%rsp)
movq %r14, %rdi
callq 0x44b9b3
movl %eax, %ebp
movq 0xa0(%r14), %rax
testq %rax, %rax
cmoveq %r14, %rax
movb $0x1, 0x20(%rax)
andl $0x0, 0x8(%rsp)
andq $0x0, (%rsp)
leaq 0x3c(%rsp), %r9
movq %r14, %rdi
movq %r13, %rsi
movl %ebx, %edx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x45249f
movq %r15, %rdi
movl $0x84, %esi
movq 0x30(%rsp), %rdx
movl %ebp, 0x20(%rsp)
movl %ebp, %ecx
callq 0x432a3f
leaq 0x3c(%rsp), %rax
movl (%rax), %esi
movq %r14, %rdi
callq 0x452680
movq 0x40(%rsp), %rbp
leal 0x1(%rbp), %ecx
pushq $0x5
popq %rsi
movq %r15, %rdi
movl %ebx, %edx
callq 0x432a3f
movq %r15, %rdi
movl %ebp, %esi
callq 0x4485a5
cmpl $0x0, 0x1c(%rsp)
movl 0x18(%rsp), %ebp
jns 0x45214a
movq %r15, %rdi
movl $0x8a, %esi
movl %ebp, %edx
movl %r12d, %ecx
callq 0x432a3f
movl $0xfffffff7, (%rsp)     # imm = 0xFFFFFFF7
pushq $0x6e
popq %rsi
movq %r15, %rdi
movl 0x24(%rsp), %edx
movl %ebp, %ecx
movl %r12d, %r8d
movq 0x28(%rsp), %r9
callq 0x4485b6
movslq 0xb8(%r15), %rax
testq %rax, %rax
jle 0x452192
xorl %ecx, %ecx
cmpl $0x0, 0x1c(%rsp)
setns %cl
shll $0x4, %ecx
incl %ecx
movq 0x68(%r15), %rdx
imulq $0x18, %rax, %rax
movw %cx, -0x16(%rdx,%rax)
pushq $0x22
popq %rsi
movq %r15, %rdi
movq 0x30(%rsp), %r12
movl %r12d, %edx
xorl %ecx, %ecx
callq 0x432a3f
movl %eax, 0x1c(%rsp)
cmpb $0x0, 0x62(%r13)
je 0x452204
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x44863d
movl %eax, %ecx
movl %eax, 0x28(%rsp)
movl 0xb8(%r15), %eax
movl %eax, 0x18(%rsp)
movzwl 0x5e(%r13), %r9d
pushq $0x7e
popq %rsi
movq %r15, %rdi
movl %r12d, %edx
movl 0x20(%rsp), %ebp
movl %ebp, %r8d
callq 0x40c85b
pushq $0x2
popq %rsi
movq %r14, %rdi
movq %r13, %rdx
callq 0x4526a4
movq %r15, %rdi
movl 0x28(%rsp), %esi
callq 0x4485a5
jmp 0x452213
movl 0xb8(%r15), %eax
movl %eax, 0x18(%rsp)
movl 0x20(%rsp), %ebp
pushq $0x7f
popq %rsi
movq %r15, %rdi
movl %r12d, %edx
movl %ebp, %ecx
movl 0x24(%rsp), %r13d
movl %r13d, %r8d
callq 0x432a44
movq %r15, %rdi
movl $0x83, %esi
movl %r13d, %edx
callq 0x449fcc
movq %r15, %rdi
movl $0x85, %esi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x432a3f
movslq 0xb8(%r15), %rax
testq %rax, %rax
jle 0x452268
movq 0x68(%r15), %rcx
imulq $0x18, %rax, %rax
movw $0x10, -0x16(%rcx,%rax)
testl %ebp, %ebp
je 0x452286
movzbl 0x1f(%r14), %eax
cmpq $0x7, %rax
ja 0x452286
leal 0x1(%rax), %ecx
movb %cl, 0x1f(%r14)
movl %ebp, 0xc4(%r14,%rax,4)
pushq $0x3
popq %rsi
movq %r15, %rdi
movl %r12d, %edx
movl 0x18(%rsp), %ecx
callq 0x432a3f
movq %r15, %rdi
movl 0x1c(%rsp), %esi
callq 0x4485a5
pushq $0x75
popq %rbp
movq %r15, %rdi
movl %ebp, %esi
movl %ebx, %edx
callq 0x449fcc
movq %r15, %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0x449fcc
movq %r15, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0x449fcc
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq