// File: /workspace/github_c_makefile_star2_O1/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
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
xorl %eax, %eax
cmpq $0x0, 0x48(%rdi)
jne 0x3bc28
leaq 0x48(%r13), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x3be07
testl %eax, %eax
jne 0x3bc53
movq 0x48(%r13), %rsi
movq 0x50(%r13), %rax
movslq 0x10(%r14), %rcx
leaq (%rax,%rcx), %rdx
addq $0x9, %rdx
movq %r15, %rdi
callq 0x3be9a
movq %r13, %rdi
movq %r14, %rsi
callq 0x3b536
testl %eax, %eax
jne 0x3bd43
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 0xbf9b
movq %rax, -0x58(%rbp)
testq %rax, %rax
je 0x3bcac
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 0x3bcb3
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 0x32f32
leaq -0x60(%rbp), %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0x3bf27
movq (%r14), %r12
testq %r12, %r12
je 0x3bd2f
leaq -0x60(%rbp), %r13
movq 0x8(%r12), %rbx
movslq (%r12), %rsi
movq %r15, %rdi
callq 0x32f32
movq %r13, %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0x3bf27
leaq 0x10(%r12), %rsi
movl (%r12), %edx
movq %r13, %rdi
callq 0x3bf27
cmpq $0x0, 0x8(%r14)
jne 0x3bd27
movq %r12, %rdi
callq 0xa620
movq %rbx, %r12
testq %rbx, %rbx
jne 0x3bce9
movq $0x0, (%r14)
leaq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x3bfd0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq