user: Please show me the C implementation that matches the assembly code listed below:

```asm
<mem_parse>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    0x50(%rsp),%rbp
  test   %r8,%r8
  jle    L178
  mov    %rdi,%rbx
  mov    %rdx,%r15
  mov    %rsi,%rdi
  mov    %r8,%rdx
  mov    %rbx,%rsi
  mov    %r9,0x8(%rsp)
  mov    %r8,%r13
  mov    %rcx,(%rsp)
  call   <search_linear@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L178
  mov    0x8(%rsp),%r9
  mov    (%rsp),%rcx
  lea    (%rax,%r13,1),%r12
  test   %r9,%r9
  jg     L182
  sub    %r12,%rbx
  lea    (%rbx,%rcx,1),%eax
  mov    0x58(%rsp),%ebx
  movslq %eax,%rcx
  cmp    0x58(%rsp),%rcx
  lea    -0x1(%rbx),%edx
  cmovge %edx,%eax
  test   %eax,%eax
  jle    L202
  lea    0x1(%r14,%r13,1),%rdi
  mov    %rbp,%rcx
  lea    -0x1(%rax),%edx
  mov    %eax,%esi
  sub    %rdi,%rcx
  cmp    $0xe,%rcx
  jbe    L225
  cmp    $0x6,%edx
  jbe    L225
  cmp    $0xe,%edx
  jbe    L371
  mov    %eax,%ecx
  xor    %edx,%edx
  shr    $0x4,%ecx
  shl    $0x4,%rcx
  nopl   0x0(%rax)
L143:
  movdqu (%r12,%rdx,1),%xmm0
  movups %xmm0,0x0(%rbp,%rdx,1)
  add    $0x10,%rdx
  cmp    %rcx,%rdx
  jne    L143
  mov    %eax,%ecx
  and    $0xfffffff0,%ecx
  mov    %ecx,%edx
  cmp    %ecx,%eax
  je     L237
  mov    %eax,%esi
  sub    %ecx,%esi
  lea    -0x1(%rsi),%edi
  cmp    $0x6,%edi
  jbe    L183
L359:
  mov    (%r12,%rcx,1),%rdi
  mov    %rdi,0x0(%rbp,%rcx,1)
  mov    %esi,%ecx
  and    $0xfffffff8,%ecx
  add    %ecx,%edx
  cmp    %ecx,%esi
  je     L237
L183:
  movslq %edx,%rcx
  movzbl (%r12,%rcx,1),%esi
  mov    %sil,0x0(%rbp,%rcx,1)
  lea    0x1(%rdx),%ecx
  cmp    %ecx,%eax
  jle    L237
  movslq %ecx,%rcx
  movzbl (%r12,%rcx,1),%esi
  mov    %sil,0x0(%rbp,%rcx,1)
  lea    0x2(%rdx),%ecx
  cmp    %ecx,%eax
  jle    L237
  movslq %ecx,%rcx
  movzbl (%r12,%rcx,1),%esi
  mov    %sil,0x0(%rbp,%rcx,1)
  lea    0x3(%rdx),%ecx
  cmp    %ecx,%eax
  jle    L237
  movslq %ecx,%rcx
  movzbl (%r12,%rcx,1),%esi
  mov    %sil,0x0(%rbp,%rcx,1)
  lea    0x4(%rdx),%ecx
  cmp    %ecx,%eax
  jle    L237
L318:
  movslq %ecx,%rcx
  movzbl (%r12,%rcx,1),%esi
  mov    %sil,0x0(%rbp,%rcx,1)
  lea    0x5(%rdx),%ecx
  cmp    %ecx,%eax
  jle    L237
  movslq %ecx,%rcx
  add    $0x6,%edx
  movzbl (%r12,%rcx,1),%esi
  mov    %sil,0x0(%rbp,%rcx,1)
  cmp    %edx,%eax
  jle    L237
  movslq %edx,%rdx
  movzbl (%r12,%rdx,1),%ecx
  mov    %cl,0x0(%rbp,%rdx,1)
L237:
  movslq %eax,%rdx
  add    %rdx,%rbp
L202:
  movb   $0x0,0x0(%rbp)
L367:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L182:
  add    %rbx,%rcx
  mov    %r9,%rdx
  mov    %r12,%rsi
  mov    %r15,%rdi
  sub    %r12,%rcx
  call   <search_linear@plt>
  test   %rax,%rax
  je     L178
  mov    0x58(%rsp),%ebx
  sub    %r12,%rax
  movslq %eax,%rcx
  cmp    0x58(%rsp),%rcx
  lea    -0x1(%rbx),%edx
  cmovge %edx,%eax
  test   %eax,%eax
  jle    L202
  lea    0x1(%r14,%r13,1),%rdi
  mov    %rbp,%rcx
  lea    -0x1(%rax),%edx
  mov    %eax,%esi
  sub    %rdi,%rcx
  cmp    $0xe,%rcx
  jbe    L144
  cmp    $0x6,%edx
  jbe    L144
  cmp    $0xe,%edx
  jbe    L94
  mov    %eax,%ecx
  xor    %edx,%edx
  shr    $0x4,%ecx
  shl    $0x4,%rcx
  nopl   (%rax)
L11:
  movdqu (%r12,%rdx,1),%xmm1
  movups %xmm1,0x0(%rbp,%rdx,1)
  add    $0x10,%rdx
  cmp    %rcx,%rdx
  jne    L11
  mov    %eax,%ecx
  and    $0xfffffff0,%ecx
  mov    %ecx,%edx
  cmp    %ecx,%eax
  je     L237
  mov    %eax,%esi
  sub    %ecx,%esi
  lea    -0x1(%rsi),%edi
  cmp    $0x6,%edi
  jbe    L258
L220:
  mov    (%r12,%rcx,1),%rdi
  mov    %rdi,0x0(%rbp,%rcx,1)
  mov    %esi,%ecx
  and    $0xfffffff8,%ecx
  add    %ecx,%edx
  cmp    %ecx,%esi
  je     L237
L258:
  movslq %edx,%rcx
  movzbl (%r12,%rcx,1),%esi
  mov    %sil,0x0(%rbp,%rcx,1)
  lea    0x1(%rdx),%ecx
  cmp    %ecx,%eax
  jle    L237
  movslq %ecx,%rcx
  movzbl (%r12,%rcx,1),%esi
  mov    %sil,0x0(%rbp,%rcx,1)
  lea    0x2(%rdx),%ecx
  cmp    %eax,%ecx
  jge    L237
  movslq %ecx,%rcx
  movzbl (%r12,%rcx,1),%esi
  mov    %sil,0x0(%rbp,%rcx,1)
  lea    0x3(%rdx),%ecx
  cmp    %eax,%ecx
  jge    L237
  movslq %ecx,%rcx
  movzbl (%r12,%rcx,1),%esi
  mov    %sil,0x0(%rbp,%rcx,1)
  lea    0x4(%rdx),%ecx
  cmp    %eax,%ecx
  jl     L318
  jmp    L237
  nopl   0x0(%rax)
L225:
  mov    %eax,%esi
  xor    %edx,%edx
  nopl   0x0(%rax)
L79:
  movzbl (%r12,%rdx,1),%ecx
  mov    %cl,0x0(%rbp,%rdx,1)
  add    $0x1,%rdx
  cmp    %rsi,%rdx
  jne    L79
  jmp    L237
  nopw   0x0(%rax,%rax,1)
L144:
  mov    %eax,%esi
  xor    %edx,%edx
  nopl   0x0(%rax)
L37:
  movzbl (%r12,%rdx,1),%ecx
  mov    %cl,0x0(%rbp,%rdx,1)
  add    $0x1,%rdx
  cmp    %rsi,%rdx
  jne    L37
  jmp    L237
L371:
  xor    %ecx,%ecx
  xor    %edx,%edx
  jmp    L359
L178:
  mov    $0xffffffff,%eax
  jmp    L367
L94:
  xor    %ecx,%ecx
  xor    %edx,%edx
  jmp    L220
```

assistant: ```c
int mem_parse(char *buf, char *mp1, char *mp2, uint32_t buf_len, uint32_t mp1_len, uint32_t mp2_len, char *dbuf, uint32_t dlen) {
  char *src = NULL, *dst = NULL;
  int i = 0;
  int len = -1;
  if (mp1_len > 0) {
    src = search_linear(mp1, buf, mp1_len, buf_len);
    if (src != NULL) {
      if (mp2_len > 0) {
        src += mp1_len;
        if ((dst = search_linear(mp2, src, mp2_len, buf_len - ((unsigned long)src - (unsigned long)buf))) != NULL) {
          if ((len = (unsigned long)dst - (unsigned long)src) > (dlen - 1)) {
            len = dlen - 1;
          }
          for (i = 0; i < len; i++) {
            *(dbuf + i) = *(src + i);
          }
          *(dbuf + i) = '\0';
        }
      } else {
        src += mp1_len;
        len = buf_len - ((unsigned long)src - (unsigned long)buf);
        if (len > (dlen - 1)) {
          len = dlen - 1;
        }
        for (i = 0; i < len; i++) {
          *(dbuf + i) = *(src + i);
        }
        *(dbuf + i) = '\0';
      }
    }
  }
  return len;
}
```