// File: /workspace/github_c_makefile_star2_O3/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
movq 0x20(%rax), %rax
testq %rcx, %rcx
je 0x458eb8
leaq 0x18(%rax), %rdx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
incl %ebp
leaq 0x20(%rdx), %rsi
cmpq %rcx, (%rdx)
movq %rsi, %rdx
jne 0x458ea8
jmp 0x458ebd
movl $0xfff0bdc0, %ebp       # imm = 0xFFF0BDC0
movq (%r13), %rdx
movslq %ebp, %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %r8
movq %r14, %rdi
movl $0x1b, %esi
xorl %ecx, %ecx
callq 0x453d2a
testl %eax, %eax
jne 0x45930b
movl 0x38(%r12), %edx
movq (%r12), %r8
movq %r14, %rdi
movl %ebp, %esi
movl $0x1, %ecx
callq 0x44def5
movq %r14, %rdi
callq 0x44dbe5
testq %rax, %rax
je 0x45930b
movq %rax, %r15
movl (%rsp), %eax
movl %eax, 0x4(%rsp)
testl %eax, %eax
jns 0x458f22
movl 0x58(%r13), %eax
movl %eax, 0x4(%rsp)
movq %r12, 0x8(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x44e052
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 0x458f52
incl (%r12)
movq %r15, %rdi
movl $0x72, %esi
movq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq 0x43a65f
movq %r15, %rdi
movl %eax, %esi
movq %r12, 0x28(%rsp)
movq %r12, %rdx
movl $0xfffffff7, %ecx       # imm = 0xFFFFFFF7
callq 0x40e765
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
movq 0x8(%rsp), %rcx
movl $0x6d, %r8d
callq 0x44ddf0
movq %r15, %rdi
movl $0x24, %esi
movq %rbx, 0x20(%rsp)
movl %ebx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43a65f
movb 0x1f(%r14), %cl
testb %cl, %cl
movq %rax, 0x18(%rsp)
je 0x458fcd
decb %cl
movb %cl, 0x1f(%r14)
movzbl %cl, %eax
movl 0xc4(%r14,%rax,4), %ebx
jmp 0x458fd7
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 0x4595a6
addq $0x10, %rsp
movq %r15, %rdi
movl $0x84, %esi
movq 0x10(%rsp), %rdx
movl %ebx, 0x8(%rsp)
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x43a65f
movl (%r12), %eax
testl %eax, %eax
je 0x45904f
movq 0x10(%r14), %rcx
movq 0x18(%rcx), %rdx
movq 0x50(%rdx), %rdx
testq %rdx, %rdx
je 0x45904f
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 0x43a65f
movl 0xb8(%r15), %eax
movq (%r15), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x459089
leaq 0x14bd81(%rip), %rcx    # 0x5a4e08
jmp 0x4590a2
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 0x4590c8
movq %r15, %rdi
movl $0x8a, %esi
movl 0x4(%rsp), %edx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x43a65f
movq %r15, %rdi
movl $0x6e, %esi
movl %ebx, 0x18(%rsp)
movl %ebx, %edx
movl 0x4(%rsp), %ecx
movl %ebp, %r8d
callq 0x43a65f
movq %r15, %rdi
movl %eax, %esi
movq 0x28(%rsp), %rdx
movl $0xfffffff7, %ecx       # imm = 0xFFFFFFF7
callq 0x40e765
movslq 0xb8(%r15), %rax
testq %rax, %rax
jle 0x45911d
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 0x43a65f
movl %eax, 0x4(%rsp)
cmpb $0x0, 0x62(%r13)
movq 0x20(%rsp), %rbx
je 0x4591cb
movq %r15, %rdi
movl $0xb, %esi
xorl %edx, %edx
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x43a65f
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 0x43a65f
movq (%r15), %rcx
cmpb $0x0, 0x61(%rcx)
jne 0x4591a2
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 0x4597d0
movl 0xb8(%r15), %eax
movq (%r15), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x4591e0
leaq 0x14bc3f(%rip), %rcx    # 0x5a4e08
jmp 0x4591f7
movl 0xb8(%r15), %eax
movl %eax, (%rsp)
movl 0x8(%rsp), %ebp
movl 0x18(%rsp), %r13d
jmp 0x459208
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 0x43a65f
movq %r15, %rdi
movl $0x83, %esi
movl %r13d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43a65f
movq %r15, %rdi
movl $0x85, %esi
movl %r13d, %edx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x43a65f
movslq 0xb8(%r15), %rax
testq %rax, %rax
jle 0x459262
movq 0x68(%r15), %rcx
leaq (%rax,%rax,2), %rax
movw $0x10, -0x16(%rcx,%rax,8)
testl %ebp, %ebp
je 0x459280
movzbl 0x1f(%r14), %eax
cmpq $0x7, %rax
ja 0x459280
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 0x43a65f
movl 0xb8(%r15), %eax
movq (%r15), %rcx
cmpb $0x0, 0x61(%rcx)
je 0x4592af
leaq 0x14bb5b(%rip), %rcx    # 0x5a4e08
jmp 0x4592ca
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 0x43a65f
movq %r15, %rdi
movl $0x75, %esi
movl %r13d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43a65f
movq %r15, %rdi
movl $0x75, %esi
movl %r12d, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x43a65f
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq