user: What is the c source code of the assembly code below?

```asm
<rangematch>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r12
  mov    %edx,%edi
  mov    %edx,0x8(%rsp)
  mov    %esi,%r14d
  movzbl (%r12),%eax
  cmp    $0x21,%al
  sete   %dl
  cmp    $0x5e,%al
  sete   %al
  mov    %edx,%ecx
  or     %eax,%ecx
  mov    %cl,0xf(%rsp)
  cmp    $0x1,%cl
  sbb    $0xffffffffffffffff,%r12
  and    $0x10,%edi
  mov    %edi,%r15d
  jne    L16
L28:
  lea    0x1(%r12),%rbp
  movzbl (%r12),%ebx
  cmp    $0x5d,%bl
  je     L46
  mov    $0x0,%r13d
  mov    0x8(%rsp),%eax
  and    $0x1,%eax
  mov    %eax,0x8(%rsp)
  jmp    L178
L16:
  movzbl %sil,%edi
  call   <tolower@plt>
  mov    %eax,%r14d
  jmp    L28
L149:
  cmpl   $0x0,0x8(%rsp)
  jne    L225
  lea    0x2(%r12),%rbp
  movzbl 0x1(%r12),%ebx
  jmp    L163
L47:
  movzbl %bl,%edi
  call   <tolower@plt>
  mov    %eax,%ebx
  jmp    L21
L120:
  lea    0x2(%rbp),%rdx
  cmp    $0x5c,%al
  je     L124
L254:
  mov    %rdx,%rbp
L104:
  test   %r15d,%r15d
  jne    L106
L2:
  cmp    %r14b,%bl
  ja     L189
  cmp    %al,%r14b
  mov    $0x1,%eax
  cmovbe %eax,%r13d
  jmp    L189
L124:
  cmpl   $0x0,0x8(%rsp)
  jne    L254
  lea    0x3(%rbp),%rdx
  movzbl 0x2(%rbp),%eax
  test   %al,%al
  je     L235
  mov    %rdx,%rbp
  jmp    L104
L106:
  movzbl %al,%edi
  call   <tolower@plt>
  jmp    L2
L201:
  cmp    %bl,%r14b
  mov    $0x1,%eax
  cmove  %eax,%r13d
L189:
  lea    0x1(%rbp),%rax
  movzbl 0x0(%rbp),%ebx
  cmp    $0x5d,%bl
  je     L153
L171:
  mov    %rbp,%r12
  mov    %rax,%rbp
L178:
  cmp    $0x5c,%bl
  je     L149
L163:
  test   %bl,%bl
  je     L7
L225:
  test   %r15d,%r15d
  jne    L47
L21:
  movzbl 0x0(%rbp),%edx
  cmp    $0x2d,%dl
  jne    L201
  movzbl 0x1(%rbp),%eax
  cmp    $0x5d,%al
  je     L112
  test   %al,%al
  jne    L120
L112:
  cmp    %bl,%r14b
  je     L228
  lea    0x1(%rbp),%rax
  movzbl 0x0(%rbp),%ebx
  jmp    L171
L46:
  mov    %rbp,%rax
  mov    $0x0,%r13d
L153:
  movzbl 0xf(%rsp),%edx
  cmp    %r13d,%edx
  mov    $0x0,%edx
  cmove  %rdx,%rax
L110:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L7:
  mov    $0x0,%eax
  jmp    L110
L235:
  mov    $0x0,%eax
  jmp    L110
L228:
  lea    0x1(%rbp),%rax
  mov    %edx,%ebx
  mov    $0x1,%r13d
  jmp    L171
```

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