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

```asm
<primary>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  lea    D21(%rip),%rdi
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <match@plt>
  test   %eax,%eax
  jne    L31
  lea    0xd(%rsp),%rbp
  xor    %eax,%eax
  mov    %rbp,%rdi
  call   <symname@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  jne    L73
  xor    %eax,%eax
  lea    0x8(%rsp),%rdi
  call   <constant@plt>
  test   %eax,%eax
  je     L69
  movq   $0x0,0x0(%r13)
L2:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L16
  add    $0x28,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L73:
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <findloc@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  jne    L92
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <findglb@plt>
  movslq %eax,%rbx
  test   %eax,%eax
  je     L95
  cmpb   $0x4,0xb(%rbx)
  je     L95
  mov    %eax,0x0(%r13)
  movl   $0x0,0x4(%r13)
  cmpb   $0x2,0xb(%rbx)
  je     L59
  mov    $0x1,%r12d
  jmp    L2
  xchg   %ax,%ax
L31:
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <heir1@plt>
  lea    D7(%rip),%rdi
  mov    %eax,%r12d
  xor    %eax,%eax
  call   <needbrack@plt>
  jmp    L2
L92:
  movslq %eax,%rbp
  xor    %eax,%eax
  mov    %rbp,%rdi
  call   <getloc@plt>
  mov    %r12d,0x0(%r13)
  movsbl 0xc(%rbp),%eax
  mov    $0x2,%edx
  mov    %eax,0x4(%r13)
  cmpb   $0x3,0xb(%rbp)
  cmove  %edx,%eax
  xor    %r12d,%r12d
  mov    %eax,0x4(%r13)
  cmpb   $0x2,0xb(%rbp)
  setne  %r12b
  jmp    L2
  nopl   0x0(%rax)
L69:
  lea    D13(%rip),%rdi
  xor    %eax,%eax
  call   <error@plt>
  xor    %eax,%eax
  call   <immed@plt>
  xor    %edi,%edi
  xor    %eax,%eax
  call   <outdec@plt>
  xor    %eax,%eax
  call   <nl@plt>
  xor    %eax,%eax
  call   <junk@plt>
  jmp    L2
  nopl   0x0(%rax)
L95:
  mov    $0x1,%r8d
  xor    %ecx,%ecx
  mov    $0x2,%edx
  mov    %rbp,%rdi
  mov    $0x4,%esi
  xor    %eax,%eax
  call   <addglb@plt>
  movl   $0x0,0x4(%r13)
  mov    %eax,0x0(%r13)
  jmp    L2
  nopl   (%rax)
L59:
  xor    %eax,%eax
  call   <immed@plt>
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <outname@plt>
  xor    %eax,%eax
  call   <nl@plt>
  movsbl 0xc(%rbx),%eax
  mov    %eax,0x4(%r13)
  jmp    L2
L16:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D21
datatype: string
name: parse_data
arguments: tag: D7
datatype: string
name: parse_data
arguments: tag: D13
datatype: string

tool: D21: (

tool: D7: )

tool: D13: invalid expression

assistant: ```c
primary(lval) int *lval;
{
  char *ptr, sname[11];
  int num[1];
  int k;
  if (match("(")) {
    k = heir1(lval);
    needbrack(")");
    return k;
  }
  if (symname(sname)) {
    if (ptr = findloc(sname)) {
      getloc(ptr);
      lval[0] = ptr;
      lval[1] = ptr[12];
      if (ptr[11] == 3)
        lval[1] = 2;
      if (ptr[11] == 2)
        return 0;
      else
        return 1;
    }
    if (ptr = findglb(sname))
      if (ptr[11] != 4) {
        lval[0] = ptr;
        lval[1] = 0;
        if (ptr[11] != 2)
          return 1;
        immed();
        outname(ptr);
        nl();
        lval[1] = ptr[12];
        return 0;
      }
    ptr = addglb(sname, 4, 2, 0, 1);
    lval[0] = ptr;
    lval[1] = 0;
    return 0;
  }
  if (constant(num))
    return (lval[0] = lval[1] = 0);
  else {
    error("invalid expression");
    immed();
    outdec(0);
    nl();
    junk();
    return 0;
  }
}
```