// File: /workspace/github_c_makefile_star2_O1/Ihsoh[P]ilang/compiler/backend/asmgen_gas32.c
// Function: asm_stat_func_call
static void _asm_stat_func_call(
	ASMGeneratorGas32Context *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,
			_ASM_REG_BX,
			node_func_call_param
		);

		_asm_inst_push_x(
			ctx,
			ctx->body,
			BE_TYPE_UINT32,
			_ASM_REG_NAME_EBX
		);

		_asm_inst_push_x(
			ctx,
			ctx->body,
			BE_TYPE_UINT32,
			_ASM_REG_NAME_EAX
		);
	}

	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,
				_ASM_REG_BX,
				node_func
			);
			_asm_inst_callabs_x(ctx, ctx->body, _ASM_REG_NAME_EAX);
		} else {
			assert(0);
		}
	} else if (node_func->type == BE_NODE_EXPR) {
		_move_id_or_constexpr_to_reg(
			ctx,
			_ASM_REG_AX,
			_ASM_REG_BX,
			node_func
		);
		_asm_inst_call_x(ctx, ctx->body, _ASM_REG_NAME_EAX);
	} 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_UINT32,
		_ASM_REG_NAME_ESP,
		RSTR_CSTR(&rstr_tmp)
	);
	rstr_free(&rstr_tmp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rsi, %rsi
je 0x17285
cmpl $0xbd2, (%rsi)          # imm = 0xBD2
jne 0x172a4
cmpl $0x2, 0x44(%rsi)
jne 0x172c3
movq %rdi, %rbx
movq %rsi, -0x30(%rbp)
movq 0x48(%rsi), %rax
movq 0x8(%rax), %r13
movslq 0x44(%r13), %r14
testq %r14, %r14
jle 0x17112
incq %r14
leaq 0x2bd0a(%rip), %r15     # 0x42dd9
leaq 0x2bcfe(%rip), %r12     # 0x42dd4
movq 0x48(%r13), %rax
movq -0x10(%rax,%r14,8), %rcx
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
xorl %r8d, %r8d
callq 0x14c2b
movq 0x20(%rbx), %rdi
movq %r15, %rsi
callq 0x15aa4
movq 0x20(%rbx), %rdi
movq %r12, %rsi
callq 0x15aa4
decq %r14
cmpq $0x1, %r14
jg 0x170d6
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %r14
movl (%r14), %eax
cmpl $0x200, %eax            # imm = 0x200
je 0x1715c
cmpl $0xe00, %eax            # imm = 0xE00
jne 0x172e2
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x14c2b
movq 0x20(%rbx), %rdi
leaq 0x2bc82(%rip), %rsi     # 0x42dd4
callq 0x1733f
jmp 0x17222
movq %rbx, %rdi
movq %r14, %rsi
callq 0x145eb
movl (%rax), %eax
cmpl $0x1, %eax
je 0x171ae
cmpl $0x3, %eax
jne 0x17301
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movl 0x4(%rax), %edx
leaq -0x40(%rbp), %r14
movq %r14, %rdi
callq 0x76ad
movq 0x20(%rbx), %rdi
movq 0x8(%r14), %rax
testq %rax, %rax
leaq 0x2b8bb(%rip), %rsi     # 0x42a5b
cmovneq %rax, %rsi
callq 0x1733f
movq %r14, %rdi
jmp 0x1721d
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x14c2b
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x17320
leaq 0x2bbfd(%rip), %rsi     # 0x42dd4
leaq -0x40(%rbp), %r15
movq %r15, %rdi
callq 0x7537
movq %r15, %rdi
movl $0x2a, %esi
callq 0x7f65
movq 0x8(%r15), %rax
testq %rax, %rax
leaq 0x2b85d(%rip), %rcx     # 0x42a5b
cmovneq %rax, %rcx
leaq 0x2c4af(%rip), %rsi     # 0x436b8
leaq 0x2db69(%rip), %rdx     # 0x44d79
movq %r14, %rdi
xorl %eax, %eax
callq 0x7af1
movq %r15, %rdi
callq 0x79f8
leaq -0x40(%rbp), %r14
movq %r14, %rdi
callq 0x7508
movslq 0x44(%r13), %rdx
shlq $0x3, %rdx
leaq 0x2c1a8(%rip), %rsi     # 0x433e5
movq %r14, %rdi
xorl %eax, %eax
callq 0x7af1
movq 0x20(%rbx), %rdi
movq 0x8(%r14), %rax
testq %rax, %rax
leaq 0x2b802(%rip), %rcx     # 0x42a5b
cmovneq %rax, %rcx
leaq 0x2cd47(%rip), %rdx     # 0x43fab
movl $0x8, %esi
callq 0x15888
movq %r14, %rdi
callq 0x79f8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2bcbf(%rip), %rdi     # 0x42f4b
leaq 0x2b1e5(%rip), %rsi     # 0x42478
leaq 0x2da1c(%rip), %rcx     # 0x44cb6
movl $0x17ae, %edx           # imm = 0x17AE
callq 0x30a0
leaq 0x2da51(%rip), %rdi     # 0x44cfc
leaq 0x2b1c6(%rip), %rsi     # 0x42478
leaq 0x2d9fd(%rip), %rcx     # 0x44cb6
movl $0x17af, %edx           # imm = 0x17AF
callq 0x30a0
leaq 0x3733b(%rip), %rdi     # 0x4e605
leaq 0x2b1a7(%rip), %rsi     # 0x42478
leaq 0x2d9de(%rip), %rcx     # 0x44cb6
movl $0x17b0, %edx           # imm = 0x17B0
callq 0x30a0
leaq 0x290a4(%rip), %rdi     # 0x4038d
leaq 0x2b188(%rip), %rsi     # 0x42478
leaq 0x2d9bf(%rip), %rcx     # 0x44cb6
movl $0x17ea, %edx           # imm = 0x17EA
callq 0x30a0
leaq 0x29085(%rip), %rdi     # 0x4038d
leaq 0x2b169(%rip), %rsi     # 0x42478
leaq 0x2d9a0(%rip), %rcx     # 0x44cb6
movl $0x17df, %edx           # imm = 0x17DF
callq 0x30a0
leaq 0x29729(%rip), %rdi     # 0x40a50
leaq 0x2b14a(%rip), %rsi     # 0x42478
leaq 0x2da4a(%rip), %rcx     # 0x44d7f
movl $0x6f0, %edx            # imm = 0x6F0
callq 0x30a0