// File: /workspace/github_c_makefile_star2_O0/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
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x2502c
jmp 0x2504b
leaq 0x5b12e(%rip), %rdi     # 0x80161
leaq 0x508be(%rip), %rsi     # 0x758f8
movl $0x17ad, %edx           # imm = 0x17AD
leaq 0x53802(%rip), %rcx     # 0x78848
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x25054
jmp 0x25073
leaq 0x51501(%rip), %rdi     # 0x7655c
leaq 0x50896(%rip), %rsi     # 0x758f8
movl $0x17ae, %edx           # imm = 0x17AE
leaq 0x537da(%rip), %rcx     # 0x78848
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xbd2, (%rax)          # imm = 0xBD2
jne 0x25081
jmp 0x250a0
leaq 0x53806(%rip), %rdi     # 0x7888e
leaq 0x50869(%rip), %rsi     # 0x758f8
movl $0x17af, %edx           # imm = 0x17AF
leaq 0x537ad(%rip), %rcx     # 0x78848
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x250ac
jmp 0x250cb
leaq 0x5dc91(%rip), %rdi     # 0x82d44
leaq 0x5083e(%rip), %rsi     # 0x758f8
movl $0x17b0, %edx           # imm = 0x17B0
leaq 0x53782(%rip), %rcx     # 0x78848
callq 0x30a0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x44(%rax), %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jl 0x2515b
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rcx
xorl %esi, %esi
movl $0x1, %edx
callq 0x22a20
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x8, %edx
leaq 0x512bc(%rip), %rcx     # 0x763ea
callq 0x221b0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x8, %edx
leaq 0x5129a(%rip), %rcx     # 0x763e5
callq 0x221b0
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x250e8
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x200, (%rax)          # imm = 0x200
jne 0x2525a
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x1f800
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x25200
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rsi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x4(%rax), %edx
leaq -0x48(%rbp), %rdi
callq 0x8ee0
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x251dc
leaq 0x50d69(%rip), %rax     # 0x75f3f
movq %rax, -0x70(%rbp)
jmp 0x251e4
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rdx
callq 0x25340
leaq -0x48(%rbp), %rdi
callq 0x9310
jmp 0x25258
movq -0x38(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x25237
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rcx
xorl %esi, %esi
movl $0x1, %edx
callq 0x22a20
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0x511b5(%rip), %rdx     # 0x763e5
callq 0x25400
jmp 0x25256
leaq 0x4e21c(%rip), %rdi     # 0x7345a
leaq 0x506b3(%rip), %rsi     # 0x758f8
movl $0x17df, %edx           # imm = 0x17DF
leaq 0x535f7(%rip), %rcx     # 0x78848
callq 0x30a0
jmp 0x25258
jmp 0x252b5
movq -0x30(%rbp), %rax
cmpl $0xe00, (%rax)          # imm = 0xE00
jne 0x25294
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rcx
xorl %esi, %esi
movl $0x1, %edx
callq 0x22a20
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0x51158(%rip), %rdx     # 0x763e5
callq 0x25340
jmp 0x252b3
leaq 0x4e1bf(%rip), %rdi     # 0x7345a
leaq 0x50656(%rip), %rsi     # 0x758f8
movl $0x17ea, %edx           # imm = 0x17EA
leaq 0x5359a(%rip), %rcx     # 0x78848
callq 0x30a0
jmp 0x252b5
leaq -0x58(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x44(%rax), %eax
shll $0x3, %eax
movslq %eax, %rdx
leaq -0x58(%rbp), %rsi
callq 0x21e80
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x25303
leaq 0x50c45(%rip), %rax     # 0x75f3f
movq %rax, -0x88(%rbp)
jmp 0x2530e
movq -0x50(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x78(%rbp), %rsi
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %r8
movl $0x8, %edx
leaq 0x525d8(%rip), %rcx     # 0x77901
callq 0x21eb0
leaq -0x58(%rbp), %rdi
callq 0x9310
addq $0x90, %rsp
popq %rbp
retq