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

```asm
<parse_canframe>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x8,%rsp
  call   <strlen@plt>
  xor    %esi,%esi
  mov    $0x18,%edx
  mov    %rbx,%rdi
  mov    %eax,%r12d
  call   <memset@plt>
  cmp    $0x3,%r12d
  jle    L20
  cmpb   $0x23,0x3(%rbp)
  je     L77
  cmpb   $0x23,0x8(%rbp)
  jne    L20
  mov    %rbp,%r14
  mov    $0x1c,%r13d
  xchg   %ax,%ax
L109:
  movsbl (%r14),%edi
  call   <asc2nibble@plt>
  cmp    $0xf,%al
  ja     L20
  mov    %r13d,%ecx
  movzbl %al,%eax
  sub    $0x4,%r13d
  add    $0x1,%r14
  shl    %cl,%eax
  or     (%rbx),%al
  mov    %al,(%rbx)
  cmp    $0xfffffffc,%r13d
  jne    L109
  mov    D1(%rip),%rdx
  mov    (%rdx),%esi
  and    %eax,%esi
  test   %sil,%sil
  jne    L6
  mov    D8(%rip),%rdx
  mov    $0x9,%r14d
  or     (%rdx),%al
  mov    $0x9,%edx
  mov    %al,(%rbx)
  jmp    L30
  nopl   0x0(%rax,%rax,1)
L20:
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L77:
  mov    %rbp,%r14
  mov    $0x8,%r13d
L83:
  movsbl (%r14),%edi
  call   <asc2nibble@plt>
  cmp    $0xf,%al
  ja     L20
  mov    %r13d,%ecx
  movzbl %al,%eax
  sub    $0x4,%r13d
  add    $0x1,%r14
  shl    %cl,%eax
  or     (%rbx),%al
  mov    %al,(%rbx)
  cmp    $0xfffffffc,%r13d
  jne    L83
  mov    $0x4,%edx
  mov    $0x4,%r14d
L30:
  movzbl 0x0(%rbp,%rdx,1),%edx
  xor    %r15d,%r15d
  mov    %edx,%ecx
  and    $0xffffffdf,%ecx
  cmp    $0x52,%cl
  je     L70
L18:
  xor    %eax,%eax
  cmp    $0x2e,%dl
  mov    %r15d,%ecx
  sete   %al
  add    %eax,%r14d
  cmp    %r12d,%r14d
  jge    L132
  movslq %r14d,%rax
  lea    0x1(%r14),%r13d
  movsbl 0x0(%rbp,%rax,1),%edi
  call   <asc2nibble@plt>
  cmp    $0xf,%al
  ja     L20
  mov    0x8(%rbx),%rdx
  shl    $0x4,%eax
  movslq %r13d,%r13
  add    $0x2,%r14d
  mov    %al,(%rdx,%r15,1)
  movsbl 0x0(%rbp,%r13,1),%edi
  call   <asc2nibble@plt>
  cmp    $0xf,%al
  ja     L20
  mov    0x8(%rbx),%rdx
  add    %r15,%rdx
  add    $0x1,%r15
  or     %al,(%rdx)
  cmp    $0x8,%r15
  je     L142
  movslq %r14d,%rax
  movzbl 0x0(%rbp,%rax,1),%edx
  jmp    L18
  nop
L142:
  mov    $0x8,%ecx
L132:
  mov    %ecx,0x10(%rbx)
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L70:
  mov    D4(%rip),%rdx
  or     (%rdx),%al
  mov    %al,(%rbx)
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L6:
  mov    $0x9,%edx
  mov    $0x9,%r14d
  jmp    L30
```

assistant: ```c
int parse_canframe(char *cs, struct can_frame *cf) {
  int i, idx, dlc, len;
  unsigned char tmp;
  len = strlen(cs);
  memset(cf, 0, sizeof(*cf));
  if (len < 4)
    return 1;
  if (cs[3] == '#') {
    idx = 4;
    for (i = 0; i < 3; i++) {
      if ((tmp = asc2nibble(cs[i])) > 0x0F)
        return 1;
      cf->can_id |= (tmp << (2 - i) * 4);
    }
  } else if (cs[8] == '#') {
    idx = 9;
    for (i = 0; i < 8; i++) {
      if ((tmp = asc2nibble(cs[i])) > 0x0F)
        return 1;
      cf->can_id |= (tmp << (7 - i) * 4);
    }
    if (!(cf->can_id & CAN_ERR_FLAG))
      cf->can_id |= CAN_EFF_FLAG;
  } else
    return 1;
  if ((cs[idx] == 'R') || (cs[idx] == 'r')) {
    cf->can_id |= CAN_RTR_FLAG;
    return 0;
  }
  for (i = 0, dlc = 0; i < 8; i++) {
    if (cs[idx] == '.')
      idx++;
    if (idx >= len)
      break;
    if ((tmp = asc2nibble(cs[idx++])) > 0x0F)
      return 1;
    cf->data[i] = (tmp << 4);
    if ((tmp = asc2nibble(cs[idx++])) > 0x0F)
      return 1;
    cf->data[i] |= tmp;
    dlc++;
  }
  cf->can_dlc = dlc;
  return 0;
}
```