// File: /workspace/github_cpp_makefile_star2_O1/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 $0x98, %rsp
movq %rdi, -0x38(%rbp)
movq %rsi, -0x30(%rbp)
movq (%rsi), %rsi
leaq 0x158e9(%rip), %rdi     # 0x1c60e
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x1599c
callq 0x4848
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x1d60a(%rip), %rbx     # 0x24358
subq 0x1d5fb(%rip), %rbx     # 0x24350
movq %rbx, %r12
sarq $0x6, %r12
addq $-0x38, %rbx
incq %r12
xorl %r14d, %r14d
decq %r12
je 0x6da3
movq 0x1d5de(%rip), %rdi     # 0x24350
addq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq 0x195ca
movq %rax, %r13
testq %rax, %rax
je 0x6d9a
leaq 0x28(%r13), %rsi
movslq 0x4c(%r13), %r15
movb $0x1, %r14b
leaq -0x58(%rbp), %rdi
callq 0x3110
addq $-0x40, %rbx
testq %r13, %r13
je 0x6d66
testb $0x1, %r14b
je 0x6db7
xorl %r12d, %r12d
xorl %ebx, %ebx
movq -0x38(%rbp), %r14
jmp 0x6ed1
leaq 0x1d5e2(%rip), %rdi     # 0x243a0
movq -0x30(%rbp), %rsi
callq 0x19586
movq -0x38(%rbp), %r14
movq %rax, %r12
testq %rax, %rax
jne 0x6e58
leaq 0x1d66a(%rip), %rdi     # 0x24448
movq -0x30(%rbp), %rsi
callq 0x19542
movq %rax, %r15
testq %rax, %rax
je 0x6df6
cmpq $0x0, 0x40(%r15)
jne 0x6e0b
movq -0x30(%rbp), %rax
movq (%rax), %rsi
leaq 0x15826(%rip), %rdi     # 0x1c62a
xorl %eax, %eax
callq 0x1585f
cmpq $0x2, 0x40(%r15)
jb 0x6e27
movq -0x30(%rbp), %rax
movq (%rax), %rsi
leaq 0x15820(%rip), %rdi     # 0x1c640
xorl %eax, %eax
callq 0x1585f
movq 0x38(%r15), %rsi
addq $0x8, %rsi
leaq 0x1d56a(%rip), %rdi     # 0x243a0
callq 0x19586
movq %rax, %r12
testq %rax, %rax
jne 0x6e58
movq -0x30(%rbp), %rax
movq (%rax), %rsi
leaq 0x157d9(%rip), %rdi     # 0x1c62a
xorl %eax, %eax
callq 0x1585f
leaq 0x28(%r12), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x1678e
movq 0x70(%r12), %rax
leaq -0x90(%rbp), %rsi
movq %rax, 0x20(%rsi)
movq 0x78(%r12), %r15
movq %r15, 0x28(%rsi)
movb 0x80(%r12), %r12b
movb %r12b, 0x30(%rsi)
leaq -0x58(%rbp), %rdi
callq 0x3110
leaq -0x80(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6eb0
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x31d0
leaq -0xa0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6ecf
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x31d0
movb $0x1, %bl
movq -0x30(%rbp), %rax
movq (%rax), %rsi
leaq 0x15417(%rip), %rax     # 0x1c2f6
leaq 0x15415(%rip), %rdx     # 0x1c2fb
testb $0x1, %r12b
cmovneq %rax, %rdx
leaq 0x157ac(%rip), %rax     # 0x1c6a1
leaq 0x157ac(%rip), %rcx     # 0x1c6a8
testb %bl, %bl
cmovneq %rax, %rcx
movq -0x58(%rbp), %r9
leaq 0x15757(%rip), %rdi     # 0x1c664
movq %r15, %r8
xorl %eax, %eax
callq 0x1559d
movb %r12b, (%r14)
leaq 0x8(%r14), %rdi
leaq 0x18(%r14), %rax
movq %rax, 0x8(%r14)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
callq 0x16d2e
movq %r15, 0x28(%r14)
movb %bl, 0x30(%r14)
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x6f57
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x31d0
movq %r14, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6f87
jmp 0x6f87
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x15636
jmp 0x6f8a
jmp 0x6f87
jmp 0x6f87
jmp 0x6f87
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x6fa3
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x31d0
movq %rbx, %rdi
callq 0x3320