// File: /workspace/github_c_makefile_star2_O2/sisshiki1969[P]monocc/src/parse.c
// Function: parse_type_specifier
Type *parse_type_specifier(bool allow_undefined_tag) {
  Token *t = consume();
  Type *ty;
  switch (t->kind) {
    case TK_BOOL:
      return new_type_bool();
    case TK_VOID:
      return new_type_void();
    case TK_STRUCT:
      return parse_struct_specifier(allow_undefined_tag);
    case TK_ENUM:
      return parse_enum_specifier();
    case TK_IDENT:
      // typedef-name
      ty = find_typedef(t);
      if (ty)
        return ty;
      else
        error_at_token(t, "Internal error: Must be typedef name.");
  }
  int flag = 0;
  enum {
    CHAR = 1,
    SHORT = 4,
    INT = 16,
    LONG = 64,
    SIGNED = 256,
    UNSIGNED = 1024
  } size;
  while (is_type_specifier(t)) {
    switch (t->kind) {
      case TK_CHAR:
        flag += CHAR;
        break;
      case TK_SHORT:
        flag += SHORT;
        break;
      case TK_INT:
        flag += INT;
        break;
      case TK_LONG:
        flag += LONG;
        break;
      case TK_SIGNED:
        flag += SIGNED;
        break;
      case TK_UNSIGNED:
        flag += UNSIGNED;
        break;
      default:
        error_at_token(t, "Illegal type specifier.");
    }
    switch (flag) {
      case CHAR:
        ty = new_type_char();
        break;
      case SHORT:
      case SHORT + INT:
      case SIGNED + SHORT:
      case SIGNED + SHORT + INT:
        ty = new_type_short();
        break;
      case UNSIGNED + SHORT:
      case UNSIGNED + SHORT + INT:
        ty = new_type_ushort();
        break;
      case INT:
      case SIGNED + INT:
        ty = new_type_int();
        break;
      case UNSIGNED + INT:
        ty = new_type_uint();
        break;
      case LONG:
      case LONG + INT:
      case SIGNED + LONG:
      case SIGNED + LONG + INT:
        ty = new_type_long();
        break;
      case UNSIGNED + LONG:
      case UNSIGNED + LONG + INT:
        ty = new_type_ulong();
        break;
      case SIGNED:
      case UNSIGNED:
        ty = NULL;
        break;
      default:
        error_at_token(t, "Illegal type specifier.");
    }
    if (!is_type_specifier(token)) {
      break;
    }
    t = consume();
  }
  if (!ty) error_at_token(t, "Illegal type specifier.");
  return ty;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x9c12(%rip), %r13      # 0x11228
movq (%r13), %rbx
movq 0x8(%rbx), %rax
movq %rax, (%r13)
movl (%rbx), %ecx
leal -0x36(%rcx), %eax
cmpl $0x5, %eax
ja 0x7651
leaq 0x3c45(%rip), %rcx      # 0xb278
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x90bc
testl %ecx, %ecx
jne 0x767a
movq %rbx, %rdi
callq 0x5afb
movq %rax, %r15
testq %rax, %rax
jne 0x7870
leaq 0x4075(%rip), %rsi      # 0xb6e5
movq %rbx, %rdi
xorl %eax, %eax
callq 0x48b3
leaq 0x3c0f(%rip), %rbp      # 0xb290
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x5ad3
testb %al, %al
je 0x7857
movl (%rbx), %eax
addl $-0x34, %eax
cmpl $0xa, %eax
ja 0x76c0
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
addl $0x10, %r14d
jmp 0x76e5
addl $0x4, %r14d
jmp 0x76e5
addl $0x400, %r14d           # imm = 0x400
jmp 0x76e5
movq %rbx, %rdi
leaq 0x4041(%rip), %rsi      # 0xb70b
xorl %eax, %eax
callq 0x48b3
jmp 0x76e5
incl %r14d
jmp 0x76e5
addl $0x40, %r14d
jmp 0x76e5
addl $0x100, %r14d           # imm = 0x100
cmpl $0x450, %r14d           # imm = 0x450
je 0x77bb
cmpl $0x4, %r14d
je 0x77a0
cmpl $0x10, %r14d
je 0x77b2
cmpl $0x14, %r14d
je 0x77a0
cmpl $0x40, %r14d
je 0x77a9
cmpl $0x50, %r14d
je 0x77a9
cmpl $0x100, %r14d           # imm = 0x100
je 0x77fa
cmpl $0x104, %r14d           # imm = 0x104
je 0x77a0
cmpl $0x110, %r14d           # imm = 0x110
je 0x77b2
cmpl $0x114, %r14d           # imm = 0x114
je 0x77a0
cmpl $0x140, %r14d           # imm = 0x140
je 0x77a9
cmpl $0x150, %r14d           # imm = 0x150
je 0x77a9
movl $0x0, %r12d
cmpl $0x400, %r14d           # imm = 0x400
je 0x77d7
cmpl $0x404, %r14d           # imm = 0x404
je 0x77c4
cmpl $0x410, %r14d           # imm = 0x410
je 0x77cd
cmpl $0x414, %r14d           # imm = 0x414
je 0x77c4
cmpl $0x440, %r14d           # imm = 0x440
je 0x77bb
cmpl $0x1, %r14d
jne 0x77ff
xorl %eax, %eax
callq 0x90b4
jmp 0x77d4
xorl %eax, %eax
callq 0x9094
jmp 0x77d4
xorl %eax, %eax
callq 0x90a4
jmp 0x77d4
xorl %eax, %eax
callq 0x9084
jmp 0x77d4
xorl %eax, %eax
callq 0x90ac
jmp 0x77d4
xorl %eax, %eax
callq 0x909c
jmp 0x77d4
xorl %eax, %eax
callq 0x908c
movq %rax, %r12
movq (%r13), %r15
movq %r15, %rdi
callq 0x5ad3
testb %al, %al
je 0x7854
movq 0x8(%r15), %rax
movq %rax, (%r13)
movq %r15, %rbx
movq %r12, %r15
jmp 0x7687
xorl %r12d, %r12d
jmp 0x77d7
movq %rbx, %rdi
leaq 0x3f02(%rip), %rsi      # 0xb70b
xorl %eax, %eax
callq 0x48b3
movq %r15, %r12
jmp 0x77d7
movzbl %dil, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7456
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7379
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x90c4
movq %r12, %r15
testq %r15, %r15
jne 0x7870
leaq 0x3ea8(%rip), %rsi      # 0xb70b
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x48b3
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq