// File: /workspace/github_c_makefile_star2_O3/Ihsoh[P]ilang/compiler/frontend/irgen_llvmir.c
// Function: ir_expr_shift_right
static void _ir_expr_shift_right(
	IRGeneratorLlvmirContext *ctx,
	ResizableString *rstr,
	ResizableString *rstr_result_lhs_ptr,
	_ExprResult *expr_result,
	ParserASTNode *node
) {
	assert(ctx);
	assert(rstr);
	assert(expr_result);
	assert(node);
	assert(node->type == FE_NODE_EXPR_SHIFT_RIGHT
			|| node->type == FE_NODE_EXPR_SHIFT_RIGHT_ASSIGN);

	ParserSymbol *func_symbol = ctx->func_symbol;
	assert(func_symbol);

	ParserASTNode *node_lhs = node->childs[0];
	ParserASTNode *node_rhs = node->childs[1];

	ParserASTNode *node_lhs_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node_lhs);
	ParserASTNode *node_rhs_type = FE_EXPR_AST_NODE_GET_TYPE_NODE(node_rhs);

	_ExprResult result_lhs;
	_ExprResult result_rhs;
	_ExprResult result_rhs_casted;

	_expr_result_init(&result_lhs);
	_expr_result_init(&result_rhs);
	_expr_result_init(&result_rhs_casted);

	_ir_expr(ctx, rstr, &result_lhs, node_lhs);
	rstr_append_with_rstr(rstr, &(result_lhs.rstr_for_result_ptr));
	rstr_append_with_rstr(rstr, &(result_lhs.rstr_for_result));

	if (rstr_result_lhs_ptr != NULL) {
		rstr_append_with_rstr(
			rstr_result_lhs_ptr,
			&(result_lhs.rstr_result_ptr)
		);
	}

	_ir_expr(ctx, rstr, &result_rhs, node_rhs);
	rstr_append_with_rstr(rstr, &(result_rhs.rstr_for_result_ptr));
	rstr_append_with_rstr(rstr, &(result_rhs.rstr_for_result));

	_expr_result_cast(
		ctx,
		&result_rhs_casted,
		node_lhs_type,
		&result_rhs,
		node_rhs_type
	);
	rstr_append_with_rstr(rstr, &(result_rhs_casted.rstr_for_result_ptr));
	rstr_append_with_rstr(rstr, &(result_rhs_casted.rstr_for_result));

	ResizableString rstr_tmp_label_val;
	rstr_init(&rstr_tmp_label_val);
	_generate_func_tmp(ctx, func_symbol, &rstr_tmp_label_val);

	uint8_t lhs_type = FE_EXPR_AST_NODE_GET_TYPE(node_lhs);
	if (fe_sem_is_signed_type(lhs_type)) {
		rstr_appendf(
			&(expr_result->rstr_for_result),
			"%s = ashr %s, %s\n",
			RSTR_CSTR(&rstr_tmp_label_val),
			RSTR_CSTR(&(result_lhs.rstr_result)),
			RSTR_CSTR(&(result_rhs_casted.rstr_result_val))
		);
	} else if (fe_sem_is_unsigned_type(lhs_type)) {
		rstr_appendf(
			&(expr_result->rstr_for_result),
			"%s = lshr %s, %s\n",
			RSTR_CSTR(&rstr_tmp_label_val),
			RSTR_CSTR(&(result_lhs.rstr_result)),
			RSTR_CSTR(&(result_rhs_casted.rstr_result_val))
		);
	} else {
		assert(0);
	}
	_expr_result_set_result(
		expr_result,
		RSTR_CSTR(&(result_lhs.rstr_result_type)),
		RSTR_CSTR(&rstr_tmp_label_val)
	);

	_expr_result_free(&result_lhs);
	_expr_result_free(&result_rhs);
	_expr_result_free(&result_rhs_casted);
	rstr_free(&rstr_tmp_label_val);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
testq %rcx, %rcx
je 0x1f9ec
movq %rsi, %r15
movq %rdi, %r12
movl (%r8), %eax
cmpl $0xe1a, %eax            # imm = 0xE1A
je 0x1f7eb
cmpl $0xe91, %eax            # imm = 0xE91
jne 0x1fa2a
movq %rdx, -0x50(%rbp)
movq %rcx, -0x48(%rbp)
movq 0x40(%r12), %rax
movq %rax, -0x58(%rbp)
testq %rax, %rax
je 0x1fa0b
movq 0x48(%r8), %rax
movq (%rax), %r14
movq 0x8(%rax), %rbx
movq 0x68(%r14), %rax
movq %rax, -0x30(%rbp)
movq 0x68(%rbx), %rax
movq %rax, -0x38(%rbp)
leaq -0x1e8(%rbp), %r13
movq %r13, %rdi
callq 0x19b1c
leaq -0x168(%rbp), %rdi
callq 0x19b1c
leaq -0xe8(%rbp), %rdi
callq 0x19b1c
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r14, -0x40(%rbp)
movq %r14, %rcx
callq 0x1a9a8
leaq -0x1d8(%rbp), %rsi
movq %r15, %rdi
callq 0x769e
movq %r15, %rdi
movq %r13, %rsi
callq 0x769e
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x1f88b
leaq -0x198(%rbp), %rsi
callq 0x769e
leaq -0x168(%rbp), %r13
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x1a9a8
leaq -0x158(%rbp), %rsi
movq %r15, %rdi
callq 0x769e
movq %r15, %rdi
movq %r13, %rsi
callq 0x769e
leaq -0xe8(%rbp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
movq -0x30(%rbp), %rdx
movq %r13, %rcx
movq -0x38(%rbp), %r8
callq 0x19bc3
leaq -0xd8(%rbp), %rsi
movq %r15, %rdi
callq 0x769e
movq %r15, %rdi
movq %rbx, %rsi
callq 0x769e
leaq -0x68(%rbp), %rbx
movq %rbx, %rdi
callq 0x7354
movq -0x58(%rbp), %rcx
movl 0x54(%rcx), %edx
leal 0x1(%rdx), %eax
movl %eax, 0x54(%rcx)
leaq 0x25856(%rip), %rsi     # 0x4516a
movq %rbx, %rdi
xorl %eax, %eax
callq 0x7945
movq -0x40(%rbp), %rax
movzbl 0x60(%rax), %ebx
movl %ebx, %edi
callq 0x2a444
testb %al, %al
je 0x1f93a
leaq 0x260f6(%rip), %rsi     # 0x45a2e
jmp 0x1f950
movl %ebx, %edi
callq 0x2a454
testb %al, %al
je 0x1fa49
leaq 0x260f0(%rip), %rsi     # 0x45a40
leaq -0x68(%rbp), %rbx
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
leaq 0x235a4(%rip), %r12     # 0x42f06
cmoveq %r12, %rdx
leaq -0x1e8(%rbp), %r15
movq 0x28(%r15), %rcx
testq %rcx, %rcx
cmoveq %r12, %rcx
leaq -0xe8(%rbp), %r14
movq 0x48(%r14), %r8
testq %r8, %r8
cmoveq %r12, %r8
movq -0x48(%rbp), %r13
movq %r13, %rdi
xorl %eax, %eax
callq 0x7945
movq 0x38(%r15), %rsi
testq %rsi, %rsi
cmoveq %r12, %rsi
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
cmoveq %r12, %rdx
movq %r13, %rdi
callq 0x1def5
movq %r15, %rdi
callq 0x1a3fd
leaq -0x168(%rbp), %rdi
callq 0x1a3fd
movq %r14, %rdi
callq 0x1a3fd
movq %rbx, %rdi
callq 0x7852
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x221e1(%rip), %rdi     # 0x41bd4
leaq 0x24f4a(%rip), %rsi     # 0x44944
leaq 0x25fb1(%rip), %rcx     # 0x459b2
movl $0xe84, %edx            # imm = 0xE84
callq 0x30a0
leaq 0x23555(%rip), %rdi     # 0x42f67
leaq 0x24f2b(%rip), %rsi     # 0x44944
leaq 0x25f92(%rip), %rcx     # 0x459b2
movl $0xe8a, %edx            # imm = 0xE8A
callq 0x30a0
leaq 0x22db0(%rip), %rdi     # 0x427e1
leaq 0x24f0c(%rip), %rsi     # 0x44944
leaq 0x25f73(%rip), %rcx     # 0x459b2
movl $0xe87, %edx            # imm = 0xE87
callq 0x30a0
leaq 0x1f910(%rip), %rdi     # 0x3f360
leaq 0x24eed(%rip), %rsi     # 0x44944
leaq 0x25f54(%rip), %rcx     # 0x459b2
movl $0xec9, %edx            # imm = 0xEC9
callq 0x30a0