// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/frontend/array_type.c
// Function: prv_check_dynamic_dim
static void prv_check_dynamic_dim(subtilis_parser_t *p, subtilis_exp_t *e,
				  int32_t lower_bound, subtilis_exp_t *max_dim,
				  subtilis_error_t *err)
{
	subtilis_ir_operand_t error_label;
	subtilis_ir_operand_t ok_label;
	subtilis_exp_t *zero = NULL;
	subtilis_exp_t *edup = NULL;
	subtilis_exp_t *maxe = NULL;

	error_label = subtilis_array_type_error_label(p);
	ok_label.label = subtilis_ir_section_new_label(p->current);

	edup = subtilis_type_if_dup(e, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if (max_dim) {
		maxe = subtilis_type_if_dup(e, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	zero = subtilis_exp_new_int32(lower_bound, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	if (max_dim) {
		maxe = subtilis_type_if_lte(p, maxe, max_dim, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
		max_dim = NULL;
		edup = subtilis_type_if_and(p, edup, maxe, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
		maxe = NULL;
	}

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  edup->exp.ir_op, ok_label,
					  error_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, ok_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

cleanup:

	subtilis_exp_delete(max_dim);
	subtilis_exp_delete(maxe);
	subtilis_exp_delete(edup);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r14
movq %rcx, %r12
movl %edx, %r13d
movq %rsi, %rbp
movq %rdi, %r15
callq 0x3feb4
movq %rax, 0x8(%rsp)
movq 0x48(%r15), %rdi
callq 0x2b774
movq %rax, 0x10(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x341c4
cmpl $0x0, (%r14)
je 0x40f39
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
testq %r12, %r12
je 0x40f57
movq %rbp, %rdi
movq %r14, %rsi
callq 0x341c4
cmpl $0x0, (%r14)
jne 0x40f2a
movq %rax, %rbp
jmp 0x40f59
xorl %ebp, %ebp
movl %r13d, %edi
movq %r14, %rsi
callq 0x2a369
cmpl $0x0, (%r14)
jne 0x40f84
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x35259
movq %rax, %rbx
cmpl $0x0, (%r14)
je 0x40fad
movq %rbp, %r13
movq %r12, %rdi
callq 0x29d88
movq %r13, %rdi
callq 0x29d88
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x29d88
testq %r12, %r12
je 0x40fee
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x35195
movq %rax, %r13
cmpl $0x0, (%r14)
jne 0x40f87
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x34ca6
movq %rax, %rbx
xorl %ebp, %ebp
cmpl $0x0, (%r14)
movl $0x0, %r12d
jne 0x40f87
movq 0x48(%r15), %rdi
movq 0x148(%rbx), %rdx
pushq $0x43
popq %rsi
movq 0x10(%rsp), %r12
movq %r12, %rcx
movq 0x8(%rsp), %r8
movq %r14, %r9
callq 0x2a8c1
cmpl $0x0, (%r14)
je 0x4101f
xorl %r12d, %r12d
jmp 0x40f84
movq 0x48(%r15), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2b781
cmpl $0x0, (%r14)
jne 0x40f2a
jmp 0x41017