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

```asm
<is_fido_security_token_desc>:
  endbr64
  test   %rsi,%rsi
  je     L162
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r10
  mov    %rsi,%r9
  mov    $0x0,%r8d
  mov    $0x0,%ebx
  mov    $0x4,%r12d
  jmp    L195
L287:
  mov    0x4(%r10,%rax,1),%eax
  add    $0x3,%eax
  cltq
  add    %rax,%r8
L10:
  cmp    %r9,%r8
  jae    L258
L195:
  lea    0x0(,%r8,4),%rax
  mov    (%r10,%r8,4),%esi
  cmp    $0xfe,%esi
  jne    L238
  lea    0x1(%r8),%rdx
  cmp    %r9,%rdx
  jb     L287
  mov    D6(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
L5:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L238:
  mov    %esi,%ebp
  sar    $0x4,%ebp
  mov    %esi,%r11d
  sar    $0x2,%r11d
  and    $0x3,%r11d
  and    $0x3,%esi
  cmp    $0x2,%esi
  jg     L202
  movslq %esi,%rsi
  lea    0x1(%r8),%rax
  lea    (%rsi,%rax,1),%r8
  cmp    %r9,%r8
  ja     L39
  test   %rsi,%rsi
  jne    L252
  test   %ebp,%ebp
  sete   %dl
  cmp    $0x1,%r11d
  jne    L13
  mov    %rax,%r8
  mov    $0x0,%edi
  test   %dl,%dl
  jne    L161
L13:
  cmp    $0x2,%r11d
  jne    L264
  test   %dl,%dl
  je     L264
  mov    %rax,%r8
  mov    $0x0,%edi
  jmp    L286
L39:
  mov    D6(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L5
L185:
  mov    D6(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L5
L4:
  cmp    $0x2,%r11d
  jne    L10
  test   %al,%al
  je     L10
  cmp    $0x4,%rsi
  je     L178
L286:
  mov    %di,%bx
L12:
  cmp    $0xf1d00001,%ebx
  jne    L10
  mov    $0x1,%eax
  jmp    L5
L178:
  mov    %edi,%ebx
  jmp    L12
L258:
  mov    $0x0,%eax
  jmp    L5
L162:
  mov    $0x0,%eax
  ret
L202:
  lea    0x1(%r8),%rax
  add    $0x5,%r8
  cmp    %r8,%r9
  jb     L39
  mov    %r12,%rsi
L252:
  lea    (%r10,%rax,4),%r13
  mov    $0x0,%eax
  mov    $0x0,%edi
L160:
  lea    0x0(,%rax,8),%ecx
  mov    0x0(%r13,%rax,4),%edx
  shl    %cl,%edx
  or     %edx,%edi
  add    $0x1,%rax
  cmp    %rsi,%rax
  jb     L160
  test   %ebp,%ebp
  sete   %al
  cmp    $0x1,%r11d
  jne    L4
  test   %al,%al
  je     L4
  cmp    $0x2,%rsi
  ja     L185
L161:
  mov    %edi,%ebx
  shl    $0x10,%ebx
  jmp    L10
L264:
  mov    %rax,%r8
  jmp    L10
```

assistant: ```c
int is_fido_security_token_desc(const uint8_t *desc, size_t desc_len) {
  uint32_t usage = 0;
  for (size_t pos = 0; pos < desc_len;) {
    uint8_t tag, type, size_code;
    size_t size;
    uint32_t value;
    if (desc[pos] == 0xfeu) {
      if (pos + 1 >= desc_len)
        return -EINVAL;
      pos += desc[pos + 1] + 3;
      continue;
    }
    tag = desc[pos] >> 4;
    type = (desc[pos] >> 2) & 0x3;
    size_code = desc[pos] & 0x3;
    size = size_code < 3 ? size_code : 4;
    pos++;
    if (pos + size > desc_len)
      return -EINVAL;
    value = 0;
    for (size_t i = 0; i < size; i++)
      value |= (uint32_t)desc[pos + i] << (8 * i);
    pos += size;
    if (type == 0x1u && tag == 0x0u) {
      if (size > 2)
        return -EINVAL;
      usage = (value & 0x0000ffffu) << 16;
    }
    if (type == 0x2u && tag == 0x0u) {
      if (size == 4)
        usage = value;
      else
        usage = (usage & 0xffff0000u) | (value & 0x0000ffffu);
      if (usage == 0xf1d00001u)
        return 1;
    }
  }
  return 0;
}
```