// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/string_type.c
// Function: prv_right_non_const
static subtilis_exp_t *prv_right_non_const(subtilis_parser_t *p, size_t str_reg,
					   size_t right_reg, bool right_const,
					   subtilis_error_t *err)
{
	size_t data_reg;
	subtilis_ir_operand_t end;
	const subtilis_symbol_t *s;
	subtilis_ir_operand_t op0;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t op2;
	size_t len_reg;
	size_t ptr_reg;
	subtilis_ir_operand_t partial;
	char *tmp_name = NULL;
	size_t dest_data_reg = p->current->reg_counter++;
	size_t dest_len_reg = p->current->reg_counter++;

	end.label = subtilis_ir_section_new_label(p->current);
	partial.label = subtilis_ir_section_new_label(p->current);
	s = subtilis_symbol_table_insert_tmp(p->local_st, &subtilis_type_string,
					     &tmp_name, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	len_reg = prv_left_right_non_const(p, str_reg, right_reg, right_const,
					   partial, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	/*
	 * Code for dealing with the full string goes here.
	 */

	op0.reg = dest_len_reg;
	op1.reg = len_reg;
	subtilis_ir_section_add_instr_no_reg2(p->current, SUBTILIS_OP_INSTR_MOV,
					      op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op0.reg = dest_data_reg;
	op1.reg = str_reg;
	op2.integer = SUBTIILIS_STRING_DATA_OFF;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I32, op0, op1, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_no_reg(p->current, SUBTILIS_OP_INSTR_JMP,
					     end, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	/* If we're actually slicing, we end up here. */

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

	data_reg = subtilis_reference_get_data(p, str_reg, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op0.reg = data_reg;
	op1.reg = len_reg;
	op1.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_ADD_I32, op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op0.reg = dest_data_reg;
	op2.reg = right_reg;
	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_SUB_I32,
					  op0, op1, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op0.reg = dest_len_reg;
	op1.reg = right_reg;
	subtilis_ir_section_add_instr_no_reg2(p->current, SUBTILIS_OP_INSTR_MOV,
					      op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	subtilis_string_init_from_ptr(p, SUBTILIS_IR_REG_LOCAL, s->loc, str_reg,
				      dest_len_reg, dest_data_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	ptr_reg = subtilis_reference_get_pointer(p, SUBTILIS_IR_REG_LOCAL,
						 s->loc, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	return subtilis_exp_new_tmp_var(&subtilis_type_string, ptr_reg,
					tmp_name, err);

cleanup:
	free(tmp_name);
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movb %cl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq %r8, -0x30(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
movq 0x18(%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x18(%rcx)
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
movq 0x18(%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x18(%rcx)
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x30(%rbp), %rcx
leaq 0x43135(%rip), %rsi     # 0xabb60
leaq -0x80(%rbp), %rdx
callq 0x3c920
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68a4e
movq $0x0, -0x8(%rbp)
jmp 0x68cf1
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movb -0x21(%rbp), %al
movq -0x30(%rbp), %r9
movq -0x78(%rbp), %r8
andb $0x1, %al
movzbl %al, %ecx
callq 0x6b6c0
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68a81
jmp 0x68ce0
movq -0x90(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %r8
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
movl $0x1d, %esi
callq 0x385a0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68ac0
jmp 0x68ce0
movq -0x88(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x4, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %r9
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq -0x60(%rbp), %r8
movl $0x12, %esi
callq 0x38360
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68b0a
jmp 0x68ce0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rdx
movl $0x45, %esi
callq 0x38540
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68b32
jmp 0x68ce0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x78(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x39960
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68b55
jmp 0x68ce0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x6d1e0
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68b7c
jmp 0x68ce0
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %r8
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
xorl %esi, %esi
callq 0x38230
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68bb9
jmp 0x68ce0
movq -0x88(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %r9
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq -0x60(%rbp), %r8
movl $0x2, %esi
callq 0x38360
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68bfc
jmp 0x68ce0
movq -0x90(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %r8
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
movl $0x1d, %esi
callq 0x385a0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68c3b
jmp 0x68ce0
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x39960
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68c5e
jmp 0x68ce0
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rdx
movq -0x18(%rbp), %rcx
movq -0x90(%rbp), %r8
movq -0x88(%rbp), %r9
movq -0x30(%rbp), %rax
movl $0x2, %esi
movq %rax, (%rsp)
callq 0x65fb0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68c98
jmp 0x68ce0
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rax
movq (%rax), %rdx
movq -0x30(%rbp), %rcx
movl $0x2, %esi
callq 0x6d920
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68cc0
jmp 0x68ce0
movq -0x70(%rbp), %rax
movl %eax, %esi
movq -0x80(%rbp), %rdx
movq -0x30(%rbp), %rcx
leaq 0x42e8b(%rip), %rdi     # 0xabb60
callq 0x375f0
movq %rax, -0x8(%rbp)
jmp 0x68cf1
movq -0x80(%rbp), %rdi
callq 0x12290
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nop