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

```asm
<udev_queue_get_seqnum_sequence_is_finished>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpq   $0x0,-0x38(%rbp)
  jne    L86
  mov    D13(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L198
L86:
  lea    -0x20(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <open_queue_file@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L112
  mov    $0x1,%eax
  jmp    L198
L112:
  mov    -0x20(%rbp),%rax
  cmp    %rax,-0x40(%rbp)
  jae    L145
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x40(%rbp)
L145:
  mov    -0x40(%rbp),%rax
  cmp    -0x48(%rbp),%rax
  jbe    L81
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x1,%eax
  jmp    L198
L81:
  mov    -0x48(%rbp),%rax
  sub    -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    D28(%rip),%rax
  mov    (%rax),%eax
  sub    $0x1,%eax
  cltq
  cmp    %rax,%rdx
  jbe    L74
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    D15(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L198
L74:
  mov    -0x48(%rbp),%rax
  mov    %eax,%edx
  mov    -0x40(%rbp),%rax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %eax,-0x24(%rbp)
L21:
  lea    -0x20(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <udev_queue_read_seqnum@plt>
  test   %rax,%rax
  js     L92
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_queue_skip_devpath@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  js     L188
  mov    -0x20(%rbp),%rax
  cmp    %rax,-0x40(%rbp)
  jne    L8
  cmpq   $0x0,-0x10(%rbp)
  jle    L8
  addl   $0x1,-0x24(%rbp)
L8:
  cmpq   $0x0,-0x10(%rbp)
  jne    L49
  mov    -0x20(%rbp),%rax
  cmp    %rax,-0x40(%rbp)
  ja     L49
  mov    -0x20(%rbp),%rax
  cmp    %rax,-0x48(%rbp)
  jb     L49
  subl   $0x1,-0x24(%rbp)
L49:
  cmpl   $0x0,-0x24(%rbp)
  jg     L21
  jmp    L12
L92:
  nop
  jmp    L12
L188:
  nop
L12:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  cmpl   $0x0,-0x24(%rbp)
  sete   %al
  movzbl %al,%eax
L198:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L152
  call   <__stack_chk_fail@plt>
L152:
  leave
  ret
```

assistant: ```c
__attribute__((visibility("default"))) int udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_queue, unsigned long long int start, unsigned long long int end) {
  unsigned long long int seqnum;
  ssize_t devpath_len;
  int unfinished;
  FILE *queue_file;
  if (udev_queue == NULL)
    return -EINVAL;
  queue_file = open_queue_file(udev_queue, &seqnum);
  if (queue_file == NULL)
    return 1;
  if (start < seqnum)
    start = seqnum;
  if (start > end) {
    fclose(queue_file);
    return 1;
  }
  if (end - start > INT_MAX - 1) {
    fclose(queue_file);
    return -EOVERFLOW;
  }
  unfinished = end - start;
  do {
    if (udev_queue_read_seqnum(queue_file, &seqnum) < 0)
      break;
    devpath_len = udev_queue_skip_devpath(queue_file);
    if (devpath_len < 0)
      break;
    if (start == seqnum && devpath_len > 0)
      unfinished++;
    if (devpath_len == 0) {
      if (seqnum >= start && seqnum <= end)
        unfinished--;
    }
  } while (unfinished > 0);
  fclose(queue_file);
  return (unfinished == 0);
}
```