// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xd0, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rcx, -0x10(%rbp)
movq %r8, -0x18(%rbp)
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movq %rdx, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq $0x0, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movq $0x0, -0xd0(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x90(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x98(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq 0x68(%rax), %rdi
movq 0x20(%rbp), %rcx
leaq 0x3fcc1(%rip), %rsi     # 0xabb60
leaq -0xd0(%rbp), %rdx
callq 0x3c920
movq %rax, -0xb0(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bec0
jmp 0x6c4ad
movq -0x28(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %rcx
movq -0x80(%rbp), %rdx
movl $0x1d, %esi
callq 0x38490
movq %rax, -0xb8(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bef7
jmp 0x6c4ad
movq -0x28(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0xa8(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bf35
jmp 0x6c4ad
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x48(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bf58
jmp 0x6c4ad
movq -0xb8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x80(%rbp)
movl $0x1, -0x88(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0x78(%rbp), %rdx
movq -0x80(%rbp), %rcx
movq -0x88(%rbp), %r8
movl $0xb, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bfa8
jmp 0x6c4ad
movq -0xb8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x40(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6bfd6
jmp 0x6c4ad
movq -0x28(%rbp), %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x80(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x78(%rbp), %rdx
movq -0x80(%rbp), %rcx
movl $0x3d, %esi
callq 0x38230
movq %rax, -0x50(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c015
jmp 0x6c4ad
movq -0x28(%rbp), %rax
movl %eax, %edi
movq 0x20(%rbp), %rsi
callq 0x37770
movq %rax, -0xc0(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c039
jmp 0x6c4ad
movq -0x38(%rbp), %rdi
movq 0x20(%rbp), %rsi
callq 0x47d20
movq %rax, -0xc8(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c05b
jmp 0x6c4ad
movq -0x20(%rbp), %rdi
movq -0xc0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
movq 0x20(%rbp), %rcx
callq 0x497e0
movq %rax, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c096
jmp 0x6c4ad
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0xc0(%rbp), %rax
movq 0x20(%rbp), %r8
movq -0x50(%rbp), %rdx
movq 0x148(%rax), %rcx
movl $0x26, %esi
callq 0x38230
movq %rax, -0xa8(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c0d3
jmp 0x6c4ad
movq -0xc0(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0xc0(%rbp)
cmpq $-0x1, -0x30(%rbp)
je 0x6c168
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x80(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x78(%rbp), %rdx
movq -0x80(%rbp), %rcx
movl $0x2d, %esi
callq 0x38230
movq %rax, -0x70(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c130
jmp 0x6c4ad
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0xa8(%rbp), %rdx
movq -0x70(%rbp), %rcx
movl $0x26, %esi
callq 0x38230
movq %rax, -0xa8(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c166
jmp 0x6c4ad
jmp 0x6c168
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0xa8(%rbp), %rdx
movq -0x90(%rbp), %rcx
movq -0x98(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c1a1
jmp 0x6c4ad
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x90(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c1c7
jmp 0x6c4ad
movl $0x0, -0x80(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %rcx
movq -0x80(%rbp), %rdx
movl $0x1b, %esi
callq 0x38490
movq %rax, -0xa0(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c1fd
jmp 0x6c4ad
movq -0x20(%rbp), %rdi
movq -0xb0(%rbp), %rax
movq (%rax), %rdx
movq -0xa0(%rbp), %rcx
movq 0x20(%rbp), %r8
movl $0x2, %esi
callq 0x6dc50
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c22e
jmp 0x6c4ad
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %rcx
movq -0x18(%rbp), %rdx
movl $0x45, %esi
callq 0x38540
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c256
jmp 0x6c4ad
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x98(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c27c
jmp 0x6c4ad
movq -0x28(%rbp), %rax
movl %eax, %edi
movq 0x20(%rbp), %rsi
callq 0x37770
movq %rax, -0xc0(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c2a0
jmp 0x6c4ad
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq 0x20(%rbp), %rcx
callq 0x492c0
movq %rax, -0xc0(%rbp)
movq $0x0, -0x38(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c2d5
jmp 0x6c4ad
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0xc0(%rbp), %rax
movq 0x20(%rbp), %r8
movq -0x10(%rbp), %rdx
movq 0x148(%rax), %rcx
movl $0x1d, %esi
callq 0x385a0
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c30b
jmp 0x6c4ad
movq -0xc0(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0xc0(%rbp)
cmpq $-0x1, -0x30(%rbp)
je 0x6c47e
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x80(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x78(%rbp), %rdx
movq -0x80(%rbp), %rcx
movl $0x3d, %esi
callq 0x38230
movq %rax, -0x60(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c36c
jmp 0x6c4ad
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x78(%rbp), %rdx
movq -0x10(%rbp), %rcx
movl $0x33, %esi
callq 0x38230
movq %rax, -0xa8(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c39f
jmp 0x6c4ad
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0xa8(%rbp), %rdx
movq -0x60(%rbp), %rcx
movl $0x26, %esi
callq 0x38230
movq %rax, -0xa8(%rbp)
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c3d5
jmp 0x6c4ad
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r9
movq -0xa8(%rbp), %rdx
movq -0x68(%rbp), %rcx
movq -0x58(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c408
jmp 0x6c4ad
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x58(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c42b
jmp 0x6c4ad
movq -0x30(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x20(%rbp), %r8
movq -0x10(%rbp), %rdx
movq -0x80(%rbp), %rcx
movl $0x1d, %esi
callq 0x385a0
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c45c
jmp 0x6c4ad
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x68(%rbp), %rsi
movq 0x20(%rbp), %rdx
callq 0x39960
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c47c
jmp 0x6c4ad
jmp 0x6c47e
movq -0x38(%rbp), %rdi
callq 0x36ee0
movq -0xd0(%rbp), %rcx
movq 0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0xb0(%rbp), %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6c4e2
movq -0xd0(%rbp), %rdi
callq 0x12290
movq -0xc8(%rbp), %rdi
callq 0x36ee0
movq -0xc0(%rbp), %rdi
callq 0x36ee0
movq -0x38(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nop