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

	if (!new_local) {
		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;
			}

			s = subtilis_symbol_table_insert(p->st, var_name, type,
							 err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
		}
		for_ctx->is_reg = s->is_reg;
		subtilis_type_copy(&for_ctx->type, &s->t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		for_ctx->reg = op1.reg;
		for_ctx->loc = s->loc;
		return;
	}

	if (subtilis_symbol_table_lookup(p->local_st, var_name)) {
		subtilis_error_set_already_defined(
		    err, var_name, p->l->stream->name, p->l->line);
		return;
	}

	for_ctx->is_reg = true;
	for_ctx->type = *type;
	if (subtilis_type_if_reg_type(&for_ctx->type) ==
	    SUBTILIS_IR_REG_TYPE_INTEGER)
		for_ctx->loc = p->current->reg_counter++;
	else
		for_ctx->loc = p->current->freg_counter++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %r8b, %al
movq 0x10(%rbp), %r8
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq %r9, -0x30(%rbp)
movb $0x0, -0x41(%rbp)
testb $0x1, -0x21(%rbp)
jne 0x2b262
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq 0x10(%rbp), %rax
leaq -0x40(%rbp), %rcx
leaq -0x38(%rbp), %r8
leaq -0x41(%rbp), %r9
movq %rax, (%rsp)
callq 0x1b6a0
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2b179
jmp 0x2b32c
testb $0x1, -0x41(%rbp)
je 0x2b208
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
testb $0x1, 0xe0(%rax)
je 0x2b1db
movq 0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x6c, %esi
leaq 0x800b8(%rip), %rcx     # 0xab276
leaq 0x7f7e5(%rip), %rax     # 0xaa9aa
movq %rax, (%rsp)
movl $0x149, 0x8(%rsp)       # imm = 0x149
callq 0x156d0
jmp 0x2b32c
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq 0x10(%rbp), %rcx
callq 0x3c480
movq %rax, -0x40(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2b206
jmp 0x2b32c
jmp 0x2b208
movq -0x40(%rbp), %rax
movb 0x2a8(%rax), %cl
movq -0x18(%rbp), %rax
andb $0x1, %cl
movb %cl, (%rax)
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
movq -0x40(%rbp), %rsi
addq $0x8, %rsi
movq 0x10(%rbp), %rdx
callq 0x3e4f0
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2b242
jmp 0x2b32c
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x2b32c
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x3cff0
cmpq $0x0, %rax
je 0x2b2bd
movq 0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x20, %esi
leaq 0x7ffd3(%rip), %rcx     # 0xab276
leaq 0x7f700(%rip), %rax     # 0xaa9aa
movq %rax, (%rsp)
movl $0x15d, 0x8(%rsp)       # imm = 0x15D
callq 0x156d0
jmp 0x2b32c
movq -0x18(%rbp), %rax
movb $0x1, (%rax)
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
movq -0x30(%rbp), %rsi
movl $0x148, %edx            # imm = 0x148
callq 0x12190
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
callq 0x4a550
cmpl $0x0, %eax
jne 0x2b30d
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x18(%rax), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, 0x18(%rax)
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x2b32c
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x20(%rax), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, 0x20(%rax)
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)