// File: yanlinlin82[P]icpp/icpp.cpp
// Function: query_symbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
auto query_symbol(string s) -> tuple<bool, size_t, string, bool> // { is_global, offset, name, is_code }
{
	log<4>("[DEBUG] query symbol: '%s'\n", s.c_str());
	print_stack_frame();

	bool found = false;
	bool is_global = false;
	size_t offset = 0;
	string type_name;
	bool is_code = false;
	for (size_t i = stack_frame_table.size(); i > 0; --i) {
		auto& stack_frame = stack_frame_table[i - 1].second;
		auto it = stack_frame.find(s);
		if (it != stack_frame.end()) {
			found = true;
			is_global = false;
			offset = get<0>(it->second);
			type_name = get<2>(it->second);
			break;
		}
	}
	if (!found) {
		is_global = true;
		auto it = symbols.find(s);
		if (it == symbols.end()) {
			auto it2 = override_functions.find(s);
			if (it2 == override_functions.end() || it2->second.empty()) {
				err("unknown symbol '%s'!\n", s.c_str());
			}
			if (it2->second.size() > 1) {
				err("undetermined override symbol '%s'!\n", s.c_str());
			}
			it = symbols.find(*(it2->second.begin()));
			if (it == symbols.end()) {
				err("unknown symbol '%s'!\n", s.c_str());
			}
		}
		auto [ is_code_2, offset_2, size, t, ret_type, arg_count ] = it->second;
		is_code = is_code_2;
		offset = offset_2;
		type_name = t;
	}
	log<3>("[DEBUG] symbol '%s': '%s', type='%s', offset=%zd, type='%s'\n",
			s.c_str(), (is_code ? "code" : "data"), (is_global ? "global" : "local"), offset, type_name.c_str());
	return make_tuple(is_global, offset, type_name, is_code);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rsi, -0x158(%rbp)
movq %rdi, %rax
movq -0x158(%rbp), %rdi
movq %rax, -0x150(%rbp)
movq %rax, %rcx
movq %rcx, -0x148(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
callq 0x3110
movq %rax, %rsi
leaq 0x2f85d(%rip), %rdi     # 0x37551
movb $0x0, %al
callq 0x1b160
callq 0x5070
movb $0x0, -0x11(%rbp)
movb $0x0, -0x12(%rbp)
movq $0x0, -0x20(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3380
movb $0x0, -0x41(%rbp)
leaq 0x48874(%rip), %rdi     # 0x50598
callq 0x1b200
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jbe 0x7e0e
movq -0x50(%rbp), %rsi
decq %rsi
leaq 0x48852(%rip), %rdi     # 0x50598
callq 0x1b220
movq -0x158(%rbp), %rsi
addq $0x8, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x1b240
movq %rax, -0x160(%rbp)
jmp 0x7d6c
movq -0x160(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
callq 0x19ea0
movq %rax, -0x78(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x19e70
testb $0x1, %al
jne 0x7d97
jmp 0x7dfb
movb $0x1, -0x11(%rbp)
movb $0x0, -0x12(%rbp)
leaq -0x60(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x19ed0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x1b270
movq -0x168(%rbp), %rdi
movslq (%rax), %rax
movq %rax, -0x20(%rbp)
callq 0x19ed0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x1b290
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x3030
jmp 0x7de8
jmp 0x7e0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x81d0
jmp 0x7dfd
movq -0x50(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x7d2d
testb $0x1, -0x11(%rbp)
jne 0x80f0
movq -0x158(%rbp), %rsi
movb $0x1, -0x12(%rbp)
leaq 0x487be(%rip), %rdi     # 0x505e8
callq 0x1af30
movq %rax, -0x170(%rbp)
jmp 0x7e38
movq -0x170(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq 0x4879e(%rip), %rdi     # 0x505e8
callq 0x1af90
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1af60
testb $0x1, %al
jne 0x7e6f
jmp 0x8000
movq -0x158(%rbp), %rsi
leaq 0x48813(%rip), %rdi     # 0x50690
callq 0x1ace0
movq %rax, -0x178(%rbp)
jmp 0x7e8b
movq -0x178(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq 0x487f0(%rip), %rdi     # 0x50690
callq 0x1ad40
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x1ad10
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x179(%rbp)
jne 0x7eec
leaq -0x90(%rbp), %rdi
callq 0x1adb0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x1b2b0
movb %al, -0x179(%rbp)
movb -0x179(%rbp), %al
testb $0x1, %al
jne 0x7ef8
jmp 0x7f19
movq -0x158(%rbp), %rdi
callq 0x3110
movq %rax, %rsi
leaq 0x2f65f(%rip), %rdi     # 0x3756d
xorl %eax, %eax
callq 0x1a780
jmp 0x7f17
jmp 0x7f19
leaq -0x90(%rbp), %rdi
callq 0x1adb0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x1b2d0
cmpq $0x1, %rax
jbe 0x7f58
movq -0x158(%rbp), %rdi
callq 0x3110
movq %rax, %rsi
leaq 0x2f636(%rip), %rdi     # 0x37583
xorl %eax, %eax
callq 0x1a780
jmp 0x7f56
jmp 0x7f58
leaq -0x90(%rbp), %rdi
callq 0x1adb0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x1ade0
movq %rax, -0xa8(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x1af00
movq %rax, %rsi
leaq 0x4865b(%rip), %rdi     # 0x505e8
callq 0x1af30
movq %rax, -0x188(%rbp)
jmp 0x7f9b
movq -0x188(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq 0x4862d(%rip), %rdi     # 0x505e8
callq 0x1af90
movq %rax, -0xb0(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x1af60
testb $0x1, %al
jne 0x7fdd
jmp 0x7ffe
movq -0x158(%rbp), %rdi
callq 0x3110
movq %rax, %rsi
leaq 0x2f57a(%rip), %rdi     # 0x3756d
xorl %eax, %eax
callq 0x1a780
jmp 0x7ffc
jmp 0x7ffe
jmp 0x8000
leaq -0x80(%rbp), %rdi
callq 0x1afc0
movq %rax, %rsi
addq $0x20, %rsi
leaq -0x110(%rbp), %rdi
callq 0x1aff0
jmp 0x801e
leaq -0x110(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x1b020
movq -0x190(%rbp), %rdi
movq %rax, -0x118(%rbp)
callq 0x1b040
movq -0x190(%rbp), %rdi
movq %rax, -0x120(%rbp)
callq 0x1b060
movq -0x190(%rbp), %rdi
movq %rax, -0x128(%rbp)
callq 0x1b080
movq -0x190(%rbp), %rdi
movq %rax, -0x130(%rbp)
callq 0x1b0a0
movq -0x190(%rbp), %rdi
movq %rax, -0x138(%rbp)
callq 0x1b0c0
movq %rax, -0x140(%rbp)
movq -0x118(%rbp), %rax
movb (%rax), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
movq -0x120(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x130(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x3030
jmp 0x80c5
leaq -0x110(%rbp), %rdi
callq 0x198d0
jmp 0x80f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x198d0
jmp 0x81d0
movq -0x158(%rbp), %rdi
callq 0x3110
movq %rax, -0x198(%rbp)
testb $0x1, -0x41(%rbp)
je 0x8119
leaq 0x2f129(%rip), %rax     # 0x37239
movq %rax, -0x1a0(%rbp)
jmp 0x8129
leaq 0x2f11e(%rip), %rax     # 0x3723e
movq %rax, -0x1a0(%rbp)
jmp 0x8129
movq -0x1a0(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movb -0x12(%rbp), %dl
leaq 0x2f4a3(%rip), %rcx     # 0x375e4
leaq 0x2f4a3(%rip), %rax     # 0x375eb
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, -0x1b0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x1a8(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3110
movq -0x198(%rbp), %rsi
movq -0x1b8(%rbp), %rdx
movq -0x1b0(%rbp), %rcx
movq -0x1a8(%rbp), %r8
movq %rax, %r9
leaq 0x2f417(%rip), %rdi     # 0x375a7
xorl %eax, %eax
callq 0x19760
jmp 0x8199
movq -0x150(%rbp), %rdi
leaq -0x12(%rbp), %rsi
leaq -0x20(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x41(%rbp), %r8
callq 0x1b2f0
jmp 0x81b7
leaq -0x40(%rbp), %rdi
callq 0x34d8
movq -0x148(%rbp), %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x34d8
movq -0x68(%rbp), %rdi
callq 0x3460
nopw %cs:(%rax,%rax)