// File: /workspace/github_c_makefile_star2_O1/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
callq 0x12f9
cmpl $0x29, %eax
setne %al
movl 0x292e(%rip), %esi      # 0x40cc
cmpl $0xa, %esi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x18ff
leaq 0x2d0a(%rip), %rbx      # 0x44c0
leaq 0x8a5(%rip), %r14       # 0x2062
movl $0x64696f76, %ebp       # imm = 0x64696F76
leaq 0x2907(%rip), %r15      # 0x40d0
leaq 0x8be(%rip), %r13       # 0x208e
testl %esi, %esi
je 0x17f1
cmpl $0x2c, %esi
jne 0x1872
movq %r15, %rdi
callq 0x1040
movw $0x2c, (%rax,%r15)
jmp 0x18e6
movq %rbx, %rdi
callq 0x15c3
testl %eax, %eax
je 0x181c
movq %r15, %rdi
callq 0x1040
movw $0x20, (%rax,%r15)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1080
callq 0x12f9
movq %rbx, %rdi
callq 0x13e2
testl %eax, %eax
je 0x188f
movl 0x2c92(%rip), %eax      # 0x44c0
xorl %ebp, %eax
movzbl 0x2c8d(%rip), %ecx      # 0x44c4
xorl %r12d, %r12d
orl %eax, %ecx
setne %r12b
movq %r15, %rdi
callq 0x1040
movw $0x20, (%rax,%r15)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1080
callq 0x12f9
movl 0x2867(%rip), %esi      # 0x40cc
testl %esi, %esi
je 0x18af
cmpl $0x29, %esi
je 0x190e
movl $0x1, 0x284c(%rip)      # 0x40c8
movq 0x283d(%rip), %rdx      # 0x40c0
movq %r13, %rdi
xorl %eax, %eax
callq 0x1050
jmp 0x18e6
movl $0x1, 0x282f(%rip)      # 0x40c8
movq 0x2820(%rip), %rdx      # 0x40c0
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1050
jmp 0x18e6
testl %r12d, %r12d
jne 0x18cc
movq 0x2805(%rip), %rdx      # 0x40c0
leaq 0x8b7(%rip), %rdi       # 0x2179
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1050
movq %r15, %rdi
callq 0x1040
movw $0x20, (%rax,%r15)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1080
callq 0x12f9
cmpl $0x29, %eax
je 0x18ff
movl 0x27d6(%rip), %esi      # 0x40cc
cmpl $0xa, %esi
jne 0x17d0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r12d, %r12d
je 0x18ff
movl $0x1, 0x27ab(%rip)      # 0x40c8
movq 0x279c(%rip), %rsi      # 0x40c0
leaq 0x88c(%rip), %rdi       # 0x21b7
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1050