// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/frontend/string_type.c
// Function: prv_mid_str_cv
static subtilis_exp_t *prv_mid_str_cv(subtilis_parser_t *p, subtilis_exp_t *str,
				      size_t start_reg, size_t len_reg,
				      subtilis_error_t *err)
{
	size_t const_str_len;
	subtilis_ir_operand_t op0;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t end;
	const subtilis_symbol_t *s;
	size_t ptr;
	size_t id;
	size_t src_reg;
	subtilis_ir_operand_t to_copy;
	subtilis_exp_t *str_len = NULL;
	char *tmp_name = NULL;

	to_copy.reg = p->current->reg_counter++;
	const_str_len = subtilis_buffer_get_size(&str->exp.str) - 1;
	end.label = subtilis_ir_section_new_label(p->current);

	str_len = subtilis_exp_new_int32(const_str_len, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	start_reg = prv_mid_str_check(p, start_reg, len_reg, to_copy, end,
				      str_len, &s, &tmp_name, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	id = prv_add_string_constant(
	    p, subtilis_buffer_get_string(&str->exp.str), const_str_len, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op1.integer = (int32_t)id;
	src_reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_LCA, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	subtilis_string_init_from_lca(p, SUBTILIS_IR_REG_LOCAL, s->loc, src_reg,
				      to_copy.reg, true, 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;

	ptr = 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, tmp_name,
					err);

cleanup:

	free(tmp_name);
	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %rbx
movq %rcx, 0x8(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, %r13
movq %rdi, %r14
movq $0x0, 0x10(%rsp)
movq 0x48(%rdi), %rax
movq 0x18(%rax), %r12
leaq 0x1(%r12), %rcx
movq %rcx, 0x18(%rax)
addq $0x148, %r13            # imm = 0x148
movq %r13, %rdi
callq 0x14ba1
movq %rax, %rbp
decq %rbp
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, %r15
movl %ebp, %edi
movq %rbx, %rsi
callq 0x2bb29
cmpl $0x0, (%rbx)
jne 0x4a993
subq $0x8, %rsp
leaq 0x18(%rsp), %r10
leaq 0x28(%rsp), %r11
movq %r14, %rdi
movq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r12, %rcx
movq %r15, %r8
movq %rax, %r9
pushq %rbx
pushq %r10
pushq %r11
callq 0x4c324
addq $0x20, %rsp
cmpl $0x0, (%rbx)
jne 0x4a993
movq %rax, 0x8(%rsp)
movq %r13, %rdi
callq 0x14dfb
movq %r14, %rdi
movq %rax, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x4829f
cmpl $0x0, (%rbx)
jne 0x4a989
movq 0x48(%r14), %rdi
movl %eax, %edx
movl $0x7d, %esi
movq %rbx, %rcx
callq 0x2c189
cmpl $0x0, (%rbx)
jne 0x4a989
movq 0x48(%r14), %rdi
xorl %esi, %esi
movq %rax, %rdx
movq 0x8(%rsp), %rcx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x4a989
movq 0x20(%rsp), %r13
movq (%r13), %rdx
subq $0x8, %rsp
movl $0x2, %esi
movq %r14, %rdi
movq %rax, %rcx
movq %r12, %r8
movl $0x1, %r9d
pushq %rbx
callq 0x4851e
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x4a989
movq 0x48(%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x4a989
movq (%r13), %rdx
movl $0x2, %esi
movq %r14, %rdi
movq %rbx, %rcx
callq 0x4d763
cmpl $0x0, (%rbx)
je 0x4a9a4
movq 0x10(%rsp), %rdi
callq 0x122c0
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rdx
leaq 0x2a1d8(%rip), %rdi     # 0x74b88
movl %eax, %esi
movq %rbx, %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b99d