// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_loops.c
// Function: prv_range_loop_start_index
static size_t prv_range_loop_start_index(subtilis_parser_t *p,
					 subtilis_exp_t *e, size_t var_count,
					 subtilis_range_var_t *range_vars,
					 bool new_locals, subtilis_error_t *err)
{
	subtilis_exp_t *zero;
	subtilis_exp_t *dim;
	subtilis_exp_t *e_dup;
	subtilis_ir_operand_t ok_label;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t op2;
	subtilis_ir_operand_t condee;
	subtilis_ir_operand_t ptr;
	subtilis_ir_operand_t counter;
	size_t i;

	ptr.reg = subtilis_reference_get_data(p, e->exp.ir_op.reg, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	for (i = 1; i < var_count; i++) {
		range_vars[i].start_label.label =
		    subtilis_ir_section_new_label(p->current);
		range_vars[i].end_label.label =
		    subtilis_ir_section_new_label(p->current);
		e_dup = subtilis_type_if_dup(e, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;
		dim = subtilis_exp_new_int32(i, err);
		if (err->type != SUBTILIS_ERROR_OK) {
			subtilis_exp_delete(dim);
			return SIZE_MAX;
		}
		dim = subtilis_array_get_dim(p, e_dup, dim, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;
		dim = subtilis_type_if_exp_to_var(p, dim, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;
		range_vars[i].end_reg = dim->exp.ir_op;
		subtilis_exp_delete(dim);
	}

	for (i = 1; i < var_count; i++) {
		zero = subtilis_exp_new_int32(0, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;

		if (range_vars[i].for_ctx.is_reg)
			subtilis_type_if_assign_to_reg(
			    p, range_vars[i].for_ctx.loc, zero, err);
		else
			subtilis_type_if_assign_to_mem(
			    p, range_vars[i].for_ctx.reg,
			    range_vars[i].for_ctx.loc, zero, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;

		subtilis_ir_section_add_label(
		    p->current, range_vars[i].start_label.label, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;

		if (range_vars[i].for_ctx.is_reg) {
			counter.reg = range_vars[i].for_ctx.loc;
		} else {
			op1.reg = range_vars[i].for_ctx.reg;
			op2.integer = range_vars[i].for_ctx.loc;
			counter.reg = subtilis_ir_section_add_instr(
			    p->current, SUBTILIS_OP_INSTR_LOADO_I32, op1, op2,
			    err);
		}
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;

		condee.reg = subtilis_ir_section_add_instr(
		    p->current, SUBTILIS_OP_INSTR_LTE_I32, counter,
		    range_vars[i].end_reg, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;

		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,
		    range_vars[i].end_label, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;
		subtilis_ir_section_add_label(p->current, ok_label.label, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;
	}

	subtilis_parser_handle_escape(p, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	if (range_vars[0].name) {
		prv_assign_range_var(p, ptr, &range_vars[0], new_locals, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;
	}

	return ptr.reg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
andb $0x1, %al
movb %al, -0x29(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x148(%rax), %rsi
movq -0x38(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0x6d1e0
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c38d
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
movq $0x1, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x2c4f5
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, %rcx
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rdx # imm = 0x2C8
addq %rdx, %rax
movq %rcx, 0x2b0(%rax)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, %rcx
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rdx # imm = 0x2C8
addq %rdx, %rax
movq %rcx, 0x2b8(%rax)
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x47d20
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c422
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
movq -0x88(%rbp), %rax
movl %eax, %edi
movq -0x38(%rbp), %rsi
callq 0x37800
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c457
movq -0x48(%rbp), %rdi
callq 0x36ee0
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x5fd10
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c486
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x47c10
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c4b1
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
movq -0x48(%rbp), %rcx
movq 0x148(%rcx), %rcx
movq %rcx, 0x2c0(%rax)
movq -0x48(%rbp), %rdi
callq 0x36ee0
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x2c398
movq $0x1, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x2c7ad
movq -0x38(%rbp), %rsi
xorl %edi, %edi
callq 0x37800
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c536
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
testb $0x1, 0x150(%rax)
je 0x2c57d
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
movq 0x160(%rax), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x47ea0
jmp 0x2c5c0
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
movq 0x158(%rax), %rsi
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
movq 0x160(%rax), %rdx
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r8
callq 0x47f20
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c5d6
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
movq 0x2b0(%rax), %rsi
movq -0x38(%rbp), %rdx
callq 0x39960
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c616
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
testb $0x1, 0x150(%rax)
je 0x2c650
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
movq 0x160(%rax), %rax
movq %rax, -0x80(%rbp)
jmp 0x2c6ab
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
movq 0x158(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
movq 0x160(%rax), %rax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x38(%rbp), %r8
movq -0x60(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x12, %esi
callq 0x38230
movq %rax, -0x80(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c6c1
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
movq -0x38(%rbp), %r8
movq -0x80(%rbp), %rdx
movq 0x2c0(%rax), %rcx
movl $0x37, %esi
callq 0x38230
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c70e
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rax
imulq $0x2c8, -0x88(%rbp), %rcx # imm = 0x2C8
addq %rcx, %rax
movq -0x38(%rbp), %r9
movq -0x70(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq 0x2b8(%rax), %r8
movl $0x43, %esi
callq 0x38360
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c76c
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x58(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x39960
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c794
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
jmp 0x2c796
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x2c500
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2d400
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c7cd
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0x2c809
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rdx
movb -0x29(%rbp), %al
movq -0x38(%rbp), %r8
movq -0x78(%rbp), %rsi
andb $0x1, %al
movzbl %al, %ecx
callq 0x2ca50
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2c807
movq $-0x1, -0x8(%rbp)
jmp 0x2c811
jmp 0x2c809
movq -0x78(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nop