// File: /workspace/github_c_makefile_star2_O2/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: vdbeSorterListToPMA
static int vdbeSorterListToPMA(SortSubtask *pTask, SorterList *pList){
  sqlite3 *db = pTask->pSorter->db;
  int rc = SQLITE_OK;             /* Return code */
  PmaWriter writer;               /* Object used to write to the file */

#ifdef SQLITE_DEBUG
  /* Set iSz to the expected size of file pTask->file after writing the PMA. 
  ** This is used by an assert() statement at the end of this function.  */
  i64 iSz = pList->szPMA + sqlite3VarintLen(pList->szPMA) + pTask->file.iEof;
#endif

  vdbeSorterWorkDebug(pTask, "enter");
  memset(&writer, 0, sizeof(PmaWriter));
  assert( pList->szPMA>0 );

  /* If the first temporary PMA file has not been opened, open it now. */
  if( pTask->file.pFd==0 ){
    rc = vdbeSorterOpenTempFile(db, 0, &pTask->file.pFd);
    assert( rc!=SQLITE_OK || pTask->file.pFd );
    assert( pTask->file.iEof==0 );
    assert( pTask->nPMA==0 );
  }

  /* Try to get the file to memory map */
  if( rc==SQLITE_OK ){
    vdbeSorterExtendFile(db, pTask->file.pFd, pTask->file.iEof+pList->szPMA+9);
  }

  /* Sort the list */
  if( rc==SQLITE_OK ){
    rc = vdbeSorterSort(pTask, pList);
  }

  if( rc==SQLITE_OK ){
    SorterRecord *p;
    SorterRecord *pNext = 0;

    vdbePmaWriterInit(pTask->file.pFd, &writer, pTask->pSorter->pgsz,
                      pTask->file.iEof);
    pTask->nPMA++;
    vdbePmaWriteVarint(&writer, pList->szPMA);
    for(p=pList->pList; p; p=pNext){
      pNext = p->u.pNext;
      vdbePmaWriteVarint(&writer, p->nVal);
      vdbePmaWriteBlob(&writer, SRVAL(p), p->nVal);
      if( pList->aMemory==0 ) sqlite3_free(p);
    }
    pList->pList = p;
    rc = vdbePmaWriterFinish(&writer, &pTask->file.iEof);
  }

  vdbeSorterWorkDebug(pTask, "exit");
  assert( rc!=SQLITE_OK || pList->pList==0 );
  assert( rc!=SQLITE_OK || pTask->file.iEof==iSz );
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x10(%rdi), %rax
movq 0x20(%rax), %r15
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movq 0x48(%rdi), %rsi
testq %rsi, %rsi
je 0x34e2c
movq 0x50(%r14), %rax
movslq 0x10(%rbx), %rcx
leaq (%rax,%rcx), %rdx
addq $0x9, %rdx
movq %r15, %rdi
callq 0x34fa9
movq %r14, %rdi
movq %rbx, %rsi
callq 0x34726
testl %eax, %eax
jne 0x34e5a
leaq 0x50(%r14), %r15
movq 0x10(%r14), %rax
movq 0x48(%r14), %rdi
movl 0xc(%rax), %edx
movq 0x50(%r14), %rcx
leaq -0x60(%rbp), %r12
movq %r12, %rsi
callq 0x3502f
incl 0x38(%r14)
movslq 0x10(%rbx), %rsi
movq %r12, %rdi
callq 0x35093
movq (%rbx), %r13
testq %r13, %r13
je 0x34e4a
movq %r13, %r14
movq 0x8(%r13), %r13
movslq (%r14), %rsi
movq %r12, %rdi
callq 0x35093
leaq 0x10(%r14), %rsi
movl (%r14), %edx
movq %r12, %rdi
callq 0x350c3
cmpq $0x0, 0x8(%rbx)
jne 0x34df5
movq %r14, %rdi
callq 0xa828
jmp 0x34df5
leaq 0x48(%r14), %r12
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x34f18
testl %eax, %eax
jne 0x34e5a
movq (%r12), %rsi
jmp 0x34d98
andq $0x0, (%rbx)
leaq -0x60(%rbp), %rdi
movq %r15, %rsi
callq 0x35166
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq