// File: yanlinlin82[P]icpp/icpp.cpp
// Function: parse_type_name[abi:cxx11]()
string parse_type_name()
{
	string prefix;
	if (token == "static" || token == "extern") {
		prefix = token;
		next(); // skip this prefix
	}
	string type_name;
	if (token == "auto") {
		type_name = token; next();
	} else {
		vector<pair<token_type, string>> a;
		int angle_bracket = 0;
		while (token == "const" || is_built_in_type() ||
				token == "*" || token == "&" ||
				token == "<" || token == ">" || token == ">>") {
			if (token == "<") {
				++angle_bracket;
				a.push_back(make_pair(type, token));
				next();
			} else if (token == ">") {
				if (--angle_bracket < 0) { err("unexpected '>'!\n"); }
				a.push_back(make_pair(type, token));
				next();
			} else if (token == ">>") {
				if (angle_bracket < 2) { err("unexpected '>>'!\n"); }
				angle_bracket -= 2;
				a.push_back(make_pair(type, ">"));
				a.push_back(make_pair(type, ">"));
				next();
			} else {
				a.push_back(make_pair(type, token));
				next();
			}
		}
		token_type last_token_type = unknown;
		for (auto e : a) {
			if (e.first == symbol && last_token_type == symbol && !type_name.empty()) {
				type_name += " ";
			}
			type_name += e.second;
			last_token_type = e.first;
		}
	}
	if (type_name == "size_t") { // TODO: support typedef
		type_name = "int";
	}
	return type_name;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x1a0(%rbp)
movq %rdi, %rax
movq %rax, -0x198(%rbp)
movq %rdi, -0x8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x3380
leaq 0x49438(%rip), %rdi     # 0x504e8
leaq 0x303e4(%rip), %rsi     # 0x3749b
callq 0x1a9c0
movb %al, -0x189(%rbp)
jmp 0x70c4
movb -0x189(%rbp), %al
testb $0x1, %al
jne 0x70f7
jmp 0x70d0
leaq 0x49411(%rip), %rdi     # 0x504e8
leaq 0x303c4(%rip), %rsi     # 0x374a2
callq 0x1a9c0
movb %al, -0x1a1(%rbp)
jmp 0x70eb
movb -0x1a1(%rbp), %al
testb $0x1, %al
jne 0x70f7
jmp 0x7123
leaq 0x493ea(%rip), %rsi     # 0x504e8
leaq -0x28(%rbp), %rdi
callq 0x3030
jmp 0x7109
callq 0x6030
jmp 0x7110
jmp 0x7123
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x77a6
movq -0x1a0(%rbp), %rdi
movb $0x0, -0x35(%rbp)
callq 0x3380
leaq 0x493ae(%rip), %rdi     # 0x504e8
leaq 0x30368(%rip), %rsi     # 0x374a9
callq 0x1a9c0
movb %al, -0x1a2(%rbp)
jmp 0x714e
movb -0x1a2(%rbp), %al
testb $0x1, %al
jne 0x715a
jmp 0x718c
movq -0x1a0(%rbp), %rdi
leaq 0x49380(%rip), %rsi     # 0x504e8
callq 0x3030
jmp 0x716f
callq 0x6030
jmp 0x7176
jmp 0x772d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x779a
leaq -0x50(%rbp), %rdi
callq 0x1a9f0
movl $0x0, -0x54(%rbp)
leaq 0x49345(%rip), %rdi     # 0x504e8
leaq 0x30304(%rip), %rsi     # 0x374ae
callq 0x1a9c0
movb %al, -0x1a3(%rbp)
jmp 0x71b7
movb -0x1a3(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x1a4(%rbp)
jne 0x72e7
jmp 0x71d0
callq 0x6f20
movb %al, -0x1a5(%rbp)
jmp 0x71dd
movb -0x1a5(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x1a4(%rbp)
jne 0x72e7
jmp 0x71f6
leaq 0x492eb(%rip), %rdi     # 0x504e8
leaq 0x2ff0d(%rip), %rsi     # 0x37111
callq 0x1a9c0
movb %al, -0x1a6(%rbp)
jmp 0x7211
movb -0x1a6(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x1a4(%rbp)
jne 0x72e7
jmp 0x722a
leaq 0x492b7(%rip), %rdi     # 0x504e8
leaq 0x2fef3(%rip), %rsi     # 0x3712b
callq 0x1a9c0
movb %al, -0x1a7(%rbp)
jmp 0x7245
movb -0x1a7(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x1a4(%rbp)
jne 0x72e7
jmp 0x725e
leaq 0x49283(%rip), %rdi     # 0x504e8
leaq 0x30bae(%rip), %rsi     # 0x37e1a
callq 0x1a9c0
movb %al, -0x1a8(%rbp)
jmp 0x7279
movb -0x1a8(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x1a4(%rbp)
jne 0x72e7
jmp 0x728e
leaq 0x49253(%rip), %rdi     # 0x504e8
leaq 0x30111(%rip), %rsi     # 0x373ad
callq 0x1a9c0
movb %al, -0x1a9(%rbp)
jmp 0x72a9
movb -0x1a9(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x1a4(%rbp)
jne 0x72e7
jmp 0x72be
leaq 0x49223(%rip), %rdi     # 0x504e8
leaq 0x2fe4f(%rip), %rsi     # 0x3711b
callq 0x1a9c0
movb %al, -0x1aa(%rbp)
jmp 0x72d9
movb -0x1aa(%rbp), %al
movb %al, -0x1a4(%rbp)
jmp 0x72e7
movb -0x1a4(%rbp), %al
testb $0x1, %al
jne 0x72f6
jmp 0x7612
leaq 0x491eb(%rip), %rdi     # 0x504e8
leaq 0x30b16(%rip), %rsi     # 0x37e1a
callq 0x1a9c0
movb %al, -0x1ab(%rbp)
jmp 0x7311
movb -0x1ab(%rbp), %al
testb $0x1, %al
jne 0x731d
jmp 0x738d
movl -0x54(%rbp), %eax
incl %eax
movl %eax, -0x54(%rbp)
leaq 0x491b4(%rip), %rsi     # 0x504e0
leaq 0x491b5(%rip), %rdx     # 0x504e8
leaq -0x80(%rbp), %rdi
callq 0x1aa40
jmp 0x733e
leaq -0x50(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x1aa10
jmp 0x734d
leaq -0x80(%rbp), %rdi
callq 0x1aa80
callq 0x6030
jmp 0x735d
jmp 0x760d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7722
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x1aa80
jmp 0x7722
leaq 0x49154(%rip), %rdi     # 0x504e8
leaq 0x30012(%rip), %rsi     # 0x373ad
callq 0x1a9c0
movb %al, -0x1ac(%rbp)
jmp 0x73a8
movb -0x1ac(%rbp), %al
testb $0x1, %al
jne 0x73b7
jmp 0x743a
movl -0x54(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, %eax
jge 0x73d7
leaq 0x300e8(%rip), %rdi     # 0x374b4
xorl %eax, %eax
callq 0x1a780
jmp 0x73d5
jmp 0x73d7
leaq 0x49102(%rip), %rsi     # 0x504e0
leaq 0x49103(%rip), %rdx     # 0x504e8
leaq -0xa8(%rbp), %rdi
callq 0x1aa40
jmp 0x73f3
leaq -0x50(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x1aa10
jmp 0x7405
leaq -0xa8(%rbp), %rdi
callq 0x1aa80
callq 0x6030
jmp 0x7418
jmp 0x760b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x1aa80
jmp 0x7722
leaq 0x490a7(%rip), %rdi     # 0x504e8
leaq 0x2fcd3(%rip), %rsi     # 0x3711b
callq 0x1a9c0
movb %al, -0x1ad(%rbp)
jmp 0x7455
movb -0x1ad(%rbp), %al
testb $0x1, %al
jne 0x7464
jmp 0x75a9
cmpl $0x2, -0x54(%rbp)
jge 0x747c
leaq 0x30054(%rip), %rdi     # 0x374c5
xorl %eax, %eax
callq 0x1a780
jmp 0x747a
jmp 0x747c
movl -0x54(%rbp), %eax
addl $-0x2, %eax
movl %eax, -0x54(%rbp)
leaq 0x49054(%rip), %rdi     # 0x504e0
leaq 0x2ff1a(%rip), %rsi     # 0x373ad
callq 0x1aaa0
movq %rdx, -0x1c0(%rbp)
movl %eax, -0x1b4(%rbp)
jmp 0x74a7
movq -0x1c0(%rbp), %rax
movl -0x1b4(%rbp), %ecx
movl %ecx, -0xe0(%rbp)
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x1aae0
jmp 0x74d6
leaq -0x50(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x1aa10
jmp 0x74e8
leaq -0xd0(%rbp), %rdi
callq 0x1aa80
leaq 0x48fe5(%rip), %rdi     # 0x504e0
leaq 0x2feab(%rip), %rsi     # 0x373ad
callq 0x1aaa0
movq %rdx, -0x1d0(%rbp)
movl %eax, -0x1c4(%rbp)
jmp 0x7516
movq -0x1d0(%rbp), %rax
movl -0x1c4(%rbp), %ecx
movl %ecx, -0x118(%rbp)
movq %rax, -0x110(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x1aae0
jmp 0x7545
leaq -0x50(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x1aa10
jmp 0x7557
leaq -0x108(%rbp), %rdi
callq 0x1aa80
callq 0x6030
jmp 0x756a
jmp 0x7609
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x1aa80
jmp 0x7722
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x1aa80
jmp 0x7722
leaq 0x48f30(%rip), %rsi     # 0x504e0
leaq 0x48f31(%rip), %rdx     # 0x504e8
leaq -0x140(%rbp), %rdi
callq 0x1aa40
jmp 0x75c5
leaq -0x50(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x1aa10
jmp 0x75d7
leaq -0x140(%rbp), %rdi
callq 0x1aa80
callq 0x6030
jmp 0x75ea
jmp 0x7609
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x1aa80
jmp 0x7722
jmp 0x760b
jmp 0x760d
jmp 0x719c
movl $0x0, -0x144(%rbp)
leaq -0x50(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rdi
callq 0x1ab60
movq %rax, -0x158(%rbp)
movq -0x150(%rbp), %rdi
callq 0x1ab90
movq %rax, -0x160(%rbp)
leaq -0x158(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x1abc0
testb $0x1, %al
jne 0x7669
jmp 0x7717
leaq -0x158(%rbp), %rdi
callq 0x1ac00
movq %rax, %rsi
leaq -0x188(%rbp), %rdi
callq 0x1ac20
jmp 0x7686
cmpl $0x1, -0x188(%rbp)
jne 0x76d9
cmpl $0x1, -0x144(%rbp)
jne 0x76d9
movq -0x1a0(%rbp), %rdi
callq 0x3430
testb $0x1, %al
jne 0x76d9
movq -0x1a0(%rbp), %rdi
leaq 0x2fb0a(%rip), %rsi     # 0x371c0
callq 0x3240
jmp 0x76bd
jmp 0x76d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x1aa80
jmp 0x7722
movq -0x1a0(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x3330
jmp 0x76ee
movl -0x188(%rbp), %eax
movl %eax, -0x144(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x1aa80
leaq -0x158(%rbp), %rdi
callq 0x1ac60
jmp 0x764d
leaq -0x50(%rbp), %rdi
callq 0x1ac80
jmp 0x772d
leaq -0x50(%rbp), %rdi
callq 0x1ac80
jmp 0x779a
movq -0x1a0(%rbp), %rdi
leaq 0x2fd59(%rip), %rsi     # 0x37494
callq 0x1a9c0
movb %al, -0x1d1(%rbp)
jmp 0x7748
movb -0x1d1(%rbp), %al
testb $0x1, %al
jne 0x7754
jmp 0x776b
movq -0x1a0(%rbp), %rdi
leaq 0x306c2(%rip), %rsi     # 0x37e24
callq 0x3370
jmp 0x7769
jmp 0x776b
movb $0x1, -0x35(%rbp)
testb $0x1, -0x35(%rbp)
jne 0x7781
movq -0x1a0(%rbp), %rdi
callq 0x34d8
leaq -0x28(%rbp), %rdi
callq 0x34d8
movq -0x198(%rbp), %rax
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
movq -0x1a0(%rbp), %rdi
callq 0x34d8
leaq -0x28(%rbp), %rdi
callq 0x34d8
movq -0x30(%rbp), %rdi
callq 0x3460
nopl (%rax,%rax)