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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x408,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x3f8(%rsp)
  xor    %eax,%eax
  mov    $0x0,%r15d
  movl   $0x0,0x4(%rsp)
  movl   $0x0,(%rsp)
  mov    $0x0,%r13d
  mov    $0x0,%ebx
  mov    $0x0,%r12d
  mov    $0x0,%ebp
  lea    0x10(%rsp),%rax
  mov    %rax,0x8(%rsp)
  mov    $0x0,%r14d
L15:
  mov    $0x3e8,%esi
  mov    0x8(%rsp),%rdi
  call   <getline@plt>
  test   %eax,%eax
  jle    L285
  movzbl 0x10(%rsp),%eax
  mov    $0x0,%ecx
  test   %al,%al
  jne    L506
  jmp    L15
L121:
  mov    %ebp,%esi
  or     %r12d,%esi
  mov    %esi,%edx
  or     %ebx,%edx
  or     %r13d,%edx
  je     L48
  test   %ebx,%ebx
  je     L330
  or     %r13d,%esi
  setne  %bl
  movzbl %bl,%ebx
L330:
  test   %ebx,%ebx
  je     L433
  test   %ebp,%ebp
  je     L433
  mov    $0x0,%ebp
  cmp    $0x22,%al
  je     L60
L281:
  mov    %r12d,%edx
  or     %r13d,%edx
  or     %ebx,%edx
  cmp    $0x2f,%al
  sete   %sil
L237:
  test   %r12d,%r12d
  je     L540
  test   %sil,%sil
  jne    L196
L540:
  or     %ebp,%edx
  jne    L27
  cmp    $0x5b,%al
  je     L86
  cmp    $0x5d,%al
  jne    L148
  subl   $0x1,0x4(%rsp)
L138:
  cmp    $0x7b,%al
  jne    L499
  add    $0x1,%r15d
  mov    $0x0,%ebp
  mov    %r14d,%r12d
  jmp    L27
L433:
  cmp    $0x22,%al
  jne    L521
  mov    %r12d,%edx
  or     %r13d,%edx
  or     %ebx,%edx
  jne    L493
  mov    $0x1,%r13d
L60:
  mov    %r12d,%edx
  or     %ebx,%edx
  or     %r13d,%edx
  cmp    $0x2f,%al
  sete   %sil
  jmp    L237
L493:
  mov    %r12d,%edi
  or     %ebx,%edi
  jne    L60
  mov    $0x0,%r13d
  jmp    L60
L48:
  mov    $0x1,%ebx
L521:
  mov    %r12d,%edx
  or     %r13d,%edx
  cmp    $0x2f,%al
  sete   %sil
  or     %ebx,%edx
  jne    L237
  test   %sil,%sil
  je     L237
  lea    0x1(%rcx),%esi
  movslq %esi,%rdx
  movzbl 0x10(%rsp,%rdx,1),%edx
  cmp    $0x2a,%dl
  je     L244
  mov    %ebp,%r13d
  mov    %ebp,%ebx
  test   %ebp,%ebp
  jne    L114
L148:
  cmp    $0x28,%al
  jne    L42
  addl   $0x1,(%rsp)
L499:
  cmp    $0x7d,%al
  jne    L103
  sub    $0x1,%r15d
  mov    $0x0,%ebp
  mov    %r14d,%r12d
  jmp    L27
L196:
  lea    -0x1(%rcx),%eax
  cltq
  cmpb   $0x2a,0x10(%rsp,%rax,1)
  jne    L27
  add    $0x1,%ecx
  mov    %r14d,%r12d
  jmp    L27
L86:
  addl   $0x1,0x4(%rsp)
L42:
  cmp    $0x29,%al
  jne    L138
  subl   $0x1,(%rsp)
  mov    $0x0,%ebp
  mov    %r14d,%r12d
L27:
  add    $0x1,%ecx
  movslq %ecx,%rax
  movzbl 0x10(%rsp,%rax,1),%eax
  test   %al,%al
  je     L15
L506:
  cmp    $0x27,%al
  je     L121
  cmp    $0x5c,%al
  jne    L330
  test   %ebx,%ebx
  setne  %sil
  je     L281
  mov    %ebp,%edx
  or     %r12d,%edx
  or     %r13d,%edx
  je     L384
  test   %ebp,%ebp
  je     L281
  test   %sil,%sil
  cmovne %r14d,%ebp
  jmp    L281
L103:
  mov    $0x0,%ebp
  mov    %r14d,%r12d
  jmp    L27
L244:
  mov    %esi,%ecx
  mov    %edx,%eax
  mov    $0x0,%r13d
  mov    %r14d,%ebx
  mov    $0x1,%r12d
  jmp    L506
L285:
  test   %r15d,%r15d
  jne    L170
L410:
  cmpl   $0x0,0x4(%rsp)
  jne    L415
L306:
  cmpl   $0x0,(%rsp)
  jne    L362
L269:
  test   %ebx,%ebx
  jne    L51
L259:
  test   %r13d,%r13d
  jne    L115
L191:
  test   %r12d,%r12d
  jne    L24
  test   %ebp,%ebp
  jne    L396
  mov    %ebx,%eax
  or     %r13d,%eax
  or     (%rsp),%eax
  or     0x4(%rsp),%eax
  or     %r15d,%eax
  jne    L549
  lea    D43(%rip),%rdi
  call   <printf@plt>
  jmp    L549
L170:
  lea    D2(%rip),%rdi
  call   <printf@plt>
  jmp    L410
L415:
  lea    D39(%rip),%rdi
  call   <printf@plt>
  jmp    L306
L362:
  lea    D5(%rip),%rdi
  call   <printf@plt>
  jmp    L269
L51:
  lea    D0(%rip),%rdi
  call   <printf@plt>
  jmp    L259
L115:
  lea    D26(%rip),%rdi
  call   <printf@plt>
  jmp    L191
L24:
  lea    D59(%rip),%rdi
  call   <printf@plt>
  test   %ebp,%ebp
  je     L549
L396:
  lea    D1(%rip),%rdi
  call   <printf@plt>
L549:
  mov    0x3f8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L326
  mov    $0x0,%eax
  add    $0x408,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L384:
  mov    %ebx,%ebp
  jmp    L281
L114:
  mov    $0x0,%r13d
  mov    %r14d,%ebx
  jmp    L27
L326:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D43
data_type: string
name: read_data
arguments: tag: D2
data_type: string
name: read_data
arguments: tag: D39
data_type: string
name: read_data
arguments: tag: D5
data_type: string
name: read_data
arguments: tag: D0
data_type: string
name: read_data
arguments: tag: D26
data_type: string
name: read_data
arguments: tag: D59
data_type: string
name: read_data
arguments: tag: D1
data_type: string

tool: D43: Syntax is OK.


tool: D2: Unbalanced brace.


tool: D39: Unbalanced bracket.


tool: D5: Unbalanced parenthese.


tool: D0: Unbalanced single quote


tool: D26: Unbalanced double quote


tool: D59: Unbalanced comments


tool: D1: Illegal escape sequence


assistant: ```c
main() {
  int i;
  int escape, comment, charconst, quoted, parenthese, bracket, brace;
  int len;
  char line[1000];
  escape = comment = charconst = quoted = parenthese = bracket = brace = 0;
  while ((len = getline(line, 1000)) > 0) {
    i = 0;
    while (line[i] != '\0') {
      if (line[i] == '\'') {
        if (charconst == 0 && quoted == 0 && comment == 0 && escape == 0)
          charconst = 1;
        else if (charconst && quoted == 0 && comment == 0 && escape == 0) {
          charconst = 0;
        }
      }
      if (line[i] == '\\') {
        if (charconst && quoted == 0 && comment == 0 && escape == 0)
          escape = 1;
        else if (charconst && escape)
          escape = 0;
      }
      if (line[i] != '\\' && charconst && escape)
        escape = 0;
      if (line[i] == '\"') {
        if (charconst == 0 && quoted == 0 && comment == 0)
          quoted = 1;
        else if (charconst == 0 && quoted && comment == 0)
          quoted = 0;
      }
      if (charconst == 0 && quoted == 0 && comment == 0 && line[i] == '/' && line[i + 1] == '*')
        comment = 1;
      else if (comment && line[i] == '/' && line[i - 1] == '*') {
        comment = 0;
        ++i;
      } else if (quoted == 0 && charconst == 0 && comment == 0 && escape == 0) {
        if (line[i] == '[')
          ++bracket;
        if (line[i] == ']')
          --bracket;
        if (line[i] == '(')
          ++parenthese;
        if (line[i] == ')')
          --parenthese;
        if (line[i] == '{')
          ++brace;
        if (line[i] == '}')
          --brace;
      }
      ++i;
    }
  }
  if (brace != 0)
    printf("Unbalanced brace.\n");
  if (bracket != 0)
    printf("Unbalanced bracket.\n");
  if (parenthese != 0)
    printf("Unbalanced parenthese.\n");
  if (charconst != 0)
    printf("Unbalanced single quote\n");
  if (quoted != 0)
    printf("Unbalanced double quote\n");
  if (comment != 0)
    printf("Unbalanced comments\n");
  if (escape != 0)
    printf("Illegal escape sequence\n");
  if (brace == 0 && bracket == 0 && parenthese == 0 && charconst == 0 && quoted == 0 && comment == 0 && escape == 0)
    printf("Syntax is OK.\n");
  return 0;
}
```