// File: /workspace/github_c_makefile_star2_O1/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 0xa9d2(%rip), %r13      # 0x13228
movq (%r13), %rbx
movq 0x8(%rbx), %rax
movq %rax, (%r13)
movl (%rbx), %ecx
leal -0x36(%rcx), %eax
cmpl $0x5, %eax
ja 0x8891
leaq 0x49b5(%rip), %rcx      # 0xd228
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 0xada8
testl %ecx, %ecx
jne 0x88ba
movq %rbx, %rdi
callq 0x626a
movq %rax, %r15
testq %rax, %rax
jne 0x8b38
leaq 0x4e11(%rip), %rsi      # 0xd6c1
movq %rbx, %rdi
xorl %eax, %eax
callq 0x52f9
leaq 0x497f(%rip), %rbp      # 0xd240
xorl %r15d, %r15d
xorl %r14d, %r14d
movl (%rbx), %r12d
addl $-0x34, %r12d
cmpl $0xa, %r12d
ja 0x88f1
movslq (%rbp,%r12,4), %rax
addq %rbp, %rax
jmpq *%rax
movq %rbx, %rdi
leaq 0x4dff(%rip), %rsi      # 0xd6e7
xorl %eax, %eax
callq 0x52f9
jmp 0x893f
movq %rbx, %rdi
callq 0x626a
testq %rax, %rax
je 0x8b22
cmpl $0xa, %r12d
ja 0x88de
leaq 0x495d(%rip), %rcx      # 0xd26c
movslq (%rcx,%r12,4), %rax
addq %rcx, %rax
jmpq *%rax
addl $0x10, %r14d
jmp 0x893f
addl $0x400, %r14d           # imm = 0x400
jmp 0x893f
addl $0x40, %r14d
jmp 0x893f
addl $0x4, %r14d
jmp 0x893f
incl %r14d
jmp 0x893f
addl $0x100, %r14d           # imm = 0x100
cmpl $0x113, %r14d           # imm = 0x113
jg 0x8991
cmpl $0x3f, %r14d
jle 0x89d6
cmpl $0xff, %r14d
jle 0x8a47
movl $0x0, %r12d
cmpl $0x100, %r14d           # imm = 0x100
je 0x8a93
cmpl $0x104, %r14d           # imm = 0x104
je 0x8a21
cmpl $0x110, %r14d           # imm = 0x110
je 0x8a77
jmp 0x8aca
cmpl $0x403, %r14d           # imm = 0x403
jle 0x89f1
cmpl $0x413, %r14d           # imm = 0x413
jle 0x8a5c
cmpl $0x414, %r14d           # imm = 0x414
je 0x8a80
cmpl $0x440, %r14d           # imm = 0x440
je 0x89ca
cmpl $0x450, %r14d           # imm = 0x450
jne 0x8aca
xorl %eax, %eax
callq 0xad98
jmp 0x8a90
cmpl $0xf, %r14d
jg 0x8a11
cmpl $0x1, %r14d
je 0x8a89
cmpl $0x4, %r14d
je 0x8a21
jmp 0x8aca
cmpl $0x14f, %r14d           # imm = 0x14F
jg 0x8a2a
cmpl $0x114, %r14d           # imm = 0x114
je 0x8a21
cmpl $0x140, %r14d           # imm = 0x140
je 0x8a53
jmp 0x8aca
cmpl $0x10, %r14d
je 0x8a77
cmpl $0x14, %r14d
jne 0x8aca
xorl %eax, %eax
callq 0xad80
jmp 0x8a90
cmpl $0x150, %r14d           # imm = 0x150
je 0x8a53
movl $0x0, %r12d
cmpl $0x400, %r14d           # imm = 0x400
je 0x8a93
jmp 0x8aca
cmpl $0x40, %r14d
je 0x8a53
cmpl $0x50, %r14d
jne 0x8aca
xorl %eax, %eax
callq 0xad90
jmp 0x8a90
cmpl $0x404, %r14d           # imm = 0x404
je 0x8a80
cmpl $0x410, %r14d           # imm = 0x410
jne 0x8aca
xorl %eax, %eax
callq 0xad78
jmp 0x8a90
xorl %eax, %eax
callq 0xad70
jmp 0x8a90
xorl %eax, %eax
callq 0xad88
jmp 0x8a90
xorl %eax, %eax
callq 0xada0
movq %rax, %r12
movq (%r13), %r15
movl (%r15), %eax
leal -0x34(%rax), %ecx
cmpl $0x8, %ecx
jb 0x8ab7
addl $-0x3d, %eax
cmpl $0x2, %eax
jb 0x8ab7
movq %r15, %rdi
callq 0x626a
testq %rax, %rax
je 0x8b1f
movq 0x8(%r15), %rax
movq %rax, (%r13)
movq %r15, %rbx
movq %r12, %r15
jmp 0x88c7
movq %rbx, %rdi
leaq 0x4c13(%rip), %rsi      # 0xd6e7
xorl %eax, %eax
callq 0x52f9
movq %r15, %r12
jmp 0x8a93
movzbl %dil, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8653
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x84d0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xadb0
movq %r12, %r15
testq %r15, %r15
jne 0x8b38
leaq 0x4bb9(%rip), %rsi      # 0xd6e7
movq %rbx, %rdi
xorl %eax, %eax
callq 0x52f9
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq