user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<u_lock>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %edx,%r13d
  mov    $0x1b6,%edx
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x58,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  mov    D29(%rip),%rax
  mov    (%rax),%esi
  mov    D98(%rip),%rax
  or     (%rax),%esi
  call   <open@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  js     L297
  mov    D65(%rip),%rax
  mov    %r12d,%edi
  mov    (%rax),%rdx
  mov    D22(%rip),%rax
  mov    (%rax),%esi
  call   <fcntl@plt>
  test   %ebp,%ebp
  jne    L55
  test   %r13d,%r13d
  mov    D10(%rip),%r14
  lea    0x10(%rsp),%rbp
  mov    D114(%rip),%r13
  jne    L164
  lea    0x20(%rsp),%rax
  mov    D76(%rip),%r15
  mov    %rax,0x8(%rsp)
  jmp    L167
  nopl   0x0(%rax)
L69:
  mov    0x8(%rsp),%rsi
  mov    %r12d,%edi
  call   <fstat@plt>
  test   %rax,%rax
  jne    L119
  lea    0x30(%rsp),%rsi
  mov    %rbx,%rdi
  call   <stat@plt>
  test   %rax,%rax
  jne    L119
  mov    0x30(%rsp),%rax
  cmp    %rax,0x20(%rsp)
  jne    L83
  mov    0x38(%rsp),%rax
  cmp    %rax,0x28(%rsp)
  je     L297
L83:
  mov    %r12d,%edi
  call   <close@plt>
L167:
  mov    (%r14),%eax
  mov    (%r15),%esi
  mov    %rbp,%rdx
  mov    %r12d,%edi
  movl   $0x0,0x1c(%rsp)
  mov    %eax,0x18(%rsp)
  mov    0x0(%r13),%eax
  movl   $0x1,0x10(%rsp)
  mov    %eax,0x14(%rsp)
  call   <fcntl@plt>
  test   %eax,%eax
  je     L69
  nopl   (%rax)
L119:
  mov    %r12d,%edi
  mov    $0xffffffff,%r12d
  call   <close@plt>
L297:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L306
  add    $0x58,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L55:
  test   %r13d,%r13d
  lea    0x10(%rsp),%rbp
  mov    D114(%rip),%r13
  jne    L109
  lea    0x20(%rsp),%rax
  mov    D76(%rip),%r15
  mov    D5(%rip),%r14
  mov    %rax,0x8(%rsp)
  jmp    L314
  nopw   0x0(%rax,%rax,1)
L239:
  mov    0x8(%rsp),%rsi
  mov    %r12d,%edi
  call   <fstat@plt>
  test   %rax,%rax
  jne    L119
  lea    0x30(%rsp),%rsi
  mov    %rbx,%rdi
  call   <stat@plt>
  test   %rax,%rax
  jne    L119
  mov    0x30(%rsp),%rax
  cmp    %rax,0x20(%rsp)
  jne    L317
  mov    0x38(%rsp),%rax
  cmp    %rax,0x28(%rsp)
  je     L297
L317:
  mov    %r12d,%edi
  call   <close@plt>
L314:
  mov    (%r14),%eax
  mov    (%r15),%esi
  mov    %rbp,%rdx
  mov    %r12d,%edi
  movl   $0x0,0x1c(%rsp)
  mov    %eax,0x18(%rsp)
  mov    0x0(%r13),%eax
  movl   $0x1,0x10(%rsp)
  mov    %eax,0x14(%rsp)
  call   <fcntl@plt>
  test   %eax,%eax
  je     L239
  jmp    L119
  nopw   0x0(%rax,%rax,1)
L164:
  lea    0x20(%rsp),%rax
  mov    D77(%rip),%r15
  mov    %rax,0x8(%rsp)
  jmp    L274
  nopl   0x0(%rax,%rax,1)
L123:
  mov    0x8(%rsp),%rsi
  mov    %r12d,%edi
  call   <fstat@plt>
  test   %rax,%rax
  jne    L119
  lea    0x30(%rsp),%rsi
  mov    %rbx,%rdi
  call   <stat@plt>
  test   %rax,%rax
  jne    L119
  mov    0x30(%rsp),%rax
  cmp    %rax,0x20(%rsp)
  jne    L319
  mov    0x38(%rsp),%rax
  cmp    %rax,0x28(%rsp)
  je     L297
L319:
  mov    %r12d,%edi
  call   <close@plt>
L274:
  mov    (%r14),%eax
  mov    (%r15),%esi
  mov    %rbp,%rdx
  mov    %r12d,%edi
  movl   $0x0,0x1c(%rsp)
  mov    %eax,0x18(%rsp)
  mov    0x0(%r13),%eax
  movl   $0x1,0x10(%rsp)
  mov    %eax,0x14(%rsp)
  call   <fcntl@plt>
  test   %eax,%eax
  je     L123
  jmp    L119
  nopw   0x0(%rax,%rax,1)
L109:
  lea    0x20(%rsp),%rax
  mov    D77(%rip),%r15
  mov    D5(%rip),%r14
  mov    %rax,0x8(%rsp)
  jmp    L97
  nopw   0x0(%rax,%rax,1)
L259:
  mov    0x8(%rsp),%rsi
  mov    %r12d,%edi
  call   <fstat@plt>
  test   %rax,%rax
  jne    L119
  lea    0x30(%rsp),%rsi
  mov    %rbx,%rdi
  call   <stat@plt>
  test   %rax,%rax
  jne    L119
  mov    0x30(%rsp),%rax
  cmp    %rax,0x20(%rsp)
  jne    L207
  mov    0x38(%rsp),%rax
  cmp    %rax,0x28(%rsp)
  je     L297
L207:
  mov    %r12d,%edi
  call   <close@plt>
L97:
  mov    (%r14),%eax
  mov    (%r15),%esi
  mov    %rbp,%rdx
  mov    %r12d,%edi
  movl   $0x0,0x1c(%rsp)
  mov    %eax,0x18(%rsp)
  mov    0x0(%r13),%eax
  movl   $0x1,0x10(%rsp)
  mov    %eax,0x14(%rsp)
  call   <fcntl@plt>
  test   %eax,%eax
  je     L259
  jmp    L119
L306:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int u_lock(const char *path, int excl, int dowait) {
  int h;
  h = open(path, O_RDWR | O_CREAT, 0666);
  if (!((h) >= 0))
    return h;
  fcntl(h, F_SETFD, FD_CLOEXEC);
  for (;;) {
    int success;
    struct flock lck = {0};
    lck.l_type = excl ? F_WRLCK : F_RDLCK;
    lck.l_whence = SEEK_SET;
    lck.l_len = 1;
    success = !fcntl(h, dowait ? F_SETLKW : F_SETLK, &lck);
    if (!success)
      break;
    struct stat s1, s2;
    if (fstat(h, &s1) || stat(path, &s2))
      break;
    success = s1.st_dev == s2.st_dev && s1.st_ino == s2.st_ino;
    if (success)
      return h;
    close(h);
  }
  close(h);
  return -1;
}
```