user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<rangematch>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbx
  mov    %edx,%r15d
  mov    %rcx,0x8(%rsp)
  mov    %esi,%r13d
  movzbl (%rdi),%eax
  cmp    $0x21,%al
  sete   %dl
  cmp    $0x5e,%al
  sete   %al
  or     %eax,%edx
  mov    %dl,0x7(%rsp)
  cmp    $0x1,%dl
  sbb    $0xffffffffffffffff,%rbx
  mov    %r15d,%r14d
  and    $0x10,%r14d
  jne    L210
L155:
  lea    0x1(%rbx),%rbp
  movzbl (%rbx),%ebx
  mov    $0x0,%r12d
  mov    %r15d,%eax
  and    $0x2,%eax
  mov    %eax,(%rsp)
  jmp    L209
L210:
  movzbl %sil,%edi
  call   <tolower@plt>
  mov    %eax,%r13d
  jmp    L155
L55:
  test   $0x1,%r15b
  jne    L29
  movzbl 0x0(%rbp),%ebx
  lea    0x1(%rbp),%rbp
  jmp    L101
L29:
  test   %r14d,%r14d
  jne    L158
L234:
  movzbl 0x0(%rbp),%edx
  cmp    $0x2d,%dl
  je     L144
  cmp    %bl,%r13b
  mov    $0x1,%eax
  cmove  %eax,%r12d
L162:
  lea    0x1(%rbp),%rax
  movzbl 0x0(%rbp),%ebx
  cmp    $0x5d,%bl
  je     L50
L26:
  mov    %rax,%rbp
L209:
  cmp    $0x5c,%bl
  je     L55
L101:
  test   %bl,%bl
  je     L273
  cmp    $0x2f,%bl
  jne    L29
  cmpl   $0x0,(%rsp)
  je     L29
  mov    $0x0,%eax
  jmp    L118
L158:
  movzbl %bl,%edi
  call   <tolower@plt>
  mov    %eax,%ebx
  jmp    L234
L144:
  movzbl 0x1(%rbp),%eax
  cmp    $0x5d,%al
  je     L237
  test   %al,%al
  jne    L167
L237:
  cmp    %bl,%r13b
  je     L184
  lea    0x1(%rbp),%rax
  movzbl 0x0(%rbp),%ebx
  jmp    L26
L167:
  lea    0x2(%rbp),%rdx
  cmp    $0x5c,%al
  je     L2
L263:
  mov    %rdx,%rbp
L231:
  test   %r14d,%r14d
  jne    L58
L250:
  cmp    %bl,%r13b
  jl     L162
  cmp    %al,%r13b
  mov    $0x1,%eax
  cmovle %eax,%r12d
  jmp    L162
L2:
  test   $0x1,%r15b
  jne    L263
  lea    0x3(%rbp),%rdx
  movzbl 0x2(%rbp),%eax
  test   %al,%al
  je     L78
  mov    %rdx,%rbp
  jmp    L231
L58:
  movzbl %al,%edi
  call   <tolower@plt>
  jmp    L250
L50:
  mov    0x8(%rsp),%rcx
  mov    %rax,(%rcx)
  movzbl 0x7(%rsp),%eax
  cmp    %r12d,%eax
  setne  %al
  movzbl %al,%eax
  jmp    L118
L273:
  mov    $0xffffffff,%eax
L118:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L78:
  mov    $0xffffffff,%eax
  jmp    L118
L184:
  lea    0x1(%rbp),%rax
  mov    %edx,%ebx
  mov    $0x1,%r12d
  jmp    L26
```

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