// File: /workspace/github_c_makefile_star2_O1/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 0x43614
callq 0x2d00a
movq %rax, %r13
movq 0x48(%r15), %rax
movq %r13, 0xb0(%rax)
movq 0x48(%r15), %rdi
callq 0x2d00a
movq %rax, 0x10(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x362d2
cmpl $0x0, (%rbx)
je 0x43641
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x43660
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %r14
callq 0x362d2
cmpl $0x0, (%rbx)
jne 0x43632
movq %rax, 0x8(%rsp)
jmp 0x4366c
movq %rax, %r14
movq $0x0, 0x8(%rsp)
movl %ebp, %edi
movq %rbx, %rsi
callq 0x2bb29
cmpl $0x0, (%rbx)
jne 0x43694
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0x372a2
movq %rax, %r14
cmpl $0x0, (%rbx)
je 0x436bf
movq 0x8(%rsp), %rbp
movq %r12, %rdi
callq 0x2b4c3
movq %rbp, %rdi
callq 0x2b4c3
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b4c3
testq %r12, %r12
je 0x43707
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x3720e
movq %rax, %rbp
cmpl $0x0, (%rbx)
jne 0x43699
movq %r15, %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x36db8
movq %rax, %r14
movq $0x0, 0x8(%rsp)
cmpl $0x0, (%rbx)
movl $0x0, %r12d
jne 0x43699
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 0x2c0c2
cmpl $0x0, (%rbx)
je 0x43737
xorl %r12d, %r12d
jmp 0x43694
movq 0x48(%r15), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
movq 0x8(%rsp), %rbp
jne 0x43632
xorl %r12d, %r12d
jmp 0x43699