// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_assignment.c
// Function: subtilis_parser_create_array_ref
void subtilis_parser_create_array_ref(subtilis_parser_t *p,
				      const char *var_name,
				      const subtilis_type_t *array_type,
				      subtilis_exp_t *e, bool local,
				      subtilis_error_t *err)
{
	subtilis_type_t type;
	const subtilis_symbol_t *s;

	if (array_type->type != e->type.type) {
		subtilis_error_set_array_type_mismatch(err, p->l->stream->name,
						       p->l->line);
		goto cleanup;
	}
	subtilis_type_init_copy(&type, &e->type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	/*
	 * If the expression is a temporary variable and we're assigning to
	 * a local variable, we can simply just promote the temporary to a
	 * full local variable and avoid copying the data.
	 */

	if (local && e->temporary) {
		(void)subtilis_symbol_table_promote_tmp(
		    p->local_st, &e->type, e->temporary, var_name, err);
		subtilis_type_free(&type);
		subtilis_exp_delete(e);
		return;
	}

	s = subtilis_symbol_table_insert(local ? p->local_st : p->st, var_name,
					 &type, err);
	subtilis_type_free(&type);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_array_type_create_ref(
	    p, var_name, s,
	    local ? SUBTILIS_IR_REG_LOCAL : SUBTILIS_IR_REG_GLOBAL, e, err);
	return;

cleanup:

	subtilis_exp_delete(e);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movb %r8b, %al
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)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
je 0x1afea
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %ecx
movl $0x41, %esi
leaq 0x8f5e2(%rip), %r8      # 0xaa5bc
movl $0x58, %r9d
callq 0x15930
jmp 0x1b0f3
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
leaq -0x178(%rbp), %rdi
callq 0x3dec0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1b00c
jmp 0x1b0f3
testb $0x1, -0x21(%rbp)
je 0x1b05e
movq -0x20(%rbp), %rax
cmpq $0x0, 0x158(%rax)
je 0x1b05e
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x158(%rax), %rdx
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x3cac0
leaq -0x178(%rbp), %rdi
callq 0x3e100
movq -0x20(%rbp), %rdi
callq 0x36ee0
jmp 0x1b0fc
testb $0x1, -0x21(%rbp)
je 0x1b075
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x188(%rbp)
jmp 0x1b084
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rcx
leaq -0x178(%rbp), %rdx
callq 0x3c480
movq %rax, -0x180(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x3e100
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1b0bd
jmp 0x1b0f3
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x180(%rbp), %rdx
movb -0x21(%rbp), %r8b
movl $0x1, %eax
movl $0x2, %ecx
testb $0x1, %r8b
cmovnel %ecx, %eax
movslq %eax, %rcx
movq -0x20(%rbp), %r8
movq -0x30(%rbp), %r9
callq 0x5e180
jmp 0x1b0fc
movq -0x20(%rbp), %rdi
callq 0x36ee0
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
nopw %cs:(%rax,%rax)