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

```asm
<partition>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8,-0x48(%rbp)
  mov    -0x40(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x1,%edi
  call   <calloc@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x30(%rbp),%rax
  imul   -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %eax,-0x18(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %eax,-0x14(%rbp)
  jmp    L24
L87:
  mov    -0x18(%rbp),%eax
  cltq
  mov    -0x38(%rbp),%rdx
  sub    $0x1,%rdx
  cmp    %rdx,%rax
  je     L53
L24:
  addl   $0x1,-0x18(%rbp)
  mov    -0x18(%rbp),%eax
  cltq
  imul   -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x8(%rbp),%rax
  mov    -0x48(%rbp),%rdx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   *%rdx
  test   %eax,%eax
  js     L87
  jmp    L88
L53:
  nop
  jmp    L88
L89:
  mov    -0x14(%rbp),%eax
  cltq
  cmp    %rax,-0x30(%rbp)
  je     L95
L88:
  subl   $0x1,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  imul   -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x8(%rbp),%rax
  mov    -0x48(%rbp),%rdx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   *%rdx
  test   %eax,%eax
  jg     L89
  jmp    L68
L95:
  nop
L68:
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jge    L13
  mov    -0x18(%rbp),%eax
  cltq
  imul   -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x40(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x14(%rbp),%eax
  cltq
  imul   -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0x18(%rbp),%eax
  cltq
  imul   -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x14(%rbp),%eax
  cltq
  imul   -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x40(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  jmp    L24
L13:
  nop
  mov    -0x40(%rbp),%rdx
  mov    -0x8(%rbp),%rcx
  mov    -0x10(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x14(%rbp),%eax
  cltq
  imul   -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x40(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x14(%rbp),%eax
  cltq
  imul   -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x40(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x14(%rbp),%eax
  leave
  ret
```

assistant: ```c
int partition(void *base, size_t lo, size_t hi, size_t width, int (*cmp)(const void *, const void *)) {
  void *buffer = calloc(1, width);
  void *pivot = (char *)base + lo * width;
  int i = lo;
  int j = hi;
  while (1) {
    while (cmp((char *)base + ++i * width, pivot) < 0) {
      if (i == hi - 1) {
        break;
      }
    }
    while (cmp((char *)base + --j * width, pivot) > 0) {
      if (j == lo) {
        break;
      }
    }
    if (i >= j) {
      break;
    }
    memcpy(buffer, (char *)base + i * width, width);
    memcpy((char *)base + i * width, (char *)base + j * width, width);
    memcpy((char *)base + j * width, buffer, width);
  }
  memcpy(buffer, pivot, width);
  memcpy(pivot, (char *)base + j * width, width);
  memcpy((char *)base + j * width, buffer, width);
  free(buffer);
  return j;
}
```