user: What would the C source look like for the assembly code provided here:

```asm
<compute_all_permutations>:
  endbr64
  push   %r15
  lea    0x1(%rdi),%edx
  mov    %rsi,%r15
  mov    $0x1,%eax
  push   %r14
  mov    %edi,%r14d
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  test   %edi,%edi
  jle    L42
  nopl   0x0(%rax)
L73:
  mov    %eax,-0x4(%r15,%rax,4)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L73
L42:
  movslq %r14d,%r12
  movl   $0x1,0x4(%rsp)
  lea    0x0(,%r12,4),%rax
  mov    %rax,0x8(%rsp)
  lea    -0x1(%r14),%eax
  movslq %eax,%rdi
  mov    %eax,0x1c(%rsp)
  mov    %eax,%eax
  lea    0x4(%r15,%rax,4),%rbx
  lea    -0x2(%r14),%eax
  mov    %rdi,0x38(%rsp)
  mov    %eax,0x18(%rsp)
  cltq
  lea    0x0(,%rdi,4),%rdx
  lea    -0x8(%r15,%r12,8),%rdi
  shl    $0x2,%rax
  mov    %rdx,0x28(%rsp)
  mov    %rax,0x20(%rsp)
  lea    -0x4(%rdx),%rax
  mov    %rdi,0x10(%rsp)
  mov    %rax,0x30(%rsp)
L33:
  mov    %r14d,%edi
  call   <factorial@plt>
  cmp    0x4(%rsp),%eax
  jle    L22
  mov    %r15,%rax
  test   %r14d,%r14d
  jle    L90
  nopw   0x0(%rax,%rax,1)
L16:
  mov    (%rax),%edx
  mov    %edx,(%rax,%r12,4)
  add    $0x4,%rax
  cmp    %rbx,%rax
  jne    L16
L90:
  mov    0x10(%rsp),%rax
  mov    0x18(%rsp),%r13d
  add    0x8(%rsp),%r15
  mov    (%rax),%ecx
  mov    %rax,%rdi
  test   %r13d,%r13d
  js     L53
  mov    0x20(%rsp),%rax
  add    %r15,%rax
  jmp    L120
  xchg   %ax,%ax
L156:
  sub    $0x4,%rax
  test   %r13d,%r13d
  je     L22
  sub    $0x1,%r13d
L120:
  mov    (%rax),%ecx
  mov    %rax,%rdi
  cmp    0x4(%rax),%ecx
  jge    L156
L41:
  mov    0x28(%rsp),%rax
  lea    (%rax,%r15,1),%r9
  cmp    %ecx,(%r15,%rax,1)
  jg     L19
  mov    0x1c(%rsp),%esi
  test   %esi,%esi
  js     L22
  mov    0x30(%rsp),%rax
  add    %r15,%rax
  jmp    L57
L140:
  sub    $0x4,%rax
  cmp    $0xffffffff,%esi
  je     L22
L57:
  sub    $0x1,%esi
  mov    %rax,%r9
  cmp    %ecx,(%rax)
  jle    L140
L19:
  mov    %r9,%rsi
  call   <swap@plt>
  lea    0x1(%r13),%ecx
  cmp    %ecx,0x1c(%rsp)
  jle    L103
  movslq %ecx,%rax
  mov    %r12,0x40(%rsp)
  lea    (%r15,%rax,4),%rbp
  movslq %r13d,%rax
  add    0x38(%rsp),%rax
  mov    %rbx,0x48(%rsp)
  lea    (%r15,%rax,2),%rax
  mov    %rbp,%r12
  mov    %ecx,%ebx
  lea    0x4(%rax,%rax,1),%rax
  mov    %rax,%rbp
  nopl   0x0(%rax,%rax,1)
L162:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  add    $0x1,%ebx
  sub    %r12,%rsi
  add    $0x4,%r12
  call   <swap@plt>
  mov    %r14d,%eax
  sub    %ebx,%eax
  add    %r13d,%eax
  cmp    %ebx,%eax
  jg     L162
  mov    0x40(%rsp),%r12
  mov    0x48(%rsp),%rbx
L103:
  mov    0x8(%rsp),%rdi
  addl   $0x1,0x4(%rsp)
  add    %rdi,0x10(%rsp)
  add    %rdi,%rbx
  jmp    L33
  nopw   0x0(%rax,%rax,1)
L22:
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L53:
  mov    0x18(%rsp),%r13d
  jmp    L41
```

assistant: ```c
void compute_all_permutations(int n, int *res) {
  int i;
  int *curr = res;
  for (i = 1; i <= n; i++) {
    res[i - 1] = i;
  }
  int found = 1;
  while (found < factorial(n)) {
    int k;
    for (k = 0; k < n; k++) {
      curr[k + n] = curr[k];
    }
    curr += n;
    int j;
    for (j = n - 2; j >= 0 && curr[j] >= curr[j + 1]; j--) {
      if (j == 0) {
        return;
      }
    }
    int l;
    for (l = n - 1; curr[j] >= curr[l]; l--) {
      if (l < 0) {
        return;
      }
    }
    swap(&curr[j], &curr[l]);
    for (k = j + 1, l = n - 1; k < l;) {
      swap(&curr[k], &curr[l]);
      k++;
      l--;
    }
    found++;
  }
}
```