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

```asm
<rangematch>:
  endbr64
  push   %r15
  mov    %esi,%r15d
  push   %r14
  push   %r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x18,%rsp
  movzbl (%rdi),%eax
  cmp    $0x21,%al
  sete   %r13b
  cmp    $0x5e,%al
  sete   %al
  or     %eax,%r13d
  cmp    $0x1,%r13b
  mov    %r13b,0xf(%rsp)
  mov    %edx,%r13d
  sbb    $0xffffffffffffffff,%rbx
  and    $0x10,%r13d
  jne    L105
L88:
  movzbl (%rbx),%edi
  lea    0x1(%rbx),%rax
  xor    %r14d,%r14d
  cmp    $0x5d,%dil
  je     L29
  and    $0x1,%r12d
  jmp    L7
L89:
  cmp    %bpl,%r15b
  mov    $0x1,%eax
  cmove  %eax,%r14d
L140:
  lea    0x1(%rbx),%rax
  cmp    $0x5d,%dil
  je     L29
L7:
  cmp    $0x5c,%dil
  je     L221
L159:
  test   %dil,%dil
  je     L206
L84:
  mov    %edi,%ebp
  mov    %rax,%rbx
L226:
  test   %r13d,%r13d
  jne    L107
L20:
  movzbl (%rbx),%edi
  cmp    $0x2d,%dil
  jne    L89
  movzbl 0x1(%rbx),%eax
  cmp    $0x5d,%al
  je     L150
  test   %al,%al
  je     L150
  lea    0x2(%rbx),%rcx
  cmp    $0x5c,%al
  je     L133
L258:
  mov    %rcx,%rbx
L153:
  test   %r13d,%r13d
  jne    L101
L44:
  movzbl (%rbx),%edi
  cmp    %r15b,%bpl
  ja     L140
  cmp    %al,%r15b
  mov    $0x1,%eax
  cmovbe %eax,%r14d
  lea    0x1(%rbx),%rax
  cmp    $0x5d,%dil
  jne    L7
  cs nopw 0x0(%rax,%rax,1)
L29:
  movzbl 0xf(%rsp),%r13d
  cmp    %r14d,%r13d
  jne    L9
  nopl   0x0(%rax,%rax,1)
L206:
  xor    %eax,%eax
L9:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L221:
  test   %r12d,%r12d
  jne    L84
  movzbl 0x1(%rbx),%edi
  lea    0x2(%rbx),%rax
  jmp    L159
  xchg   %ax,%ax
L107:
  call   <tolower@plt>
  mov    %eax,%ebp
  jmp    L20
  nopl   0x0(%rax)
L150:
  cmp    %bpl,%r15b
  je     L214
  add    $0x1,%rbx
  mov    $0x2d,%ebp
  jmp    L226
  nopl   0x0(%rax,%rax,1)
L214:
  lea    0x1(%rbx),%rax
  mov    $0x1,%r14d
  jmp    L84
  nopw   0x0(%rax,%rax,1)
L133:
  test   %r12d,%r12d
  jne    L160
  movzbl 0x2(%rbx),%eax
  lea    0x3(%rbx),%rcx
  test   %al,%al
  jne    L258
  jmp    L206
  nopw   0x0(%rax,%rax,1)
L101:
  movzbl %al,%edi
  call   <tolower@plt>
  jmp    L44
  nopl   (%rax)
L105:
  movzbl %sil,%edi
  call   <tolower@plt>
  mov    %eax,%r15d
  jmp    L88
  nopl   0x0(%rax)
L160:
  mov    %rcx,%rbx
  mov    $0x5c,%eax
  jmp    L153
```

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);
}
```