// File: /workspace/github_c_makefile_star2_O0/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
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x36bac
jmp 0x36bcb
leaq 0x495ae(%rip), %rdi     # 0x80161
leaq 0x43f4a(%rip), %rsi     # 0x7ab04
movl $0x1224, %edx           # imm = 0x1224
leaq 0x45e76(%rip), %rcx     # 0x7ca3c
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x36bd4
jmp 0x36bf3
leaq 0x3f981(%rip), %rdi     # 0x7655c
leaq 0x43f22(%rip), %rsi     # 0x7ab04
movl $0x1225, %edx           # imm = 0x1225
leaq 0x45e4e(%rip), %rcx     # 0x7ca3c
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0xbd2, (%rax)          # imm = 0xBD2
jne 0x36c01
jmp 0x36c20
leaq 0x41c86(%rip), %rdi     # 0x7888e
leaq 0x43ef5(%rip), %rsi     # 0x7ab04
movl $0x1226, %edx           # imm = 0x1226
leaq 0x45e21(%rip), %rcx     # 0x7ca3c
callq 0x30a0
movq -0x10(%rbp), %rax
cmpl $0x2, 0x44(%rax)
jne 0x36c2c
jmp 0x36c4b
leaq 0x4c111(%rip), %rdi     # 0x82d44
leaq 0x43eca(%rip), %rsi     # 0x7ab04
movl $0x1227, %edx           # imm = 0x1227
leaq 0x45df6(%rip), %rcx     # 0x7ca3c
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 0x36cb9
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), %rdx
xorl %esi, %esi
callq 0x334a0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x9, %edx
leaq 0x44411(%rip), %rcx     # 0x7b0ba
callq 0x34750
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x36c68
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 0x36db3
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x32900
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x36d5e
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 0x36d3a
leaq 0x3f20b(%rip), %rax     # 0x75f3f
movq %rax, -0x70(%rbp)
jmp 0x36d42
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rdx
callq 0x36ea0
leaq -0x48(%rbp), %rdi
callq 0x9310
jmp 0x36db1
movq -0x38(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x36d90
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
xorl %esi, %esi
callq 0x334a0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0x44331(%rip), %rdx     # 0x7b0ba
callq 0x36f60
jmp 0x36daf
leaq 0x3c6c3(%rip), %rdi     # 0x7345a
leaq 0x43d66(%rip), %rsi     # 0x7ab04
movl $0x124d, %edx           # imm = 0x124D
leaq 0x45c92(%rip), %rcx     # 0x7ca3c
callq 0x30a0
jmp 0x36db1
jmp 0x36e09
movq -0x30(%rbp), %rax
cmpl $0xe00, (%rax)          # imm = 0xE00
jne 0x36de8
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
xorl %esi, %esi
callq 0x334a0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0x442d9(%rip), %rdx     # 0x7b0ba
callq 0x36ea0
jmp 0x36e07
leaq 0x3c66b(%rip), %rdi     # 0x7345a
leaq 0x43d0e(%rip), %rsi     # 0x7ab04
movl $0x1257, %edx           # imm = 0x1257
leaq 0x45c3a(%rip), %rcx     # 0x7ca3c
callq 0x30a0
jmp 0x36e09
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 0x33b00
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 0x36e57
leaq 0x3f0f1(%rip), %rax     # 0x75f3f
movq %rax, -0x88(%rbp)
jmp 0x36e62
movq -0x50(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x78(%rbp), %rsi
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %r8
movl $0x9, %edx
leaq 0x45c05(%rip), %rcx     # 0x7ca82
callq 0x33b30
leaq -0x58(%rbp), %rdi
callq 0x9310
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)