// File: /workspace/github_c_makefile_star2_O3/lucvoo[P]sparse-dev/parse.c
// Function: parse_enum_declaration
static struct token *parse_enum_declaration(struct token *token, struct symbol *parent)
{
	unsigned long long lastval = 0;
	struct symbol *ctype = NULL, *base_type = NULL;
	struct range range = { };
	int mix_bitwise = 0;

	parent->examined = 1;
	parent->ctype.base_type = &int_ctype;
	while (token_type(token) == TOKEN_IDENT) {
		struct expression *expr = NULL;
		struct token *next = token->next;
		struct decl_state ctx = { };
		struct symbol *sym;

		// FIXME: only 'deprecated' should be accepted
		next = handle_attributes(next, &ctx);

		if (match_op(next, '=')) {
			next = constant_expression(next->next, &expr);
			lastval = get_expression_value(expr);
			ctype = &void_ctype;
			if (expr && expr->ctype)
				ctype = expr->ctype;
		} else if (!ctype) {
			ctype = &int_ctype;
		} else if (is_int_type(ctype)) {
			lastval++;
		} else {
			error_die(token->pos, "can't increment the last enum member");
		}

		if (!expr) {
			expr = alloc_expression(token->pos, EXPR_VALUE);
			expr->value = lastval;
			expr->ctype = ctype;
		}

		sym = alloc_symbol(token->pos, SYM_NODE);
		bind_symbol(sym, token->ident, NS_SYMBOL);
		sym->ctype.modifiers &= ~MOD_ADDRESSABLE;
		sym->initializer = expr;
		sym->enum_member = 1;
		sym->ctype.base_type = parent;
		add_ptr_list(&parent->symbol_list, sym);

		if (base_type != &bad_ctype) {
			if (ctype->type == SYM_NODE)
				ctype = ctype->ctype.base_type;
			if (ctype->type == SYM_ENUM) {
				if (ctype == parent)
					ctype = base_type;
				else 
					ctype = ctype->ctype.base_type;
			}
			/*
			 * base_type rules:
			 *  - if all enums are of the same type, then
			 *    the base_type is that type (two first
			 *    cases)
			 *  - if enums are of different types, they
			 *    all have to be integer types, and the
			 *    base type is at least "int_ctype".
			 *  - otherwise the base_type is "bad_ctype".
			 */
			if (!base_type || ctype == &bad_ctype) {
				base_type = ctype;
			} else if (ctype == base_type) {
				/* nothing */
			} else if (is_int_type(base_type) && is_int_type(ctype)) {
				base_type = &int_ctype;
			} else if (is_restricted_type(base_type) != is_restricted_type(ctype)) {
				if (!mix_bitwise++) {
					warning(expr->pos, "mixed bitwiseness");
				}
			} else if (is_restricted_type(base_type) && base_type != ctype) {
				sparse_error(expr->pos, "incompatible restricted type");
				info(expr->pos, "   expected: %s", show_typename(base_type));
				info(expr->pos, "        got: %s", show_typename(ctype));
				base_type = &bad_ctype;
			} else if (base_type != &bad_ctype) {
				sparse_error(token->pos, "bad enum definition");
				base_type = &bad_ctype;
			}
			parent->ctype.base_type = base_type;
		}
		if (is_int_type(base_type)) {
			update_range(&range, lastval, ctype);
		}
		token = next;

		sym->endpos = token->pos;

		if (!match_op(token, ','))
			break;
		token = token->next;
	}
	if (!base_type) {
		sparse_error(token->pos, "empty enum definition");
		base_type = &bad_ctype;
	}
	else if (!is_int_type(base_type))
		;
	else if (type_is_ok(&uint_ctype, range))
		base_type = &uint_ctype;
	else if (type_is_ok(&int_ctype, range))
		base_type = &int_ctype;
	else if (type_is_ok(&ulong_ctype, range))
		base_type = &ulong_ctype;
	else if (type_is_ok(&long_ctype, range))
		base_type = &long_ctype;
	else if (type_is_ok(&ullong_ctype, range))
		base_type = &ullong_ctype;
	else if (type_is_ok(&llong_ctype, range))
		base_type = &llong_ctype;
	else
		base_type = &bad_ctype;
	parent->ctype.base_type = base_type;
	parent->ctype.modifiers |= (base_type->ctype.modifiers & MOD_UNSIGNED);
	parent->examined = 0;

	if (mix_bitwise)
		return token;
	cast_enum_list(parent->symbol_list, base_type);

	return token;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rbx
xorl %r15d, %r15d
movq %r15, 0x38(%rsp)
movq %r15, 0x30(%rsp)
orb $0x8, 0x55(%rsi)
leaq 0x4f4bd(%rip), %r14     # 0x6b738
movq %r14, 0x60(%rsi)
movq %rdi, 0x18(%rsp)
movq (%rdi), %rdi
movl %edi, %eax
andl $0x3f, %eax
cmpl $0x3, %eax
jne 0x1c6be
movq %rbx, 0x10(%rsp)
leaq 0x98(%rbx), %rax
movq %rax, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
xorl %r13d, %r13d
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x18(%rsp), %r14
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %rdi
movq %rax, 0x90(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
leaq 0x40(%rsp), %rsi
callq 0x1aed1
movq %rax, %r15
movl (%rax), %eax
andl $0x3f, %eax
cmpl $0x12, %eax
jne 0x1c345
cmpl $0x3d, 0x10(%r15)
jne 0x1c345
movq 0x8(%r15), %rdi
leaq 0x8(%rsp), %rsi
callq 0x39b4c
movq %rax, %r15
movq 0x8(%rsp), %rdi
callq 0xf401
movq %rax, %rbp
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x1c397
movq 0x10(%rax), %rbx
testq %rbx, %rbx
jne 0x1c38a
leaq 0x4edd5(%rip), %rbx     # 0x6b118
jmp 0x1c38a
testq %rbx, %rbx
je 0x1c383
movzbl (%rbx), %ecx
movq %rbx, %rax
cmpl $0x3, %ecx
jne 0x1c35c
movq 0x60(%rbx), %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
jne 0x1c368
movq 0x60(%rax), %rax
movzbl (%rax), %ecx
cmpl $0xb, %ecx
je 0x1c37e
leaq 0x4eb04(%rip), %rcx     # 0x6ae78
cmpq %rcx, 0x60(%rax)
jne 0x1cb56
incq %rbp
jmp 0x1c38a
leaq 0x4f3ae(%rip), %rbx     # 0x6b738
cmpq $0x0, 0x8(%rsp)
movq %rbx, %r12
jne 0x1c3c7
jmp 0x1c39e
leaq 0x4ed7a(%rip), %rbx     # 0x6b118
movq %r14, %r12
movq (%r14), %r14
xorl %edi, %edi
callq 0x2f9f5
movq %r14, 0x8(%rax)
movq %r12, %r14
movw $0x1, (%rax)
movq %rax, 0x8(%rsp)
movq %rbp, 0x20(%rax)
movq %rbx, 0x10(%rax)
movq %rbx, %r12
movq (%r14), %rdi
movl $0x3, %esi
callq 0x2b00b
movq %r14, %rcx
movq %rax, %r14
movq %rcx, 0x18(%rsp)
movq 0x10(%rcx), %rsi
movq %rax, %rdi
movl $0x10, %edx
callq 0x2beca
andb $-0x2, 0x69(%r14)
movq 0x8(%rsp), %rax
movq %rax, 0xb0(%r14)
orb $0x10, 0x2(%r14)
movq 0x10(%rsp), %rax
movq %rax, 0x60(%r14)
movq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x227b4
leaq 0x50495(%rip), %rcx     # 0x6c8b8
cmpq %rcx, %r13
je 0x1c452
movzbl (%r12), %eax
cmpl $0x3, %eax
jne 0x1c43c
movq 0x60(%r12), %r12
movzbl (%r12), %eax
cmpl $0x9, %eax
jne 0x1c45d
movq %r13, %rbx
cmpq 0x10(%rsp), %r12
je 0x1c460
movq 0x60(%r12), %rbx
jmp 0x1c460
movq %r12, %rbx
movq %rcx, %r13
jmp 0x1c61a
movq %r12, %rbx
testq %r13, %r13
sete %al
cmpq %rcx, %rbx
sete %cl
orb %al, %cl
je 0x1c478
movq %rbx, %r13
jmp 0x1c611
cmpq %r13, %rbx
je 0x1c611
movzbl (%r13), %eax
movl %eax, %edx
movq %r13, %rcx
cmpl $0x3, %eax
jne 0x1c497
movq 0x60(%r13), %rcx
movzbl (%rcx), %edx
cmpl $0x9, %edx
jne 0x1c4a3
movq 0x60(%rcx), %rcx
movzbl (%rcx), %edx
cmpl $0xb, %edx
je 0x1c4b5
leaq 0x4e9c9(%rip), %rdx     # 0x6ae78
cmpq %rdx, 0x60(%rcx)
jne 0x1c4ed
movzbl (%rbx), %edx
movq %rbx, %rcx
cmpl $0x3, %edx
jne 0x1c4c7
movq 0x60(%rbx), %rcx
movzbl (%rcx), %edx
cmpl $0x9, %edx
jne 0x1c4d3
movq 0x60(%rcx), %rcx
movzbl (%rcx), %edx
cmpl $0xb, %edx
je 0x1c5bb
leaq 0x4e995(%rip), %rdx     # 0x6ae78
cmpq %rdx, 0x60(%rcx)
je 0x1c5bb
movl %eax, %ecx
movq %r13, %rdx
cmpl $0x3, %eax
jne 0x1c4fe
movq 0x60(%r13), %rdx
movzbl (%rdx), %ecx
cmpl $0x9, %ecx
jne 0x1c50a
movq 0x60(%rdx), %rcx
movzbl (%rcx), %ecx
movzbl (%rbx), %edx
movq %rbx, %rsi
cmpl $0x3, %edx
jne 0x1c51c
movq 0x60(%rbx), %rsi
movzbl (%rsi), %edx
cmpl $0x9, %edx
jne 0x1c528
movq 0x60(%rsi), %rdx
movzbl (%rdx), %edx
cmpl $0xd, %ecx
sete %cl
cmpl $0xd, %edx
setne %dl
xorb %cl, %dl
je 0x1c5c4
movq %r13, %rcx
cmpl $0x3, %eax
jne 0x1c54b
movq 0x60(%r13), %rcx
movzbl (%rcx), %eax
cmpl $0x9, %eax
jne 0x1c557
movq 0x60(%rcx), %rax
movzbl (%rax), %eax
cmpl $0xd, %eax
jne 0x1c5d1
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x27050(%rip), %rsi     # 0x435bc
xorl %eax, %eax
callq 0x11a80
movq 0x8(%rsp), %r12
movq %r13, %rdi
callq 0x237c5
movq 0x8(%r12), %rdi
leaq 0x2704d(%rip), %rsi     # 0x435d9
movq %rax, %rdx
xorl %eax, %eax
callq 0x1178c
movq 0x8(%rsp), %r12
movq %rbx, %rdi
callq 0x237c5
movq 0x8(%r12), %rdi
leaq 0x2703a(%rip), %rsi     # 0x435e9
movq %rax, %rdx
xorl %eax, %eax
callq 0x1178c
jmp 0x1c5e7
leaq 0x4f176(%rip), %r13     # 0x6b738
jmp 0x1c611
movq 0x20(%rsp), %rax
testl %eax, %eax
je 0x1c5f0
incl %eax
jmp 0x1c60c
movq 0x18(%rsp), %rax
movq (%rax), %rdi
leaq 0x27019(%rip), %rsi     # 0x435f9
xorl %eax, %eax
callq 0x11a80
leaq 0x502ca(%rip), %r13     # 0x6c8b8
jmp 0x1c611
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x26faa(%rip), %rsi     # 0x435aa
xorl %eax, %eax
callq 0x118fc
movl $0x1, %eax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq %r13, 0x60(%rax)
movzbl (%r13), %ecx
movq %r13, %rax
cmpl $0x3, %ecx
jne 0x1c62e
movq 0x60(%r13), %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
jne 0x1c63a
movq 0x60(%rax), %rax
movzbl (%rax), %ecx
cmpl $0xb, %ecx
je 0x1c64c
leaq 0x4e832(%rip), %rcx     # 0x6ae78
cmpq %rcx, 0x60(%rax)
jne 0x1c672
movzbl (%rbx), %ecx
movq %rbx, %rax
cmpl $0x3, %ecx
jne 0x1c65e
movq 0x60(%rbx), %rax
movzbl (%rax), %ecx
cmpl $0x4, %ecx
jne 0x1c6a0
leaq 0x30(%rsp), %rax
cmpq %rbp, 0x30(%rsp)
jae 0x1c672
movq %rbp, (%rax)
movq (%r15), %rax
movq %rax, 0xc(%r14)
movl (%r15), %eax
andl $0x3f, %eax
cmpl $0x12, %eax
jne 0x1c6d5
cmpl $0x2c, 0x10(%r15)
jne 0x1c6d5
movq 0x8(%r15), %r14
movl (%r14), %eax
andl $0x3f, %eax
cmpl $0x3, %eax
je 0x1c2bb
jmp 0x1c6d8
testq %rbp, %rbp
jns 0x1c663
movq 0x68(%rax), %rax
andl $0x4000, %eax           # imm = 0x4000
jne 0x1c663
leaq 0x38(%rsp), %rax
cmpq %rbp, 0x38(%rsp)
jg 0x1c66f
jmp 0x1c672
leaq 0x26f48(%rip), %rsi     # 0x4360d
xorl %eax, %eax
callq 0x11a80
leaq 0x501e5(%rip), %r13     # 0x6c8b8
jmp 0x1c724
movq %r15, %r14
movzbl (%r13), %ecx
movq %r13, %rax
cmpl $0x3, %ecx
jne 0x1c6ec
movq 0x60(%r13), %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
movq 0x10(%rsp), %rbx
movq %r14, 0x18(%rsp)
jne 0x1c702
movq 0x60(%rax), %rax
movzbl (%rax), %ecx
cmpl $0xb, %ecx
leaq 0x4f02c(%rip), %r14     # 0x6b738
movq 0x20(%rsp), %r15
je 0x1c79a
movq 0x60(%rax), %rax
cmpq 0x43866(%rip), %rax     # 0x5ff88
je 0x1c79a
movq %r13, 0x60(%rbx)
movq 0x68(%r13), %rax
andl $0x4000, %eax           # imm = 0x4000
orq %rax, 0x68(%rbx)
andb $-0x9, 0x55(%rbx)
testl %r15d, %r15d
jne 0x1c91e
movq %r13, %rbp
movzbl (%r14), %edx
movq %r14, %rax
cmpl $0x3, %edx
jne 0x1c75f
leaq 0x4efe0(%rip), %rax     # 0x6b738
movq 0x60(%rax), %rax
movzbl (%rax), %edx
movq 0x98(%rbx), %rcx
movq %rcx, 0x10(%rsp)
movl 0x50(%r14), %ecx
cmpl $0x4, %edx
je 0x1c811
testb $0x40, 0x69(%rax)
jne 0x1c811
decb %cl
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, 0x28(%rsp)
leaq -0x1(%rdx), %r15
jmp 0x1c826
movq 0x38(%rsp), %rax
leaq 0x4f152(%rip), %r13     # 0x6b8f8
movl 0x50(%r13), %ecx
movq 0x68(%r13), %rsi
btl $0xe, %esi
adcl $-0x1, %ecx
movq 0x30(%rsp), %rdx
cmpl $0x40, %ecx
setae %dil
movq %rdx, %r8
shrq %cl, %r8
testq %r8, %r8
sete %r8b
orb %dil, %r8b
cmpb $0x1, %r8b
jne 0x1c93e
shrl $0xe, %esi
andl $0x1, %esi
testq %rax, %rax
sete %dil
orb %sil, %dil
jne 0x1c935
movq %rax, %rsi
notq %rsi
shrq %cl, %rsi
cmpl $0x3f, %ecx
ja 0x1c724
testq %rsi, %rsi
jne 0x1c93e
jmp 0x1c724
negb %cl
movq $-0x1, %r15
shrq %cl, %r15
movq $0x0, 0x28(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0x1c91e
movq 0x10(%rsp), %r14
movzwl (%r14), %eax
testb %al, %al
jle 0x1c90f
xorl %r13d, %r13d
movq 0x18(%r14,%r13,8), %rcx
movzwl %ax, %eax
cmpl $0x100, %eax            # imm = 0x100
jb 0x1c85e
testq %rcx, %rcx
je 0x1c8fc
movq 0xb0(%rcx), %rbx
cmpb $0x1, (%rbx)
jne 0x1c8fc
movq 0x10(%rbx), %r12
movq %rbx, %rdi
callq 0xf401
movzbl (%r12), %ecx
movl %ecx, %esi
movq %r12, %rdx
cmpl $0x3, %ecx
jne 0x1c891
movq 0x60(%r12), %rdx
movzbl (%rdx), %esi
cmpl $0x9, %esi
jne 0x1c89d
movq 0x60(%rdx), %rdx
movzbl (%rdx), %esi
cmpl $0xb, %esi
je 0x1c8af
leaq 0x4e5cf(%rip), %rsi     # 0x6ae78
cmpq %rsi, 0x60(%rdx)
jne 0x1c8c8
cmpl $0x3, %ecx
jne 0x1c8be
movq 0x60(%r12), %r12
movzbl (%r12), %ecx
cmpl $0x4, %ecx
jne 0x1c8d8
cmpq %rax, %r15
jae 0x1c8f1
movq %rbx, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0xea9c
jmp 0x1c8fc
testq %rax, %rax
jns 0x1c8c3
movq 0x68(%r12), %rcx
andl $0x4000, %ecx           # imm = 0x4000
jne 0x1c8c3
cmpq %rax, 0x28(%rsp)
jg 0x1c8c8
leaq 0x4ee40(%rip), %rax     # 0x6b738
movq %rax, 0x10(%rbx)
incq %r13
movl (%r14), %eax
movsbq %al, %rcx
cmpq %rcx, %r13
jl 0x1c846
movq 0x10(%r14), %r14
cmpq 0x10(%rsp), %r14
jne 0x1c837
movq 0x18(%rsp), %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rax, %rax
je 0x1c724
leaq 0x4edf3(%rip), %r13     # 0x6b738
movl 0x50(%r13), %ecx
movq 0x68(%r13), %rsi
btl $0xe, %esi
adcl $-0x1, %ecx
cmpl $0x40, %ecx
setae %dil
movq %rdx, %r8
shrq %cl, %r8
testq %r8, %r8
sete %r8b
orb %dil, %r8b
cmpb $0x1, %r8b
jne 0x1c9a8
shrl $0xe, %esi
andl $0x1, %esi
testq %rax, %rax
sete %dil
orb %sil, %dil
jne 0x1c99f
movq %rax, %rsi
notq %rsi
shrq %cl, %rsi
cmpl $0x3f, %ecx
ja 0x1c724
testq %rsi, %rsi
jne 0x1c9a8
jmp 0x1c724
testq %rax, %rax
je 0x1c724
leaq 0x4f1e9(%rip), %r13     # 0x6bb98
movl 0x50(%r13), %ecx
movq 0x68(%r13), %rsi
btl $0xe, %esi
adcl $-0x1, %ecx
cmpl $0x40, %ecx
setae %dil
movq %rdx, %r8
shrq %cl, %r8
testq %r8, %r8
sete %r8b
orb %dil, %r8b
cmpb $0x1, %r8b
jne 0x1ca12
shrl $0xe, %esi
andl $0x1, %esi
testq %rax, %rax
sete %dil
orb %sil, %dil
jne 0x1ca09
movq %rax, %rsi
notq %rsi
shrq %cl, %rsi
cmpl $0x3f, %ecx
ja 0x1c724
testq %rsi, %rsi
jne 0x1ca12
jmp 0x1c724
testq %rax, %rax
je 0x1c724
leaq 0x4efbf(%rip), %r13     # 0x6b9d8
movl 0x50(%r13), %ecx
movq 0x68(%r13), %rsi
btl $0xe, %esi
adcl $-0x1, %ecx
cmpl $0x40, %ecx
setae %dil
movq %rdx, %r8
shrq %cl, %r8
testq %r8, %r8
sete %r8b
orb %dil, %r8b
cmpb $0x1, %r8b
jne 0x1ca7c
shrl $0xe, %esi
andl $0x1, %esi
testq %rax, %rax
sete %dil
orb %sil, %dil
jne 0x1ca73
movq %rax, %rsi
notq %rsi
shrq %cl, %rsi
cmpl $0x3f, %ecx
ja 0x1c724
testq %rsi, %rsi
jne 0x1ca7c
jmp 0x1c724
testq %rax, %rax
je 0x1c724
leaq 0x4f3b5(%rip), %r13     # 0x6be38
movl 0x50(%r13), %ecx
movq 0x68(%r13), %rsi
btl $0xe, %esi
adcl $-0x1, %ecx
cmpl $0x40, %ecx
setae %dil
movq %rdx, %r8
shrq %cl, %r8
testq %r8, %r8
sete %r8b
orb %dil, %r8b
cmpb $0x1, %r8b
jne 0x1cae6
shrl $0xe, %esi
andl $0x1, %esi
testq %rax, %rax
sete %dil
orb %sil, %dil
jne 0x1cadd
movq %rax, %rsi
notq %rsi
shrq %cl, %rsi
cmpl $0x3f, %ecx
ja 0x1c724
testq %rsi, %rsi
jne 0x1cae6
jmp 0x1c724
testq %rax, %rax
je 0x1c724
leaq 0x4f18b(%rip), %r13     # 0x6bc78
movl 0x50(%r13), %ecx
movq 0x68(%r13), %rsi
btl $0xe, %esi
adcl $-0x1, %ecx
cmpl $0x40, %ecx
setae %dil
shrq %cl, %rdx
testq %rdx, %rdx
sete %dl
orb %dil, %dl
cmpb $0x1, %dl
jne 0x1c6cc
shrl $0xe, %esi
andl $0x1, %esi
testq %rax, %rax
sete %dl
orb %sil, %dl
jne 0x1cb48
cmpl $0x40, %ecx
setb %dl
notq %rax
shrq %cl, %rax
testq %rax, %rax
setne %al
testb %al, %dl
jne 0x1c6cc
jmp 0x1c724
testq %rax, %rax
jne 0x1c6cc
jmp 0x1c724
movq (%r14), %rdi
leaq 0x26a25(%rip), %rsi     # 0x43585
xorl %eax, %eax
callq 0x11b9c