// File: /workspace/github_cpp_makefile_star2_O2/yanlinlin82[P]icpp/icpp.cpp
// Function: add_external_symbol(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
void add_external_symbol(string name, string args_type, string ret_type = "", int arg_count = 0)
{
	// for variable arguments, arg_count is negative, and the number is fixed arguments.
	// for example
	//   `int printf(const char* fmt, ...)`, arg_count is -1
	//   `int fprintf(FILE*, const char* fmt, ...)`, arg_count is -2
	// in runtime, an integer is appended after variable arguments, specifying their numbers.
	//   the number, as in stdcall calling convention (which means the arguments are pushed into
	//   stack as the order in source code, and this interpreter follows this rule), could be
	//   found as [bp + 1] in subroutine (before ENTER)
	if (ret_type.empty()) { // data
		size_t offset = data_sec.size();
		add_symbol(name, false, offset, 1, args_type, "", 0);
		data_sec.resize(offset + 1);
	} else { // code
		size_t offset = code_sec.size();
		string name_with_args = name + "(" + args_type + ")";
		override_functions[name].insert(name_with_args);
		add_symbol(name_with_args, true, offset, 2, args_type, ret_type, arg_count);
		add_assembly_code(RET, (arg_count >= 0 ? arg_count : 0), ret_type + " " + name_with_args);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %r12
movq %rdi, %r13
cmpq $0x0, 0x8(%rdx)
je 0x4dd5
movq %rdx, %rbx
movl %ecx, -0x2c(%rbp)
movq 0x1c68d(%rip), %r15     # 0x21308
subq 0x1c67e(%rip), %r15     # 0x21300
leaq 0x11d3e(%rip), %rdx     # 0x169c7
leaq -0x170(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0xf35b
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0xf332
leaq 0x11ed7(%rip), %rdx     # 0x16b88
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xf309
leaq -0x50(%rbp), %rdi
callq 0x3368
leaq -0x170(%rbp), %rdi
callq 0x3368
leaq 0x1c75e(%rip), %rdi     # 0x21438
movq %r13, %rsi
callq 0x1246c
movl -0x2c(%rbp), %r14d
leaq -0x70(%rbp), %rsi
movq %rax, %rdi
callq 0x13290
leaq -0xf0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x3270
leaq -0xd0(%rbp), %rdi
movq %r12, %rsi
callq 0x3270
leaq -0xb0(%rbp), %rdi
movq %rbx, %rsi
callq 0x3270
sarq $0x2, %r15
movl %r14d, (%rsp)
leaq -0xf0(%rbp), %rdi
pushq $0x1
popq %rsi
pushq $0x2
popq %rcx
leaq -0xd0(%rbp), %r8
leaq -0xb0(%rbp), %r9
movq %r15, %rdx
callq 0x4213
leaq -0xb0(%rbp), %rdi
callq 0x3368
leaq -0xd0(%rbp), %rdi
callq 0x3368
leaq -0xf0(%rbp), %rdi
callq 0x3368
xorl %r15d, %r15d
testl %r14d, %r14d
cmovgl %r14d, %r15d
leaq 0x11500(%rip), %rdx     # 0x16280
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0xf35b
leaq -0x90(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0xf332
pushq $0x26
popq %rdi
leaq -0x90(%rbp), %rdx
movl %r15d, %esi
callq 0x4a27
leaq -0x90(%rbp), %rdi
callq 0x3368
leaq -0x50(%rbp), %rdi
callq 0x3368
leaq -0x70(%rbp), %rdi
callq 0x3368
jmp 0x4e78
movq 0x1c544(%rip), %rbx     # 0x21320
subq 0x1c535(%rip), %rbx     # 0x21318
leaq -0x150(%rbp), %rdi
movq %r13, %rsi
callq 0x3270
leaq -0x130(%rbp), %rdi
movq %r12, %rsi
callq 0x3270
leaq 0x1267c(%rip), %rsi     # 0x17484
leaq -0x110(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0xf1f8
sarq $0x2, %rbx
andl $0x0, (%rsp)
leaq -0x150(%rbp), %rdi
pushq $0x1
popq %rcx
leaq -0x130(%rbp), %r8
leaq -0x110(%rbp), %r9
xorl %esi, %esi
movq %rbx, %rdx
callq 0x4213
leaq -0x110(%rbp), %rdi
callq 0x3368
leaq -0x130(%rbp), %rdi
callq 0x3368
leaq -0x150(%rbp), %rdi
callq 0x3368
incq %rbx
leaq 0x1c4a8(%rip), %rdi     # 0x21318
movq %rbx, %rsi
callq 0xf254
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x3368
jmp 0x4e9e
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x3368
jmp 0x4eaf
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
jmp 0x4f28
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x3368
jmp 0x4ecc
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
jmp 0x4f00
jmp 0x4f21
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x3368
jmp 0x4ee8
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x3368
jmp 0x4ef9
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x3368
jmp 0x4f24
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3368
jmp 0x4f18
movq %rax, %rbx
leaq -0x170(%rbp), %rdi
jmp 0x4f28
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x3368
movq %rbx, %rdi
callq 0x3310