// File: /workspace/github_c_makefile_star2_O3/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 0x16ed4
cmpl $0xbd2, (%rsi)          # imm = 0xBD2
jne 0x16ef3
cmpl $0x2, 0x44(%rsi)
jne 0x16f12
movq %rdi, %rbx
movq 0x48(%rsi), %rax
movq 0x8(%rax), %r13
movslq 0x44(%r13), %r14
testq %r14, %r14
jle 0x16d69
movq %rsi, -0x30(%rbp)
incq %r14
leaq 0x2a07b(%rip), %r15     # 0x40d99
leaq 0x2a06f(%rip), %r12     # 0x40d94
movq 0x48(%r13), %rax
movq -0x10(%rax,%r14,8), %rcx
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
xorl %r8d, %r8d
callq 0x14915
movq 0x20(%rbx), %rdi
movq %r15, %rsi
callq 0x157bd
movq 0x20(%rbx), %rdi
movq %r12, %rsi
callq 0x157bd
decq %r14
cmpq $0x1, %r14
ja 0x16d25
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %r14
movl (%r14), %eax
cmpl $0x200, %eax            # imm = 0x200
je 0x16dab
cmpl $0xe00, %eax            # imm = 0xE00
jne 0x16f31
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x14915
movq 0x20(%rbx), %rdi
leaq 0x29ff3(%rip), %rsi     # 0x40d94
callq 0x16f8e
jmp 0x16e71
movq %rbx, %rdi
movq %r14, %rsi
callq 0x142d5
movl (%rax), %eax
cmpl $0x1, %eax
je 0x16dfd
cmpl $0x3, %eax
jne 0x16f50
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movl 0x4(%rax), %edx
leaq -0x40(%rbp), %r14
movq %r14, %rdi
callq 0x74bc
movq 0x20(%rbx), %rdi
movq 0x8(%r14), %rax
testq %rax, %rax
leaq 0x29c2c(%rip), %rsi     # 0x40a1b
cmovneq %rax, %rsi
callq 0x16f8e
movq %r14, %rdi
jmp 0x16e6c
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x14915
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x16f6f
leaq 0x29f6e(%rip), %rsi     # 0x40d94
leaq -0x40(%rbp), %r15
movq %r15, %rdi
callq 0x7343
movq %r15, %rdi
movl $0x2a, %esi
callq 0x7d80
movq 0x8(%r15), %rax
testq %rax, %rax
leaq 0x29bce(%rip), %rcx     # 0x40a1b
cmovneq %rax, %rcx
leaq 0x2a820(%rip), %rsi     # 0x41678
leaq 0x2beda(%rip), %rdx     # 0x42d39
movq %r14, %rdi
xorl %eax, %eax
callq 0x7905
movq %r15, %rdi
callq 0x7812
leaq -0x40(%rbp), %r14
movq %r14, %rdi
callq 0x7314
movslq 0x44(%r13), %rdx
shlq $0x3, %rdx
leaq 0x2a519(%rip), %rsi     # 0x413a5
movq %r14, %rdi
xorl %eax, %eax
callq 0x7905
movq 0x20(%rbx), %rdi
movq 0x8(%r14), %rax
testq %rax, %rax
leaq 0x29b73(%rip), %rcx     # 0x40a1b
cmovneq %rax, %rcx
leaq 0x2b0b8(%rip), %rdx     # 0x41f6b
movl $0x8, %esi
callq 0x155a1
movq %r14, %rdi
callq 0x7812
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2a030(%rip), %rdi     # 0x40f0b
leaq 0x29556(%rip), %rsi     # 0x40438
leaq 0x2bd8d(%rip), %rcx     # 0x42c76
movl $0x17ae, %edx           # imm = 0x17AE
callq 0x30a0
leaq 0x2bdc2(%rip), %rdi     # 0x42cbc
leaq 0x29537(%rip), %rsi     # 0x40438
leaq 0x2bd6e(%rip), %rcx     # 0x42c76
movl $0x17af, %edx           # imm = 0x17AF
callq 0x30a0
leaq 0x356bc(%rip), %rdi     # 0x4c5d5
leaq 0x29518(%rip), %rsi     # 0x40438
leaq 0x2bd4f(%rip), %rcx     # 0x42c76
movl $0x17b0, %edx           # imm = 0x17B0
callq 0x30a0
leaq 0x27431(%rip), %rdi     # 0x3e369
leaq 0x294f9(%rip), %rsi     # 0x40438
leaq 0x2bd30(%rip), %rcx     # 0x42c76
movl $0x17ea, %edx           # imm = 0x17EA
callq 0x30a0
leaq 0x27412(%rip), %rdi     # 0x3e369
leaq 0x294da(%rip), %rsi     # 0x40438
leaq 0x2bd11(%rip), %rcx     # 0x42c76
movl $0x17df, %edx           # imm = 0x17DF
callq 0x30a0
leaq 0x27aba(%rip), %rdi     # 0x3ea30
leaq 0x294bb(%rip), %rsi     # 0x40438
leaq 0x2bdbb(%rip), %rcx     # 0x42d3f
movl $0x6f0, %edx            # imm = 0x6F0
callq 0x30a0