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

```asm
<partition>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %edx,-0x44(%rbp)
  mov    %ecx,-0x48(%rbp)
  movl   $0x0,-0x2c(%rbp)
  movq   $0x0,-0x20(%rbp)
  movq   $0x0,-0x18(%rbp)
  movl   $0x0,-0x28(%rbp)
  movl   $0x0,-0x24(%rbp)
  movq   $0x0,-0x10(%rbp)
  movq   $0x0,-0x8(%rbp)
  mov    $0x0,%eax
  call   <rand@plt>
  mov    -0x48(%rbp),%edx
  sub    -0x44(%rbp),%edx
  lea    0x1(%rdx),%ecx
  cltd
  idiv   %ecx
  mov    -0x44(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x44(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x48(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x44(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x48(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x24(%rbp)
  jmp    L48
L102:
  addq   $0x4,-0x20(%rbp)
  addq   $0x4,-0x10(%rbp)
L118:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x2c(%rbp)
  jg     L102
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x2c(%rbp)
  jne    L79
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x24(%rbp)
  jg     L102
  jmp    L79
L12:
  subq   $0x4,-0x18(%rbp)
  subq   $0x4,-0x8(%rbp)
L79:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x2c(%rbp)
  jl     L12
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x2c(%rbp)
  jne    L103
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x24(%rbp)
  jl     L12
L103:
  mov    -0x20(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jae    L75
  mov    -0x18(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <swap@plt>
  mov    -0x8(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <swap@plt>
L75:
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x24(%rbp)
  jne    L35
  subq   $0x4,-0x18(%rbp)
  subq   $0x4,-0x8(%rbp)
L35:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x24(%rbp)
  jne    L48
  addq   $0x4,-0x20(%rbp)
  addq   $0x4,-0x10(%rbp)
L48:
  mov    -0x20(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jb     L118
  mov    -0x18(%rbp),%rax
  sub    -0x38(%rbp),%rax
  sar    $0x2,%rax
  leave
  ret
```

assistant: ```c
int partition(int *a, int *b, int left, int right) {
  int pivotMan = 0, *firstMan = NULL, *lastMan = NULL;
  int pivotPos = 0, pivotWoman = 0, *firstWoman = NULL, *lastWoman = NULL;
  pivotPos = left + rand() % (right - left + 1);
  firstMan = a + left;
  lastMan = a + right;
  firstWoman = b + left;
  lastWoman = b + right;
  pivotMan = *(a + pivotPos);
  pivotWoman = *(b + pivotPos);
  while (firstMan < lastMan) {
    while (*firstMan < pivotMan || (*firstMan == pivotMan && *firstWoman < pivotWoman)) {
      firstMan++;
      firstWoman++;
    }
    while (*lastMan > pivotMan || (*lastMan == pivotMan && *lastWoman > pivotWoman)) {
      lastMan--;
      lastWoman--;
    }
    if (firstMan < lastMan) {
      swap(firstMan, lastMan);
      swap(firstWoman, lastWoman);
    }
    if (*firstWoman == pivotWoman) {
      lastMan--;
      lastWoman--;
    }
    if (*lastWoman == pivotWoman) {
      firstMan++;
      firstWoman++;
    }
  }
  return lastMan - a;
}
```