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

```asm
<rangematch>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x28,%rsp
  movzbl (%rdi),%eax
  mov    %rcx,0x10(%rsp)
  cmp    $0x21,%al
  sete   %r13b
  cmp    $0x5e,%al
  sete   %al
  or     %eax,%r13d
  cmp    $0x1,%r13b
  mov    %r13b,0xf(%rsp)
  sbb    $0xffffffffffffffff,%rbx
  and    $0x10,%r14d
  jne    L76
L90:
  mov    %ebp,%eax
  movzbl (%rbx),%ecx
  lea    0x1(%rbx),%r13
  and    $0x2,%ebp
  and    $0x1,%eax
  xor    %r15d,%r15d
  mov    %eax,0x8(%rsp)
  jmp    L109
  nopw   0x0(%rax,%rax,1)
L99:
  test   %r14d,%r14d
  jne    L245
L72:
  movzbl 0x0(%r13),%ecx
  cmp    $0x2d,%cl
  je     L258
  cmp    %bl,%r12b
  mov    $0x1,%eax
  cmove  %eax,%r15d
L60:
  add    $0x1,%r13
  cmp    $0x5d,%cl
  je     L117
L109:
  mov    %ecx,%ebx
  cmp    $0x5c,%cl
  je     L180
  test   %bl,%bl
  je     L193
L208:
  cmp    $0x2f,%bl
  jne    L99
  test   %ebp,%ebp
  je     L99
  add    $0x28,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L180:
  mov    0x8(%rsp),%ecx
  test   %ecx,%ecx
  jne    L99
  movzbl 0x0(%r13),%ebx
  add    $0x1,%r13
  test   %bl,%bl
  jne    L208
L193:
  add    $0x28,%rsp
  mov    $0xffffffff,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L258:
  movzbl 0x1(%r13),%eax
  cmp    $0x5d,%al
  je     L228
  test   %al,%al
  je     L228
  lea    0x2(%r13),%r10
  cmp    $0x5c,%al
  je     L43
L154:
  test   %r14d,%r14d
  jne    L134
L2:
  movzbl (%r10),%ecx
  mov    %r10,%r13
  cmp    %bl,%r12b
  jl     L60
  cmp    %al,%r12b
  jg     L60
  mov    $0x1,%r15d
  add    $0x1,%r13
  cmp    $0x5d,%cl
  jne    L109
L117:
  mov    0x10(%rsp),%rax
  mov    %r13,(%rax)
  movzbl 0xf(%rsp),%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  xor    %r15d,%eax
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L245:
  movzbl %bl,%edi
  call   <tolower@plt>
  mov    %eax,%ebx
  jmp    L72
  nop
L228:
  add    $0x1,%r13
  cmp    %bl,%r12b
  mov    $0x2d,%ebx
  jne    L99
  mov    $0x1,%r15d
  jmp    L99
  nopl   (%rax)
L43:
  mov    0x8(%rsp),%edx
  test   %edx,%edx
  jne    L154
  movzbl 0x2(%r13),%eax
  lea    0x3(%r13),%r10
  test   %al,%al
  je     L193
  test   %r14d,%r14d
  je     L2
  cs nopw 0x0(%rax,%rax,1)
L134:
  movzbl %al,%edi
  mov    %r10,0x18(%rsp)
  call   <tolower@plt>
  mov    0x18(%rsp),%r10
  jmp    L2
  nopw   0x0(%rax,%rax,1)
L76:
  movzbl %sil,%edi
  call   <tolower@plt>
  mov    %eax,%r12d
  jmp    L90
```

assistant: ```c
int rangematch(const char *pattern, char test, int flags, char **newp) {
  int negate, ok;
  char c, c2;
  if ((negate = (*pattern == '!' || *pattern == '^')))
    ++pattern;
  if (flags & 0x10)
    test = tolower((unsigned char)test);
  ok = 0;
  c = *pattern++;
  do {
    if (c == '\\' && !(flags & 0x01))
      c = *pattern++;
    if (c == '\0')
      return ((-1));
    if (c == '/' && (flags & 0x02))
      return (0);
    if (flags & 0x10)
      c = tolower((unsigned char)c);
    if (*pattern == '-' && (c2 = *(pattern + 1)) != '\0' && c2 != ']') {
      pattern += 2;
      if (c2 == '\\' && !(flags & 0x01))
        c2 = *pattern++;
      if (c2 == '\0')
        return ((-1));
      if (flags & 0x10)
        c2 = tolower((unsigned char)c2);
      if (c <= test && test <= c2)
        ok = 1;
    } else if (c == test)
      ok = 1;
  } while ((c = *pattern++) != ']');
  *newp = (char *)pattern;
  return (ok == negate ? 0 : 1);
}
```