// File: /workspace/github_c_makefile_star2_O3/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 $0x58, %rsp
movq %rsi, %r14
movq %rdi, %r13
movq 0x10(%rdi), %rax
movq 0x20(%rax), %r15
movq 0x48(%rdi), %rsi
testq %rsi, %rsi
je 0x3acdd
movq 0x50(%r13), %rax
movslq 0x10(%r14), %rcx
leaq (%rax,%rcx), %rdx
addq $0x9, %rdx
movl 0x98(%r15), %edi
callq 0x3aef5
movq %r13, %rdi
movq %r14, %rsi
callq 0x3a598
testl %eax, %eax
jne 0x3ad96
movq 0x10(%r13), %rax
movq 0x48(%r13), %rbx
movl 0xc(%rax), %eax
movq 0x50(%r13), %r15
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movslq %eax, %r12
movq %r12, %rdi
callq 0xc0e2
movq %rax, -0x58(%rbp)
testq %rax, %rax
je 0x3acff
movq %r15, %rax
cqto
idivq %r12
movl %edx, -0x4c(%rbp)
movl %edx, -0x48(%rbp)
subq %rdx, %r15
movq %r15, -0x40(%rbp)
movl %r12d, -0x50(%rbp)
movq %rbx, -0x38(%rbp)
jmp 0x3ad06
leaq 0x48(%r13), %r12
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x3ae5e
testl %eax, %eax
jne 0x3ad96
movq (%r12), %rsi
jmp 0x3ac5d
movl $0x7, -0x60(%rbp)
incl 0x38(%r13)
addq $0x50, %r13
movq %r13, -0x68(%rbp)
movslq 0x10(%r14), %rsi
leaq -0x72(%rbp), %r15
movq %r15, %rdi
callq 0x323de
leaq -0x60(%rbp), %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0x3af7e
movq (%r14), %r12
testq %r12, %r12
je 0x3ad82
leaq -0x60(%rbp), %r13
movq 0x8(%r12), %rbx
movslq (%r12), %rsi
movq %r15, %rdi
callq 0x323de
movq %r13, %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0x3af7e
leaq 0x10(%r12), %rsi
movl (%r12), %edx
movq %r13, %rdi
callq 0x3af7e
cmpq $0x0, 0x8(%r14)
jne 0x3ad7a
movq %r12, %rdi
callq 0xa630
movq %rbx, %r12
testq %rbx, %rbx
jne 0x3ad3c
movq $0x0, (%r14)
leaq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x3b027
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq