// File: /workspace/github_c_makefile_star2_O0/hsjoihs[P]c-compiler/parse_type.c
// Function: parse_type_specifier
struct Type *parse_type_specifier(const struct Token **ptr_tokvec)
{
	const struct Token *tokvec = *ptr_tokvec;

	skip_consts_or_noreturns(&tokvec);

	enum TokenKind tok = tokvec[0].kind;
	struct TypeNode *ptr = calloc(1, sizeof(struct TypeNode));

	if (tok == RES_CHAR) {
		ptr->type_category = CHAR_;
		++tokvec;
	} else if (tok == RES_INT) {
		ptr->type_category = INT_;
		++tokvec;
	} else if (tok == RES_VOID) {
		ptr->type_category = VOID_;
		++tokvec;
	} else if (tok == RES_STRUCT || tok == RES_UNION) {
		++tokvec;
		expect_and_consume(&tokvec, IDENT_OR_RESERVED,
		                   "identifier after `struct` or `union`");
		const char *ident = tokvec[-1].ident_str;

		ptr->type_category = tok == RES_STRUCT ? STRUCT_NOT_UNION : UNION;
		ptr->s.struct_or_union_tag = ident;
		if (tokvec[0].kind != LEFT_BRACE) {
			ptr->s.struct_or_union_info.ptr_types_and_idents =
			    0; /* crucial; no info */
			skip_consts_or_noreturns(&tokvec);
			*ptr_tokvec = tokvec;
			return ptr;
		}
		++tokvec;
		ptr->s.struct_or_union_info.ptr_types_and_idents = init_vector_();

		while (1) {
			if (tokvec[0].kind == RIGHT_BRACE) {
				++tokvec;
				break;
			}
			const char *ident_str;
			struct Type t = parse_struct_declaration(&tokvec, &ident_str);
			expect_and_consume(
			    &tokvec, SEMICOLON,
			    "semicolon after the declarator inside struct or union");
			struct TypeAndIdent *ptr_t_and_i =
			    calloc(1, sizeof(struct TypeAndIdent));
			ptr_t_and_i->type = t;
			ptr_t_and_i->ident_str = ident_str;

			push_vector(ptr->s.struct_or_union_info.ptr_types_and_idents,
			            ptr_t_and_i);
		}
	} else if (tok == RES_ENUM) {
		++tokvec;
		expect_and_consume(&tokvec, IDENT_OR_RESERVED,
		                   "identifier after `enum`");
		const char *ident = tokvec[-1].ident_str;
		ptr->type_category = ENUM_;
		ptr->e.enum_tag = ident;
		if (tokvec[0].kind != LEFT_BRACE) {
			ptr->e.enum_info.ptr_enumerators = 0; /* crucial; no info */
			skip_consts_or_noreturns(&tokvec);
			*ptr_tokvec = tokvec;
			return ptr;
		}
		++tokvec;

		ptr->e.enum_info.ptr_enumerators = init_vector_();

		do { /* at least one enumerator is needed */
			expect_and_consume(&tokvec, IDENT_OR_RESERVED,
			                   "identifier as a declaration of an enumerator");
			const char *ident_str = tokvec[-1].ident_str;
			push_vector(ptr->e.enum_info.ptr_enumerators, ident_str);

			/* ending without comma */
			if (tokvec[0].kind == RIGHT_BRACE) {
				++tokvec;
				break;
			} else if (tokvec[0].kind == OP_COMMA) {
				++tokvec;
				if (tokvec[0].kind == RIGHT_BRACE) {
					++tokvec;
					break;
				}
			}
		} while (1);

	

	} else {
		error_unexpected_token(
		    tokvec, "type name `int`, `char`, `void`, `struct` or `enum`");
	}

	skip_consts_or_noreturns(&tokvec);
	*ptr_tokvec = tokvec;
	return ptr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
leaq -0x18(%rbp), %rdi
callq 0xc100
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
movl $0x1, %edi
movl $0x50, %esi
callq 0x10b0
movq %rax, -0x28(%rbp)
cmpl $0x38, -0x1c(%rbp)
jne 0xbae0
movq -0x28(%rbp), %rax
movl $0x4, (%rax)
movq -0x18(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x18(%rbp)
jmp 0xbdbd
cmpl $0x35, -0x1c(%rbp)
jne 0xbb01
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x18(%rbp)
jmp 0xbdbb
cmpl $0x3e, -0x1c(%rbp)
jne 0xbb22
movq -0x28(%rbp), %rax
movl $0x7, (%rax)
movq -0x18(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x18(%rbp)
jmp 0xbdb9
cmpl $0x3a, -0x1c(%rbp)
je 0xbb32
cmpl $0x4a, -0x1c(%rbp)
jne 0xbc71
movq -0x18(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x18(%rbp)
leaq -0x18(%rbp), %rdi
movl $0x18, %esi
leaq 0x99fe(%rip), %rdx      # 0x1554c
callq 0xb190
movq -0x18(%rbp), %rax
movq -0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x1c(%rbp), %edx
movl $0x6, %ecx
movl $0x5, %eax
cmpl $0x3a, %edx
cmovel %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1e, (%rax)
je 0xbbba
movq -0x28(%rbp), %rax
movq $0x0, 0x38(%rax)
leaq -0x18(%rbp), %rdi
callq 0xc100
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xbdd9
movq -0x18(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x18(%rbp)
callq 0x6200
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1f, (%rax)
jne 0xbbed
movq -0x18(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x18(%rbp)
jmp 0xbc6c
leaq -0x88(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0xc160
leaq -0x18(%rbp), %rdi
movl $0x1a, %esi
leaq 0x9960(%rip), %rdx      # 0x15571
callq 0xb190
movl $0x1, %edi
movl $0x58, %esi
callq 0x10b0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movl $0x50, %edx
callq 0x10e0
movq -0x38(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x90(%rbp), %rsi
callq 0x62c0
jmp 0xbbd6
jmp 0xbdb7
cmpl $0x43, -0x1c(%rbp)
jne 0xbda5
movq -0x18(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x18(%rbp)
leaq -0x18(%rbp), %rdi
movl $0x18, %esi
leaq 0x9910(%rip), %rdx      # 0x155a7
callq 0xb190
movq -0x18(%rbp), %rax
movq -0x18(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x28(%rbp), %rax
movl $0x8, (%rax)
movq -0x98(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1e, (%rax)
je 0xbcfa
movq -0x28(%rbp), %rax
movq $0x0, 0x48(%rax)
leaq -0x18(%rbp), %rdi
callq 0xc100
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xbdd9
movq -0x18(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x18(%rbp)
callq 0x6200
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x48(%rax)
leaq -0x18(%rbp), %rdi
movl $0x18, %esi
leaq 0x9899(%rip), %rdx      # 0x155bf
callq 0xb190
movq -0x18(%rbp), %rax
movq -0x18(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0xa0(%rbp), %rsi
callq 0x62c0
movq -0x18(%rbp), %rax
cmpl $0x1f, (%rax)
jne 0xbd65
movq -0x18(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x18(%rbp)
jmp 0xbda3
movq -0x18(%rbp), %rax
cmpl $0xa, (%rax)
jne 0xbd93
movq -0x18(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x1f, (%rax)
jne 0xbd91
movq -0x18(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x18(%rbp)
jmp 0xbda3
jmp 0xbd93
jmp 0xbd95
jmp 0xbd97
movb $0x1, %al
testb $0x1, %al
jne 0xbd16
jmp 0xbda3
jmp 0xbdb5
movq -0x18(%rbp), %rdi
leaq 0x983c(%rip), %rsi      # 0x155ec
callq 0xb070
jmp 0xbdb7
jmp 0xbdb9
jmp 0xbdbb
jmp 0xbdbd
leaq -0x18(%rbp), %rdi
callq 0xc100
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)