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

```asm
<main>:
  endbr64
  push   %r14
  lea    D24(%rip),%rdi
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x50,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%rsi
  call   <scanf@plt>
  xor    %eax,%eax
  call   <getchar@plt>
  mov    0xc(%rsp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,0xc(%rsp)
  test   %eax,%eax
  je     L126
  lea    0x10(%rsp),%rbx
  lea    0x30(%rsp),%rbp
  lea    0x11(%rsp),%r12
  lea    D18(%rip),%r14
  lea    D4(%rip),%r13
  nopl   0x0(%rax,%rax,1)
L52:
  mov    %rbx,%rdi
  call   <gets@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  jle    L61
  lea    -0x1(%rax),%r8d
  mov    %rbx,%rdx
  xor    %edi,%edi
  add    %r12,%r8
  nopl   0x0(%rax)
L37:
  movzbl (%rdx),%ecx
  lea    -0x30(%rcx),%esi
  cmp    $0x9,%sil
  ja     L16
  movslq %edi,%rsi
  add    $0x1,%edi
  mov    %cl,0x30(%rsp,%rsi,1)
L16:
  add    $0x1,%rdx
  cmp    %r8,%rdx
  jne    L37
L125:
  movslq %edi,%rdi
  cltq
  movb   $0x0,0x30(%rsp,%rdi,1)
  mov    %rbp,%rdi
  movb   $0x0,0x10(%rsp,%rax,1)
  call   <strlen@plt>
  mov    %eax,%edi
  test   %eax,%eax
  jle    L4
  mov    %rbp,%rcx
  xor    %eax,%eax
  xor    %r8d,%r8d
  xor    %esi,%esi
  jmp    L118
  nopl   0x0(%rax)
L1:
  lea    -0x60(%rdx,%rdx,1),%r10d
  add    $0x1,%eax
  add    $0x1,%rcx
  lea    -0x1(%r10),%edx
  movslq %edx,%r9
  sar    $0x1f,%edx
  imul   $0x38e38e39,%r9,%r9
  sar    $0x21,%r9
  sub    %r9d,%edx
  lea    (%rdx,%rdx,8),%edx
  add    %r10d,%edx
  add    %edx,%esi
  cmp    %eax,%edi
  je     L6
L118:
  movsbl (%rcx),%edx
  test   $0x1,%al
  je     L1
  add    $0x1,%eax
  lea    -0x30(%r8,%rdx,1),%r8d
  add    $0x1,%rcx
  cmp    %eax,%edi
  jne    L118
L6:
  add    %r8d,%esi
  imul   $0xcccccccd,%esi,%esi
  add    $0x19999998,%esi
  ror    %esi
  cmp    $0x19999998,%esi
  jbe    L4
  mov    %r13,%rdi
  call   <printf@plt>
L122:
  mov    0xc(%rsp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,0xc(%rsp)
  test   %eax,%eax
  jne    L52
L126:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L15
  add    $0x50,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopw   0x0(%rax,%rax,1)
L4:
  mov    %r14,%rdi
  call   <printf@plt>
  jmp    L122
  nopw   0x0(%rax,%rax,1)
L61:
  xor    %edi,%edi
  xor    %eax,%eax
  jmp    L125
L15:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D24
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D18
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D4
type_infered: string

tool: D24: %d

tool: D18: Valid


tool: D4: Invalid


assistant: ```c
int main() {
  char m[22], a[22];
  int b, c = 0, d = 0, ch;
  int n, i, j, l, len, len2, total;
  scanf("%d", &n);
  getchar();
  while (n--) {
    gets(m);
    len = strlen(m);
    j = 0, l = 0;
    while (j < len) {
      if (m[j] >= '0' && m[j] <= '9') {
        a[l] = m[j];
        l++;
      }
      j++;
    }
    m[j] = '\0';
    a[l] = '\0';
    len2 = strlen(a);
    for (j = 0; j < len2; j++) {
      if (j % 2 == 0) {
        ch = 0;
        b = (a[j] - '0') * 2;
        b = b - 9 * ((b - 1) / 9);
        c = c + b;
      } else {
        d += (a[j] - '0');
      }
    }
    total = c + d;
    if (total % 10 == 0) {
      printf("Valid\n");
    } else {
      printf("Invalid\n");
    }
    c = 0, d = 0, ch = 0;
  }
  return 0;
}
```