user: What would the C source look like for the assembly code provided here?

```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    L46
L220:
  movzbl (%rbx),%edi
  lea    0x1(%rbx),%rax
  xor    %r14d,%r14d
  cmp    $0x5d,%dil
  je     L19
  and    $0x1,%r12d
  jmp    L108
L174:
  cmp    %bpl,%r15b
  mov    $0x1,%eax
  cmove  %eax,%r14d
L132:
  lea    0x1(%rbx),%rax
  cmp    $0x5d,%dil
  je     L19
L108:
  cmp    $0x5c,%dil
  je     L206
L181:
  test   %dil,%dil
  je     L217
L260:
  mov    %edi,%ebp
  mov    %rax,%rbx
L100:
  test   %r13d,%r13d
  jne    L226
L6:
  movzbl (%rbx),%edi
  cmp    $0x2d,%dil
  jne    L174
  movzbl 0x1(%rbx),%eax
  cmp    $0x5d,%al
  je     L80
  test   %al,%al
  je     L80
  lea    0x2(%rbx),%rcx
  cmp    $0x5c,%al
  je     L133
L16:
  mov    %rcx,%rbx
L195:
  test   %r13d,%r13d
  jne    L104
L78:
  movzbl (%rbx),%edi
  cmp    %r15b,%bpl
  ja     L132
  cmp    %al,%r15b
  mov    $0x1,%eax
  cmovbe %eax,%r14d
  lea    0x1(%rbx),%rax
  cmp    $0x5d,%dil
  jne    L108
  cs nopw 0x0(%rax,%rax,1)
L19:
  movzbl 0xf(%rsp),%r13d
  cmp    %r14d,%r13d
  jne    L147
  nopl   0x0(%rax,%rax,1)
L217:
  xor    %eax,%eax
L147:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L206:
  test   %r12d,%r12d
  jne    L260
  movzbl 0x1(%rbx),%edi
  lea    0x2(%rbx),%rax
  jmp    L181
  xchg   %ax,%ax
L226:
  call   <tolower@plt>
  mov    %eax,%ebp
  jmp    L6
  nopl   0x0(%rax)
L80:
  cmp    %bpl,%r15b
  je     L10
  add    $0x1,%rbx
  mov    $0x2d,%ebp
  jmp    L100
  nopl   0x0(%rax,%rax,1)
L10:
  lea    0x1(%rbx),%rax
  mov    $0x1,%r14d
  jmp    L260
  nopw   0x0(%rax,%rax,1)
L133:
  test   %r12d,%r12d
  jne    L249
  movzbl 0x2(%rbx),%eax
  lea    0x3(%rbx),%rcx
  test   %al,%al
  jne    L16
  jmp    L217
  nopw   0x0(%rax,%rax,1)
L104:
  movzbl %al,%edi
  call   <tolower@plt>
  jmp    L78
  nopl   (%rax)
L46:
  movzbl %sil,%edi
  call   <tolower@plt>
  mov    %eax,%r15d
  jmp    L220
  nopl   0x0(%rax)
L249:
  mov    %rcx,%rbx
  mov    $0x5c,%eax
  jmp    L195
```

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