// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movl %edx, (%rsp)
movq %rsi, %r13
movq %rdi, %r14
movq 0x18(%rsi), %r12
movl 0x34(%rdi), %ebx
leal 0x2(%rbx), %eax
movl %eax, 0x34(%rdi)
movq (%rdi), %rax
movq 0x30(%rsi), %rcx
testq %rcx, %rcx
je 0x459d15
movq 0x20(%rax), %rdx
addq $0x18, %rdx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
incl %ebp
leaq 0x20(%rdx), %rsi
cmpq %rcx, (%rdx)
movq %rsi, %rdx
jne 0x459d05
jmp 0x459d1a
movl $0xfff0bdc0, %ebp       # imm = 0xFFF0BDC0
movq (%r13), %rdx
movq 0x20(%rax), %rax
movslq %ebp, %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %r8
movq %r14, %rdi
movl $0x1b, %esi
xorl %ecx, %ecx
callq 0x454a3c
testl %eax, %eax
jne 0x45a16c
movl 0x38(%r12), %edx
movq (%r12), %r8
movq %r14, %rdi
movl %ebp, %esi
movl $0x1, %ecx
callq 0x44ebb0
movq %r14, %rdi
callq 0x44e8aa
testq %rax, %rax
je 0x45a16c
movq %rax, %r15
movl (%rsp), %eax
movl %eax, 0x4(%rsp)
testl %eax, %eax
jns 0x459d83
movl 0x58(%r13), %eax
movl %eax, 0x4(%rsp)
movq %r12, 0x8(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x44ed15
movq %rax, %r12
movl 0x34(%r14), %ecx
movq %rcx, 0x10(%rsp)
incl %ecx
movl %ecx, 0x34(%r14)
movzwl 0x5e(%r13), %r8d
testq %rax, %rax
je 0x459db3
incl (%r12)
movq %r15, %rdi
movl $0x72, %esi
movq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x43bae0
movq %r15, %rdi
movl %eax, %esi
movq %r12, 0x28(%rsp)
movq %r12, %rdx
movl $0xfffffff7, %ecx       # imm = 0xFFFFFFF7
callq 0x40e507
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
movq 0x8(%rsp), %rcx
movl $0x6d, %r8d
callq 0x44eaae
movq %r15, %rdi
movl $0x24, %esi
movq %rbx, 0x20(%rsp)
movl %ebx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43bae0
movb 0x1f(%r14), %cl
testb %cl, %cl
movq %rax, 0x18(%rsp)
je 0x459e2e
decb %cl
movb %cl, 0x1f(%r14)
movzbl %cl, %eax
movl 0xc4(%r14,%rax,4), %ebx
jmp 0x459e38
movl 0x38(%r14), %ebx
incl %ebx
movl %ebx, 0x38(%r14)
movq 0xa0(%r14), %rax
testq %rax, %rax
cmoveq %r14, %rax
movb $0x1, 0x20(%rax)
leaq 0x34(%rsp), %r12
movq %r14, %rdi
movq %r13, %rsi
movq 0x20(%rsp), %rdx
movl %ebx, %ecx
xorl %r8d, %r8d
movq %r12, %r9
pushq $0x0
pushq $0x0
callq 0x45a426
addq $0x10, %rsp
movq %r15, %rdi
movl $0x84, %esi
movq 0x10(%rsp), %rdx
movl %ebx, 0x8(%rsp)
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x43bae0
movl (%r12), %eax
testl %eax, %eax
je 0x459eb0
movq 0x10(%r14), %rcx
movq 0x18(%rcx), %rdx
movq 0x50(%rdx), %rdx
testq %rdx, %rdx
je 0x459eb0
notl %eax
movl 0xb8(%rcx), %ecx
cltq
movl %ecx, (%rdx,%rax,4)
movq 0x18(%rsp), %r12
leal 0x1(%r12), %ecx
movq %r15, %rdi
movl $0x5, %esi
movq 0x20(%rsp), %rbx
movl %ebx, %edx
xorl %r8d, %r8d
callq 0x43bae0
movl 0xb8(%r15), %eax
movq (%r15), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x459eea
leaq 0x14af20(%rip), %rcx    # 0x5a4e08
jmp 0x459f03
leal -0x1(%rax), %ecx
testl %r12d, %r12d
cmovnsl %r12d, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x68(%r15), %rcx
movq 0x10(%rsp), %r12
incl %ebx
movl %eax, 0x8(%rcx)
cmpl $0x0, (%rsp)
jns 0x459f29
movq %r15, %rdi
movl $0x8a, %esi
movl 0x4(%rsp), %edx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x43bae0
movq %r15, %rdi
movl $0x6e, %esi
movl %ebx, 0x18(%rsp)
movl %ebx, %edx
movl 0x4(%rsp), %ecx
movl %ebp, %r8d
callq 0x43bae0
movq %r15, %rdi
movl %eax, %esi
movq 0x28(%rsp), %rdx
movl $0xfffffff7, %ecx       # imm = 0xFFFFFFF7
callq 0x40e507
movslq 0xb8(%r15), %rax
testq %rax, %rax
jle 0x459f7e
xorl %ecx, %ecx
cmpl $0x0, (%rsp)
setns %cl
shll $0x4, %ecx
incl %ecx
movq 0x68(%r15), %rdx
leaq (%rax,%rax,2), %rax
movw %cx, -0x16(%rdx,%rax,8)
movq %r15, %rdi
movl $0x22, %esi
movl %r12d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43bae0
movl %eax, 0x4(%rsp)
cmpb $0x0, 0x62(%r13)
movq 0x20(%rsp), %rbx
je 0x45a02c
movq %r15, %rdi
movl $0xb, %esi
xorl %edx, %edx
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x43bae0
movl %eax, %ebp
movl 0xb8(%r15), %eax
movl %eax, (%rsp)
movq %r12, %rdx
movzwl 0x5e(%r13), %r12d
movq %r15, %rdi
movl $0x7e, %esi
movl %ebp, %ecx
movl 0x8(%rsp), %r8d
callq 0x43bae0
movq (%r15), %rcx
cmpb $0x0, 0x61(%rcx)
jne 0x45a003
movq 0x68(%r15), %rcx
cltq
leaq (%rax,%rax,2), %rax
movb $-0x3, 0x1(%rcx,%rax,8)
movl %r12d, 0x10(%rcx,%rax,8)
movq %r14, %rdi
movl $0x2, %esi
movq %r13, %rdx
callq 0x45a647
movl 0xb8(%r15), %eax
movq (%r15), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x45a041
leaq 0x14adde(%rip), %rcx    # 0x5a4e08
jmp 0x45a058
movl 0xb8(%r15), %eax
movl %eax, (%rsp)
movl 0x8(%rsp), %ebp
movl 0x18(%rsp), %r13d
jmp 0x45a069
leal -0x1(%rax), %ecx
testl %ebp, %ebp
cmovnsl %ebp, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x68(%r15), %rcx
movq 0x10(%rsp), %r12
movl 0x8(%rsp), %ebp
movl 0x18(%rsp), %r13d
movl %eax, 0x8(%rcx)
movq %r15, %rdi
movl $0x7f, %esi
movl %r12d, %edx
movl %ebp, %ecx
movl %r13d, %r8d
callq 0x43bae0
movq %r15, %rdi
movl $0x83, %esi
movl %r13d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43bae0
movq %r15, %rdi
movl $0x85, %esi
movl %r13d, %edx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x43bae0
movslq 0xb8(%r15), %rax
testq %rax, %rax
jle 0x45a0c3
movq 0x68(%r15), %rcx
leaq (%rax,%rax,2), %rax
movw $0x10, -0x16(%rcx,%rax,8)
testl %ebp, %ebp
je 0x45a0e1
movzbl 0x1f(%r14), %eax
cmpq $0x7, %rax
ja 0x45a0e1
leal 0x1(%rax), %ecx
movb %cl, 0x1f(%r14)
movl %ebp, 0xc4(%r14,%rax,4)
movq %r15, %rdi
movl $0x3, %esi
movl %r12d, %edx
movl (%rsp), %ecx
xorl %r8d, %r8d
callq 0x43bae0
movl 0xb8(%r15), %eax
movq (%r15), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x45a110
leaq 0x14acfa(%rip), %rcx    # 0x5a4e08
jmp 0x45a12b
leal -0x1(%rax), %ecx
movl 0x4(%rsp), %edx
testl %edx, %edx
cmovnsl %edx, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
addq 0x68(%r15), %rcx
movl %eax, 0x8(%rcx)
movq %r15, %rdi
movl $0x75, %esi
movl %ebx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43bae0
movq %r15, %rdi
movl $0x75, %esi
movl %r13d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43bae0
movq %r15, %rdi
movl $0x75, %esi
movl %r12d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43bae0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq