// File: /workspace/github_cpp_makefile_star2_O3/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 0x149ab(%rip), %rdi     # 0x1b60e
xorl %eax, %eax
callq 0x155af
callq 0x484b
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x1c6cf(%rip), %r15     # 0x23358
subq 0x1c6c0(%rip), %r15     # 0x23350
movq %r15, %r12
sarq $0x6, %r12
addq $-0x38, %r15
incq %r12
decq %r12
je 0x6cdd
movq 0x1c6a6(%rip), %rdi     # 0x23350
addq %r15, %rdi
movq %r14, %rsi
callq 0x191d0
addq $-0x40, %r15
testq %rax, %rax
je 0x6c9e
movq %rax, %rsi
addq $0x28, %rsi
movslq 0x4c(%rax), %r15
leaq -0x48(%rbp), %rdi
callq 0x3110
xorl %r12d, %r12d
xorl %r13d, %r13d
jmp 0x6de7
leaq 0x1c6bc(%rip), %rdi     # 0x233a0
movq %r14, %rsi
callq 0x1918c
movq %rax, %r12
testq %rax, %rax
jne 0x6d70
leaq 0x1c74d(%rip), %rdi     # 0x23448
movq %r14, %rsi
callq 0x19148
movq %rax, %r15
testq %rax, %rax
je 0x6d14
movq 0x40(%r15), %rax
testq %rax, %rax
jne 0x6d29
movq (%r14), %rsi
leaq 0x1490c(%rip), %rdi     # 0x1b62a
xorl %eax, %eax
callq 0x1546f
movq 0x40(%r15), %rax
cmpq $0x2, %rax
jb 0x6d40
movq (%r14), %rsi
leaq 0x14907(%rip), %rdi     # 0x1b640
xorl %eax, %eax
callq 0x1546f
movq 0x38(%r15), %rsi
addq $0x8, %rsi
leaq 0x1c651(%rip), %rdi     # 0x233a0
callq 0x1918c
movq %rax, %r12
testq %rax, %rax
jne 0x6d70
movq (%r14), %rsi
xorl %r12d, %r12d
leaq 0x148c1(%rip), %rdi     # 0x1b62a
xorl %eax, %eax
callq 0x1546f
leaq 0x28(%r12), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x163a6
movq 0x70(%r12), %rax
leaq -0x80(%rbp), %rsi
movq %rax, 0x20(%rsi)
movq 0x78(%r12), %r15
movq %r15, 0x28(%rsi)
movb 0x80(%r12), %r12b
movb %r12b, 0x30(%rsi)
leaq -0x48(%rbp), %rdi
callq 0x3110
leaq -0x70(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6dc5
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x31d0
leaq -0x90(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6de4
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x31d0
movb $0x1, %r13b
movq (%r14), %rsi
leaq 0x14505(%rip), %rax     # 0x1b2f6
leaq 0x14503(%rip), %rdx     # 0x1b2fb
testb $0x1, %r12b
cmovneq %rax, %rdx
leaq 0x1489a(%rip), %rax     # 0x1b6a1
leaq 0x1489a(%rip), %rcx     # 0x1b6a8
testb %r13b, %r13b
cmovneq %rax, %rcx
movq -0x48(%rbp), %r9
leaq 0x14844(%rip), %rdi     # 0x1b664
movq %r15, %r8
xorl %eax, %eax
callq 0x151ad
movb %r12b, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0x18(%rbx), %rax
movq %rax, 0x8(%rbx)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq %rsi, %rdx
callq 0x16942
movq %r15, 0x28(%rbx)
movb %r13b, 0x30(%rbx)
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x6e6a
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x31d0
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6e9c
jmp 0x6e9c
jmp 0x6e9c
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x15246
jmp 0x6e9f
jmp 0x6e9c
jmp 0x6e9c
jmp 0x6e9c
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x6eb8
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x31d0
movq %rbx, %rdi
callq 0x3320