// File: yanlinlin82[P]icpp/icpp.cpp
// Function: parse_enum()
void parse_enum()
{
	next(); // skip 'enum'

	if (type != symbol) {
		err("missing symbol for 'enum' name!\n");
	}
	string name = token;
	next(); // skip name

	expect_token("{", "enum " + name);
	next(); // skip '{'

	int value = 0;
	while (!token.empty() && token != "}") {
		if (type != symbol) {
			err("invalid token '%s' for 'enum' value!\n", token.c_str());
		}
		string enum_key = token;
		next(); // skip

		string value_txt;
		if (token == "=") {
			next(); // skip '='
			if (type != symbol && type != number) {
				err("invalid token '%s' for 'enum' declearation!\n", token.c_str());
			}
			value_txt = token;
			value = eval_number(value_txt);
			next();
		}
		log<3>("[DEBUG] enum '%s': %s%s%s\n", name.c_str(), enum_key.c_str(),
				(value_txt.empty() ? "" : " = "), value_txt.c_str());

		auto it = enum_values.find(name);
		if (it == enum_values.end()) {
			enum_values.insert(make_pair(name, unordered_map<string, int>()));
			it = enum_values.find(name);
		}
		auto it2 = it->second.find(enum_key);
		if (it2 != it->second.end()) {
			err("duplidated enum key '%s'!\n", enum_key.c_str());
		}
		it->second.insert(make_pair(enum_key, value++));
		auto it3 = enum_types.find(enum_key);
		if (it3 != enum_types.end()) {
			err("symbol '%s' has existed!\n", enum_key.c_str());
		}
		enum_types.insert(make_pair(enum_key, make_pair(name, value)));

		if (token == "}") break;
		expect_token(",", "enum " + name);
		next();
	}
	expect_token("}", "enum " + name);
	next(); // skip '}'
	expect_token(";", "enum " + name);
	next(); // skip ';'
	log<3>("[DEBUG] end of enum %s\n", name.c_str());
	if (verbose >= 4) dump_enum();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x400, %rsp            # imm = 0x400
callq 0x6030
cmpl $0x1, 0x3c369(%rip)     # 0x504e0
je 0x14187
leaq 0x23b4b(%rip), %rdi     # 0x37ccb
movb $0x0, %al
callq 0x1a780
leaq 0x3c35a(%rip), %rsi     # 0x504e8
leaq -0x20(%rbp), %rdi
callq 0x3120
callq 0x6030
jmp 0x1419e
leaq -0x51(%rbp), %rdi
movq %rdi, -0x360(%rbp)
callq 0x3470
movq -0x360(%rbp), %rdx
leaq 0x231f6(%rip), %rsi     # 0x373b2
leaq -0x50(%rbp), %rdi
callq 0x199b0
jmp 0x141c7
leaq 0x23b1e(%rip), %rsi     # 0x37cec
leaq -0x78(%rbp), %rdi
leaq -0x20(%rbp), %rdx
callq 0x1b340
jmp 0x141dd
leaq -0x50(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x6790
jmp 0x141ec
leaq -0x78(%rbp), %rdi
callq 0x34d8
leaq -0x50(%rbp), %rdi
callq 0x34d8
leaq -0x51(%rbp), %rdi
callq 0x32b0
callq 0x6030
jmp 0x1420e
movl $0x0, -0x7c(%rbp)
leaq 0x3c2cc(%rip), %rdi     # 0x504e8
callq 0x3430
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x361(%rbp)
jne 0x14259
leaq 0x3c2b1(%rip), %rdi     # 0x504e8
leaq 0x22f12(%rip), %rsi     # 0x37150
callq 0x1b450
movb %al, -0x362(%rbp)
jmp 0x1424b
movb -0x362(%rbp), %al
movb %al, -0x361(%rbp)
jmp 0x14259
movb -0x361(%rbp), %al
testb $0x1, %al
jne 0x14268
jmp 0x149c7
cmpl $0x1, 0x3c271(%rip)     # 0x504e0
je 0x142eb
leaq 0x3c270(%rip), %rdi     # 0x504e8
callq 0x3110
movq %rax, %rsi
leaq 0x23a6b(%rip), %rdi     # 0x37cf2
xorl %eax, %eax
callq 0x1a780
jmp 0x14290
jmp 0x142eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x14bba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x142dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x142d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x34d8
leaq -0x50(%rbp), %rdi
callq 0x34d8
leaq -0x51(%rbp), %rdi
callq 0x32b0
jmp 0x14bba
leaq 0x3c1f6(%rip), %rsi     # 0x504e8
leaq -0xa0(%rbp), %rdi
callq 0x3120
jmp 0x14300
callq 0x6030
jmp 0x14307
leaq -0xc0(%rbp), %rdi
callq 0x3380
leaq 0x3c1ce(%rip), %rdi     # 0x504e8
leaq 0x22e05(%rip), %rsi     # 0x37126
callq 0x1a9c0
movb %al, -0x363(%rbp)
jmp 0x1432e
movb -0x363(%rbp), %al
testb $0x1, %al
jne 0x1433d
jmp 0x14412
callq 0x6030
jmp 0x14344
cmpl $0x1, 0x3c195(%rip)     # 0x504e0
je 0x14399
cmpl $0x2, 0x3c18c(%rip)     # 0x504e0
je 0x14399
leaq 0x3c18b(%rip), %rdi     # 0x504e8
callq 0x3110
movq %rax, %rsi
leaq 0x239ac(%rip), %rdi     # 0x37d18
xorl %eax, %eax
callq 0x1a780
jmp 0x14375
jmp 0x14399
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x149b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x149aa
leaq 0x3c148(%rip), %rsi     # 0x504e8
leaq -0xc0(%rbp), %rdi
callq 0x3030
jmp 0x143ae
leaq -0xe0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3120
jmp 0x143c3
leaq -0xe0(%rbp), %rdi
callq 0x6ba0
movl %eax, -0x368(%rbp)
jmp 0x143d7
movl -0x368(%rbp), %eax
movl %eax, -0x7c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x34d8
callq 0x6030
jmp 0x143f3
jmp 0x14412
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x34d8
jmp 0x149aa
leaq -0x20(%rbp), %rdi
callq 0x3110
movq %rax, -0x380(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3110
movq %rax, -0x378(%rbp)
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x388(%rbp)
callq 0x3430
movq -0x388(%rbp), %rdi
movb %al, %dl
leaq 0x23f6c(%rip), %rcx     # 0x383c4
leaq 0x23901(%rip), %rax     # 0x37d60
testb %dl, %dl
cmovneq %rcx, %rax
movq %rax, -0x370(%rbp)
callq 0x3110
movq -0x380(%rbp), %rsi
movq -0x378(%rbp), %rdx
movq -0x370(%rbp), %rcx
movq %rax, %r8
leaq 0x238b5(%rip), %rdi     # 0x37d45
xorl %eax, %eax
callq 0x19760
jmp 0x14499
leaq 0x3c318(%rip), %rdi     # 0x507b8
leaq -0x20(%rbp), %rsi
callq 0x1c3f0
movq %rax, -0x390(%rbp)
jmp 0x144b2
movq -0x390(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq 0x3c2f1(%rip), %rdi     # 0x507b8
callq 0x193f0
movq %rax, -0xf0(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x1c420
testb $0x1, %al
jne 0x144ef
jmp 0x14600
xorps %xmm0, %xmm0
movaps %xmm0, -0x160(%rbp)
movaps %xmm0, -0x170(%rbp)
movaps %xmm0, -0x180(%rbp)
movq $0x0, -0x150(%rbp)
leaq -0x180(%rbp), %rdi
movq %rdi, -0x398(%rbp)
callq 0x1c4d0
movq -0x398(%rbp), %rdx
leaq -0x148(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x1c490
jmp 0x1453e
leaq 0x3c273(%rip), %rdi     # 0x507b8
leaq -0x148(%rbp), %rsi
callq 0x1c450
movb %dl, -0x3a1(%rbp)
movq %rax, -0x3a0(%rbp)
jmp 0x14560
movb -0x3a1(%rbp), %al
movq -0x3a0(%rbp), %rcx
movq %rcx, -0x190(%rbp)
movb %al, -0x188(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x1c4f0
leaq -0x180(%rbp), %rdi
callq 0x18e70
leaq 0x3c21f(%rip), %rdi     # 0x507b8
leaq -0x20(%rbp), %rsi
callq 0x1c3f0
movq %rax, -0x3b0(%rbp)
jmp 0x145ab
movq -0x3b0(%rbp), %rax
movq %rax, -0x198(%rbp)
movq -0x198(%rbp), %rax
movq %rax, -0xe8(%rbp)
jmp 0x14600
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x145ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x1c4f0
leaq -0x180(%rbp), %rdi
callq 0x18e70
jmp 0x149aa
leaq -0xe8(%rbp), %rdi
callq 0x194c0
movq %rax, %rdi
addq $0x20, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x1a850
movq %rax, -0x3b8(%rbp)
jmp 0x14628
movq -0x3b8(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x194c0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x19520
movq %rax, -0x1a8(%rbp)
leaq -0x1a0(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x19550
testb $0x1, %al
jne 0x1466e
jmp 0x1468f
leaq -0xa0(%rbp), %rdi
callq 0x3110
movq %rax, %rsi
leaq 0x236e0(%rip), %rdi     # 0x37d64
xorl %eax, %eax
callq 0x1a780
jmp 0x1468d
jmp 0x1468f
leaq -0xe8(%rbp), %rdi
callq 0x194c0
addq $0x20, %rax
movq %rax, -0x3c0(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, %ecx
incl %ecx
movl %ecx, -0x7c(%rbp)
movl %eax, -0x1d4(%rbp)
leaq -0x1d0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0x1d4(%rbp), %rdx
callq 0x1c560
jmp 0x146d2
movq -0x3c0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x1c520
movb %dl, -0x3c9(%rbp)
movq %rax, -0x3c8(%rbp)
jmp 0x146f4
movb -0x3c9(%rbp), %al
movq -0x3c8(%rbp), %rcx
movq %rcx, -0x1e8(%rbp)
movb %al, -0x1e0(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x1c140
leaq 0x3c0cf(%rip), %rdi     # 0x507f0
leaq -0xa0(%rbp), %rsi
callq 0x1ba00
movq %rax, -0x3d8(%rbp)
jmp 0x14736
movq -0x3d8(%rbp), %rax
movq %rax, -0x1f0(%rbp)
leaq 0x3c0a5(%rip), %rdi     # 0x507f0
callq 0x196b0
movq %rax, -0x1f8(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x19680
testb $0x1, %al
jne 0x14770
jmp 0x147ae
leaq -0xa0(%rbp), %rdi
callq 0x3110
movq %rax, %rsi
leaq 0x235f9(%rip), %rdi     # 0x37d7f
xorl %eax, %eax
callq 0x1a780
jmp 0x1478f
jmp 0x147ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x1c140
jmp 0x149aa
leaq -0x268(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x7c(%rbp), %rdx
callq 0x1c0e0
jmp 0x147c4
leaq -0x240(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0x268(%rbp), %rdx
callq 0x1c5e0
jmp 0x147e0
leaq 0x3c009(%rip), %rdi     # 0x507f0
leaq -0x240(%rbp), %rsi
callq 0x1c5a0
movb %dl, -0x3e1(%rbp)
movq %rax, -0x3e0(%rbp)
jmp 0x14802
movb -0x3e1(%rbp), %al
movq -0x3e0(%rbp), %rcx
movq %rcx, -0x278(%rbp)
movb %al, -0x270(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x1c620
leaq -0x268(%rbp), %rdi
callq 0x1c140
leaq 0x3bcad(%rip), %rdi     # 0x504e8
leaq 0x2290e(%rip), %rsi     # 0x37150
callq 0x1a9c0
movb %al, -0x3e2(%rbp)
jmp 0x1484f
movb -0x3e2(%rbp), %al
testb $0x1, %al
jne 0x1485b
jmp 0x148a1
movl $0x3, -0x27c(%rbp)
jmp 0x14933
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x14890
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x1c620
leaq -0x268(%rbp), %rdi
callq 0x1c140
jmp 0x149aa
leaq -0x2a1(%rbp), %rdi
movq %rdi, -0x3f0(%rbp)
callq 0x3470
movq -0x3f0(%rbp), %rdx
leaq 0x2288a(%rip), %rsi     # 0x3714c
leaq -0x2a0(%rbp), %rdi
callq 0x199b0
jmp 0x148d0
leaq 0x23415(%rip), %rsi     # 0x37cec
leaq -0x2c8(%rbp), %rdi
leaq -0x20(%rbp), %rdx
callq 0x1b340
jmp 0x148e9
leaq -0x2a0(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0x6790
jmp 0x148fe
leaq -0x2c8(%rbp), %rdi
callq 0x34d8
leaq -0x2a0(%rbp), %rdi
callq 0x34d8
leaq -0x2a1(%rbp), %rdi
callq 0x32b0
callq 0x6030
jmp 0x14929
movl $0x0, -0x27c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x34d8
leaq -0xa0(%rbp), %rdi
callq 0x34d8
movl -0x27c(%rbp), %eax
testl %eax, %eax
je 0x14959
jmp 0x14957
jmp 0x149c7
jmp 0x14215
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x1499e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x14992
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x34d8
leaq -0x2a0(%rbp), %rdi
callq 0x34d8
leaq -0x2a1(%rbp), %rdi
callq 0x32b0
leaq -0xc0(%rbp), %rdi
callq 0x34d8
leaq -0xa0(%rbp), %rdi
callq 0x34d8
jmp 0x14bba
leaq -0x2e9(%rbp), %rdi
movq %rdi, -0x3f8(%rbp)
callq 0x3470
movq -0x3f8(%rbp), %rdx
leaq 0x22768(%rip), %rsi     # 0x37150
leaq -0x2e8(%rbp), %rdi
callq 0x199b0
jmp 0x149f6
leaq 0x232ef(%rip), %rsi     # 0x37cec
leaq -0x310(%rbp), %rdi
leaq -0x20(%rbp), %rdx
callq 0x1b340
jmp 0x14a0f
leaq -0x2e8(%rbp), %rdi
leaq -0x310(%rbp), %rsi
callq 0x6790
jmp 0x14a24
leaq -0x310(%rbp), %rdi
callq 0x34d8
leaq -0x2e8(%rbp), %rdi
callq 0x34d8
leaq -0x2e9(%rbp), %rdi
callq 0x32b0
callq 0x6030
jmp 0x14a4f
leaq -0x331(%rbp), %rdi
movq %rdi, -0x400(%rbp)
callq 0x3470
movq -0x400(%rbp), %rdx
leaq 0x226e2(%rip), %rsi     # 0x37152
leaq -0x330(%rbp), %rdi
callq 0x199b0
jmp 0x14a7e
leaq 0x23267(%rip), %rsi     # 0x37cec
leaq -0x358(%rbp), %rdi
leaq -0x20(%rbp), %rdx
callq 0x1b340
jmp 0x14a97
leaq -0x330(%rbp), %rdi
leaq -0x358(%rbp), %rsi
callq 0x6790
jmp 0x14aac
leaq -0x358(%rbp), %rdi
callq 0x34d8
leaq -0x330(%rbp), %rdi
callq 0x34d8
leaq -0x331(%rbp), %rdi
callq 0x32b0
callq 0x6030
jmp 0x14ad7
leaq -0x20(%rbp), %rdi
callq 0x3110
movq %rax, %rsi
leaq 0x232af(%rip), %rdi     # 0x37d99
xorl %eax, %eax
callq 0x19760
jmp 0x14af3
cmpl $0x4, 0x3bd2e(%rip)     # 0x50828
jl 0x14ba8
callq 0x4420
jmp 0x14b07
jmp 0x14ba8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x14b4c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x14b40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x310(%rbp), %rdi
callq 0x34d8
leaq -0x2e8(%rbp), %rdi
callq 0x34d8
leaq -0x2e9(%rbp), %rdi
callq 0x32b0
jmp 0x14bba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x14b9a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x14b8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x358(%rbp), %rdi
callq 0x34d8
leaq -0x330(%rbp), %rdi
callq 0x34d8
leaq -0x331(%rbp), %rdi
callq 0x32b0
jmp 0x14bba
leaq -0x20(%rbp), %rdi
callq 0x34d8
addq $0x400, %rsp            # imm = 0x400
popq %rbp
retq
leaq -0x20(%rbp), %rdi
callq 0x34d8
movq -0x28(%rbp), %rdi
callq 0x3460
nopl (%rax)