user: 请将以下的汇编代码转换成C语言代码:

```asm
<permute>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %esi,-0x38(%rbp)
  mov    %rdx,-0x40(%rbp)
  mov    %rcx,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x28(%rbp),%rax
  test   %rax,%rax
  jne    L102
  mov    -0x34(%rbp),%eax
  mov    %eax,%edi
  call   <factorial@plt>
  add    $0x1,%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x28(%rbp)
  mov    -0x28(%rbp),%rdx
  mov    -0x40(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x28(%rbp),%rax
  movq   $0x0,(%rax)
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  movl   $0x0,-0x30(%rbp)
  jmp    L17
L60:
  mov    -0x20(%rbp),%rdx
  mov    -0x30(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x30(%rbp)
L17:
  mov    -0x30(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jl     L60
  mov    -0x20(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x34(%rbp),%eax
  mov    %eax,-0x38(%rbp)
L102:
  cmpl   $0x1,-0x34(%rbp)
  jne    L92
  movl   $0x0,-0x30(%rbp)
L6:
  mov    -0x28(%rbp),%rdx
  mov    -0x30(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L80
  mov    -0x28(%rbp),%rdx
  mov    -0x30(%rbp),%eax
  cltq
  add    $0x1,%rax
  shl    $0x3,%rax
  add    %rdx,%rax
  movq   $0x0,(%rax)
  mov    -0x38(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edx
  mov    -0x28(%rbp),%rcx
  mov    -0x30(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    (%rcx,%rax,1),%rbx
  mov    %edx,%edi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  mov    -0x38(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%rcx
  mov    -0x28(%rbp),%rsi
  mov    -0x30(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rsi,%rax
  mov    (%rax),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  jmp    L43
L80:
  addl   $0x1,-0x30(%rbp)
  jmp    L6
L92:
  movl   $0x0,-0x30(%rbp)
  jmp    L5
L53:
  mov    -0x34(%rbp),%eax
  lea    -0x1(%rax),%edi
  lea    -0x20(%rbp),%rcx
  lea    -0x28(%rbp),%rdx
  mov    -0x38(%rbp),%eax
  mov    %eax,%esi
  call   <permute>
  mov    -0x34(%rbp),%eax
  cltd
  shr    $0x1f,%edx
  add    %edx,%eax
  and    $0x1,%eax
  sub    %edx,%eax
  cmp    $0x1,%eax
  jne    L23
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x20(%rbp),%rdx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x2,%rax
  sub    $0x4,%rax
  add    %rax,%rdx
  mov    -0x20(%rbp),%rax
  mov    (%rdx),%edx
  mov    %edx,(%rax)
  mov    -0x20(%rbp),%rdx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x2,%rax
  sub    $0x4,%rax
  add    %rax,%rdx
  mov    -0x2c(%rbp),%eax
  mov    %eax,(%rdx)
  jmp    L108
L23:
  mov    -0x20(%rbp),%rdx
  mov    -0x30(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x20(%rbp),%rdx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x2,%rax
  sub    $0x4,%rax
  add    %rdx,%rax
  mov    -0x20(%rbp),%rcx
  mov    -0x30(%rbp),%edx
  movslq %edx,%rdx
  shl    $0x2,%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  mov    -0x20(%rbp),%rdx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x2,%rax
  sub    $0x4,%rax
  add    %rax,%rdx
  mov    -0x2c(%rbp),%eax
  mov    %eax,(%rdx)
L108:
  addl   $0x1,-0x30(%rbp)
L5:
  mov    -0x30(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jl     L53
L43:
  nop
  mov    -0x18(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L85
  call   <__stack_chk_fail@plt>
L85:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
void permute(int n, int m, int ***perms_p, int **a_p) {
  int i;
  int **perms = *perms_p;
  int *a = *a_p;
  if (perms == NULL) {
    perms = malloc((factorial((unsigned int)n) + 1) * sizeof(int *));
    *perms_p = perms;
    perms[0] = NULL;
    a = malloc(n * sizeof(int));
    for (i = 0; i < n; i++)
      a[i] = i;
    *a_p = a;
    m = n;
  }
  if (n == 1) {
    for (i = 0;; i++) {
      if (perms[i] == NULL) {
        perms[i + 1] = NULL;
        perms[i] = malloc(m * sizeof(int));
        memcpy(perms[i], a, m * sizeof(int));
        break;
      }
    }
  } else {
    for (i = 0; i < n; i++) {
      permute(n - 1, m, &perms, &a);
      int swap;
      if (n % 2 == 1) {
        swap = a[0];
        a[0] = a[n - 1];
        a[n - 1] = swap;
      } else {
        swap = a[i];
        a[i] = a[n - 1];
        a[n - 1] = swap;
      }
    }
  }
}
```