// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: vdbeSorterSort
static int vdbeSorterSort(SortSubtask *pTask, SorterList *pList){
  int i;
  SorterRecord *p;
  int rc;
  SorterRecord *aSlot[64];

  rc = vdbeSortAllocUnpacked(pTask);
  if( rc!=SQLITE_OK ) return rc;

  p = pList->pList;
  pTask->xCompare = vdbeSorterGetCompare(pTask->pSorter);
  memset(aSlot, 0, sizeof(aSlot));

  while( p ){
    SorterRecord *pNext;
    if( pList->aMemory ){
      if( (u8*)p==pList->aMemory ){
        pNext = 0;
      }else{
        assert( p->u.iNext<sqlite3MallocSize(pList->aMemory) );
        pNext = (SorterRecord*)&pList->aMemory[p->u.iNext];
      }
    }else{
      pNext = p->u.pNext;
    }

    p->u.pNext = 0;
    for(i=0; aSlot[i]; i++){
      p = vdbeSorterMerge(pTask, p, aSlot[i]);
      aSlot[i] = 0;
    }
    aSlot[i] = p;
    p = pNext;
  }

  p = 0;
  for(i=0; i<ArraySize(aSlot); i++){
    if( aSlot[i]==0 ) continue;
    p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i];
  }
  pList->pList = p;

  assert( pTask->pUnpacked->errCode==SQLITE_OK
       || pTask->pUnpacked->errCode==SQLITE_NOMEM
  );
  return pTask->pUnpacked->errCode;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x408680
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x408420
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4085be
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x408700
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
leaq -0x230(%rbp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x19360
cmpq $0x0, -0x28(%rbp)
je 0x40852c
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x4084a3
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x408487
movq $0x0, -0x238(%rbp)
jmp 0x4084a1
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
movslq 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x238(%rbp)
jmp 0x4084b2
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x238(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, 0x8(%rax)
movl $0x0, -0x1c(%rbp)
movslq -0x1c(%rbp), %rax
cmpq $0x0, -0x230(%rbp,%rax,8)
je 0x40850c
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movslq -0x1c(%rbp), %rax
movq -0x230(%rbp,%rax,8), %rdx
callq 0x408750
movq %rax, -0x28(%rbp)
movslq -0x1c(%rbp), %rax
movq $0x0, -0x230(%rbp,%rax,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x4084c5
movq -0x28(%rbp), %rcx
movslq -0x1c(%rbp), %rax
movq %rcx, -0x230(%rbp,%rax,8)
movq -0x238(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x408456
movq $0x0, -0x28(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x40, -0x1c(%rbp)
jge 0x4085a4
movslq -0x1c(%rbp), %rax
cmpq $0x0, -0x230(%rbp,%rax,8)
jne 0x408552
jmp 0x408599
cmpq $0x0, -0x28(%rbp)
je 0x40857b
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movslq -0x1c(%rbp), %rax
movq -0x230(%rbp,%rax,8), %rdx
callq 0x408750
movq %rax, -0x240(%rbp)
jmp 0x40858e
movslq -0x1c(%rbp), %rax
movq -0x230(%rbp,%rax,8), %rax
movq %rax, -0x240(%rbp)
movq -0x240(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x40853b
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movzbl 0x13(%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
nopw (%rax,%rax)