// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/array_type.c
// Function: prv_check_gran
static subtilis_exp_t *prv_check_gran(subtilis_parser_t *p,
				      subtilis_exp_t *gran,
				      subtilis_error_t *err)
{
	char num[32];
	subtilis_ir_operand_t condee;
	subtilis_ir_operand_t zero;
	subtilis_ir_operand_t error_label;
	subtilis_ir_operand_t ok_label;

	gran = subtilis_type_if_to_int(p, gran, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	if (gran->type.type == SUBTILIS_TYPE_CONST_INTEGER) {
		if (gran->exp.ir_op.integer <= 0) {
			snprintf(num, sizeof(num), "%d",
				 gran->exp.ir_op.integer);
			subtilis_error_set_expected(err, "positive integer",
						    num, p->l->stream->name,
						    p->l->line);
		}
	} else {
		/* Need a runtime check */

		zero.integer = 0;
		condee.reg = subtilis_ir_section_add_instr(
		    p->current, SUBTILIS_OP_INSTR_GTI_I32, gran->exp.ir_op,
		    zero, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return NULL;

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

		subtilis_ir_section_add_instr_reg(
		    p->current, SUBTILIS_OP_INSTR_JMPC, condee, ok_label,
		    error_label, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return NULL;

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

	return gran;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x488b0
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x60cc2
movq $0x0, -0x8(%rbp)
jmp 0x60e13
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x60d40
movq -0x18(%rbp), %rax
cmpl $0x0, 0x148(%rax)
jg 0x60d3b
leaq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x148(%rax), %ecx
movl $0x20, %esi
leaq 0x49969(%rip), %rdx     # 0xaa65b
movb $0x0, %al
callq 0x12100
movq -0x20(%rbp), %rdi
leaq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0x4bc98(%rip), %rdx     # 0xac9bb
leaq 0x4bc53(%rip), %rax     # 0xac97d
movq %rax, (%rsp)
movl $0xa8b, 0x8(%rsp)       # imm = 0xA8B
callq 0x156d0
jmp 0x60e0b
movl $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %r8
movq 0x148(%rax), %rdx
movq -0x50(%rbp), %rcx
movl $0x35, %esi
callq 0x38230
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x60d86
movq $0x0, -0x8(%rbp)
jmp 0x60e13
movq -0x10(%rbp), %rdi
callq 0x5d190
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x20(%rbp), %r9
movq -0x48(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq -0x58(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x60de1
movq $0x0, -0x8(%rbp)
jmp 0x60e13
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x60(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x39960
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x60e09
movq $0x0, -0x8(%rbp)
jmp 0x60e13
jmp 0x60e0b
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq