user: Please show me the C implementation that matches the assembly code listed below:

```asm
<rangematch>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,%eax
  mov    %edx,-0x20(%rbp)
  mov    %al,-0x1c(%rbp)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x21,%al
  je     L30
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x5e,%al
  jne    L2
L30:
  mov    $0x1,%eax
  jmp    L228
L2:
  mov    $0x0,%eax
L228:
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L251
  addq   $0x1,-0x18(%rbp)
L251:
  mov    -0x20(%rbp),%eax
  and    $0x10,%eax
  test   %eax,%eax
  je     L126
  movzbl -0x1c(%rbp),%eax
  movzbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %al,-0x1c(%rbp)
L126:
  movl   $0x0,-0x8(%rbp)
  jmp    L35
L65:
  cmpb   $0x5c,-0xa(%rbp)
  jne    L82
  mov    -0x20(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  jne    L82
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0xa(%rbp)
L82:
  cmpb   $0x0,-0xa(%rbp)
  jne    L91
  mov    $0x0,%eax
  jmp    L235
L91:
  mov    -0x20(%rbp),%eax
  and    $0x10,%eax
  test   %eax,%eax
  je     L39
  movzbl -0xa(%rbp),%eax
  movzbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %al,-0xa(%rbp)
L39:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2d,%al
  jne    L37
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  mov    %al,-0x9(%rbp)
  cmpb   $0x0,-0x9(%rbp)
  je     L37
  cmpb   $0x5d,-0x9(%rbp)
  je     L37
  addq   $0x2,-0x18(%rbp)
  cmpb   $0x5c,-0x9(%rbp)
  jne    L119
  mov    -0x20(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  jne    L119
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0x9(%rbp)
L119:
  cmpb   $0x0,-0x9(%rbp)
  jne    L69
  mov    $0x0,%eax
  jmp    L235
L69:
  mov    -0x20(%rbp),%eax
  and    $0x10,%eax
  test   %eax,%eax
  je     L71
  movzbl -0x9(%rbp),%eax
  movzbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %al,-0x9(%rbp)
L71:
  movzbl -0xa(%rbp),%edx
  movzbl -0x1c(%rbp),%eax
  cmp    %al,%dl
  ja     L35
  movzbl -0x1c(%rbp),%edx
  movzbl -0x9(%rbp),%eax
  cmp    %al,%dl
  ja     L35
  movl   $0x1,-0x8(%rbp)
  jmp    L35
L37:
  movzbl -0xa(%rbp),%eax
  cmp    -0x1c(%rbp),%al
  jne    L35
  movl   $0x1,-0x8(%rbp)
L35:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0xa(%rbp)
  cmpb   $0x5d,-0xa(%rbp)
  jne    L65
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  je     L78
  mov    -0x18(%rbp),%rax
  jmp    L235
L78:
  mov    $0x0,%eax
L235:
  leave
  ret
```

assistant: ```c
const char *rangematch(const char *pattern, char test, int flags) {
  int negate, ok;
  char c, c2;
  if ((negate = (*pattern == '!' || *pattern == '^')))
    ++pattern;
  if (flags & 0x10)
    test = tolower((unsigned char)test);
  for (ok = 0; (c = *pattern++) != ']';) {
    if (c == '\\' && !(flags & 0x01))
      c = *pattern++;
    if (c == '\0')
      return (NULL);
    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 (NULL);
      if (flags & 0x10)
        c2 = tolower((unsigned char)c2);
      if ((unsigned char)c <= (unsigned char)test && (unsigned char)test <= (unsigned char)c2)
        ok = 1;
    } else if (c == test)
      ok = 1;
  }
  return (ok == negate ? NULL : pattern);
}
```