// File: /workspace/github_c_makefile_star2_O3/Ihsoh[P]ilang/compiler/backend/asmgen_gas64.c
// Function: asm_stat_func_call
static void _asm_stat_func_call(
	ASMGeneratorGas64Context *ctx,
	ParserASTNode *node
) {
	assert(ctx);
	assert(node);
	assert(node->type == BE_NODE_STAT_FUNC_CALL);
	assert(node->nchilds == 2);

	ParserASTNode *node_func_call_params = node->childs[1];
	for (int i = node_func_call_params->nchilds - 1; i >= 0; i--) {
		ParserASTNode *node_func_call_param = node_func_call_params->childs[i];

		_move_id_or_constexpr_to_reg(
			ctx,
			_ASM_REG_AX,
			node_func_call_param
		);

		_asm_inst_push_x(
			ctx,
			ctx->body,
			BE_TYPE_UINT64,
			_ASM_REG_NAME_RAX
		);
	}

	ParserASTNode *node_func = node->childs[0];
	if (node_func->type == BE_NODE_IDENTIFIER) {
		ParserSymbol *symbol_func = _get_symbol_by_id_node(ctx, node_func);
		if (symbol_func->type == BE_SYM_FUNC) {
			ResizableString rstr_func_name;
			rstr_init_with_raw(&rstr_func_name, node_func->token->content, node_func->token->len);

			_asm_inst_call_x(ctx, ctx->body, RSTR_CSTR(&rstr_func_name));

			rstr_free(&rstr_func_name);
		} else if (symbol_func->type == BE_SYM_VAR) {
			_move_id_or_constexpr_to_reg(
				ctx,
				_ASM_REG_AX,
				node_func
			);
			_asm_inst_callabs_x(ctx, ctx->body, _ASM_REG_NAME_RAX);
		} else {
			assert(0);
		}
	} else if (node_func->type == BE_NODE_EXPR) {
		_move_id_or_constexpr_to_reg(
			ctx,
			_ASM_REG_AX,
			node_func
		);
		_asm_inst_call_x(ctx, ctx->body, _ASM_REG_NAME_RAX);
	} else {
		assert(0);
	}

	ResizableString rstr_tmp;
	rstr_init(&rstr_tmp);
	_asm_inst_uint_const(ctx, &rstr_tmp, node_func_call_params->nchilds * 8);
	_asm_inst_add_x_x(
		ctx,
		ctx->body,
		BE_TYPE_UINT64,
		_ASM_REG_NAME_RSP,
		RSTR_CSTR(&rstr_tmp)
	);
	rstr_free(&rstr_tmp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
testq %rsi, %rsi
je 0x1f2cf
movq %rsi, %r14
cmpl $0xbd2, (%rsi)          # imm = 0xBD2
jne 0x1f2ee
cmpl $0x2, 0x44(%r14)
jne 0x1f30d
movq %rdi, %rbx
movq 0x48(%r14), %rax
movq 0x8(%rax), %r12
movslq 0x44(%r12), %r15
testq %r15, %r15
jle 0x1f171
incq %r15
movq 0x48(%r12), %rax
movq -0x10(%rax,%r15,8), %rdx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x1dec3
movq 0x20(%rbx), %rdi
callq 0x1e515
decq %r15
cmpq $0x1, %r15
ja 0x1f145
movq 0x48(%r14), %rax
movq (%rax), %r14
movl (%r14), %eax
cmpl $0x200, %eax            # imm = 0x200
je 0x1f1ad
cmpl $0xe00, %eax            # imm = 0xE00
jne 0x1f32c
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x1dec3
movq 0x20(%rbx), %rdi
leaq 0x2596f(%rip), %rsi     # 0x44b12
callq 0x1f389
jmp 0x1f26d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1d657
movl (%rax), %eax
cmpl $0x1, %eax
je 0x1f1ff
cmpl $0x3, %eax
jne 0x1f34b
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movl 0x4(%rax), %edx
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x74bc
movq 0x20(%rbx), %rdi
movq 0x8(%r14), %rax
testq %rax, %rax
leaq 0x2182a(%rip), %rsi     # 0x40a1b
cmovneq %rax, %rsi
callq 0x1f389
movq %r14, %rdi
jmp 0x1f268
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x1dec3
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x1f36a
leaq 0x258f0(%rip), %rsi     # 0x44b12
leaq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0x7343
movq %r15, %rdi
movl $0x2a, %esi
callq 0x7d80
movq 0x8(%r15), %rax
testq %rax, %rax
leaq 0x217d2(%rip), %rcx     # 0x40a1b
cmovneq %rax, %rcx
leaq 0x22424(%rip), %rsi     # 0x41678
leaq 0x270c7(%rip), %rdx     # 0x46322
movq %r14, %rdi
xorl %eax, %eax
callq 0x7905
movq %r15, %rdi
callq 0x7812
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x7314
movslq 0x44(%r12), %rdx
shlq $0x3, %rdx
leaq 0x2211c(%rip), %rsi     # 0x413a5
movq %r14, %rdi
xorl %eax, %eax
callq 0x7905
movq 0x20(%rbx), %rdi
movq 0x8(%r14), %rax
testq %rax, %rax
leaq 0x21776(%rip), %rcx     # 0x40a1b
cmovneq %rax, %rcx
leaq 0x2701a(%rip), %rdx     # 0x462ca
movl $0x9, %esi
callq 0x1ddc6
movq %r14, %rdi
callq 0x7812
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21c35(%rip), %rdi     # 0x40f0b
leaq 0x2538b(%rip), %rsi     # 0x44668
leaq 0x26fa0(%rip), %rcx     # 0x46284
movl $0x1225, %edx           # imm = 0x1225
callq 0x30a0
leaq 0x239c7(%rip), %rdi     # 0x42cbc
leaq 0x2536c(%rip), %rsi     # 0x44668
leaq 0x26f81(%rip), %rcx     # 0x46284
movl $0x1226, %edx           # imm = 0x1226
callq 0x30a0
leaq 0x2d2c1(%rip), %rdi     # 0x4c5d5
leaq 0x2534d(%rip), %rsi     # 0x44668
leaq 0x26f62(%rip), %rcx     # 0x46284
movl $0x1227, %edx           # imm = 0x1227
callq 0x30a0
leaq 0x1f036(%rip), %rdi     # 0x3e369
leaq 0x2532e(%rip), %rsi     # 0x44668
leaq 0x26f43(%rip), %rcx     # 0x46284
movl $0x1257, %edx           # imm = 0x1257
callq 0x30a0
leaq 0x1f017(%rip), %rdi     # 0x3e369
leaq 0x2530f(%rip), %rsi     # 0x44668
leaq 0x26f24(%rip), %rcx     # 0x46284
movl $0x124d, %edx           # imm = 0x124D
callq 0x30a0
leaq 0x1f6bf(%rip), %rdi     # 0x3ea30
leaq 0x252f0(%rip), %rsi     # 0x44668
leaq 0x26fa9(%rip), %rcx     # 0x46328
movl $0x644, %edx            # imm = 0x644
callq 0x30a0