user: Converte this assembly snippet into its equivalent C code:

```asm
<pattern_match_length>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %ecx,-0x40(%rbp)
  mov    %r8d,-0x4c(%rbp)
  jmp    L521
L242:
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    $0x5c,%eax
  je     L33
  cmp    $0x5c,%eax
  jg     L376
  cmp    $0x5b,%eax
  je     L86
  cmp    $0x5b,%eax
  jg     L376
  cmp    $0x2a,%eax
  je     L186
  cmp    $0x3f,%eax
  je     L428
  jmp    L376
L119:
  addq   $0x1,-0x48(%rbp)
  subl   $0x1,-0x40(%rbp)
L186:
  mov    -0x48(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x2a,%al
  je     L119
  cmpl   $0x1,-0x40(%rbp)
  jne    L450
  mov    $0x1,%eax
  jmp    L80
L92:
  mov    -0x40(%rbp),%eax
  lea    -0x1(%rax),%esi
  mov    -0x48(%rbp),%rax
  lea    0x1(%rax),%rdi
  mov    -0x4c(%rbp),%ecx
  mov    -0x3c(%rbp),%edx
  mov    -0x38(%rbp),%rax
  mov    %ecx,%r8d
  mov    %edx,%ecx
  mov    %rax,%rdx
  call   <pattern_match_length>
  test   %eax,%eax
  je     L11
  mov    $0x1,%eax
  jmp    L80
L11:
  addq   $0x1,-0x38(%rbp)
  subl   $0x1,-0x3c(%rbp)
L450:
  cmpl   $0x0,-0x3c(%rbp)
  jne    L92
  mov    $0x0,%eax
  jmp    L80
L428:
  cmpl   $0x0,-0x3c(%rbp)
  jne    L487
  mov    $0x0,%eax
  jmp    L80
L487:
  addq   $0x1,-0x38(%rbp)
  subl   $0x1,-0x3c(%rbp)
  jmp    L313
L86:
  addq   $0x1,-0x48(%rbp)
  subl   $0x1,-0x40(%rbp)
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x5e,%al
  sete   %al
  movzbl %al,%eax
  mov    %eax,-0x18(%rbp)
  cmpl   $0x0,-0x18(%rbp)
  je     L161
  addq   $0x1,-0x48(%rbp)
  subl   $0x1,-0x40(%rbp)
L161:
  movl   $0x0,-0x28(%rbp)
L173:
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x5c,%al
  jne    L40
  addq   $0x1,-0x48(%rbp)
  subl   $0x1,-0x40(%rbp)
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  jne    L271
  movl   $0x1,-0x28(%rbp)
  jmp    L271
L40:
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x5d,%al
  je     L29
  cmpl   $0x0,-0x40(%rbp)
  jne    L377
  subq   $0x1,-0x48(%rbp)
  addl   $0x1,-0x40(%rbp)
  jmp    L418
L377:
  mov    -0x48(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x2d,%al
  jne    L391
  cmpl   $0x2,-0x40(%rbp)
  jle    L391
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x48(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x24(%rbp),%eax
  cmp    -0x20(%rbp),%eax
  jle    L293
  mov    -0x24(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,-0x20(%rbp)
L293:
  cmpl   $0x0,-0x4c(%rbp)
  je     L346
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %eax,-0x24(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %eax,-0x20(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %eax,-0x1c(%rbp)
L346:
  addq   $0x2,-0x48(%rbp)
  subl   $0x2,-0x40(%rbp)
  mov    -0x1c(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L303
  mov    -0x1c(%rbp),%eax
  cmp    -0x20(%rbp),%eax
  jg     L303
  movl   $0x1,-0x28(%rbp)
  jmp    L303
L391:
  cmpl   $0x0,-0x4c(%rbp)
  jne    L38
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  jne    L271
  movl   $0x1,-0x28(%rbp)
  jmp    L271
L38:
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %eax,%ebx
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  cmp    %eax,%ebx
  jne    L271
  movl   $0x1,-0x28(%rbp)
  jmp    L271
L303:
  nop
L271:
  addq   $0x1,-0x48(%rbp)
  subl   $0x1,-0x40(%rbp)
  jmp    L173
L29:
  nop
L418:
  cmpl   $0x0,-0x18(%rbp)
  je     L486
  cmpl   $0x0,-0x28(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    %eax,-0x28(%rbp)
L486:
  cmpl   $0x0,-0x28(%rbp)
  jne    L219
  mov    $0x0,%eax
  jmp    L80
L219:
  addq   $0x1,-0x38(%rbp)
  subl   $0x1,-0x3c(%rbp)
  jmp    L313
L33:
  cmpl   $0x1,-0x40(%rbp)
  jle    L376
  addq   $0x1,-0x48(%rbp)
  subl   $0x1,-0x40(%rbp)
L376:
  cmpl   $0x0,-0x4c(%rbp)
  jne    L87
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  je     L378
  mov    $0x0,%eax
  jmp    L80
L87:
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %eax,%ebx
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <tolower@plt>
  cmp    %eax,%ebx
  je     L378
  mov    $0x0,%eax
  jmp    L80
L378:
  addq   $0x1,-0x38(%rbp)
  subl   $0x1,-0x3c(%rbp)
  nop
L313:
  addq   $0x1,-0x48(%rbp)
  subl   $0x1,-0x40(%rbp)
  cmpl   $0x0,-0x3c(%rbp)
  jne    L521
  jmp    L330
L549:
  addq   $0x1,-0x48(%rbp)
  subl   $0x1,-0x40(%rbp)
L330:
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2a,%al
  je     L549
  jmp    L69
L521:
  cmpl   $0x0,-0x40(%rbp)
  jne    L242
L69:
  cmpl   $0x0,-0x40(%rbp)
  jne    L148
  cmpl   $0x0,-0x3c(%rbp)
  jne    L148
  mov    $0x1,%eax
  jmp    L80
L148:
  mov    $0x0,%eax
L80:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
int pattern_match_length(const char *string, int slength, const char *pattern, int plength, int nocase) {
  while (plength) {
    switch (pattern[0]) {
    case '*':
      while (pattern[1] == '*') {
        pattern++;
        plength--;
      }
      if (plength == 1)
        return 1;
      while (slength) {
        if (pattern_match_length(pattern + 1, plength - 1, string, slength, nocase))
          return 1;
        string++;
        slength--;
      }
      return 0;
      break;
    case '?':
      if (slength == 0)
        return 0;
      string++;
      slength--;
      break;
    case '[': {
      int not, match;
      pattern++;
      plength--;
      not = pattern[0] == '^';
      if (not ) {
        pattern++;
        plength--;
      }
      match = 0;
      while (1) {
        if (pattern[0] == '\\') {
          pattern++;
          plength--;
          if (pattern[0] == string[0])
            match = 1;
        } else if (pattern[0] == ']') {
          break;
        } else if (plength == 0) {
          pattern--;
          plength++;
          break;
        } else if (pattern[1] == '-' && plength >= 3) {
          int start = pattern[0];
          int end = pattern[2];
          int c = string[0];
          if (start > end) {
            int t = start;
            start = end;
            end = t;
          }
          if (nocase) {
            start = tolower(start);
            end = tolower(end);
            c = tolower(c);
          }
          pattern += 2;
          plength -= 2;
          if (c >= start && c <= end)
            match = 1;
        } else {
          if (!nocase) {
            if (pattern[0] == string[0])
              match = 1;
          } else {
            if (tolower((int)pattern[0]) == tolower((int)string[0]))
              match = 1;
          }
        }
        pattern++;
        plength--;
      }
      if (not )
        match = !match;
      if (!match)
        return 0;
      string++;
      slength--;
      break;
    }
    case '\\':
      if (plength >= 2) {
        pattern++;
        plength--;
      }
    default:
      if (!nocase) {
        if (pattern[0] != string[0])
          return 0;
      } else {
        if (tolower((int)pattern[0]) != tolower((int)string[0]))
          return 0;
      }
      string++;
      slength--;
      break;
    }
    pattern++;
    plength--;
    if (slength == 0) {
      while (*pattern == '*') {
        pattern++;
        plength--;
      }
      break;
    }
  }
  if (plength == 0 && slength == 0)
    return 1;
  return 0;
}
```