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

```asm
<partition_memory>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    %ecx,-0x24(%rbp)
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jne    L28
  cmpl   $0x4,-0x1c(%rbp)
  je     L28
  mov    $0x1,%eax
  jmp    L47
L28:
  mov    $0x0,%eax
L47:
  mov    %eax,-0x8(%rbp)
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <get_size@plt>
  mov    -0x1c(%rbp),%edx
  add    %edx,%eax
  sub    $0x1,%eax
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  je     L1
  mov    -0x20(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x8(%rbp),%eax
  add    %edx,%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  add    $0x1,%edx
  mov    %edx,(%rax)
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x4(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  sub    -0x20(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0xc(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    -0x1c(%rbp),%ecx
  mov    -0x20(%rbp),%edx
  add    %ecx,%edx
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    -0x1c(%rbp),%ecx
  mov    -0x20(%rbp),%edx
  add    %ecx,%edx
  mov    %edx,(%rax)
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  lea    0x0(,%rax,4),%edx
  mov    -0x1c(%rbp),%ecx
  mov    -0x20(%rbp),%eax
  add    %ecx,%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  add    $0x2,%edx
  mov    %edx,(%rax)
  mov    -0x1c(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x10(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x1c(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,(%rdx)
  jmp    L42
L1:
  mov    -0x20(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x8(%rbp),%eax
  add    %edx,%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  add    $0x1,%edx
  mov    %edx,(%rax)
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  mov    -0x1c(%rbp),%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  mov    -0xc(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x10(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x10(%rbp),%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,(%rdx)
  nop
L42:
  leave
  ret
```

assistant: ```c
void partition_memory(int *mem, int fpart, int psize, int split) {
  int old_f_link = mem[fpart + 1];
  int old_b_link = mem[fpart + 2];
  int preuse_bit = ((mem[fpart - 1] == 0) && ((fpart - 1) != 3)) ? 1 : 0;
  int size_index = fpart + get_size(mem[fpart]) - 1;
  if (split) {
    mem[fpart] = 4 * psize + 2 * preuse_bit + 1;
    mem[fpart + 1] = 0;
    mem[fpart + 2] = 0;
    mem[size_index] -= psize;
    mem[old_b_link + 1] = fpart + psize;
    mem[old_f_link + 2] = fpart + psize;
    mem[fpart + psize] = 4 * (mem[size_index]) + 2 * 1 + 0;
    mem[fpart + psize + 1] = old_f_link;
    mem[fpart + psize + 2] = old_b_link;
  } else {
    mem[fpart] = 4 * psize + 2 * preuse_bit + 1;
    mem[fpart + 1] = 0;
    mem[fpart + 2] = 0;
    mem[size_index] = 0;
    mem[old_b_link + 1] = old_f_link;
    mem[old_f_link + 2] = old_b_link;
  }
  return;
}
```