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

```asm
<rangematch>:
  endbr64
  push   %r15
  push   %r14
  mov    %esi,%r14d
  push   %r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  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)
  mov    %edx,%r13d
  sbb    $0xffffffffffffffff,%rbx
  and    $0x10,%r13d
  jne    L101
L147:
  mov    %r12d,%eax
  movzbl (%rbx),%edx
  lea    0x1(%rbx),%rbp
  xor    %r15d,%r15d
  and    $0x2,%eax
  and    $0x1,%r12d
  mov    %eax,0x8(%rsp)
  jmp    L237
  nopl   (%rax)
L150:
  test   %r13d,%r13d
  jne    L205
L136:
  movzbl 0x0(%rbp),%edx
  cmp    $0x2d,%dl
  je     L52
  cmp    %bl,%r14b
  mov    $0x1,%eax
  cmove  %eax,%r15d
L116:
  add    $0x1,%rbp
  cmp    $0x5d,%dl
  je     L59
L237:
  mov    %edx,%ebx
  cmp    $0x5c,%dl
  je     L57
  test   %bl,%bl
  je     L95
L166:
  cmp    $0x2f,%bl
  jne    L150
  mov    0x8(%rsp),%eax
  test   %eax,%eax
  je     L150
  add    $0x28,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L57:
  test   %r12d,%r12d
  jne    L150
  movzbl 0x0(%rbp),%ebx
  add    $0x1,%rbp
  test   %bl,%bl
  jne    L166
L95:
  add    $0x28,%rsp
  mov    $0xffffffff,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L52:
  movzbl 0x1(%rbp),%eax
  cmp    $0x5d,%al
  je     L117
  test   %al,%al
  je     L117
  lea    0x2(%rbp),%rsi
  cmp    $0x5c,%al
  je     L223
L240:
  test   %r13d,%r13d
  jne    L70
L228:
  movzbl (%rsi),%edx
  mov    %rsi,%rbp
  cmp    %bl,%r14b
  jl     L116
  cmp    %al,%r14b
  jg     L116
  mov    $0x1,%r15d
  add    $0x1,%rbp
  cmp    $0x5d,%dl
  jne    L237
L59:
  mov    0x10(%rsp),%rax
  mov    %rbp,(%rax)
  movzbl 0xf(%rsp),%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  xor    %r15d,%eax
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L205:
  movzbl %bl,%edi
  call   <tolower@plt>
  mov    %eax,%ebx
  jmp    L136
  nop
L117:
  add    $0x1,%rbp
  cmp    %bl,%r14b
  mov    $0x2d,%ebx
  jne    L150
  mov    $0x1,%r15d
  jmp    L150
  nopl   (%rax)
L223:
  test   %r12d,%r12d
  jne    L240
  movzbl 0x2(%rbp),%eax
  lea    0x3(%rbp),%rsi
  test   %al,%al
  je     L95
  test   %r13d,%r13d
  je     L228
  nopw   0x0(%rax,%rax,1)
L70:
  movzbl %al,%edi
  mov    %rsi,0x18(%rsp)
  call   <tolower@plt>
  mov    0x18(%rsp),%rsi
  jmp    L228
  nop
L101:
  movzbl %sil,%edi
  call   <tolower@plt>
  mov    %eax,%r14d
  jmp    L147
```

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