// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rsi
leaq 0x10683(%rip), %rdi     # 0x16611
xorl %eax, %eax
callq 0xf569
callq 0x464c
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x1b397(%rip), %r15     # 0x21348
subq 0x1b388(%rip), %r15     # 0x21340
movq %r15, %r12
sarq $0x6, %r12
addq $-0x38, %r15
incq %r12
decq %r12
je 0x6005
movq 0x1b36e(%rip), %rdi     # 0x21340
addq %r15, %rdi
movq %r14, %rsi
callq 0x13714
addq $-0x40, %r15
testq %rax, %rax
je 0x5fc6
movq %rax, %rsi
addq $0x28, %rsi
movslq 0x4c(%rax), %r15
leaq -0x48(%rbp), %rdi
callq 0x3130
xorl %r12d, %r12d
xorl %r13d, %r13d
jmp 0x60cf
leaq 0x1b384(%rip), %rdi     # 0x21390
movq %r14, %rsi
callq 0x136c0
movq %rax, %r15
testq %rax, %rax
jne 0x6098
leaq 0x1b415(%rip), %rdi     # 0x21438
movq %r14, %rsi
callq 0x1367e
movq %rax, %r15
testq %rax, %rax
je 0x603c
movq 0x40(%r15), %rax
testq %rax, %rax
jne 0x6051
movq (%r14), %rsi
leaq 0x105e7(%rip), %rdi     # 0x1662d
xorl %eax, %eax
callq 0xf410
movq 0x40(%r15), %rax
cmpq $0x2, %rax
jb 0x6068
movq (%r14), %rsi
leaq 0x105e2(%rip), %rdi     # 0x16643
xorl %eax, %eax
callq 0xf410
movq 0x38(%r15), %rsi
addq $0x8, %rsi
leaq 0x1b319(%rip), %rdi     # 0x21390
callq 0x136c0
movq %rax, %r15
testq %rax, %rax
jne 0x6098
movq (%r14), %rsi
xorl %r15d, %r15d
leaq 0x1059c(%rip), %rdi     # 0x1662d
xorl %eax, %eax
callq 0xf410
addq $0x28, %r15
leaq -0xa8(%rbp), %rdi
movq %r15, %rsi
callq 0x104b4
leaq -0x80(%rbp), %rsi
movb 0x30(%rsi), %r12b
movq 0x28(%rsi), %r15
leaq -0x48(%rbp), %rdi
callq 0x3130
leaq -0xa8(%rbp), %rdi
callq 0xf1d4
movb $0x1, %r13b
movq (%r14), %rsi
leaq 0x10220(%rip), %rax     # 0x162f9
leaq 0x1021e(%rip), %rdx     # 0x162fe
testb %r12b, %r12b
cmovneq %rax, %rdx
leaq 0x105b6(%rip), %rax     # 0x166a4
leaq 0x105b6(%rip), %rcx     # 0x166ab
testb %r13b, %r13b
cmovneq %rax, %rcx
movq -0x48(%rbp), %r9
leaq 0x10560(%rip), %rdi     # 0x16667
movq %r15, %r8
xorl %eax, %eax
callq 0xf138
movb %r12b, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3270
movq %r15, 0x28(%rbx)
movb %r13b, 0x30(%rbx)
leaq -0x48(%rbp), %rdi
callq 0x3368
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6164
jmp 0x6164
jmp 0x6164
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0xf1d4
jmp 0x6167
jmp 0x6164
jmp 0x6164
jmp 0x6164
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x3368
movq %rbx, %rdi
callq 0x3310