// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/frontend/string_type.c
// Function: prv_left_right_statement
static void prv_left_right_statement(subtilis_parser_t *p, subtilis_exp_t *str,
				     subtilis_exp_t *len, subtilis_exp_t *value,
				     bool left, subtilis_error_t *err)
{
	size_t data_reg;
	subtilis_ir_operand_t end_label;
	subtilis_ir_operand_t strlen_gt0_label;
	subtilis_ir_operand_t to_copy;
	subtilis_ir_operand_t op1;
	size_t str_len_reg;
	size_t value_len_reg;

	end_label.label = subtilis_ir_section_new_label(p->current);
	strlen_gt0_label.label = subtilis_ir_section_new_label(p->current);

	len = prv_left_right_check_args(p, str, len, value, err);
	if (err->type != SUBTILIS_ERROR_OK || !len)
		goto cleanup;

	op1.integer = SUBTIILIS_STRING_SIZE_OFF;
	str_len_reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I32, str->exp.ir_op, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	to_copy.reg = prv_left_right_calc_len(p, len, value, str_len_reg,
					      &value_len_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	/*
	 * If to_copy is 0 there's nothing to do.
	 */

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  to_copy, strlen_gt0_label, end_label,
					  err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, strlen_gt0_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	data_reg = subtilis_reference_type_copy_on_write(p, str->exp.ir_op.reg,
							 0, str_len_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	prv_left_right_copy(p, data_reg, str_len_reg, value_len_reg, to_copy,
			    value, left, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, end_label.label, err);

cleanup:

	subtilis_exp_delete(str);
	subtilis_exp_delete(len);
	subtilis_exp_delete(value);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r15
movl %r8d, 0x4(%rsp)
movq %rcx, %rbx
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %r12
movq 0x48(%rdi), %rdi
callq 0x2b774
movq %rax, 0x10(%rsp)
movq 0x48(%r12), %rdi
callq 0x2b774
movq %rax, %r13
movq %r12, %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
movq %r15, %r8
callq 0x48573
movq %rax, %rbp
cmpl $0x0, (%r15)
sete %al
testq %rbp, %rbp
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x481f5
movq 0x48(%r12), %rdi
movq 0x148(%r14), %rdx
pushq $0x12
popq %rsi
xorl %ecx, %ecx
movq %r15, %r8
callq 0x2a819
cmpl $0x0, (%r15)
jne 0x481f5
leaq 0x20(%rsp), %r8
movq %r12, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %rax, %rcx
movq %rax, 0x8(%rsp)
movq %r15, %r9
callq 0x48622
cmpl $0x0, (%r15)
jne 0x481f5
movq 0x48(%r12), %rdi
pushq $0x43
popq %rsi
movq %rax, %rdx
movq %r13, %rcx
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %r8
movq %r15, %r9
callq 0x2a8c1
cmpl $0x0, (%r15)
jne 0x481f5
movq 0x48(%r12), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2b781
movq 0x8(%rsp), %rcx
cmpl $0x0, (%r15)
jne 0x481f5
movq 0x148(%r14), %rsi
movq %r12, %rdi
xorl %edx, %edx
movq %r15, %r8
callq 0x4aecb
movq 0x18(%rsp), %r8
movq 0x8(%rsp), %rdx
cmpl $0x0, (%r15)
jne 0x481f5
movq 0x20(%rsp), %rcx
movzbl 0x4(%rsp), %r10d
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %r9
pushq %r15
pushq %r10
callq 0x48806
popq %rax
popq %rcx
cmpl $0x0, (%r15)
jne 0x481f5
movq 0x48(%r12), %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
callq 0x2b781
movq %r14, %rdi
callq 0x29d88
movq %rbp, %rdi
callq 0x29d88
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x29d88