user: Converte this assembly snippet into its equivalent C code:

```asm
<PERM>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x60,%rsp
  mov    %edi,%r12d
  mov    %esi,%ebp
  mov    %edx,%ebx
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  mov    %esi,%edi
  or     %edx,%edi
  or     %r12d,%edi
  not    %edi
  shr    $0x1f,%edi
  call   <assert@plt>
  mov    $0x0,%ecx
L16:
  mov    %r12d,%eax
  sar    %cl,%eax
  and    $0x1,%eax
  mov    %eax,(%rsp,%rcx,4)
  add    $0x1,%rcx
  cmp    $0x5,%rcx
  jne    L16
  mov    $0x1,%esi
  mov    $0x0,%eax
  jmp    L9
L15:
  mov    %ebx,%edx
  mov    %eax,%ecx
  sar    %cl,%edx
  and    $0x1,%edx
  mov    %edx,0x20(%rsp,%rax,4)
L7:
  add    $0x1,%rax
  add    $0x1,%esi
L9:
  cmp    $0x8,%eax
  jle    L15
  lea    -0x9(%rax),%ecx
  mov    %ebp,%edx
  sar    %cl,%edx
  and    $0x1,%edx
  mov    %edx,0x20(%rsp,%rax,4)
  cmp    $0xd,%esi
  jle    L7
  mov    %rsp,%r12
  lea    0x8(%rsp),%r13
  lea    0x4(%rsp),%rbp
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    0x54(%rsp),%edi
  call   <BFLY@plt>
  lea    0xc(%rsp),%rbx
  mov    %rbx,%rdx
  mov    %r12,%rsi
  mov    0x50(%rsp),%edi
  call   <BFLY@plt>
  mov    %rbx,%rdx
  mov    %rbp,%rsi
  mov    0x4c(%rsp),%edi
  call   <BFLY@plt>
  lea    0x10(%rsp),%r14
  mov    %r14,%rdx
  mov    %r13,%rsi
  mov    0x48(%rsp),%edi
  call   <BFLY@plt>
  mov    %rbx,%rdx
  mov    %r12,%rsi
  mov    0x44(%rsp),%edi
  call   <BFLY@plt>
  mov    %r14,%rdx
  mov    %rbp,%rsi
  mov    0x40(%rsp),%edi
  call   <BFLY@plt>
  mov    %r14,%rdx
  mov    %rbx,%rsi
  mov    0x3c(%rsp),%edi
  call   <BFLY@plt>
  mov    %r13,%rdx
  mov    %r12,%rsi
  mov    0x38(%rsp),%edi
  call   <BFLY@plt>
  mov    %rbx,%rdx
  mov    %rbp,%rsi
  mov    0x34(%rsp),%edi
  call   <BFLY@plt>
  mov    %r14,%rdx
  mov    %r12,%rsi
  mov    0x30(%rsp),%edi
  call   <BFLY@plt>
  mov    %r14,%rdx
  mov    %rbx,%rsi
  mov    0x2c(%rsp),%edi
  call   <BFLY@plt>
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    0x28(%rsp),%edi
  call   <BFLY@plt>
  mov    %rbx,%rdx
  mov    %r13,%rsi
  mov    0x24(%rsp),%edi
  call   <BFLY@plt>
  mov    %rbp,%rdx
  mov    %r12,%rsi
  mov    0x20(%rsp),%edi
  call   <BFLY@plt>
  mov    0x4(%rsp),%eax
  lea    (%rax,%rax,1),%edx
  and    $0x2,%edx
  add    (%rsp),%edx
  mov    0x8(%rsp),%eax
  shl    $0x2,%eax
  and    $0x4,%eax
  add    %edx,%eax
  mov    0xc(%rsp),%ebx
  lea    0x0(,%rbx,8),%edx
  and    $0x8,%edx
  add    %eax,%edx
  mov    0x10(%rsp),%eax
  shl    $0x4,%eax
  and    $0x10,%eax
  add    %edx,%eax
  mov    0x58(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L39
  add    $0x60,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L39:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int PERM(int ip1, int ip2, int ip3) {
  int z[5], p[14], op;
  int i;
  assert(ip1 >= 0 && ip2 >= 0 && ip3 >= 0);
  for (i = 0; i < 5; i++)
    z[i] = (ip1 >> i) & 0x1;
  for (i = 0; i < 14; i++) {
    if (i < 9)
      p[i] = ((ip3 >> i) & 0x1);
    else
      p[i] = (ip2 >> (i - 9)) & 0x1;
  }
  BFLY(p[13], &z[1], &z[2]);
  BFLY(p[12], &z[0], &z[3]);
  BFLY(p[11], &z[1], &z[3]);
  BFLY(p[10], &z[2], &z[4]);
  BFLY(p[9], &z[0], &z[3]);
  BFLY(p[8], &z[1], &z[4]);
  BFLY(p[7], &z[3], &z[4]);
  BFLY(p[6], &z[0], &z[2]);
  BFLY(p[5], &z[1], &z[3]);
  BFLY(p[4], &z[0], &z[4]);
  BFLY(p[3], &z[3], &z[4]);
  BFLY(p[2], &z[1], &z[2]);
  BFLY(p[1], &z[2], &z[3]);
  BFLY(p[0], &z[0], &z[1]);
  op = z[0];
  op = op + ((z[1] << 1) & 0x02);
  op = op + ((z[2] << 2) & 0x04);
  op = op + ((z[3] << 3) & 0x08);
  op = op + ((z[4] << 4) & 0x10);
  return (op);
}
```