// File: /workspace/github_c_makefile_star2_O1/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 0x4b354
movq %rbp, %rdi
callq 0x14dfb
movq %rbx, 0x8(%rsp)
movq %r13, %rbx
movq %rax, %r13
movq %rbp, %rdi
callq 0x14ba1
leaq -0x1(%rax), %rdx
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %r13
movq 0x8(%rsp), %rbx
movq %r14, %rcx
callq 0x48267
jmp 0x4b365
movq (%rbp), %rsi
movq %r15, %rdi
xorl %edx, %edx
movq %r14, %rcx
callq 0x4d29c
movq %rax, %rbp
cmpl $0x0, (%r14)
je 0x4b37d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x0, 0x7(%rsp)
je 0x4b3a6
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 0x4d830
movq 0x48(%r15), %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq 0x10(%rsp), %rcx
movq %r14, %r8
callq 0x2c00f
cmpl $0x0, (%r14)
jne 0x4b36e
movq 0x48(%r15), %rdi
movl $0x2, %esi
movq %rax, %rdx
movq %r13, %rcx
movq %r14, %r8
callq 0x2c00f
cmpl $0x0, (%r14)
jne 0x4b36e
movq %rax, %rbx
movq 0x48(%r15), %rdi
xorl %esi, %esi
movq %rbp, %rdx
movq %r12, %rcx
movq %r14, %r8
callq 0x2c00f
cmpl $0x0, (%r14)
jne 0x4b36e
movq 0x48(%r15), %rdi
movl $0x2, %esi
movq %rax, %rdx
movq %r13, %rcx
movq %r14, %r8
callq 0x2c00f
cmpl $0x0, (%r14)
jne 0x4b36e
movq %rax, %rbp
jmp 0x4b384