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

```asm
<__boyer_moore>:
  endbr64
  push   %r15
  movq   %rcx,%xmm0
  push   %r14
  punpcklqdq %xmm0,%xmm0
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x838,%rsp
  mov    %rsi,(%rsp)
  mov    %rcx,0x8(%rsp)
  mov    %r8d,0x14(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x828(%rsp)
  mov    %rcx,%rax
  lea    -0x1(%rax),%rdx
  lea    0x20(%rsp),%rax
  mov    %rdx,0x18(%rsp)
  lea    0x0(%rbp,%rdx,1),%r14
  lea    0x820(%rsp),%rdx
  nopl   0x0(%rax)
L111:
  movaps %xmm0,(%rax)
  add    $0x10,%rax
  cmp    %rax,%rdx
  jne    L111
  cmp    %r14,%rbp
  jae    L47
  mov    0x14(%rsp),%ecx
  test   %ecx,%ecx
  jne    L458
  mov    %rbp,%rax
  nopl   0x0(%rax,%rax,1)
L299:
  movzbl (%rax),%edx
  mov    %r14,%rcx
  sub    %rax,%rcx
  add    $0x1,%rax
  mov    %rcx,0x20(%rsp,%rdx,8)
  cmp    %rax,%r14
  jne    L299
L47:
  mov    (%rsp),%rbx
  cmp    %rbx,0x8(%rsp)
  ja     L166
  cs nopw 0x0(%rax,%rax,1)
L68:
  mov    0x18(%rsp),%rax
  lea    (%r12,%rax,1),%r15
  cmp    %r14,%rbp
  jae    L353
  mov    0x14(%rsp),%edx
  test   %edx,%edx
  jne    L278
  xor    %ecx,%ecx
  mov    %r14,%rax
  jmp    L488
  nopl   (%rax)
L398:
  sub    $0x1,%rax
  sub    $0x1,%r15
  add    $0x1,%ecx
  cmp    %rbp,%rax
  je     L218
L488:
  movzbl (%rax),%esi
  cmp    %sil,(%r15)
  je     L398
  movzbl (%rax),%esi
  movzbl (%r15),%eax
  cmp    %sil,%al
  je     L217
L249:
  mov    0x20(%rsp,%rax,8),%r15
  cmp    %r15,0x8(%rsp)
  jne    L358
  test   %ecx,%ecx
  je     L358
  movzbl 0x0(%rbp),%eax
  cmp    %al,(%r14)
  jne    L358
L371:
  sub    $0x1,%r15
L358:
  sub    %r15,(%rsp)
  add    %r15,%r12
  mov    (%rsp),%rax
  cmp    %rax,0x8(%rsp)
  jbe    L68
L166:
  xor    %eax,%eax
L461:
  mov    0x828(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L203
  add    $0x838,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L278:
  mov    %r14,%rbx
  xor    %r13d,%r13d
  jmp    L387
L302:
  movzbl (%rbx),%edi
  call   <tolower@plt>
  mov    %eax,%ecx
L151:
  movzbl (%r15),%edi
  mov    %ecx,0x10(%rsp)
  call   <isupper@plt>
  mov    0x10(%rsp),%ecx
  test   %rax,%rax
  je     L430
  movzbl (%r15),%edi
  call   <tolower@plt>
  mov    0x10(%rsp),%ecx
  cmp    %eax,%ecx
  jne    L359
L72:
  sub    $0x1,%r15
  sub    $0x1,%rbx
  add    $0x1,%r13d
  cmp    %r15,%r12
  je     L359
L387:
  movzbl (%rbx),%edi
  call   <isupper@plt>
  test   %rax,%rax
  jne    L302
  movzbl (%rbx),%ecx
  jmp    L151
  nopl   0x0(%rax)
L430:
  movzbl (%r15),%eax
  cmp    %eax,%ecx
  je     L72
L359:
  movzbl (%rbx),%edi
L322:
  call   <isupper@plt>
  test   %rax,%rax
  je     L269
  movzbl (%rbx),%edi
  call   <tolower@plt>
  mov    %eax,%ebx
L137:
  movzbl (%r15),%edi
  call   <isupper@plt>
  test   %rax,%rax
  je     L486
  movzbl (%r15),%edi
  mov    %edi,0x10(%rsp)
  call   <tolower@plt>
  mov    0x10(%rsp),%edi
L340:
  cmp    %eax,%ebx
  je     L217
  call   <isupper@plt>
  test   %rax,%rax
  je     L162
  movzbl (%r15),%edi
  call   <tolower@plt>
L420:
  cltq
  mov    0x20(%rsp,%rax,8),%r15
  cmp    %r15,0x8(%rsp)
  jne    L358
  test   %r13d,%r13d
  je     L358
  movzbl (%r14),%edi
  call   <isupper@plt>
  test   %rax,%rax
  je     L194
  movzbl (%r14),%edi
  call   <tolower@plt>
  mov    %eax,%ebx
L43:
  movzbl 0x0(%rbp),%edi
  call   <isupper@plt>
  test   %rax,%rax
  je     L219
  movzbl 0x0(%rbp),%edi
  call   <tolower@plt>
L202:
  cmp    %eax,%ebx
  je     L371
  jmp    L358
  nopl   (%rax)
L218:
  movzbl 0x0(%rbp),%esi
  movzbl (%r15),%eax
  cmp    %sil,%al
  jne    L249
L217:
  mov    %r12,%rax
  jmp    L461
  nopl   0x0(%rax)
L486:
  movzbl (%r15),%eax
  mov    %eax,%edi
  jmp    L340
  nopl   0x0(%rax,%rax,1)
L269:
  movzbl (%rbx),%ebx
  jmp    L137
L162:
  movzbl (%r15),%eax
  jmp    L420
L219:
  movzbl 0x0(%rbp),%eax
  jmp    L202
L194:
  movzbl (%r14),%ebx
  jmp    L43
L353:
  mov    0x14(%rsp),%eax
  movzbl (%r14),%edi
  test   %eax,%eax
  jne    L264
  movzbl (%r15),%eax
  cmp    %al,%dil
  je     L217
  mov    0x20(%rsp,%rax,8),%r15
  jmp    L358
L458:
  mov    %rbp,%r13
  nopw   0x0(%rax,%rax,1)
L91:
  movzbl 0x0(%r13),%edi
  mov    %r14,%rbx
  sub    %r13,%rbx
  call   <isupper@plt>
  test   %rax,%rax
  jne    L99
  movzbl 0x0(%r13),%eax
  add    $0x1,%r13
  mov    %rbx,0x20(%rsp,%rax,8)
  cmp    %r14,%r13
  jne    L91
  jmp    L47
  nopl   (%rax)
L99:
  movzbl 0x0(%r13),%edi
  add    $0x1,%r13
  call   <tolower@plt>
  cltq
  mov    %rbx,0x20(%rsp,%rax,8)
  cmp    %r13,%r14
  jne    L91
  jmp    L47
L264:
  mov    %r14,%rbx
  xor    %r13d,%r13d
  jmp    L322
L203:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
unsigned char *__boyer_moore(const unsigned char *haystack, size_t haystacklen, const unsigned char *needle, size_t needlelen, int icase) {
  register unsigned char *hc_ptr, *nc_ptr;
  unsigned char *he_ptr, *ne_ptr, *h_ptr;
  size_t skiptable[256], n;
  register int i;
  ne_ptr = (unsigned char *)needle + needlelen - 1;
  he_ptr = (unsigned char *)haystack + haystacklen - 1;
  for (i = 0; i < 256; i++)
    skiptable[i] = needlelen;
  for (nc_ptr = (unsigned char *)needle; nc_ptr < ne_ptr; nc_ptr++)
    skiptable[((icase) ? (isupper((int)(*nc_ptr)) ? tolower((int)(*nc_ptr)) : (int)(*nc_ptr)) : (int)(*nc_ptr))] = (size_t)(ne_ptr - nc_ptr);
  h_ptr = (unsigned char *)haystack;
  while (haystacklen >= needlelen) {
    hc_ptr = h_ptr + needlelen - 1;
    nc_ptr = ne_ptr;
    for (i = 0; nc_ptr > (unsigned char *)needle; nc_ptr--, hc_ptr--, i++)
      if (!((icase) ? (isupper((int)(*nc_ptr)) ? tolower((int)(*nc_ptr)) : (int)(*nc_ptr)) == (isupper((int)(*hc_ptr)) ? tolower((int)(*hc_ptr)) : (int)(*hc_ptr)) : (*nc_ptr) == (*hc_ptr)))
        break;
    if (!((icase) ? (isupper((int)(*nc_ptr)) ? tolower((int)(*nc_ptr)) : (int)(*nc_ptr)) == (isupper((int)(*hc_ptr)) ? tolower((int)(*hc_ptr)) : (int)(*hc_ptr)) : (*nc_ptr) == (*hc_ptr))) {
      n = skiptable[((icase) ? (isupper((int)(*hc_ptr)) ? tolower((int)(*hc_ptr)) : (int)(*hc_ptr)) : (int)(*hc_ptr))];
      if (n == needlelen && i)
        if (((icase) ? (isupper((int)(*ne_ptr)) ? tolower((int)(*ne_ptr)) : (int)(*ne_ptr)) == (isupper((int)(((unsigned char *)needle)[0])) ? tolower((int)(((unsigned char *)needle)[0])) : (int)(((unsigned char *)needle)[0])) : (*ne_ptr) == (((unsigned char *)needle)[0])))
          n--;
      h_ptr += n;
      haystacklen -= n;
    } else
      return (unsigned char *)h_ptr;
  }
  return NULL;
}
```