user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<SortByDistance>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %rcx,-0x50(%rbp)
  cmpl   $0x1,-0x3c(%rbp)
  jle    L95
  movl   $0x0,-0x28(%rbp)
  movl   $0x0,-0x24(%rbp)
  mov    -0x3c(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x20(%rbp)
  mov    -0x3c(%rbp),%eax
  sub    -0x20(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x50(%rbp),%rcx
  mov    -0x48(%rbp),%rdx
  mov    -0x20(%rbp),%esi
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <SortByDistance>
  mov    -0x50(%rbp),%rcx
  mov    -0x48(%rbp),%rdx
  mov    -0x1c(%rbp),%esi
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <SortByDistance>
  mov    -0x20(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edx
  mov    -0x10(%rbp),%rcx
  mov    -0x50(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x50(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  jmp    L3
L54:
  mov    -0x28(%rbp),%eax
  cmp    -0x20(%rbp),%eax
  jne    L64
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x28(%rbp),%ecx
  mov    -0x24(%rbp),%edx
  add    %ecx,%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x24(%rbp)
  jmp    L3
L64:
  mov    -0x24(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jne    L87
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    -0x28(%rbp),%ecx
  mov    -0x24(%rbp),%edx
  add    %ecx,%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x28(%rbp)
  jmp    L3
L87:
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movss  (%rax),%xmm0
  movss  %xmm0,-0x18(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movss  (%rax),%xmm0
  movss  %xmm0,-0x14(%rbp)
  movss  -0x14(%rbp),%xmm0
  comiss -0x18(%rbp),%xmm0
  jbe    L80
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    -0x28(%rbp),%ecx
  mov    -0x24(%rbp),%edx
  add    %ecx,%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x28(%rbp)
  jmp    L3
L80:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x28(%rbp),%ecx
  mov    -0x24(%rbp),%edx
  add    %ecx,%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x24(%rbp)
L3:
  mov    -0x28(%rbp),%eax
  cmp    -0x20(%rbp),%eax
  jl     L54
  mov    -0x24(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L54
L95:
  nop
  leave
  ret
```

assistant: ```c
void SortByDistance(int *aIdx, int nIdx, float *aDistance, int *aSpare) {
  if (nIdx > 1) {
    int iLeft = 0;
    int iRight = 0;
    int nLeft = nIdx / 2;
    int nRight = nIdx - nLeft;
    int *aLeft = aIdx;
    int *aRight = &aIdx[nLeft];
    SortByDistance(aLeft, nLeft, aDistance, aSpare);
    SortByDistance(aRight, nRight, aDistance, aSpare);
    memcpy(aSpare, aLeft, sizeof(int) * nLeft);
    aLeft = aSpare;
    while (iLeft < nLeft || iRight < nRight) {
      if (iLeft == nLeft) {
        aIdx[iLeft + iRight] = aRight[iRight];
        iRight++;
      } else if (iRight == nRight) {
        aIdx[iLeft + iRight] = aLeft[iLeft];
        iLeft++;
      } else {
        float fLeft = aDistance[aLeft[iLeft]];
        float fRight = aDistance[aRight[iRight]];
        if (fLeft < fRight) {
          aIdx[iLeft + iRight] = aLeft[iLeft];
          iLeft++;
        } else {
          aIdx[iLeft + iRight] = aRight[iRight];
          iRight++;
        }
      }
    }
  }
}
```