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

```asm
<perm>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  cmpl   $0x1,-0x2c(%rbp)
  jg     L3
  mov    $0x0,%eax
  jmp    L64
L3:
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x8(%rax),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jle    L29
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    -0x2c(%rbp),%edx
  movslq %edx,%rdx
  shl    $0x2,%rdx
  lea    -0x4(%rdx),%rcx
  mov    -0x28(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,(%rdx)
  mov    $0x1,%eax
  jmp    L64
L29:
  mov    -0x2c(%rbp),%eax
  sub    $0x3,%eax
  mov    %eax,-0x20(%rbp)
  jmp    L48
L10:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jge    L11
  mov    -0x2c(%rbp),%eax
  sub    -0x20(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x1c(%rbp),%edx
  mov    -0x8(%rbp),%rcx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <find_successor@plt>
  mov    %eax,-0x18(%rbp)
  mov    -0x18(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  add    $0x1,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x28(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x10(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x1c(%rbp),%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <reverse@plt>
  mov    $0x1,%eax
  jmp    L64
L11:
  subl   $0x1,-0x20(%rbp)
L48:
  cmpl   $0x0,-0x20(%rbp)
  jns    L10
  mov    $0x0,%eax
L64:
  leave
  ret
```

assistant: ```c
int perm(int *a, int len) {
  if (len <= 1)
    return 0;
  if (a[len - 1] > a[len - 2]) {
    int temp = a[len - 1];
    a[len - 1] = a[len - 2];
    a[len - 2] = temp;
    return 1;
  }
  for (int ii = len - 3; ii >= 0; ii--) {
    if (a[ii] < a[ii + 1]) {
      const int small_len = len - ii - 1;
      int *small_a = a + ii + 1;
      const int relative_succ_index = find_successor(a[ii], small_a, small_len);
      const int succ_index = relative_succ_index + ii + 1;
      int temp = a[ii];
      a[ii] = a[succ_index];
      a[succ_index] = temp;
      reverse(small_a, small_len);
      return 1;
    }
  }
  return 0;
}
```