// File: /workspace/github_c_makefile_star2_O1/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 0x3c20a
testl %eax, %eax
je 0x3c158
testl %eax, %eax
jne 0x3c18c
cmpl $0x0, 0x20(%r15)
je 0x3c18a
movq %r15, %rdi
callq 0x3c9d0
jmp 0x3c18c
movslq 0x18(%r15), %rcx
cmpl $0x0, 0x20(%r15)
je 0x3c1bb
leaq 0x28(%r15), %rdx
movq %r12, %rdi
movq %rcx, %r13
movq %rcx, %rsi
callq 0x3be07
testl %eax, %eax
jne 0x3c143
leaq 0x38(%r15), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x3be07
jmp 0x3c143
xorl %eax, %eax
cmpl $0x1, %r14d
je 0x3c1ac
testl %eax, %eax
jne 0x3c1ac
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3c709
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
cmpq $0x0, 0x58(%r13)
jne 0x3c1e4
leaq 0x58(%r13), %rdx
movq %rcx, -0x30(%rbp)
movq 0x60(%r13), %rsi
movq %r12, %rdi
callq 0x3be07
movq -0x30(%rbp), %rcx
movq $0x0, 0x60(%r13)
testl %eax, %eax
jne 0x3c143
movq 0x58(%r13), %rax
movq %rax, 0x38(%r15)
movq 0x60(%r13), %rax
movq %rax, 0x10(%r15)
addq %rax, %rcx
movq %rcx, 0x60(%r13)
xorl %eax, %eax
jmp 0x3c143