// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/string_type.c
// Function: prv_mid_str_ccv
static subtilis_exp_t *prv_mid_str_ccv(subtilis_parser_t *p,
				       subtilis_exp_t *str, size_t len_reg,
				       subtilis_error_t *err)
{
	size_t const_str_len;
	subtilis_ir_operand_t len_zero;
	subtilis_ir_operand_t len_not_zero;
	subtilis_ir_operand_t len_too_big;
	subtilis_ir_operand_t len_below_zero;
	subtilis_ir_operand_t len_ok;
	subtilis_ir_operand_t op0;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t end;
	subtilis_ir_operand_t condee;
	const subtilis_symbol_t *s;
	size_t ptr;
	size_t id;
	size_t src_reg;
	subtilis_ir_operand_t to_copy;
	char *tmp_name = NULL;

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

	s = subtilis_symbol_table_insert_tmp(p->local_st, &subtilis_type_string,
					     &tmp_name, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	op0.reg = len_reg;
	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  op0, len_not_zero, len_zero, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	subtilis_reference_type_set_size(p, SUBTILIS_IR_REG_LOCAL, s->loc,
					 len_reg, 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;

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

	op1.integer = 0;
	len_below_zero.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LTI_I32, op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op1.integer = const_str_len;
	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_GTI_I32, op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_OR_I32, condee, len_below_zero, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  condee, len_too_big, len_ok, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

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

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

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

	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;

	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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq $0x0, -0xa8(%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, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x38(%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, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
addq $0x148, %rdi            # imm = 0x148
callq 0x16270
subq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x28(%rbp), %rcx
leaq 0x4015c(%rip), %rsi     # 0xabb60
leaq -0xa8(%rbp), %rdx
callq 0x3c920
movq %rax, -0x80(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ba2a
movq $0x0, -0x8(%rbp)
jmp 0x6bdc2
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r9
movq -0x60(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ba62
jmp 0x6bdae
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ba85
jmp 0x6bdae
movq -0x10(%rbp), %rdi
movq -0x80(%rbp), %rax
movq (%rax), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movl $0x2, %esi
callq 0x6dc50
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bab0
jmp 0x6bdae
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rcx
movq -0x70(%rbp), %rdx
movl $0x45, %esi
callq 0x38540
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bad8
jmp 0x6bdae
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bafb
jmp 0x6bdae
movl $0x0, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0x60(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x3d, %esi
callq 0x38230
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bb32
jmp 0x6bdae
movq -0x30(%rbp), %rax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0x60(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x35, %esi
callq 0x38230
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bb69
jmp 0x6bdae
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0x78(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x26, %esi
callq 0x38230
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bb99
jmp 0x6bdae
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r9
movq -0x78(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x58(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bbc9
jmp 0x6bdae
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x48(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bbec
jmp 0x6bdae
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0x60(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x1b, %esi
callq 0x385a0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bc27
jmp 0x6bdae
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x58(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bc4a
jmp 0x6bdae
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0xa0(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x1d, %esi
callq 0x385a0
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bc81
jmp 0x6bdae
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x18(%rbp), %rdi
addq $0x148, %rdi            # imm = 0x148
callq 0x16760
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x65e00
movq %rax, -0x90(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bcc8
jmp 0x6bdae
movq -0x90(%rbp), %rax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rcx
movq -0x68(%rbp), %rdx
movl $0x7d, %esi
callq 0x38490
movq %rax, -0x98(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bd01
jmp 0x6bdae
movq -0x10(%rbp), %rdi
movq -0x80(%rbp), %rax
movq (%rax), %rdx
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %r8
movq -0x28(%rbp), %rax
movl $0x2, %esi
movl $0x1, %r9d
movq %rax, (%rsp)
callq 0x66160
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bd3d
jmp 0x6bdae
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x70(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bd5d
jmp 0x6bdae
movq -0x10(%rbp), %rdi
movq -0x80(%rbp), %rax
movq (%rax), %rdx
movq -0x28(%rbp), %rcx
movl $0x2, %esi
callq 0x6d920
movq %rax, -0x88(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bd88
jmp 0x6bdae
movq -0x88(%rbp), %rax
movl %eax, %esi
movq -0xa8(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq 0x3fdbd(%rip), %rdi     # 0xabb60
callq 0x375f0
movq %rax, -0x8(%rbp)
jmp 0x6bdc2
movq -0xa8(%rbp), %rdi
callq 0x12290
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nop