user: 这段汇编代码用C语言表示是什么样的:

```asm
<crypt_loop_attach>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%r15
  mov    %rsi,%r12
  mov    %edx,%r14d
  mov    %ecx,%r13d
  mov    %r8,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsp)
  movq   $0x0,0x8(%rsp)
  movq   $0x0,0x10(%rsp)
  cmpl   $0x0,(%r8)
  je     L117
  mov    D2(%rip),%rax
  mov    (%rax),%esi
L41:
  mov    D83(%rip),%rax
  or     (%rax),%esi
  mov    %r12,%rdi
  call   <open@plt>
  mov    %eax,%ebp
  test   %eax,%eax
  js     L44
L99:
  cmpl   $0x0,(%rbx)
  je     L145
  mov    D2(%rip),%rax
  mov    (%rax),%esi
L204:
  mov    %r15,%rdi
  call   <open@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  js     L7
  mov    D101(%rip),%rax
  mov    (%rax),%edx
  mov    %r12,%rsi
  mov    0x8(%rsp),%rdi
  call   <strncpy@plt>
  mov    %r14d,(%rsp)
  test   %r13d,%r13d
  je     L90
  orl    $0x4,0x4(%rsp)
L90:
  mov    %ebp,%edx
  mov    D103(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  mov    $0x0,%eax
  call   <ioctl@plt>
  test   %rax,%rax
  js     L137
  mov    %rsp,%rdx
  mov    D62(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  mov    $0x0,%eax
  call   <ioctl@plt>
  test   %rax,%rax
  js     L92
  test   %r13d,%r13d
  jne    L211
L122:
  test   %ebp,%ebp
  js     L254
  mov    $0x0,%r12d
  jmp    L83
L117:
  mov    D6(%rip),%rax
  mov    (%rax),%esi
  jmp    L41
L44:
  mov    D87(%rip),%rdx
  mov    D97(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  je     L223
L225:
  mov    $0x1,%r12d
  mov    $0xffffffff,%ebx
  jmp    L251
L223:
  cmpl   $0x0,(%rbx)
  jne    L225
  movl   $0x1,(%rbx)
  mov    D2(%rip),%rax
  mov    (%rax),%esi
  mov    D83(%rip),%rax
  or     (%rax),%esi
  mov    %r12,%rdi
  call   <open@plt>
  mov    %eax,%ebp
  test   %eax,%eax
  jns    L99
  jmp    L225
L145:
  mov    D6(%rip),%rax
  mov    (%rax),%esi
  jmp    L204
L92:
  mov    $0x0,%edx
  mov    D54(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  mov    $0x0,%eax
  call   <ioctl@plt>
L137:
  mov    %ebx,%edi
  call   <close@plt>
  mov    $0x1,%r12d
  test   %ebp,%ebp
  js     L183
L83:
  mov    %ebp,%edi
  call   <close@plt>
L251:
  test   %r12d,%r12d
  mov    $0xffffffff,%eax
  cmovne %eax,%ebx
L254:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L237
  mov    %ebx,%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L211:
  mov    %rsp,%r12
  mov    $0x18,%edx
  mov    $0x0,%esi
  mov    %r12,%rdi
  call   <memset@plt>
  mov    %r12,%rdx
  mov    D137(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  mov    $0x0,%eax
  call   <ioctl@plt>
  test   %rax,%rax
  js     L193
  testb  $0x4,0x4(%rsp)
  jne    L122
L193:
  mov    $0x0,%edx
  mov    D54(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  mov    $0x0,%eax
  call   <ioctl@plt>
  jmp    L137
L183:
  mov    $0xffffffff,%ebx
  jmp    L254
L7:
  test   %ebp,%ebp
  js     L212
  mov    $0x1,%r12d
  jmp    L83
L212:
  mov    $0xffffffff,%ebx
  jmp    L254
L237:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int crypt_loop_attach(const char *loop, const char *file, int offset, int autoclear, int *readonly) {
  struct loop_info64 lo64 = {0};
  int loop_fd = -1, file_fd = -1, r = 1;
  file_fd = open(file, (*readonly ? O_RDONLY : O_RDWR) | O_EXCL);
  if (file_fd < 0 && errno == EROFS && !*readonly) {
    *readonly = 1;
    file_fd = open(file, O_RDONLY | O_EXCL);
  }
  if (file_fd < 0)
    goto out;
  loop_fd = open(loop, *readonly ? O_RDONLY : O_RDWR);
  if (loop_fd < 0)
    goto out;
  strncpy((char *)lo64.lo_file_name, file, LO_NAME_SIZE);
  lo64.lo_offset = offset;
  if (autoclear)
    lo64.lo_flags |= 4;
  if (ioctl(loop_fd, LOOP_SET_FD, file_fd) < 0)
    goto out;
  if (ioctl(loop_fd, LOOP_SET_STATUS64, &lo64) < 0) {
    (void)ioctl(loop_fd, LOOP_CLR_FD, 0);
    goto out;
  }
  if (autoclear) {
    memset(&lo64, 0, sizeof(lo64));
    if (ioctl(loop_fd, LOOP_GET_STATUS64, &lo64) < 0 || !(lo64.lo_flags & 4)) {
      (void)ioctl(loop_fd, LOOP_CLR_FD, 0);
      goto out;
    }
  }
  r = 0;
out:
  if (r && loop_fd >= 0)
    close(loop_fd);
  if (file_fd >= 0)
    close(file_fd);
  return r ? -1 : loop_fd;
}
```