// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/frontend/parser_loops.c
// Function: prv_init_range_var
static void prv_init_range_var(subtilis_parser_t *p, subtilis_token_t *t,
			       subtilis_for_context_t *for_ctx,
			       const char *var_name,
			       const subtilis_type_t *type,
			       subtilis_error_t *err)
{
	subtilis_ir_operand_t op1;
	const subtilis_symbol_t *s;
	subtilis_exp_t *e;
	bool new_global = false;

	subtilis_parser_lookup_assignment_var(p, t, var_name, &s, &op1.reg,
					      &new_global, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if (new_global) {
		if (p->current->proc_called) {
			subtilis_error_set_global_after_proc(
			    err, var_name, p->l->stream->name, p->l->line);
			return;
		}

		subtilis_type_copy(&for_ctx->type, type, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;

		s = subtilis_symbol_table_insert(p->st, var_name,
						 &for_ctx->type, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		if (type->type == SUBTILIS_TYPE_REC)
			subtilis_rec_type_zero(p, &for_ctx->type,
					       SUBTILIS_IR_REG_GLOBAL, s->loc,
					       true, err);
		else if (subtilis_type_if_is_numeric(&for_ctx->type) ||
			 for_ctx->type.type == SUBTILIS_TYPE_FN) {
			e = subtilis_type_if_zero(p, &for_ctx->type, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			subtilis_type_if_assign_to_mem(
			    p, SUBTILIS_IR_REG_GLOBAL, s->loc, e, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
		} else if (!subtilis_type_if_is_numeric(&for_ctx->type))
			subtilis_type_if_zero_ref(p, &for_ctx->type,
						  SUBTILIS_IR_REG_GLOBAL,
						  s->loc, true, err);
	} else {
		subtilis_type_copy(&for_ctx->type, &s->t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	for_ctx->is_reg = s->is_reg;
	for_ctx->reg = op1.reg;
	for_ctx->loc = s->loc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r14
movq %r8, %r13
movq %rcx, %rbp
movq %rdx, %rbx
movq %rdi, %r15
leaq 0x7(%rsp), %r9
movb $0x0, (%r9)
subq $0x8, %rsp
leaq 0x10(%rsp), %rcx
leaq 0x18(%rsp), %r8
movq %rbp, %rdx
pushq %r14
callq 0x17d87
popq %rax
popq %rcx
cmpl $0x0, (%r14)
je 0x22dff
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x1, 0x7(%rsp)
jne 0x22e44
movq 0x48(%r15), %rax
cmpb $0x1, 0xe0(%rax)
jne 0x22e81
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4ab23(%rip), %rax     # 0x6d948
leaq 0x4af99(%rip), %rcx     # 0x6ddc5
pushq $0x6c
popq %rsi
movq %r14, %rdi
movq %rbp, %rdx
pushq $0x63c                  # imm = 0x63C
pushq %rax
callq 0x140cd
popq %rax
popq %rcx
jmp 0x22df0
leaq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
addq $0x8, %rsi
movq %r14, %rdx
callq 0x2de8a
cmpl $0x0, (%r14)
jne 0x22df0
movq 0x8(%rsp), %rax
movb 0x2a8(%rax), %cl
movb %cl, (%rbx)
movq 0x10(%rsp), %rcx
movq %rcx, 0x8(%rbx)
movq (%rax), %rax
movq %rax, 0x10(%rbx)
jmp 0x22df0
leaq 0x18(%rbx), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x2de8a
cmpl $0x0, (%r14)
jne 0x22df0
movq 0x60(%r15), %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2cbb7
movq %rax, 0x8(%rsp)
cmpl $0x0, (%r14)
jne 0x22df0
cmpl $0x16, (%r13)
jne 0x22edf
movq (%rax), %rcx
pushq $0x1
popq %rdx
pushq $0x1
popq %r8
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %r9
callq 0x433f5
jmp 0x22e5f
movq %r12, %rdi
callq 0x35655
testb %al, %al
jne 0x22ef2
cmpl $0x9, (%r12)
jne 0x22f28
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x33e86
cmpl $0x0, (%r14)
jne 0x22df0
movq 0x8(%rsp), %rcx
movq (%rcx), %rdx
pushq $0x1
popq %rsi
movq %r15, %rdi
movq %rax, %rcx
movq %r14, %r8
callq 0x34300
jmp 0x22e59
movq %r12, %rdi
callq 0x35655
testb %al, %al
jne 0x22e5f
movq 0x8(%rsp), %rax
movq (%rax), %rcx
pushq $0x1
popq %rdx
pushq $0x1
popq %r8
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %r9
callq 0x33ebd
jmp 0x22e5f