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

```asm
<_utils_searchexp>:
  endbr64
  test   %rsi,%rsi
  je     L393
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  mov    %rsi,%rdi
  push   %rbx
  mov    %rcx,%rbx
  sub    $0x8,%rsp
  movzbl (%rsi),%eax
  test   %al,%al
  setne  %r13b
  test   %rbp,%rbp
  setne  %cl
  and    %cl,%r13b
  je     L253
  test   %edx,%edx
  setne  %r12b
  xchg   %ax,%ax
L130:
  mov    %rbp,%r9
  cmp    $0x5e,%al
  jne    L220
  movzbl 0x1(%rdi),%eax
  xor    %r9d,%r9d
  add    $0x1,%rdi
L220:
  movzbl 0x0(%rbp),%edx
  mov    %rbp,%rsi
  mov    %rdi,%r10
  xor    %r8d,%r8d
  jmp    L339
  nopl   0x0(%rax)
L216:
  test   %cl,%cl
  je     L186
  cmp    $0x5a,%dl
  jg     L172
L313:
  add    $0x20,%edx
  mov    %r13d,%ecx
L172:
  test   %r9,%r9
  je     L182
L367:
  lea    -0x41(%rax),%r10d
  cmp    $0x19,%r10b
  ja     L173
  test   %cl,%cl
  jne    L401
L173:
  test   %dl,%dl
  je     L81
  cmp    %al,%dl
  jne    L81
L205:
  movzbl 0x1(%rdi),%eax
  mov    %rdi,%r10
  xor    %r9d,%r9d
  add    $0x1,%rdi
L262:
  mov    %eax,%edx
  add    $0x1,%r8d
  and    $0xfffffff7,%edx
  cmp    $0x24,%dl
  je     L392
L12:
  test   %al,%al
  je     L392
  movzbl 0x1(%rsi),%edx
  add    $0x1,%rsi
  test   %dl,%dl
  je     L87
L339:
  cmp    $0x40,%dl
  setg   %cl
  and    %r12d,%ecx
  cmp    $0x2a,%al
  jne    L216
  lea    0x1(%rdi),%r11
  movzbl 0x1(%rdi),%eax
  mov    %rsi,%r9
  mov    %r11,%rdi
  test   %cl,%cl
  jne    L378
  mov    %r12d,%ecx
  jmp    L367
  nopl   (%rax)
L186:
  mov    %r12d,%ecx
  test   %r9,%r9
  jne    L367
L182:
  lea    -0x41(%rax),%r11d
  cmp    $0x19,%r11b
  ja     L176
  lea    0x20(%rax),%r11d
  test   %cl,%cl
  cmovne %r11d,%eax
L176:
  cmp    %al,%dl
  jne    L400
  movzbl 0x1(%rdi),%eax
  add    $0x1,%r8d
  add    $0x1,%rdi
  mov    %eax,%edx
  and    $0xfffffff7,%edx
  cmp    $0x24,%dl
  jne    L12
  nopw   0x0(%rax,%rax,1)
L392:
  xor    %edx,%edx
L388:
  cmp    $0x2a,%al
  je     L296
  cmp    $0x24,%al
  je     L43
L390:
  test   %edx,%edx
  jne    L158
L7:
  movzbl (%rdi),%eax
  cmp    $0x2c,%al
  je     L265
  test   %al,%al
  je     L265
  cmp    $0x24,%al
  je     L311
L158:
  mov    $0x2c,%esi
  call   <strchr@plt>
  test   %rax,%rax
  je     L253
L317:
  lea    0x1(%rax),%rdi
  movzbl 0x1(%rax),%eax
  jmp    L130
  nopl   0x0(%rax)
L81:
  mov    %rdi,%r10
  jmp    L262
  nopl   0x0(%rax,%rax,1)
L401:
  lea    0x20(%rax),%ecx
  cmp    %dl,%cl
  jne    L340
  test   %dl,%dl
  jne    L205
L340:
  movzbl 0x1(%rsi),%edx
  add    $0x1,%rsi
  add    $0x1,%r8d
  mov    %rdi,%r10
  test   %dl,%dl
  jne    L339
  cs nopw 0x0(%rax,%rax,1)
L87:
  cmp    $0x2a,%al
  jne    L7
  xor    %edx,%edx
L296:
  movzbl 0x1(%rdi),%eax
  add    $0x1,%rdi
  cmp    $0x24,%al
  jne    L390
L43:
  movslq %r8d,%r8
  add    $0x1,%rdi
  cmpb   $0x0,0x0(%rbp,%r8,1)
  je     L390
  mov    $0x2c,%esi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L317
L253:
  add    $0x8,%rsp
  mov    $0xfffffffc,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L378:
  cmp    $0x5a,%dl
  jle    L313
  jmp    L367
L400:
  movzbl (%r10),%eax
  mov    %r10,%rdi
  mov    $0xfffffffc,%edx
  jmp    L388
L265:
  test   %rbx,%rbx
  setne  %cl
  test   %r9,%r9
  setne  %dl
  test   %dl,%cl
  je     L311
  cmp    $0x24,%al
  jne    L272
L311:
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L272:
  mov    %r9,(%rbx)
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L393:
  mov    $0xfffffffc,%eax
  ret
```

assistant: ```c
int _utils_searchexp(const char *haystack, const char *needleslist, int ignore_case, const char **rest) {
  int ret = -4;
  if (needleslist == NULL || needleslist[0] == '\0')
    return ret;
  if (haystack != NULL) {
    int i = -1;
    const char *needle = needleslist;
    while (needle != NULL) {
      i = 0;
      ret = -2;
      const char *wildcard = &(haystack[i]);
      if (*needle == '^') {
        wildcard = NULL;
        needle++;
      }
      const char *needle_entry = needle;
      do {
        ;
        char hay = haystack[i];
        if (*needle == '*') {
          wildcard = &(haystack[i]);
          needle++;
        }
        if (ignore_case && hay > 0x40 && hay < 0x5b)
          hay += 0x20;
        if (wildcard == NULL) {
          char lneedle = *needle;
          if (ignore_case && lneedle > 0x40 && lneedle < 0x5b)
            lneedle += 0x20;
          if (lneedle != hay) {
            ;
            needle = needle_entry;
            ret = -4;
            break;
          } else if (lneedle == hay) {
            ret = 0;
          }
          needle++;
        } else {
          char lneedle = *needle;
          if (ignore_case && lneedle > 0x40 && lneedle < 0x5b)
            lneedle += 0x20;
          needle_entry = needle;
          ret = 0;
          if (hay != '\0' && lneedle == hay) {
            wildcard = NULL;
            needle++;
          }
        }
        i++;
        if (*needle == ',' || *needle == '\0' || *needle == '$') {
          ;
          break;
        }
      } while (haystack[i] != '\0');
      if (*needle == '*')
        needle++;
      if (*needle == '$') {
        if (haystack[i] != '\0')
          ret = -4;
        needle++;
      };
      if (ret == 0) {
        if (*needle == ',' || *needle == '\0' || *needle == '$') {
          if (wildcard && (*needle != '$') && (rest != NULL))
            *rest = wildcard;
          break;
        } else
          ret = -4;
      }
      needle = strchr(needle, ',');
      if (needle != NULL)
        needle++;
      wildcard = 0;
    }
  }
  return ret;
}
```