// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/frontend/string_type.c
// Function: prv_mid_str_check
static size_t prv_mid_str_check(subtilis_parser_t *p, size_t start_reg,
				size_t len_reg, subtilis_ir_operand_t to_copy,
				subtilis_ir_operand_t end,
				subtilis_exp_t *str_len,
				const subtilis_symbol_t **s_ret,
				char **tmp_name, subtilis_error_t *err)
{
	subtilis_ir_operand_t start_reg_zero;
	subtilis_ir_operand_t start_reg_not_zero;
	subtilis_ir_operand_t less_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 len_zero;
	subtilis_ir_operand_t op0;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t op2;
	subtilis_ir_operand_t empty;
	subtilis_ir_operand_t non_empty;
	subtilis_ir_operand_t zero_reg;
	subtilis_ir_operand_t condee;
	const subtilis_symbol_t *s;
	size_t start_reg_copy;
	subtilis_exp_t *a1 = NULL;
	subtilis_exp_t *a2 = NULL;
	char *local_tmp_name = NULL;

	start_reg_zero.label = subtilis_ir_section_new_label(p->current);
	start_reg_not_zero.label = subtilis_ir_section_new_label(p->current);
	empty.label = subtilis_ir_section_new_label(p->current);
	non_empty.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);

	s = subtilis_symbol_table_insert_tmp(p->local_st, &subtilis_type_string,
					     &local_tmp_name, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op1.reg = start_reg;
	start_reg_copy = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOV, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	condee.reg = start_reg;
	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  condee, start_reg_not_zero,
					  start_reg_zero, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	op0.reg = start_reg_copy;
	op1.reg = start_reg;
	op2.integer = 1;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_SUBI_I32, op0, op1, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	start_reg = start_reg_copy;

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

	op0.reg = start_reg;
	op1.integer = 0;
	less_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;

	a1 = subtilis_exp_new_int32_var(start_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;
	a2 = subtilis_type_if_dup(str_len, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	a1 = subtilis_type_if_gte(p, a1, a2, err);
	a2 = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	condee.reg =
	    subtilis_ir_section_add_instr(p->current, SUBTILIS_OP_INSTR_OR_I32,
					  less_zero, a1->exp.ir_op, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;
	subtilis_exp_delete(a1);
	a1 = NULL;

	if (len_reg != SIZE_MAX) {
		op0.reg = len_reg;
		op1.integer = 0;
		len_zero.reg = subtilis_ir_section_add_instr(
		    p->current, SUBTILIS_OP_INSTR_EQI_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_zero,
		    err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
	}

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

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

	op1.integer = 0;
	zero_reg.reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOVI_I32, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_reference_type_set_size(p, SUBTILIS_IR_REG_LOCAL, s->loc,
					 zero_reg.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	/*
	 * No need to push to the stack as this is a temporary reference
	 * which cannot be assigned to and that owns no data, i.e., it can
	 * never own any data.
	 */

	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, non_empty.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	a1 = subtilis_exp_new_int32_var(start_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	a1 = subtilis_type_if_sub(p, str_len, a1, err);
	str_len = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_no_reg2(p->current, SUBTILIS_OP_INSTR_MOV,
					      to_copy, a1->exp.ir_op, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;
	subtilis_exp_delete(a1);
	a1 = NULL;

	if (len_reg != SIZE_MAX) {
		op0.reg = len_reg;
		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;

		condee.reg = subtilis_ir_section_add_instr(
		    p->current, SUBTILIS_OP_INSTR_GT_I32, op0, to_copy, 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_ok,
		    len_too_big, 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;

		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;

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

	subtilis_exp_delete(str_len);
	*tmp_name = local_tmp_name;
	*s_ret = s;
	return start_reg;

cleanup:

	free(local_tmp_name);
	subtilis_exp_delete(a2);
	subtilis_exp_delete(a1);
	subtilis_exp_delete(str_len);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, 0x8(%rsp)
movq %r8, 0x58(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r15
movq 0xb0(%rsp), %r14
leaq 0x28(%rsp), %rax
movq $0x0, (%rax)
movq 0x48(%rdi), %rdi
callq 0x2cc99
movq %rax, (%rsp)
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, 0x60(%rsp)
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, %r13
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, %r12
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, %rbp
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, %rbx
movq 0x68(%r15), %rdi
leaq 0x28833(%rip), %rsi     # 0x74ba8
leaq 0x28(%rsp), %rdx
movq %r14, %rcx
callq 0x2e6f1
cmpl $0x0, (%r14)
jne 0x4c46b
movq %r13, 0x50(%rsp)
movq %r12, 0x48(%rsp)
movq %rbp, 0x30(%rsp)
movq %rbx, 0x38(%rsp)
movq %rax, 0x40(%rsp)
movq 0x48(%r15), %rdi
movl $0x1d, %esi
movq 0x20(%rsp), %r12
movq %r12, %rdx
movq %r14, %rcx
callq 0x2be09
cmpl $0x0, (%r14)
jne 0x4c46b
movq %rax, %r13
movq 0x48(%r15), %rdi
movl $0x43, %esi
movq %r12, %rdx
movq 0x60(%rsp), %rbp
movq %rbp, %rcx
movq (%rsp), %rbx
movq %rbx, %r8
movq %r14, %r9
callq 0x2bd42
cmpl $0x0, (%r14)
jne 0x4c46b
movq 0x48(%r15), %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x2cca6
cmpl $0x0, (%r14)
jne 0x4c46b
movq 0x48(%r15), %rdi
movl $0x1, %r8d
movl $0xb, %esi
movq %r13, %rdx
movq %r12, %rcx
movq %r14, %r9
callq 0x2bd42
cmpl $0x0, (%r14)
jne 0x4c46b
movq 0x48(%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2cca6
cmpl $0x0, (%r14)
jne 0x4c46b
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
andq %rax, %r12
movq 0x48(%r15), %rdi
movl $0x3d, %esi
movq %r13, %rdx
movq %r12, %rcx
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
je 0x4c4a8
xorl %ebp, %ebp
xorl %ebx, %ebx
movq 0x28(%rsp), %rdi
callq 0x122c0
movq %rbx, %rdi
callq 0x2b166
movq %rbp, %rdi
callq 0x2b166
movq 0x8(%rsp), %rdi
callq 0x2b166
xorl %r13d, %r13d
movq %r13, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl %r13d, %edi
movq %r14, %rsi
callq 0x2b71f
movq %rax, %rbp
cmpl $0x0, (%r14)
jne 0x4c46d
movq %rbx, 0x20(%rsp)
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x36182
movq %rax, %rbx
cmpl $0x0, (%r14)
jne 0x4c46f
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x37164
movq %rax, %rbp
cmpl $0x0, (%r14)
jne 0x4c46d
movq %r15, (%rsp)
movq 0x48(%r15), %rdi
movq 0x148(%rbp), %rcx
movl $0x26, %esi
movq 0x20(%rsp), %rdx
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
jne 0x4c46d
movq %rax, %rbx
movq %rbp, %rdi
callq 0x2b166
cmpq $-0x1, 0x10(%rsp)
je 0x4c595
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movl $0x2d, %esi
movq 0x10(%rsp), %rdx
movq %r12, %rcx
movq 0xb0(%rsp), %r14
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
jne 0x4c46b
movq (%rsp), %rcx
movq 0x48(%rcx), %rdi
movl $0x26, %esi
movq %rbx, %rdx
movq %rax, %rcx
movq 0xb0(%rsp), %r14
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
jne 0x4c46b
movq %rax, %rbx
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movl $0x43, %esi
movq %rbx, %rdx
movq 0x50(%rsp), %rcx
movq 0x48(%rsp), %r8
movq 0xb0(%rsp), %rbx
movq %rbx, %r9
callq 0x2bd42
cmpl $0x0, (%rbx)
jne 0x4c46b
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x50(%rsp), %rsi
movq 0xb0(%rsp), %rbx
movq %rbx, %rdx
callq 0x2cca6
cmpl $0x0, (%rbx)
jne 0x4c46b
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movl $0x1b, %esi
movq %r12, %rdx
movq 0xb0(%rsp), %rbx
movq %rbx, %rcx
callq 0x2be09
cmpl $0x0, (%rbx)
jne 0x4c46b
movq 0x40(%rsp), %rcx
movq (%rcx), %rdx
movl $0x2, %esi
movq (%rsp), %rdi
movq %rax, %rcx
movq 0xb0(%rsp), %rbx
movq %rbx, %r8
callq 0x4d8dd
cmpl $0x0, (%rbx)
jne 0x4c46b
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movl $0x45, %esi
movq 0x58(%rsp), %rdx
movq 0xb0(%rsp), %rbx
movq %rbx, %rcx
callq 0x2be1f
cmpl $0x0, (%rbx)
jne 0x4c46b
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x48(%rsp), %rsi
movq 0xb0(%rsp), %rbx
movq %rbx, %rdx
callq 0x2cca6
cmpl $0x0, (%rbx)
jne 0x4c46b
movl %r13d, %edi
movq 0xb0(%rsp), %rbx
movq %rbx, %rsi
callq 0x2b71f
movq %rax, %rbp
cmpl $0x0, (%rbx)
jne 0x4c46d
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %rbp, %rdx
movq 0xb0(%rsp), %rbx
movq %rbx, %rcx
callq 0x36de4
movq %rax, %rbp
cmpl $0x0, (%rbx)
jne 0x4c706
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x148(%rbp), %rcx
movl $0x1d, %esi
movq 0x18(%rsp), %rdx
movq 0xb0(%rsp), %rbx
movq %rbx, %r8
callq 0x2be2c
cmpl $0x0, (%rbx)
je 0x4c714
movq $0x0, 0x8(%rsp)
jmp 0x4c46d
movq %rbp, %rdi
callq 0x2b166
cmpq $-0x1, 0x10(%rsp)
je 0x4c864
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movl $0x3d, %esi
movq 0x10(%rsp), %rdx
movq %r12, %rcx
movq 0xb0(%rsp), %r14
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
jne 0x4c856
movq %rax, %rbx
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movl $0x33, %esi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq 0xb0(%rsp), %r14
movq %r14, %r8
callq 0x2bc8f
cmpl $0x0, (%r14)
jne 0x4c856
movq (%rsp), %rcx
movq 0x48(%rcx), %rdi
movl $0x26, %esi
movq %rax, %rdx
movq %rbx, %rcx
movq 0xb0(%rsp), %rbx
movq %rbx, %r8
callq 0x2bc8f
cmpl $0x0, (%rbx)
jne 0x4c856
movq (%rsp), %rcx
movq 0x48(%rcx), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq 0x38(%rsp), %rcx
movq 0x30(%rsp), %r8
movq 0xb0(%rsp), %rbx
movq %rbx, %r9
callq 0x2bd42
cmpl $0x0, (%rbx)
jne 0x4c856
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x30(%rsp), %rsi
movq 0xb0(%rsp), %rbx
movq %rbx, %rdx
callq 0x2cca6
cmpl $0x0, (%rbx)
jne 0x4c856
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movl $0x1d, %esi
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq 0xb0(%rsp), %rbx
movq %rbx, %r8
callq 0x2be2c
cmpl $0x0, (%rbx)
jne 0x4c856
movq (%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x38(%rsp), %rsi
movq 0xb0(%rsp), %rbx
movq %rbx, %rdx
callq 0x2cca6
cmpl $0x0, (%rbx)
je 0x4c864
movq $0x0, 0x8(%rsp)
jmp 0x4c46b
movq 0xa8(%rsp), %rbx
movq 0xa0(%rsp), %r14
xorl %edi, %edi
callq 0x2b166
movq 0x28(%rsp), %rax
movq %rax, (%rbx)
movq 0x40(%rsp), %rax
movq %rax, (%r14)
jmp 0x4c496