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

```asm
<bcd_valid>:
  endbr64
  movzbl (%rdi),%edx
  mov    %edx,%esi
  and    $0xf,%esi
  mov    $0x0,%ecx
  cmp    $0x9,%sil
  jg     L14
  mov    %rdi,%rax
  mov    %edx,%r8d
  shr    $0x4,%r8b
  cmp    $0x9f,%dl
  ja     L14
  movzbl 0x1(%rdi),%edx
  mov    %edx,%edi
  and    $0xf,%edi
  cmp    $0x9,%dil
  jg     L14
  mov    %edx,%r9d
  shr    $0x4,%r9b
  cmp    $0x9f,%dl
  ja     L14
  movzbl 0x2(%rax),%r10d
  mov    %r10d,%edx
  and    $0xf,%edx
  cmp    $0x9,%dl
  jg     L14
  mov    %r10d,%r11d
  shr    $0x4,%r11b
  cmp    $0x9f,%r10b
  ja     L14
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  movzbl 0x3(%rax),%ebx
  mov    %ebx,%r10d
  and    $0xf,%r10d
  cmp    $0x9,%r10b
  jg     L123
  mov    %ebx,%ebp
  shr    $0x4,%bpl
  cmp    $0x9f,%bl
  ja     L123
  movzbl 0x4(%rax),%r13d
  mov    %r13d,%ebx
  and    $0xf,%ebx
  cmp    $0x9,%bl
  jg     L123
  mov    %r13d,%r12d
  shr    $0x4,%r12b
  cmp    $0x9f,%r13b
  ja     L123
  movzbl 0x5(%rax),%eax
  mov    %eax,%r13d
  and    $0xf,%r13d
  cmp    $0x9,%r13b
  jg     L123
  mov    %eax,%r14d
  shr    $0x4,%r14b
  cmp    $0x9f,%al
  ja     L123
  movsbl %r8b,%r8d
  lea    (%r8,%r8,4),%ecx
  movsbl %sil,%eax
  lea    (%rax,%rcx,2),%eax
  cmp    $0x17,%eax
  setg   %cl
  movsbl %r9b,%r9d
  lea    (%r9,%r9,4),%eax
  movsbl %dil,%edi
  lea    (%rdi,%rax,2),%eax
  cmp    $0x3b,%eax
  setg   %al
  or     %cl,%al
  jne    L93
  movsbl %r11b,%r11d
  lea    (%r11,%r11,4),%eax
  movsbl %dl,%edx
  lea    (%rdx,%rax,2),%eax
  cmp    $0x3c,%eax
  jg     L93
  movsbl %r12b,%r12d
  lea    (%r12,%r12,4),%eax
  movsbl %bl,%ebx
  lea    (%rbx,%rax,2),%esi
  lea    -0x1(%rsi),%eax
  mov    $0x0,%ecx
  cmp    $0xb,%eax
  ja     L123
  movsbl %bpl,%ebp
  lea    0x0(%rbp,%rbp,4),%eax
  movsbl %r10b,%r10d
  lea    (%r10,%rax,2),%edi
  test   %edi,%edi
  jle    L123
  mov    $0x1,%ecx
  cmp    $0x1c,%edi
  jle    L123
  movsbl %r14b,%ecx
  imul   $0xa,%ecx,%ecx
  movsbl %r13b,%r13d
  add    %r13d,%ecx
  mov    $0x190,%r8d
  mov    %ecx,%eax
  cltd
  idiv   %r8d
  test   %edx,%edx
  je     L233
  test   $0x3,%cl
  jne    L90
  mov    $0x64,%r8d
  mov    %ecx,%eax
  cltd
  idiv   %r8d
  test   %edx,%edx
  je     L90
L233:
  mov    $0x1,%ecx
  cmp    $0x1d,%edi
  jle    L123
L90:
  cmp    $0x2,%esi
  je     L136
  mov    $0x1,%ecx
  cmp    $0x1e,%edi
  jle    L123
L136:
  mov    %esi,%ecx
  sar    $0x3,%ecx
  xor    %esi,%ecx
  xor    $0x1,%ecx
  and    $0x1,%ecx
  cmp    $0x1f,%edi
  setg   %al
  or     %eax,%ecx
  xor    $0x1,%ecx
  movzbl %cl,%ecx
  jmp    L123
L93:
  mov    $0x0,%ecx
L123:
  mov    %ecx,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L14:
  mov    %ecx,%eax
  ret
```

assistant: ```c
int bcd_valid(const char *bcd) {
  int a, b, c;
  if (!((((bcd[0]) & 15) < 10 && (((bcd[0]) >> 4) & 15) < 10) && (((bcd[1]) & 15) < 10 && (((bcd[1]) >> 4) & 15) < 10) && (((bcd[2]) & 15) < 10 && (((bcd[2]) >> 4) & 15) < 10) && (((bcd[3]) & 15) < 10 && (((bcd[3]) >> 4) & 15) < 10) && (((bcd[4]) & 15) < 10 && (((bcd[4]) >> 4) & 15) < 10) && (((bcd[5]) & 15) < 10 && (((bcd[5]) >> 4) & 15) < 10)))
    return 0;
  a = (((bcd[0]) & 15) + (((bcd[0]) >> 4) & 15) * 10);
  b = (((bcd[1]) & 15) + (((bcd[1]) >> 4) & 15) * 10);
  c = (((bcd[2]) & 15) + (((bcd[2]) >> 4) & 15) * 10);
  if (a > 23 || b > 59 || c > 60)
    return 0;
  a = (((bcd[3]) & 15) + (((bcd[3]) >> 4) & 15) * 10);
  b = (((bcd[4]) & 15) + (((bcd[4]) >> 4) & 15) * 10);
  c = (((bcd[5]) & 15) + (((bcd[5]) >> 4) & 15) * 10);
  if (b < 1 || b > 12)
    return 0;
  if (!(1 <= a && (a <= 28 || (((c) % 400 == 0 || ((c) % 4 == 0 && (c) % 100 != 0)) && a <= 29) || (b != 2 && a <= 30) || (((((b) >> 3) ^ (b)) & 1) && a <= 31))))
    return 0;
  return 1;
}
```