// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movq %rcx, %r12
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
movq 0x48(%rdi), %rdi
movq 0xb0(%rdi), %r13
cmpq $-0x1, %r13
jne 0x4356b
callq 0x2cc99
movq %rax, %r13
movq 0x48(%r15), %rdi
movq %rax, 0xb0(%rdi)
callq 0x2cc99
movq %rax, 0x10(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x36182
cmpl $0x0, (%rbx)
je 0x43594
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x435b3
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %r14
callq 0x36182
cmpl $0x0, (%rbx)
jne 0x43585
movq %rax, 0x8(%rsp)
jmp 0x435bf
movq %rax, %r14
movq $0x0, 0x8(%rsp)
movl %ebp, %edi
movq %rbx, %rsi
callq 0x2b7af
cmpl $0x0, (%rbx)
jne 0x435e7
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x37164
movq %rax, %r14
cmpl $0x0, (%rbx)
je 0x43612
movq 0x8(%rsp), %rbp
movq %r12, %rdi
callq 0x2b166
movq %rbp, %rdi
callq 0x2b166
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b166
testq %r12, %r12
je 0x4365a
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x370d0
movq %rax, %rbp
cmpl $0x0, (%rbx)
jne 0x435ec
movq %r15, %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x36c60
movq %rax, %r14
movq $0x0, 0x8(%rsp)
cmpl $0x0, (%rbx)
movl $0x0, %r12d
jne 0x435ec
movq 0x48(%r15), %rdi
movq 0x148(%r14), %rdx
movl $0x43, %esi
movq 0x10(%rsp), %r12
movq %r12, %rcx
movq %r13, %r8
movq %rbx, %r9
callq 0x2bd42
cmpl $0x0, (%rbx)
je 0x4368a
xorl %r12d, %r12d
jmp 0x435e7
movq 0x48(%r15), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x2cca6
cmpl $0x0, (%rbx)
movq 0x8(%rsp), %rbp
jne 0x43585
xorl %r12d, %r12d
jmp 0x435ec