// File: /workspace/github_c_makefile_star2_O3/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 0x1830a
addq $0x10, %rsp
cmpl $0x0, (%r14)
je 0x23cc4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x1, 0x7(%rsp)
jne 0x23d0d
movq 0x48(%r15), %rax
cmpb $0x1, 0xe0(%rax)
jne 0x23d4a
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4fca2(%rip), %rax     # 0x7398c
leaq 0x50124(%rip), %rcx     # 0x73e15
movq %r14, %rdi
movl $0x6c, %esi
movq %rbp, %rdx
pushq $0x63c                  # imm = 0x63C
pushq %rax
callq 0x143da
addq $0x10, %rsp
jmp 0x23cb5
leaq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
addq $0x8, %rsi
movq %r14, %rdx
callq 0x2f78a
cmpl $0x0, (%r14)
jne 0x23cb5
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 0x23cb5
leaq 0x18(%rbx), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x2f78a
cmpl $0x0, (%r14)
jne 0x23cb5
movq 0x60(%r15), %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x2e3cd
movq %rax, 0x8(%rsp)
cmpl $0x0, (%r14)
jne 0x23cb5
cmpl $0x16, (%r13)
jne 0x23daf
movq (%rax), %rcx
movl $0x1, %edx
movq %r15, %rdi
movq %r12, %rsi
movl $0x1, %r8d
movq %r14, %r9
callq 0x45c2d
jmp 0x23d28
movq %r12, %rdi
callq 0x37534
testb %al, %al
jne 0x23dc2
cmpl $0x9, (%r12)
jne 0x23dfa
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x35e20
cmpl $0x0, (%r14)
jne 0x23cb5
movq 0x8(%rsp), %rcx
movq (%rcx), %rdx
movl $0x1, %esi
movq %r15, %rdi
movq %rax, %rcx
movq %r14, %r8
callq 0x362c6
jmp 0x23d22
movq %r12, %rdi
callq 0x37534
testb %al, %al
jne 0x23d28
movq 0x8(%rsp), %rax
movq (%rax), %rcx
movl $0x1, %edx
movq %r15, %rdi
movq %r12, %rsi
movl $0x1, %r8d
movq %r14, %r9
callq 0x35e59
jmp 0x23d28