// File: /workspace/github_c_makefile_star2_O1/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 0x1f6ab
movq %rsi, %r14
cmpl $0xbd2, (%rsi)          # imm = 0xBD2
jne 0x1f6ca
cmpl $0x2, 0x44(%r14)
jne 0x1f6e9
movq %rdi, %rbx
movq 0x48(%r14), %rax
movq 0x8(%rax), %r12
movslq 0x44(%r12), %r15
testq %r15, %r15
jle 0x1f549
incq %r15
movq 0x48(%r12), %rax
movq -0x10(%rax,%r15,8), %rdx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x1e2b8
movq 0x20(%rbx), %rdi
callq 0x1e8fa
decq %r15
cmpq $0x1, %r15
jg 0x1f521
movq 0x48(%r14), %rax
movq (%rax), %r14
movl (%r14), %eax
cmpl $0x200, %eax            # imm = 0x200
je 0x1f589
cmpl $0xe00, %eax            # imm = 0xE00
jne 0x1f708
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x1e2b8
movq 0x20(%rbx), %rdi
leaq 0x275d3(%rip), %rsi     # 0x46b52
callq 0x1f765
jmp 0x1f649
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1da4c
movl (%rax), %eax
cmpl $0x1, %eax
je 0x1f5db
cmpl $0x3, %eax
jne 0x1f727
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movl 0x4(%rax), %edx
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x76ad
movq 0x20(%rbx), %rdi
movq 0x8(%r14), %rax
testq %rax, %rax
leaq 0x2348e(%rip), %rsi     # 0x42a5b
cmovneq %rax, %rsi
callq 0x1f765
movq %r14, %rdi
jmp 0x1f644
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x1e2b8
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x1f746
leaq 0x27554(%rip), %rsi     # 0x46b52
leaq -0x30(%rbp), %r15
movq %r15, %rdi
callq 0x7537
movq %r15, %rdi
movl $0x2a, %esi
callq 0x7f65
movq 0x8(%r15), %rax
testq %rax, %rax
leaq 0x23436(%rip), %rcx     # 0x42a5b
cmovneq %rax, %rcx
leaq 0x24088(%rip), %rsi     # 0x436b8
leaq 0x28d2b(%rip), %rdx     # 0x48362
movq %r14, %rdi
xorl %eax, %eax
callq 0x7af1
movq %r15, %rdi
callq 0x79f8
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x7508
movslq 0x44(%r12), %rdx
shlq $0x3, %rdx
leaq 0x23d80(%rip), %rsi     # 0x433e5
movq %r14, %rdi
xorl %eax, %eax
callq 0x7af1
movq 0x20(%rbx), %rdi
movq 0x8(%r14), %rax
testq %rax, %rax
leaq 0x233da(%rip), %rcx     # 0x42a5b
cmovneq %rax, %rcx
leaq 0x28c7e(%rip), %rdx     # 0x4830a
movl $0x9, %esi
callq 0x1e1bb
movq %r14, %rdi
callq 0x79f8
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x23899(%rip), %rdi     # 0x42f4b
leaq 0x26fef(%rip), %rsi     # 0x466a8
leaq 0x28c04(%rip), %rcx     # 0x482c4
movl $0x1225, %edx           # imm = 0x1225
callq 0x30a0
leaq 0x2562b(%rip), %rdi     # 0x44cfc
leaq 0x26fd0(%rip), %rsi     # 0x466a8
leaq 0x28be5(%rip), %rcx     # 0x482c4
movl $0x1226, %edx           # imm = 0x1226
callq 0x30a0
leaq 0x2ef15(%rip), %rdi     # 0x4e605
leaq 0x26fb1(%rip), %rsi     # 0x466a8
leaq 0x28bc6(%rip), %rcx     # 0x482c4
movl $0x1227, %edx           # imm = 0x1227
callq 0x30a0
leaq 0x20c7e(%rip), %rdi     # 0x4038d
leaq 0x26f92(%rip), %rsi     # 0x466a8
leaq 0x28ba7(%rip), %rcx     # 0x482c4
movl $0x1257, %edx           # imm = 0x1257
callq 0x30a0
leaq 0x20c5f(%rip), %rdi     # 0x4038d
leaq 0x26f73(%rip), %rsi     # 0x466a8
leaq 0x28b88(%rip), %rcx     # 0x482c4
movl $0x124d, %edx           # imm = 0x124D
callq 0x30a0
leaq 0x21303(%rip), %rdi     # 0x40a50
leaq 0x26f54(%rip), %rsi     # 0x466a8
leaq 0x28c0d(%rip), %rcx     # 0x48368
movl $0x644, %edx            # imm = 0x644
callq 0x30a0