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

```asm
<twoway_memmem>:
  endbr64
  push   %r15
  pxor   %xmm0,%xmm0
  mov    %rdi,%r8
  push   %r14
  mov    %rsi,%r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  mov    %rcx,%rbx
  sub    $0x848,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x838(%rsp)
  xor    %eax,%eax
  movaps %xmm0,0x10(%rsp)
  movaps %xmm0,0x20(%rsp)
  test   %rcx,%rcx
  je     L349
  mov    $0x1,%edi
L405:
  movzbl 0x0(%rbp,%rax,1),%ecx
  mov    %rdi,%rsi
  add    $0x1,%rax
  mov    %ecx,%edx
  shl    %cl,%rsi
  mov    %rax,0x30(%rsp,%rcx,8)
  shr    $0x6,%dl
  movzbl %dl,%edx
  or     %rsi,0x10(%rsp,%rdx,8)
  cmp    %rbx,%rax
  jne    L405
  cmp    $0x1,%rbx
  je     L349
  mov    $0x1,%r12d
  mov    $0x1,%eax
  xor    %ecx,%ecx
  mov    $0xffffffffffffffff,%r13
  mov    $0x1,%edx
  jmp    L106
  nopl   0x0(%rax,%rax,1)
L214:
  jbe    L338
  mov    %rdx,%r12
  mov    %rdx,%rcx
  mov    $0x1,%eax
  sub    %r13,%r12
L147:
  lea    (%rax,%rcx,1),%rdx
  cmp    %rbx,%rdx
  jae    L393
L106:
  lea    0x0(%rbp,%rax,1),%rsi
  movzbl 0x0(%rbp,%rdx,1),%edi
  cmp    %dil,(%rsi,%r13,1)
  jne    L214
  cmp    %r12,%rax
  je     L387
  add    $0x1,%rax
  lea    (%rax,%rcx,1),%rdx
  cmp    %rbx,%rdx
  jb     L106
L393:
  mov    $0x1,%r9d
  mov    $0x1,%edx
  xor    %ecx,%ecx
  mov    $0xffffffffffffffff,%rdi
  mov    $0x1,%eax
  jmp    L227
  xchg   %ax,%ax
L246:
  jae    L250
  mov    %rax,%r9
  mov    %rax,%rcx
  mov    $0x1,%edx
  sub    %rdi,%r9
L197:
  lea    (%rdx,%rcx,1),%rax
  cmp    %rbx,%rax
  jae    L221
L227:
  lea    0x0(%rbp,%rdx,1),%rsi
  movzbl 0x0(%rbp,%rax,1),%r11d
  cmp    %r11b,(%rsi,%rdi,1)
  jne    L246
  cmp    %rdx,%r9
  je     L223
  add    $0x1,%rdx
  lea    (%rdx,%rcx,1),%rax
  cmp    %rbx,%rax
  jb     L227
L221:
  lea    0x1(%rdi),%rax
  lea    0x1(%r13),%r15
  cmp    %r15,%rax
  jbe    L258
  mov    %rax,%r15
  mov    %rdi,%r13
  mov    %r9,%r12
L258:
  lea    0x0(%rbp,%r12,1),%rsi
  mov    %r15,%rdx
  mov    %rbp,%rdi
  mov    %r8,0x8(%rsp)
  call   <memcmp@plt>
  mov    %rbx,%rsi
  mov    0x8(%rsp),%r8
  sub    %r12,%rsi
  test   %rax,%rax
  je     L348
  lea    -0x1(%rbx),%rax
  sub    %r13,%rax
  cmp    %r13,%rax
  cmovb  %r13,%rax
  xor    %esi,%esi
  lea    0x1(%rax),%r12
L348:
  mov    %r14,%rax
  sub    %r8,%rax
  cmp    %rax,%rbx
  ja     L296
  mov    %rbx,%rdi
  lea    -0x1(%rbx),%rdx
  xor    %r9d,%r9d
  sub    %r12,%rdi
  jmp    L340
  nopl   (%rax)
L150:
  mov    %rbx,%rax
  sub    0x30(%rsp,%rcx,8),%rax
  je     L254
  test   %rsi,%rsi
  setne  %r10b
  test   %r9,%r9
  setne  %cl
  test   %cl,%r10b
  je     L0
  cmp    %rax,%r12
  cmova  %rdi,%rax
L0:
  add    %rax,%r8
  xor    %r9d,%r9d
L263:
  mov    %r14,%rax
  sub    %r8,%rax
  cmp    %rbx,%rax
  jb     L296
L340:
  movzbl (%r8,%rdx,1),%ecx
  mov    %ecx,%eax
  shr    $0x6,%al
  movzbl %al,%eax
  mov    0x10(%rsp,%rax,8),%rax
  shr    %cl,%rax
  test   $0x1,%al
  jne    L150
  add    %rbx,%r8
  mov    %r14,%rax
  xor    %r9d,%r9d
  sub    %r8,%rax
  cmp    %rbx,%rax
  jae    L340
L296:
  xor    %r8d,%r8d
L288:
  mov    0x838(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L279
  add    $0x848,%rsp
  mov    %r8,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L338:
  mov    %rcx,%r13
  mov    $0x1,%r12d
  add    $0x1,%rcx
  mov    $0x1,%eax
  jmp    L147
  nop
L387:
  add    %rax,%rcx
  mov    $0x1,%eax
  jmp    L147
  nopl   (%rax)
L250:
  mov    %rcx,%rdi
  mov    $0x1,%r9d
  add    $0x1,%rcx
  mov    $0x1,%edx
  jmp    L197
  nopw   0x0(%rax,%rax,1)
L223:
  add    %r9,%rcx
  mov    $0x1,%edx
  jmp    L197
  nopl   (%rax)
L254:
  cmp    %r15,%r9
  mov    %r15,%rax
  cmovae %r9,%rax
  cmp    %rax,%rbx
  ja     L274
  jmp    L298
  nopl   0x0(%rax)
L306:
  add    $0x1,%rax
  cmp    %rax,%rbx
  je     L298
L274:
  movzbl (%r8,%rax,1),%ecx
  cmp    %cl,0x0(%rbp,%rax,1)
  je     L306
  cmp    %rax,%rbx
  jbe    L298
  sub    %r13,%rax
  jmp    L0
  nopl   0x0(%rax)
L298:
  mov    %r15,%rax
  jmp    L22
  nopl   (%rax)
L98:
  sub    $0x1,%rax
  movzbl (%r8,%rax,1),%ecx
  cmp    %cl,0x0(%rbp,%rax,1)
  jne    L241
L22:
  cmp    %r9,%rax
  ja     L98
  jmp    L288
  nopl   0x0(%rax)
L241:
  add    %r12,%r8
  mov    %rsi,%r9
  jmp    L263
L349:
  xor    %r15d,%r15d
  mov    $0xffffffffffffffff,%r13
  mov    $0x1,%r12d
  jmp    L258
L279:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *twoway_memmem(const unsigned char *h, const unsigned char *z, const unsigned char *n, size_t l) {
  size_t i, ip, jp, k, p, ms, p0, mem, mem0;
  size_t byteset[32 / sizeof(size_t)] = {0};
  size_t shift[256];
  for (i = 0; i < l; i++)
    ((byteset)[(size_t)(n[i]) / (8 * sizeof *(byteset))] |= (size_t)1 << ((size_t)(n[i]) % (8 * sizeof *(byteset)))), shift[n[i]] = i + 1;
  ip = -1;
  jp = 0;
  k = p = 1;
  while (jp + k < l) {
    if (n[ip + k] == n[jp + k]) {
      if (k == p) {
        jp += p;
        k = 1;
      } else
        k++;
    } else if (n[ip + k] > n[jp + k]) {
      jp += k;
      k = 1;
      p = jp - ip;
    } else {
      ip = jp++;
      k = p = 1;
    }
  }
  ms = ip;
  p0 = p;
  ip = -1;
  jp = 0;
  k = p = 1;
  while (jp + k < l) {
    if (n[ip + k] == n[jp + k]) {
      if (k == p) {
        jp += p;
        k = 1;
      } else
        k++;
    } else if (n[ip + k] < n[jp + k]) {
      jp += k;
      k = 1;
      p = jp - ip;
    } else {
      ip = jp++;
      k = p = 1;
    }
  }
  if (ip + 1 > ms + 1)
    ms = ip;
  else
    p = p0;
  if (memcmp(n, n + p, ms + 1)) {
    mem0 = 0;
    p = ((ms) > (l - ms - 1) ? (ms) : (l - ms - 1)) + 1;
  } else
    mem0 = l - p;
  mem = 0;
  for (;;) {
    if (z - h < l)
      return 0;
    if (((byteset)[(size_t)(h[l - 1]) / (8 * sizeof *(byteset))] & (size_t)1 << ((size_t)(h[l - 1]) % (8 * sizeof *(byteset))))) {
      k = l - shift[h[l - 1]];
      if (k) {
        if (mem0 && mem && k < p)
          k = l - p;
        h += k;
        mem = 0;
        continue;
      }
    } else {
      h += l;
      mem = 0;
      continue;
    }
    for (k = ((ms + 1) > (mem) ? (ms + 1) : (mem)); k < l && n[k] == h[k]; k++)
      ;
    if (k < l) {
      h += k - ms;
      mem = 0;
      continue;
    }
    for (k = ms + 1; k > mem && n[k - 1] == h[k - 1]; k--)
      ;
    if (k <= mem)
      return (char *)h;
    h += p;
    mem = mem0;
  }
}
```