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

```asm
<permute>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  mov    %rdx,%r15
  push   %r14
  push   %r13
  push   %r12
  lea    0x7(%rsi),%r12d
  push   %rbx
  sub    $0x68,%rsp
  mov    %rdi,-0x70(%rbp)
  mov    %esi,-0x44(%rbp)
  mov    %rcx,-0x60(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  test   %esi,%esi
  cmovns %esi,%r12d
  sar    $0x3,%r12d
  add    $0x1,%r12d
  mov    %r12d,%edi
  call   <malloc@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L36
L108:
  lea    0x17(%r15),%rax
  mov    %rsp,%rcx
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L42
L62:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L62
L42:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L29
L168:
  lea    0xf(%rsp),%rax
  mov    %r12d,%edx
  xor    %esi,%esi
  mov    %r14,%rdi
  and    $0xfffffffffffffff0,%rax
  mov    %r15,%r13
  mov    %rax,-0x88(%rbp)
  call   <memset@plt>
  mov    -0x70(%rbp),%rax
  movslq -0x44(%rbp),%rbx
  movq   $0x0,-0x58(%rbp)
  mov    %rax,-0x78(%rbp)
  mov    %rbx,-0x80(%rbp)
  test   %ebx,%ebx
  jg     L131
  jmp    L4
  nopl   0x0(%rax)
L222:
  addq   $0x1,-0x58(%rbp)
  mov    -0x58(%rbp),%rax
  add    %r13,-0x78(%rbp)
  cmp    %rax,-0x80(%rbp)
  je     L4
L131:
  mov    -0x58(%rbp),%rax
  mov    %eax,%r11d
  mov    %eax,%ecx
  mov    %eax,%r12d
  sar    $0x3,%r11d
  and    $0x7,%ecx
  movslq %r11d,%r11
  add    %r14,%r11
  movzbl (%r11),%eax
  bt     %ecx,%eax
  jb     L222
  mov    -0x78(%rbp),%rsi
  mov    -0x88(%rbp),%rdi
  mov    %r13,%rdx
  mov    %ecx,-0x48(%rbp)
  mov    %r11,-0x50(%rbp)
  mov    %rsi,%rbx
  call   <memcpy@plt>
  mov    -0x58(%rbp),%rax
  mov    -0x60(%rbp),%rdi
  mov    -0x50(%rbp),%r11
  mov    -0x48(%rbp),%ecx
  mov    (%rdi,%rax,4),%r15d
  mov    %eax,-0x64(%rbp)
  cmp    %eax,%r15d
  je     L139
  mov    %r13,%rax
  mov    %r12d,%r13d
  mov    %rax,%r12
  jmp    L81
L20:
  cmp    %r13d,-0x44(%rbp)
  jle    L10
L63:
  test   %r13d,%r13d
  js     L10
L5:
  movslq %r15d,%r9
  movslq %r13d,%rdi
  mov    -0x70(%rbp),%rax
  mov    %r12,%rdx
  mov    %r9,%rsi
  imul   %r12,%rdi
  mov    %r9,-0x50(%rbp)
  imul   %r12,%rsi
  add    %rax,%rdi
  lea    (%rax,%rsi,1),%rbx
  mov    %rbx,%rsi
  call   <memcpy@plt>
  mov    %r13d,%eax
  mov    %r13d,%ecx
  mov    $0x1,%edx
  sar    $0x3,%eax
  and    $0x7,%ecx
  mov    -0x50(%rbp),%r9
  mov    %r15d,%r13d
  cltq
  shl    %cl,%edx
  or     %dl,(%r14,%rax,1)
  mov    -0x60(%rbp),%rax
  mov    (%rax,%r9,4),%eax
  cmp    -0x64(%rbp),%eax
  je     L70
  mov    %eax,%r15d
L81:
  cmp    %r15d,-0x44(%rbp)
  mov    %r15d,%eax
  setle  %bl
  shr    $0x1f,%eax
  or     %al,%bl
  mov    %bl,-0x48(%rbp)
  je     L20
  xor    %eax,%eax
  call   <abort@plt>
  cmp    %r13d,-0x44(%rbp)
  jg     L63
  nopw   0x0(%rax,%rax,1)
L10:
  xor    %eax,%eax
  call   <abort@plt>
  jmp    L5
  nopl   0x0(%rax)
L70:
  mov    %r15d,%r11d
  mov    %r15d,%ecx
  mov    %r12,%r13
  sar    $0x3,%r11d
  and    $0x7,%ecx
  movslq %r11d,%r11
  add    %r14,%r11
L137:
  cmpb   $0x0,-0x48(%rbp)
  jne    L33
L26:
  mov    -0x88(%rbp),%rsi
  mov    %r13,%rdx
  mov    %rbx,%rdi
  mov    %ecx,-0x48(%rbp)
  mov    %r11,-0x50(%rbp)
  call   <memcpy@plt>
  mov    -0x48(%rbp),%ecx
  mov    -0x50(%rbp),%r11
  mov    $0x1,%eax
  shl    %cl,%eax
  or     %al,(%r11)
  jmp    L222
  nopl   0x0(%rax,%rax,1)
L4:
  mov    %r14,%rdi
  call   <free@plt>
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L145
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  cs nopw 0x0(%rax,%rax,1)
L33:
  xor    %eax,%eax
  mov    %ecx,-0x48(%rbp)
  mov    %r11,-0x50(%rbp)
  call   <abort@plt>
  mov    -0x48(%rbp),%ecx
  mov    -0x50(%rbp),%r11
  jmp    L26
  nopw   0x0(%rax,%rax,1)
L139:
  cmp    %r15d,-0x44(%rbp)
  setle  -0x48(%rbp)
  jmp    L137
L29:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L168
L36:
  lea    D7(%rip),%rsi
  mov    $0xffffffff,%edi
  call   <fastpm_raise@plt>
  jmp    L108
L145:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D7
type: string

tool: D7: no memory for 'done'


assistant: ```c
void permute(void *data, int np, size_t elsize, int *ind) {
  unsigned char *done = malloc(np / 8 + 1);
  if (!done) {
    fastpm_raise(-1, "no memory for 'done'\n");
  }
  char *q = data;
  char *temp1 = alloca(elsize);
  int j, i;
  memset(done, 0, np / 8 + 1);
  for (i = 0; i < np; i++) {
    if (done[i >> 3] & (1 << (i & 7)))
      continue;
    if (i >= np || i < 0) {
      abort();
    }
    memcpy(temp1, &q[i * elsize], elsize);
    int ii = i;
    for (j = ind[ii]; j != i; ii = j, j = ind[j]) {
      if (j >= np || j < 0) {
        abort();
      }
      if (ii >= np || ii < 0) {
        abort();
      }
      memcpy(&q[ii * elsize], &q[j * elsize], elsize);
      ;
      done[ii >> 3] |= 1 << (ii & 7);
    }
    if (ii >= np || ii < 0) {
      abort();
    }
    memcpy(&q[ii * elsize], temp1, elsize);
    done[ii >> 3] |= 1 << (ii & 7);
  }
  free(done);
}
```