// File: /workspace/github_c_makefile_star2_O2/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_5/exercise_5_20/dcl.c
// Function: attr_dcl
void attr_dcl(void)
{
  while (get_next_token() != PAREN_CLOSE && next_token != '\n')
  {
    if (next_token == ATTR_SEPARATOR)
    {
      strcat(out, ",");
    }
    else if (next_token == NAME)
    {
      if (is_valid_qualifier(token))
      {
        strcat(out, " ");
        strcat(out, token);
        get_next_token();
      }

      if (is_valid_data_type(token))
      {
        enum boolean is_void_type = FALSE;
        if (strcmp(token, "void") == 0)
        {
          is_void_type = TRUE;
        }

        strcat(out, " ");
        strcat(out, token);

        get_next_token();
        if (next_token == NAME)
        {
          if (is_void_type)
          {
            printf("Error: variable '%s' has incomplete type 'void' on line %zu.\n", token, line_nr);
          }

          strcat(out, " ");
          strcat(out, token);
        }
        else if (next_token == PAREN_CLOSE)
        {
          if (is_void_type)
          {
            return;
          }

          Error = TRUE;
          printf("Syntax Error: missing variable name on line %zu.\n", line_nr);
          return;
        }
        else
        {
          Error = TRUE;
          printf("Syntax Error: '%c' unexpected on line %zu.\n", next_token, line_nr);
        }
      }
      else
      {
        Error = TRUE;
        printf("Syntax Error: '%s' unexpected on line %zu.\n", token, line_nr);
      }
    }
    else
    {
      Error = TRUE;
      printf("Syntax Error: '%c' unexpected on line %zu.\n", next_token, line_nr);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x2d7f(%rip), %rbx      # 0x44c0
leaq 0x8bc(%rip), %r15       # 0x2004
pushq $0x5
popq %r12
leaq 0x297d(%rip), %r13      # 0x40d0
leaq 0x934(%rip), %rbp       # 0x208e
callq 0x12fd
cmpl $0x29, %eax
je 0x18c4
movl 0x295e(%rip), %esi      # 0x40cc
cmpl $0xa, %esi
je 0x18c4
testl %esi, %esi
je 0x1795
cmpl $0x2c, %esi
jne 0x180f
movq %r13, %rdi
callq 0x1040
movw $0x2c, (%rax,%r13)
jmp 0x175a
movq %rbx, %rdi
callq 0x1572
testl %eax, %eax
je 0x17c0
movq %r13, %rdi
callq 0x1040
movw $0x20, (%rax,%r13)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x1090
callq 0x12fd
movq %rbx, %rdi
callq 0x13d5
testl %eax, %eax
je 0x182f
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1080
movl %eax, %r14d
movq %r13, %rdi
callq 0x1040
movw $0x20, (%rax,%r13)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x1090
callq 0x12fd
movl 0x28ca(%rip), %esi      # 0x40cc
testl %esi, %esi
je 0x1856
cmpl $0x29, %esi
je 0x1892
movl $0x1, 0x28af(%rip)      # 0x40c8
movq 0x28a0(%rip), %rdx      # 0x40c0
movq %rbp, %rdi
xorl %eax, %eax
callq 0x1050
jmp 0x175a
movl $0x1, 0x288f(%rip)      # 0x40c8
movq 0x2880(%rip), %rdx      # 0x40c0
leaq 0x81b(%rip), %rdi       # 0x2062
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1050
jmp 0x175a
testl %r14d, %r14d
jne 0x1873
movq 0x285e(%rip), %rdx      # 0x40c0
leaq 0x910(%rip), %rdi       # 0x2179
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1050
movq %r13, %rdi
callq 0x1040
movw $0x20, (%rax,%r13)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x1090
jmp 0x175a
testl %r14d, %r14d
je 0x18c4
movl $0x1, 0x2827(%rip)      # 0x40c8
movq 0x2818(%rip), %rsi      # 0x40c0
leaq 0x908(%rip), %rdi       # 0x21b7
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1050
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq