// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: vdbeMergeEngineInit
static int vdbeMergeEngineInit(
  SortSubtask *pTask,             /* Thread that will run pMerger */
  MergeEngine *pMerger,           /* MergeEngine to initialize */
  int eMode                       /* One of the INCRINIT_XXX constants */
){
  int rc = SQLITE_OK;             /* Return code */
  int i;                          /* For looping over PmaReader objects */
  int nTree;                      /* Number of subtrees to merge */

  /* Failure to allocate the merge would have been detected prior to
  ** invoking this routine */
  assert( pMerger!=0 );

  /* eMode is always INCRINIT_NORMAL in single-threaded mode */
  assert( SQLITE_MAX_WORKER_THREADS>0 || eMode==INCRINIT_NORMAL );

  /* Verify that the MergeEngine is assigned to a single thread */
  assert( pMerger->pTask==0 );
  pMerger->pTask = pTask;

  nTree = pMerger->nTree;
  for(i=0; i<nTree; i++){
    if( SQLITE_MAX_WORKER_THREADS>0 && eMode==INCRINIT_ROOT ){
      /* PmaReaders should be normally initialized in order, as if they are
      ** reading from the same temp file this makes for more linear file IO.
      ** However, in the INCRINIT_ROOT case, if PmaReader aReadr[nTask-1] is
      ** in use it will block the vdbePmaReaderNext() call while it uses
      ** the main thread to fill its buffer. So calling PmaReaderNext()
      ** on this PmaReader before any of the multi-threaded PmaReaders takes
      ** better advantage of multi-processor hardware. */
      rc = vdbePmaReaderNext(&pMerger->aReadr[nTree-i-1]);
    }else{
      rc = vdbePmaReaderIncrInit(&pMerger->aReadr[i], INCRINIT_NORMAL);
    }
    if( rc!=SQLITE_OK ) return rc;
  }

  for(i=pMerger->nTree-1; i>0; i--){
    vdbeMergeEngineCompare(pMerger, i);
  }
  return pTask->pUnpacked->errCode;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, 0x10(%rsp)
movq %rdi, 0x8(%rsi)
movl (%rsi), %eax
xorl %ebx, %ebx
testl %eax, %eax
cmovlel %ebx, %eax
imulq $0x50, %rax, %rax
movq %rax, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
cmpq %rbx, 0x20(%rsp)
je 0x249e1b
movq 0x18(%r14), %r15
movq 0x48(%r15,%rbx), %r14
testq %r14, %r14
je 0x249e0d
movq (%r14), %r12
movq 0x8(%r14), %rsi
movq 0x10(%r12), %rax
movq 0x20(%rax), %r13
movq %r12, %rdi
callq 0x249d46
testl %eax, %eax
jne 0x249ed7
movslq 0x18(%r14), %rbp
movq 0x58(%r12), %rax
movq 0x60(%r12), %rsi
testq %rax, %rax
jne 0x249dea
leaq 0x58(%r12), %rax
movq %r13, %rdi
movq %rax, %r13
movq %rax, %rdx
callq 0x249a9a
andq $0x0, 0x60(%r12)
testl %eax, %eax
jne 0x249ed7
movq (%r13), %rax
xorl %esi, %esi
addq %rbx, %r15
movq %rax, 0x38(%r14)
movq %rsi, 0x10(%r14)
addq %rsi, %rbp
movq %rbp, 0x60(%r12)
movq %r15, %rdi
callq 0x24a224
testl %eax, %eax
jne 0x249ed7
addq $0x50, %rbx
movq 0x18(%rsp), %r14
jmp 0x249d77
movl (%r14), %r12d
leal -0x1(%r12), %r13d
leal -0x2(,%r12,2), %ebx
pushq $0x2
popq %rdi
cmpl $0x2, %r12d
jl 0x249eca
movl (%r14), %eax
cltd
idivl %edi
cmpl %r12d, %eax
jge 0x249e4f
addl %eax, %eax
movl %ebx, %ebp
subl %eax, %ebp
leal 0x1(%rbp), %r15d
jmp 0x249e5f
movq 0x10(%r14), %rax
movl %ebx, %ecx
movl (%rax,%rcx,4), %ebp
leal 0x1(%rbx), %ecx
movl (%rax,%rcx,4), %r15d
movq 0x18(%r14), %rax
movslq %ebp, %rcx
imulq $0x50, %rcx, %rcx
cmpq $0x0, 0x18(%rax,%rcx)
je 0x249eb4
movslq %r15d, %rdx
imulq $0x50, %rdx, %rsi
addq %rax, %rsi
cmpq $0x0, 0x18(%rsi)
je 0x249eb1
addq %rcx, %rax
movq 0x8(%r14), %rdi
andl $0x0, 0xc(%rsp)
movq 0x28(%rax), %rdx
movl 0x14(%rax), %ecx
movq 0x28(%rsi), %r8
movl 0x14(%rsi), %r9d
leaq 0xc(%rsp), %rsi
callq *0x40(%rdi)
pushq $0x2
popq %rdi
testl %eax, %eax
cmovlel %ebp, %r15d
jmp 0x249eb4
movl %ebp, %r15d
movq 0x10(%r14), %rax
movl %r15d, (%rax,%r13,4)
decl %r12d
decq %r13
addl $-0x2, %ebx
jmp 0x249e2e
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movzbl 0x13(%rax), %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq