// File: /workspace/github_c_makefile_star2_O0/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
subq $0x270, %rsp            # imm = 0x270
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x38998
jmp 0x389b7
leaq 0x43bb7(%rip), %rdi     # 0x7c556
leaq 0x3f72a(%rip), %rsi     # 0x780d0
movl $0xe82, %edx            # imm = 0xE82
leaq 0x408bd(%rip), %rcx     # 0x7926f
callq 0x30a0
cmpq $0x0, -0x10(%rbp)
je 0x389c0
jmp 0x389df
leaq 0x3a147(%rip), %rdi     # 0x72b0e
leaq 0x3f702(%rip), %rsi     # 0x780d0
movl $0xe83, %edx            # imm = 0xE83
leaq 0x40895(%rip), %rcx     # 0x7926f
callq 0x30a0
cmpq $0x0, -0x20(%rbp)
je 0x389e8
jmp 0x38a07
leaq 0x3c224(%rip), %rdi     # 0x74c13
leaq 0x3f6da(%rip), %rsi     # 0x780d0
movl $0xe84, %edx            # imm = 0xE84
leaq 0x4086d(%rip), %rcx     # 0x7926f
callq 0x30a0
cmpq $0x0, -0x28(%rbp)
je 0x38a10
jmp 0x38a2f
leaq 0x3d5bc(%rip), %rdi     # 0x75fd3
leaq 0x3f6b2(%rip), %rsi     # 0x780d0
movl $0xe85, %edx            # imm = 0xE85
leaq 0x40845(%rip), %rcx     # 0x7926f
callq 0x30a0
movq -0x28(%rbp), %rax
cmpl $0xe91, (%rax)          # imm = 0xE91
je 0x38a47
movq -0x28(%rbp), %rax
cmpl $0xe1a, (%rax)          # imm = 0xE1A
jne 0x38a49
jmp 0x38a68
leaq 0x3cf82(%rip), %rdi     # 0x759d2
leaq 0x3f679(%rip), %rsi     # 0x780d0
movl $0xe87, %edx            # imm = 0xE87
leaq 0x4080c(%rip), %rcx     # 0x7926f
callq 0x30a0
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x38a7d
jmp 0x38a9c
leaq 0x3d6ef(%rip), %rdi     # 0x76173
leaq 0x3f645(%rip), %rsi     # 0x780d0
movl $0xe8a, %edx            # imm = 0xE8A
leaq 0x407d8(%rip), %rcx     # 0x7926f
callq 0x30a0
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x50(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x2a260
leaq -0x150(%rbp), %rdi
callq 0x2a260
leaq -0x1d0(%rbp), %rdi
callq 0x2a260
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rcx
leaq -0xd0(%rbp), %rdx
callq 0x2d590
movq -0x10(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x9100
cmpq $0x0, -0x18(%rbp)
je 0x38b4e
movq -0x18(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
addq $0x50, %rsi
callq 0x9100
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rcx
leaq -0x150(%rbp), %rdx
callq 0x2d590
movq -0x10(%rbp), %rdi
leaq -0x150(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x9100
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %r8
leaq -0x1d0(%rbp), %rsi
leaq -0x150(%rbp), %rcx
callq 0x2a360
movq -0x10(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
addq $0x10, %rsi
callq 0x9100
movq -0x10(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x9100
leaq -0x1e0(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq -0x1e0(%rbp), %rdx
callq 0x35980
movq -0x38(%rbp), %rax
movb 0x60(%rax), %al
movb %al, -0x1e1(%rbp)
movzbl -0x1e1(%rbp), %edi
callq 0x4d310
testb $0x1, %al
jne 0x38c0f
jmp 0x38cdd
movq -0x20(%rbp), %rax
movq %rax, -0x1f0(%rbp)
cmpq $0x0, -0x1d8(%rbp)
jne 0x38c34
leaq 0x3ec8a(%rip), %rax     # 0x778b5
movq %rax, -0x1f8(%rbp)
jmp 0x38c42
movq -0x1d8(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq -0x1f8(%rbp), %rax
movq %rax, -0x200(%rbp)
cmpq $0x0, -0xa8(%rbp)
jne 0x38c6a
leaq 0x3ec54(%rip), %rax     # 0x778b5
movq %rax, -0x208(%rbp)
jmp 0x38c78
movq -0xa8(%rbp), %rax
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rax
movq %rax, -0x210(%rbp)
cmpq $0x0, -0x188(%rbp)
jne 0x38ca0
leaq 0x3ec1e(%rip), %rax     # 0x778b5
movq %rax, -0x218(%rbp)
jmp 0x38cae
movq -0x188(%rbp), %rax
movq %rax, -0x218(%rbp)
movq -0x210(%rbp), %rcx
movq -0x200(%rbp), %rdx
movq -0x1f0(%rbp), %rdi
movq -0x218(%rbp), %r8
leaq 0x4061a(%rip), %rsi     # 0x792eb
movb $0x0, %al
callq 0x94d0
jmp 0x38dde
movzbl -0x1e1(%rbp), %edi
callq 0x4d360
testb $0x1, %al
jne 0x38cf2
jmp 0x38dbd
movq -0x20(%rbp), %rax
movq %rax, -0x220(%rbp)
cmpq $0x0, -0x1d8(%rbp)
jne 0x38d17
leaq 0x3eba7(%rip), %rax     # 0x778b5
movq %rax, -0x228(%rbp)
jmp 0x38d25
movq -0x1d8(%rbp), %rax
movq %rax, -0x228(%rbp)
movq -0x228(%rbp), %rax
movq %rax, -0x230(%rbp)
cmpq $0x0, -0xa8(%rbp)
jne 0x38d4d
leaq 0x3eb71(%rip), %rax     # 0x778b5
movq %rax, -0x238(%rbp)
jmp 0x38d5b
movq -0xa8(%rbp), %rax
movq %rax, -0x238(%rbp)
movq -0x238(%rbp), %rax
movq %rax, -0x240(%rbp)
cmpq $0x0, -0x188(%rbp)
jne 0x38d83
leaq 0x3eb3b(%rip), %rax     # 0x778b5
movq %rax, -0x248(%rbp)
jmp 0x38d91
movq -0x188(%rbp), %rax
movq %rax, -0x248(%rbp)
movq -0x240(%rbp), %rcx
movq -0x230(%rbp), %rdx
movq -0x220(%rbp), %rdi
movq -0x248(%rbp), %r8
leaq 0x40549(%rip), %rsi     # 0x792fd
movb $0x0, %al
callq 0x94d0
jmp 0x38ddc
leaq 0x39697(%rip), %rdi     # 0x7245b
leaq 0x3f305(%rip), %rsi     # 0x780d0
movl $0xec9, %edx            # imm = 0xEC9
leaq 0x40498(%rip), %rcx     # 0x7926f
callq 0x30a0
jmp 0x38dde
movq -0x20(%rbp), %rax
movq %rax, -0x250(%rbp)
cmpq $0x0, -0x98(%rbp)
jne 0x38e03
leaq 0x3eabb(%rip), %rax     # 0x778b5
movq %rax, -0x258(%rbp)
jmp 0x38e11
movq -0x98(%rbp), %rax
movq %rax, -0x258(%rbp)
movq -0x258(%rbp), %rax
movq %rax, -0x260(%rbp)
cmpq $0x0, -0x1d8(%rbp)
jne 0x38e39
leaq 0x3ea85(%rip), %rax     # 0x778b5
movq %rax, -0x268(%rbp)
jmp 0x38e47
movq -0x1d8(%rbp), %rax
movq %rax, -0x268(%rbp)
movq -0x260(%rbp), %rsi
movq -0x250(%rbp), %rdi
movq -0x268(%rbp), %rdx
callq 0x358a0
leaq -0xd0(%rbp), %rdi
callq 0x2c6a0
leaq -0x150(%rbp), %rdi
callq 0x2c6a0
leaq -0x1d0(%rbp), %rdi
callq 0x2c6a0
leaq -0x1e0(%rbp), %rdi
callq 0x9310
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
nopw (%rax,%rax)