// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x69cf0
movq %rax, -0x18(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x69716
cmpq $0x0, -0x18(%rbp)
jne 0x6971b
jmp 0x69860
movl $0x0, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %r8
movq 0x148(%rax), %rdx
movq -0x58(%rbp), %rcx
movl $0x12, %esi
callq 0x38230
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x69759
jmp 0x69860
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq -0x30(%rbp), %r9
leaq -0x68(%rbp), %r8
callq 0x69e20
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x69788
jmp 0x69860
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %r9
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x697b8
jmp 0x69860
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x48(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x39960
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x697db
jmp 0x69860
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x148(%rax), %rsi
movq -0x60(%rbp), %rcx
movq -0x30(%rbp), %r8
xorl %eax, %eax
movl %eax, %edx
callq 0x6e000
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6980a
jmp 0x69860
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq -0x68(%rbp), %rcx
movq -0x20(%rbp), %r9
movb -0x21(%rbp), %r10b
movq -0x30(%rbp), %rax
movq -0x50(%rbp), %r8
andb $0x1, %r10b
movzbl %r10b, %r10d
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x6a160
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6984b
jmp 0x69860
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x39960
movq -0x10(%rbp), %rdi
callq 0x36ee0
movq -0x18(%rbp), %rdi
callq 0x36ee0
movq -0x20(%rbp), %rdi
callq 0x36ee0
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)