// File: yanlinlin82[P]icpp/icpp.cpp
// Function: parse_function(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string parse_function(string name)
{
	log<3>("[DEBUG] %s: '%s'\n", __FUNCTION__, name.c_str());
	next();
	vector<string> arg_types;
	if (token != ")") {
		for (;;) {
			string type = parse_expression(",");
			arg_types.push_back(type);
			add_assembly_code(PUSH);
			if (token == ")") break;
			expect_token(",", "function '" + name + "'");
			next();
		}
	}
	expect_token(")", "function '" + name + "'");
	log<3>("[DEBUG] function '%s' has %zd args\n", name.c_str(), arg_types.size());
	auto [ offset, ret_type, is_code, type_name, arg_count ] = query_function(name, arg_types);
	if (arg_count < 0) {
		add_assembly_code(MOV, arg_types.size() + arg_count, "variable parameter count");
		add_assembly_code(PUSH);
	}
	add_assembly_code(CALL, offset, ret_type + " " + name + "(" + type_name + ")");
	if (arg_count < 0) {
		add_assembly_code(ADJ, arg_types.size());
	}
	log<3>("[DEBUG] ret_type = '%s'\n", ret_type.c_str());
	next();
	return ret_type;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3b0, %rsp            # imm = 0x3B0
movq %rsi, -0x348(%rbp)
movq %rdi, %rax
movq -0x348(%rbp), %rdi
movq %rax, -0x340(%rbp)
movq %rax, %rcx
movq %rcx, -0x338(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
callq 0x3110
movq %rax, %rdx
leaq 0x2da60(%rip), %rdi     # 0x37654
leaq 0x2da6b(%rip), %rsi     # 0x37666
xorl %eax, %eax
callq 0x19760
callq 0x6030
leaq -0x28(%rbp), %rdi
callq 0x18fa0
leaq 0x468d1(%rip), %rdi     # 0x504e8
leaq 0x2deaa(%rip), %rsi     # 0x37ac8
callq 0x1b450
movb %al, -0x32a(%rbp)
jmp 0x9c2b
movb -0x32a(%rbp), %al
testb $0x1, %al
jne 0x9c3a
jmp 0x9f0a
jmp 0x9c3c
leaq -0x79(%rbp), %rdi
movq %rdi, -0x350(%rbp)
callq 0x3470
movq -0x350(%rbp), %rdx
leaq 0x2d4f2(%rip), %rsi     # 0x3714c
leaq -0x78(%rbp), %rdi
callq 0x199b0
jmp 0x9c65
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0xa530
jmp 0x9c7b
leaq -0x78(%rbp), %rdi
callq 0x34d8
leaq -0x79(%rbp), %rdi
callq 0x32b0
leaq -0x28(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x1b480
jmp 0x9c9c
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x358(%rbp)
callq 0x3470
movq -0x358(%rbp), %rdx
leaq 0x2e707(%rip), %rsi     # 0x383c4
leaq -0xa0(%rbp), %rdi
callq 0x199b0
jmp 0x9ccb
movl $0x1, %edi
xorl %esi, %esi
leaq -0xa0(%rbp), %rdx
callq 0x56e0
jmp 0x9ce0
leaq -0xa0(%rbp), %rdi
callq 0x34d8
leaq -0xa1(%rbp), %rdi
callq 0x32b0
leaq 0x467e9(%rip), %rdi     # 0x504e8
leaq 0x2ddc2(%rip), %rsi     # 0x37ac8
callq 0x1a9c0
movb %al, -0x359(%rbp)
jmp 0x9d13
movb -0x359(%rbp), %al
testb $0x1, %al
jne 0x9d22
jmp 0x9dbb
movl $0x2, -0xa8(%rbp)
jmp 0x9e78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa51a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x9d65
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x34d8
leaq -0x79(%rbp), %rdi
callq 0x32b0
jmp 0xa51a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x9efa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x9daa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x34d8
leaq -0xa1(%rbp), %rdi
callq 0x32b0
jmp 0x9efa
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x368(%rbp)
callq 0x3470
movq -0x368(%rbp), %rdx
leaq 0x2d370(%rip), %rsi     # 0x3714c
leaq -0xc8(%rbp), %rdi
callq 0x199b0
jmp 0x9dea
movq -0x348(%rbp), %rdx
leaq 0x2d87d(%rip), %rsi     # 0x37675
leaq -0x110(%rbp), %rdi
callq 0x1b340
jmp 0x9e06
leaq 0x2dbc9(%rip), %rdx     # 0x379d6
leaq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x1a4a0
jmp 0x9e22
leaq -0xc8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x6790
jmp 0x9e37
leaq -0xf0(%rbp), %rdi
callq 0x34d8
leaq -0x110(%rbp), %rdi
callq 0x34d8
leaq -0xc8(%rbp), %rdi
callq 0x34d8
leaq -0xc9(%rbp), %rdi
callq 0x32b0
callq 0x6030
jmp 0x9e6e
movl $0x0, -0xa8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x34d8
movl -0xa8(%rbp), %eax
testl %eax, %eax
je 0x9e8f
jmp 0x9e8d
jmp 0x9f08
jmp 0x9c3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x9eee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x9ee2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x9ed6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x34d8
leaq -0x110(%rbp), %rdi
callq 0x34d8
leaq -0xc8(%rbp), %rdi
callq 0x34d8
leaq -0xc9(%rbp), %rdi
callq 0x32b0
leaq -0x58(%rbp), %rdi
callq 0x34d8
jmp 0xa51a
jmp 0x9f0a
leaq -0x131(%rbp), %rdi
movq %rdi, -0x370(%rbp)
callq 0x3470
movq -0x370(%rbp), %rdx
leaq 0x2db9d(%rip), %rsi     # 0x37ac8
leaq -0x130(%rbp), %rdi
callq 0x199b0
jmp 0x9f39
movq -0x348(%rbp), %rdx
leaq 0x2d72e(%rip), %rsi     # 0x37675
leaq -0x178(%rbp), %rdi
callq 0x1b340
jmp 0x9f55
leaq 0x2da7a(%rip), %rdx     # 0x379d6
leaq -0x158(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x1a4a0
jmp 0x9f71
leaq -0x130(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x6790
jmp 0x9f86
leaq -0x158(%rbp), %rdi
callq 0x34d8
leaq -0x178(%rbp), %rdi
callq 0x34d8
leaq -0x130(%rbp), %rdi
callq 0x34d8
leaq -0x131(%rbp), %rdi
callq 0x32b0
movq -0x348(%rbp), %rdi
callq 0x3110
movq %rax, -0x378(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x1a730
movq -0x378(%rbp), %rsi
movq %rax, %rdx
leaq 0x2d69d(%rip), %rdi     # 0x37680
xorl %eax, %eax
callq 0x19760
jmp 0x9fec
movq -0x348(%rbp), %rsi
leaq -0x1f0(%rbp), %rdi
callq 0x3120
jmp 0xa001
leaq -0x1d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x77c0
jmp 0xa01a
leaq -0x1f0(%rbp), %rdi
callq 0x34d8
leaq -0x1d0(%rbp), %rdi
callq 0x1b4f0
movq %rax, -0x1f8(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x1b510
movq %rax, -0x200(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x1b530
movq %rax, -0x208(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x1b550
movq %rax, -0x210(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x1b570
movq %rax, -0x218(%rbp)
movq -0x218(%rbp), %rax
cmpl $0x0, (%rax)
jge 0xa266
leaq -0x28(%rbp), %rdi
callq 0x1a730
movq -0x218(%rbp), %rcx
movl (%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x384(%rbp)
leaq -0x239(%rbp), %rdi
movq %rdi, -0x380(%rbp)
callq 0x3470
movq -0x380(%rbp), %rdx
leaq 0x2d5d4(%rip), %rsi     # 0x376a4
leaq -0x238(%rbp), %rdi
callq 0x199b0
jmp 0xa0de
movl -0x384(%rbp), %esi
movl $0x4, %edi
leaq -0x238(%rbp), %rdx
callq 0x56e0
jmp 0xa0f7
leaq -0x238(%rbp), %rdi
callq 0x34d8
leaq -0x239(%rbp), %rdi
callq 0x32b0
leaq -0x261(%rbp), %rdi
movq %rdi, -0x390(%rbp)
callq 0x3470
movq -0x390(%rbp), %rdx
leaq 0x2e294(%rip), %rsi     # 0x383c4
leaq -0x260(%rbp), %rdi
callq 0x199b0
jmp 0xa13e
movl $0x1, %edi
xorl %esi, %esi
leaq -0x260(%rbp), %rdx
callq 0x56e0
jmp 0xa153
leaq -0x260(%rbp), %rdi
callq 0x34d8
leaq -0x261(%rbp), %rdi
callq 0x32b0
jmp 0xa266
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa1ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa1be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa1b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x34d8
leaq -0x178(%rbp), %rdi
callq 0x34d8
leaq -0x130(%rbp), %rdi
callq 0x34d8
leaq -0x131(%rbp), %rdi
callq 0x32b0
jmp 0xa51a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x34d8
jmp 0xa51a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa21e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x34d8
leaq -0x239(%rbp), %rdi
callq 0x32b0
jmp 0xa50e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa255
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x34d8
leaq -0x261(%rbp), %rdi
callq 0x32b0
jmp 0xa50e
movq -0x1f8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x394(%rbp)
movq -0x200(%rbp), %rsi
leaq 0x2cf3d(%rip), %rdx     # 0x371c0
leaq -0x308(%rbp), %rdi
callq 0x1a540
jmp 0xa291
movq -0x348(%rbp), %rdx
leaq -0x2e8(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0x1a4f0
jmp 0xa2ad
leaq 0x2d653(%rip), %rdx     # 0x37907
leaq -0x2c8(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0x1a4a0
jmp 0xa2c9
movq -0x210(%rbp), %rdx
leaq -0x2a8(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0x1a4f0
jmp 0xa2e5
leaq 0x2d7dc(%rip), %rdx     # 0x37ac8
leaq -0x288(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0x1a4a0
jmp 0xa301
movl -0x394(%rbp), %esi
movl $0x25, %edi
leaq -0x288(%rbp), %rdx
callq 0x56e0
jmp 0xa31a
leaq -0x288(%rbp), %rdi
callq 0x34d8
leaq -0x2a8(%rbp), %rdi
callq 0x34d8
leaq -0x2c8(%rbp), %rdi
callq 0x34d8
leaq -0x2e8(%rbp), %rdi
callq 0x34d8
leaq -0x308(%rbp), %rdi
callq 0x34d8
movq -0x218(%rbp), %rax
cmpl $0x0, (%rax)
jge 0xa4a4
leaq -0x28(%rbp), %rdi
callq 0x1a730
movl %eax, -0x3a4(%rbp)
leaq -0x329(%rbp), %rdi
movq %rdi, -0x3a0(%rbp)
callq 0x3470
movq -0x3a0(%rbp), %rdx
leaq 0x2e02e(%rip), %rsi     # 0x383c4
leaq -0x328(%rbp), %rdi
callq 0x199b0
jmp 0xa3a4
movl -0x3a4(%rbp), %esi
movl $0x3, %edi
leaq -0x328(%rbp), %rdx
callq 0x56e0
jmp 0xa3bd
leaq -0x328(%rbp), %rdi
callq 0x34d8
leaq -0x329(%rbp), %rdi
callq 0x32b0
jmp 0xa4a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa50e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa45f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa453
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa447
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa43b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x34d8
leaq -0x2a8(%rbp), %rdi
callq 0x34d8
leaq -0x2c8(%rbp), %rdi
callq 0x34d8
leaq -0x2e8(%rbp), %rdi
callq 0x34d8
leaq -0x308(%rbp), %rdi
callq 0x34d8
jmp 0xa50e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xa496
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x328(%rbp), %rdi
callq 0x34d8
leaq -0x329(%rbp), %rdi
callq 0x32b0
jmp 0xa50e
movq -0x200(%rbp), %rdi
callq 0x3110
movq %rax, %rsi
leaq 0x2d203(%rip), %rdi     # 0x376bd
xorl %eax, %eax
callq 0x19760
jmp 0xa4c3
callq 0x6030
jmp 0xa4ca
movq -0x340(%rbp), %rdi
movq -0x200(%rbp), %rsi
callq 0x3120
jmp 0xa4df
movl $0x1, -0xa8(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x1b590
leaq -0x28(%rbp), %rdi
callq 0x18fc0
movq -0x338(%rbp), %rax
addq $0x3b0, %rsp            # imm = 0x3B0
popq %rbp
retq
leaq -0x1d0(%rbp), %rdi
callq 0x1b590
leaq -0x28(%rbp), %rdi
callq 0x18fc0
movq -0x30(%rbp), %rdi
callq 0x3460
nopl (%rax)