// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: vdbeMergeEngineCompare
static void vdbeMergeEngineCompare(
  MergeEngine *pMerger,  /* Merge engine containing PmaReaders to compare */
  int iOut               /* Store the result in pMerger->aTree[iOut] */
){
  int i1;
  int i2;
  int iRes;
  PmaReader *p1;
  PmaReader *p2;

  assert( iOut<pMerger->nTree && iOut>0 );

  if( iOut>=(pMerger->nTree/2) ){
    i1 = (iOut - pMerger->nTree/2) * 2;
    i2 = i1 + 1;
  }else{
    i1 = pMerger->aTree[iOut*2];
    i2 = pMerger->aTree[iOut*2+1];
  }

  p1 = &pMerger->aReadr[i1];
  p2 = &pMerger->aReadr[i2];

  if( p1->pFd==0 ){
    iRes = i2;
  }else if( p2->pFd==0 ){
    iRes = i1;
  }else{
    SortSubtask *pTask = pMerger->pTask;
    int bCached = 0;
    int res;
    assert( pTask->pUnpacked!=0 );  /* from vdbeSortSubtaskMain() */
    res = pTask->xCompare(
        pTask, &bCached, p1->aKey, p1->nKey, p2->aKey, p2->nKey
    );
    if( res<=0 ){
      iRes = i1;
    }else{
      iRes = i2;
    }
  }

  pMerger->aTree[iOut] = iRes;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x3c(%rbp), %eax
cmpl %ecx, %eax
jl 0x40a577
movl -0xc(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x40(%rbp), %eax
subl %ecx, %eax
shll %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x40a5a6
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xc(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0xc(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x10(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x40a5e7
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x40a659
movq -0x28(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x40a5fa
movl -0x10(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x40a657
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rcx
movq 0x28(%rcx), %rdx
movq -0x20(%rbp), %rcx
movl 0x14(%rcx), %ecx
movq -0x28(%rbp), %rsi
movq 0x28(%rsi), %r8
movq -0x28(%rbp), %rsi
movl 0x14(%rsi), %r9d
leaq -0x34(%rbp), %rsi
callq *%rax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jg 0x40a64f
movl -0x10(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x40a655
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x40a657
jmp 0x40a659
movl -0x18(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0xc(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)