// File: /workspace/github_c_makefile_star2_O3/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: vdbePmaReaderIncrMergeInit
static int vdbePmaReaderIncrMergeInit(PmaReader *pReadr, int eMode){
  int rc = SQLITE_OK;
  IncrMerger *pIncr = pReadr->pIncr;
  SortSubtask *pTask = pIncr->pTask;
  sqlite3 *db = pTask->pSorter->db;

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

  rc = vdbeMergeEngineInit(pTask, pIncr->pMerger, eMode);

  /* Set up the required files for pIncr. A multi-theaded IncrMerge object
  ** requires two temp files to itself, whereas a single-threaded object
  ** only requires a region of pTask->file2. */
  if( rc==SQLITE_OK ){
    int mxSz = pIncr->mxSz;
#if SQLITE_MAX_WORKER_THREADS>0
    if( pIncr->bUseThread ){
      rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[0].pFd);
      if( rc==SQLITE_OK ){
        rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[1].pFd);
      }
    }else
#endif
    /*if( !pIncr->bUseThread )*/{
      if( pTask->file2.pFd==0 ){
        assert( pTask->file2.iEof>0 );
        rc = vdbeSorterOpenTempFile(db, pTask->file2.iEof, &pTask->file2.pFd);
        pTask->file2.iEof = 0;
      }
      if( rc==SQLITE_OK ){
        pIncr->aFile[1].pFd = pTask->file2.pFd;
        pIncr->iStartOff = pTask->file2.iEof;
        pTask->file2.iEof += mxSz;
      }
    }
  }

#if SQLITE_MAX_WORKER_THREADS>0
  if( rc==SQLITE_OK && pIncr->bUseThread ){
    /* Use the current thread to populate aFile[1], even though this
    ** PmaReader is multi-threaded. If this is an INCRINIT_TASK object,
    ** then this function is already running in background thread 
    ** pIncr->pTask->thread. 
    **
    ** If this is the INCRINIT_ROOT object, then it is running in the 
    ** main VDBE thread. But that is Ok, as that thread cannot return
    ** control to the VDBE or proceed with anything useful until the 
    ** first results are ready from this merger object anyway.
    */
    assert( eMode==INCRINIT_ROOT || eMode==INCRINIT_TASK );
    rc = vdbeIncrPopulate(pIncr);
  }
#endif

  if( rc==SQLITE_OK && (SQLITE_MAX_WORKER_THREADS==0 || eMode!=INCRINIT_TASK) ){
    rc = vdbePmaReaderNext(pReadr);
  }

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movq 0x48(%rdi), %r15
movq (%r15), %r13
movq 0x8(%r15), %rsi
movq 0x10(%r13), %rax
movq 0x20(%rax), %r12
movq %r13, %rdi
movl %r14d, %edx
callq 0x3b265
testl %eax, %eax
je 0x3b1a4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0x18(%r15), %rcx
cmpl $0x0, 0x20(%r15)
je 0x3b1da
leaq 0x28(%r15), %rdx
movq %r12, %rdi
movq %rcx, %rsi
movq %rcx, %r13
callq 0x3ae5e
testl %eax, %eax
jne 0x3b195
leaq 0x38(%r15), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x3ae5e
testl %eax, %eax
jne 0x3b195
jmp 0x3b1f6
movq 0x58(%r13), %rax
movq 0x60(%r13), %rsi
testq %rax, %rax
je 0x3b207
movq %rax, 0x38(%r15)
movq %rsi, 0x10(%r15)
addq %rsi, %rcx
movq %rcx, 0x60(%r13)
cmpl $0x0, 0x20(%r15)
je 0x3b239
movq %r15, %rdi
callq 0x3ba17
jmp 0x3b23b
movq %rcx, -0x30(%rbp)
leaq 0x58(%r13), %rax
movq %r12, %rdi
movq %rax, %r12
movq %rax, %rdx
callq 0x3ae5e
movq $0x0, 0x60(%r13)
testl %eax, %eax
jne 0x3b195
movq (%r12), %rax
xorl %esi, %esi
movq -0x30(%rbp), %rcx
jmp 0x3b1e7
xorl %eax, %eax
testl %eax, %eax
setne %cl
cmpl $0x1, %r14d
sete %dl
orb %cl, %dl
jne 0x3b195
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3b76b