// File: /workspace/github_c_makefile_star2_O2/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 0x1d38b
movq %rsi, %r14
cmpl $0xbd2, (%rsi)          # imm = 0xBD2
jne 0x1d3aa
cmpl $0x2, 0x44(%r14)
jne 0x1d3c9
movq %rdi, %rbx
movq 0x48(%r14), %rax
movq 0x8(%rax), %r12
movl 0x44(%r12), %r15d
testl %r15d, %r15d
jle 0x1d234
movq 0x48(%r12), %rax
movq -0x8(%rax,%r15,8), %rdx
decq %r15
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1bbd1
movq 0x20(%rbx), %rdi
callq 0x1c60f
jmp 0x1d20d
movq 0x48(%r14), %rax
movq (%rax), %r14
movl (%r14), %eax
cmpl $0x200, %eax            # imm = 0x200
je 0x1d272
cmpl $0xe00, %eax            # imm = 0xE00
jne 0x1d3e8
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x1bbd1
movq 0x20(%rbx), %rdi
leaq 0x248da(%rip), %rsi     # 0x41b42
callq 0x1d445
jmp 0x1d32b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1b707
movl (%rax), %eax
cmpl $0x1, %eax
je 0x1d2c1
cmpl $0x3, %eax
jne 0x1d407
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movl 0x4(%rax), %edx
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x6fa2
movq 0x20(%rbx), %rdi
movq 0x8(%r14), %rax
testq %rax, %rax
leaq 0x20775(%rip), %rsi     # 0x3da2b
cmovneq %rax, %rsi
callq 0x1d445
jmp 0x1d323
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x1bbd1
movq 0x20(%rbx), %r15
testq %r15, %r15
je 0x1d426
leaq 0x24860(%rip), %rsi     # 0x41b42
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x6e49
pushq $0x2a
popq %rsi
movq %r14, %rdi
callq 0x7814
movq 0x8(%r14), %rax
testq %rax, %rax
leaq 0x20724(%rip), %rcx     # 0x3da2b
cmovneq %rax, %rcx
leaq 0x21398(%rip), %rsi     # 0x3e6aa
leaq 0x26039(%rip), %rdx     # 0x43352
movq %r15, %rdi
xorl %eax, %eax
callq 0x739a
movq %r14, %rdi
callq 0x72b9
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x6e1c
movslq 0x44(%r12), %rdx
shlq $0x3, %rdx
leaq 0x2105d(%rip), %rsi     # 0x3e3a4
movq %r14, %rdi
xorl %eax, %eax
callq 0x739a
movq 0x20(%rbx), %rdi
movq 0x8(%r14), %rax
testq %rax, %rax
leaq 0x206c8(%rip), %rcx     # 0x3da2b
cmovneq %rax, %rcx
leaq 0x25f8c(%rip), %rdx     # 0x432fa
pushq $0x9
popq %rsi
callq 0x1be70
movq %r14, %rdi
callq 0x72b9
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20b78(%rip), %rdi     # 0x3df0a
leaq 0x242ff(%rip), %rsi     # 0x41698
leaq 0x25f14(%rip), %rcx     # 0x432b4
movl $0x1225, %edx           # imm = 0x1225
callq 0x30a0
leaq 0x2293d(%rip), %rdi     # 0x3fcee
leaq 0x242e0(%rip), %rsi     # 0x41698
leaq 0x25ef5(%rip), %rcx     # 0x432b4
movl $0x1226, %edx           # imm = 0x1226
callq 0x30a0
leaq 0x2c235(%rip), %rdi     # 0x49605
leaq 0x242c1(%rip), %rsi     # 0x41698
leaq 0x25ed6(%rip), %rcx     # 0x432b4
movl $0x1227, %edx           # imm = 0x1227
callq 0x30a0
leaq 0x1df7a(%rip), %rdi     # 0x3b369
leaq 0x242a2(%rip), %rsi     # 0x41698
leaq 0x25eb7(%rip), %rcx     # 0x432b4
movl $0x1257, %edx           # imm = 0x1257
callq 0x30a0
leaq 0x1df5b(%rip), %rdi     # 0x3b369
leaq 0x24283(%rip), %rsi     # 0x41698
leaq 0x25e98(%rip), %rcx     # 0x432b4
movl $0x124d, %edx           # imm = 0x124D
callq 0x30a0
leaq 0x1e603(%rip), %rdi     # 0x3ba30
leaq 0x24264(%rip), %rsi     # 0x41698
leaq 0x25f1d(%rip), %rcx     # 0x43358
movl $0x644, %edx            # imm = 0x644
callq 0x30a0