// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/frontend/string_type.c
// Function: prv_left_right_copy
static void prv_left_right_copy(subtilis_parser_t *p, size_t data_reg,
				size_t str_len_reg, size_t value_len_reg,
				subtilis_ir_operand_t to_copy,
				subtilis_exp_t *value, bool left,
				subtilis_error_t *err)
{
	subtilis_ir_operand_t data;
	subtilis_ir_operand_t str_len;
	subtilis_ir_operand_t value_len;
	subtilis_ir_operand_t source_str;

	if (value->type.type == SUBTILIS_TYPE_CONST_STRING)
		source_str.reg = subtilis_string_type_lca_const(
		    p, subtilis_buffer_get_string(&value->exp.str),
		    subtilis_buffer_get_size(&value->exp.str) - 1, err);
	else
		source_str.reg = subtilis_reference_get_data(
		    p, value->exp.ir_op.reg, 0, err);

	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if (!left) {
		data.reg = data_reg;
		str_len.reg = str_len_reg;
		data.reg = subtilis_ir_section_add_instr(
		    p->current, SUBTILIS_OP_INSTR_ADD_I32, data, str_len, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		data_reg = subtilis_ir_section_add_instr(
		    p->current, SUBTILIS_OP_INSTR_SUB_I32, data, to_copy, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		value_len.reg = value_len_reg;
		source_str.reg = subtilis_ir_section_add_instr(
		    p->current, SUBTILIS_OP_INSTR_ADD_I32, source_str,
		    value_len, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		source_str.reg = subtilis_ir_section_add_instr(
		    p->current, SUBTILIS_OP_INSTR_SUB_I32, source_str, to_copy,
		    err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	subtilis_reference_type_memcpy_dest(p, data_reg, source_str.reg,
					    to_copy.reg, err);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r13
movq %rcx, %r12
movq %rdx, 0x10(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
movq 0x58(%rsp), %r14
movb 0x50(%rsp), %al
movb %al, 0x7(%rsp)
leaq 0x148(%r9), %rbp
cmpl $0x3, (%r9)
jne 0x4b306
movq %rbp, %rdi
callq 0x14db1
movq %rbx, 0x8(%rsp)
movq %r13, %rbx
movq %rax, %r13
movq %rbp, %rdi
callq 0x14b57
leaq -0x1(%rax), %rdx
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %r13
movq 0x8(%rsp), %rbx
movq %r14, %rcx
callq 0x481e7
jmp 0x4b317
movq (%rbp), %rsi
movq %r15, %rdi
xorl %edx, %edx
movq %r14, %rcx
callq 0x4d258
movq %rax, %rbp
cmpl $0x0, (%r14)
je 0x4b32f
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x0, 0x7(%rsp)
je 0x4b358
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r13, %rcx
movq %r14, %r8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4d7ec
movq 0x48(%r15), %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq 0x10(%rsp), %rcx
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
jne 0x4b320
movq 0x48(%r15), %rdi
movl $0x2, %esi
movq %rax, %rdx
movq %r13, %rcx
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
jne 0x4b320
movq %rax, %rbx
movq 0x48(%r15), %rdi
xorl %esi, %esi
movq %rbp, %rdx
movq %r12, %rcx
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
jne 0x4b320
movq 0x48(%r15), %rdi
movl $0x2, %esi
movq %rax, %rdx
movq %r13, %rcx
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
jne 0x4b320
movq %rax, %rbp
jmp 0x4b336