// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/frontend/parser_assignment.c
// Function: prv_assign_array_or_vector
static void prv_assign_array_or_vector(subtilis_parser_t *p,
				       subtilis_token_t *t, size_t dims,
				       subtilis_exp_t **indices,
				       const char *var_name,
				       const subtilis_type_t *array_type,
				       bool array, subtilis_error_t *err)
{
	const char *tbuf;
	size_t i;
	subtilis_assign_type_t at;
	subtilis_ir_operand_t op1;
	const subtilis_symbol_t *s;
	subtilis_array_desc_t desc;
	subtilis_exp_t *e = NULL;
	bool new_global = false;
	bool local;
	subtilis_type_t el_type;
	char scratch[32];

	subtilis_lexer_get(p->l, t, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	tbuf = subtilis_token_get_text(t);
	if ((t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, ".")) {
		prv_assign_col_field(p, t, dims, indices, var_name, array_type,
				     err);
		goto cleanup;
	}

	if ((t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, "(")) {
		/*
		 * We have a procedure call, and not an assignment.
		 */

		s = subtilis_parser_get_symbol(p, var_name, &op1.reg, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		e = subtilis_type_if_indexed_read(p, var_name, &s->t, op1.reg,
						  s->loc, indices, dims, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
		(void)subtilis_parser_call_known_ptr(p, t, &e->type,
						     e->exp.ir_op.reg, err);
		goto cleanup;
	}

	at = prv_get_ass_op(p, t, err);
	if (err->type != SUBTILIS_ERROR_OK) {
		prv_missing_operator_error(p, tbuf, var_name, err);
		goto cleanup;
	}

	if ((dims == 0) && ((at == SUBTILIS_ASSIGN_TYPE_PLUS_EQUAL) ||
			    (at == SUBTILIS_ASSIGN_TYPE_MINUS_EQUAL))) {
		subtilis_error_set_expected(err, ":= or =", tbuf,
					    p->l->stream->name, p->l->line);
		goto cleanup;
	}

	subtilis_parser_lookup_assignment_var(p, t, var_name, &s, &op1.reg,
					      &new_global, err);
	if (err->type == SUBTILIS_ERROR_UNKNOWN_VARIABLE ||
	    err->type == SUBTILIS_ERROR_VARIABLE_BAD_LEVEL) {
		if (at != SUBTILIS_ASSIGN_TYPE_CREATE_EQUAL)
			goto cleanup;
		subtilis_error_init(err);
		if (dims != 0) {
			sprintf(scratch, "%zu", dims);
			subtilis_error_bad_index(
			    err, scratch, p->l->stream->name, p->l->line);
			goto cleanup;
		}
		e = subtilis_parser_expression(p, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
		subtilis_parser_create_array_ref(p, var_name, array_type, e,
						 true, err);
		return;
	} else if (err->type != SUBTILIS_ERROR_OK) {
		goto cleanup;
	}

	if (s && (array != subtilis_type_if_is_array(&s->t))) {
		if (array)
			subtilis_error_set_expected(
			    err, "{", "(", p->l->stream->name, p->l->line);
		else
			subtilis_error_set_expected(
			    err, "(", "{", p->l->stream->name, p->l->line);
		goto cleanup;
	}

	subtilis_lexer_get(p->l, t, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	/*
	 * Check to see whether we're resetting a structure.
	 */

	tbuf = subtilis_token_get_text(t);
	if (((array_type->type == SUBTILIS_TYPE_ARRAY_REC) ||
	     (array_type->type == SUBTILIS_TYPE_VECTOR_REC)) &&
	    (dims > 0) && !strcmp(tbuf, "(")) {
		e = subtilis_type_if_indexed_address(
		    p, var_name, &s->t, op1.reg, s->loc, indices, dims, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
		subtilis_type_if_element_type(p, &s->t, &el_type, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
		subtilis_parser_rec_reset(p, t, &el_type, e->exp.ir_op.reg, 0,
					  err);
		subtilis_type_free(&el_type);
		goto cleanup;
	}

	e = subtilis_parser_priority7(p, t, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if (new_global) {
		if (dims != 0) {
			subtilis_error_set_unknown_variable(
			    err, var_name, p->l->stream->name, p->l->line);
			goto cleanup;
		}
		local = (at == SUBTILIS_ASSIGN_TYPE_CREATE_EQUAL);
		if (!local && p->current->proc_called) {
			subtilis_error_set_global_after_proc(
			    err, var_name, p->l->stream->name, p->l->line);
			goto cleanup;
		}
		subtilis_parser_create_array_ref(p, var_name, array_type, e,
						 local, err);
		return;
	}

	switch (at) {
	case SUBTILIS_ASSIGN_TYPE_EQUAL:
		if (dims == 0) {
			/* We're assigning an array reference */

			desc.name = s->key;
			desc.loc = s->loc;
			desc.reg = op1.reg;
			desc.t = &s->t;
			subtilis_parser_array_assign_reference(p, t, &desc, e,
							       err);
		} else {
			subtilis_type_if_indexed_write(p, var_name, &s->t,
						       op1.reg, s->loc, e,
						       indices, dims, err);
		}
		e = NULL;
		break;
	case SUBTILIS_ASSIGN_TYPE_PLUS_EQUAL:
		subtilis_type_if_indexed_add(p, var_name, &s->t, op1.reg,
					     s->loc, e, indices, dims, err);
		e = NULL;
		break;
	case SUBTILIS_ASSIGN_TYPE_MINUS_EQUAL:
		subtilis_type_if_indexed_sub(p, var_name, &s->t, op1.reg,
					     s->loc, e, indices, dims, err);
		e = NULL;
		break;
	case SUBTILIS_ASSIGN_TYPE_CREATE_EQUAL:
		subtilis_error_set_already_defined(
		    err, var_name, p->l->stream->name, p->l->line);
		break;
	default:
		subtilis_error_set_assertion_failed(err);
		break;
	}

cleanup:

	subtilis_exp_delete(e);
	for (i = 0; i < dims; i++)
		subtilis_exp_delete(indices[i]);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %r9, %r12
movq %r8, %r14
movq %rcx, 0x10(%rsp)
movq %rdx, 0x28(%rsp)
movq %rsi, %r13
movq %rdi, %rbp
movq 0x1e8(%rsp), %r15
movb 0x1e0(%rsp), %bl
movb $0x0, 0xf(%rsp)
movq (%rdi), %rdi
movq %r15, %rdx
callq 0x12edc
cmpl $0x0, (%r15)
jne 0x198a6
movb %bl, 0x38(%rsp)
movq %r12, 0x50(%rsp)
movq %rbp, 0x18(%rsp)
movq %r13, %rdi
callq 0x12ad0
movq %rax, %rbp
cmpl $0x2, (%r13)
jne 0x19872
movzbl (%rbp), %eax
cmpl $0x28, %eax
je 0x19868
cmpl $0x2e, %eax
jne 0x19872
cmpb $0x0, 0x1(%rbp)
jne 0x19872
movq 0x50(%rsp), %rdi
movl (%rdi), %eax
cmpl $0xf, %eax
je 0x197dc
cmpl $0x15, %eax
jne 0x19b23
cmpq $0x0, 0x28(%rsp)
movq 0x18(%rsp), %rdi
je 0x19b5a
subq $0x8, %rsp
leaq 0x60(%rsp), %rcx
leaq 0x38(%rsp), %r8
leaq 0x2f(%rsp), %r9
movq %r14, %rbx
movq %r14, %rdx
pushq %r15
callq 0x1830a
addq $0x10, %rsp
cmpl $0x0, (%r15)
movq 0x28(%rsp), %r14
jne 0x19b96
cmpb $0x1, 0x27(%rsp)
jne 0x19ca0
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x59d62(%rip), %rax     # 0x735a4
leaq 0x5a5cc(%rip), %rcx     # 0x73e15
movq %r15, %rdi
movl $0x1b, %esi
movq %rbx, %rdx
pushq $0xd1
pushq %rax
callq 0x143da
addq $0x10, %rsp
jmp 0x19b96
cmpb $0x0, 0x1(%rbp)
je 0x19a0c
movq %r14, 0x48(%rsp)
movq %r13, %r12
movq 0x18(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x19fab
cmpl $0x0, (%r15)
je 0x198e5
movq %r13, %rdi
movq %rbp, %rsi
movq 0x48(%rsp), %rdx
movq %r15, %rcx
callq 0x18c4b
xorl %ebp, %ebp
movq 0x10(%rsp), %rbx
movq 0x28(%rsp), %r14
movq %rbp, %rdi
callq 0x2b166
testq %r14, %r14
je 0x198d3
xorl %r15d, %r15d
movq (%rbx,%r15,8), %rdi
callq 0x2b166
incq %r15
cmpq %r15, %r14
jne 0x198c2
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%rsp), %r14
testq %r14, %r14
sete %dl
leal -0x1(%rax), %ecx
cmpl $0x2, %ecx
setb %cl
andb %dl, %cl
cmpb $0x1, %cl
jne 0x19944
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x59c8d(%rip), %rax     # 0x735a4
leaq 0x59cd2(%rip), %rdx     # 0x735f0
movq %r15, %rdi
movl $0x1d, %esi
movq %rbp, %rcx
pushq $0x11e                  # imm = 0x11E
pushq %rax
callq 0x143da
addq $0x10, %rsp
xorl %ebp, %ebp
movq %rbp, %rdi
callq 0x2b166
jmp 0x198d3
movq %rax, %r13
subq $0x8, %rsp
leaq 0x60(%rsp), %rcx
leaq 0x38(%rsp), %r8
leaq 0x17(%rsp), %r9
movq 0x20(%rsp), %rbp
movq %rbp, %rdi
movq 0x50(%rsp), %rdx
pushq %r15
callq 0x1830a
addq $0x10, %rsp
movl (%r15), %eax
testl %eax, %eax
je 0x19a84
cmpl $0x3e, %eax
je 0x1998b
cmpl $0x1b, %eax
jne 0x19b96
cmpl $0x3, %r13d
jne 0x19b96
movq %r15, %rdi
callq 0x143b4
testq %r14, %r14
je 0x19ba2
leaq 0x5a8a3(%rip), %rsi     # 0x74250
movq %r15, %r12
movq %rbp, %r15
xorl %ebp, %ebp
leaq 0x60(%rsp), %r13
movq %r13, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x12280
movq (%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x59bcb(%rip), %rax     # 0x735a4
leaq 0x5a435(%rip), %rcx     # 0x73e15
movq %r12, %rdi
movl $0x39, %esi
movq %r13, %rdx
pushq $0x12c                  # imm = 0x12C
pushq %rax
callq 0x143da
addq $0x10, %rsp
movq 0x10(%rsp), %rbx
movq %rbp, %rdi
callq 0x2b166
jmp 0x198bf
leaq 0x30(%rsp), %rdx
movq 0x18(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rcx
callq 0x1e8b1
cmpl $0x0, (%r15)
jne 0x198a6
movq %rax, %rdx
addq $0x8, %rdx
movq 0x30(%rsp), %rcx
movq (%rax), %r8
movq %r12, %rdi
movq %r14, %rsi
movq 0x10(%rsp), %r9
pushq %r15
movq 0x30(%rsp), %r14
pushq %r14
callq 0x36555
addq $0x10, %rsp
movq %rax, %rbp
cmpl $0x0, (%r15)
jne 0x19b98
movq 0x148(%rbp), %rcx
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r15, %r8
callq 0x1c086
jmp 0x19b98
movq 0x58(%rsp), %rcx
testq %rcx, %rcx
movq %rcx, 0x40(%rsp)
je 0x19ae5
leaq 0x8(%rcx), %rdi
callq 0x376b5
cmpb 0x38(%rsp), %al
je 0x19ae5
movq (%rbp), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
cmpb $0x0, 0x38(%rsp)
movq 0x10(%rsp), %rbx
leaq 0x59ae5(%rip), %rax     # 0x735a4
je 0x19bec
leaq 0x5cbc5(%rip), %rdx     # 0x76691
leaq 0x5a75f(%rip), %rcx     # 0x74232
movq %r15, %rdi
movl $0x1d, %esi
pushq $0x13c                  # imm = 0x13C
jmp 0x19c07
movq (%rbp), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x12edc
cmpl $0x0, (%r15)
jne 0x19b96
movq %r12, 0x38(%rsp)
movq %r12, %rdi
callq 0x12ad0
movq 0x50(%rsp), %rcx
movl (%rcx), %ecx
cmpl $0xf, %ecx
jne 0x19c18
testq %r14, %r14
jmp 0x19c26
callq 0x2f5ad
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x59a65(%rip), %r10     # 0x735a4
leaq 0x599ba(%rip), %rdx     # 0x73500
movq %r15, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0xc0
pushq %r10
jmp 0x19b88
movq (%rdi), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x59a38(%rip), %rax     # 0x735a4
leaq 0x5998d(%rip), %rdx     # 0x73500
leaq 0x59a7e(%rip), %rcx     # 0x735f8
movq %r15, %rdi
movl $0x1d, %esi
pushq $0xc7
pushq %rax
callq 0x143da
addq $0x10, %rsp
movq 0x28(%rsp), %r14
xorl %ebp, %ebp
movq 0x10(%rsp), %rbx
jmp 0x198b2
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x1ec4c
movq %rbp, %rdi
movq %rax, %rbp
cmpl $0x0, (%r15)
jne 0x1993a
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rbp, %rcx
movl $0x1, %r8d
movq %r15, %r9
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17e40
leaq 0x5a63f(%rip), %rdx     # 0x74232
leaq 0x5ca97(%rip), %rcx     # 0x76691
movq %r15, %rdi
movl $0x1d, %esi
pushq $0x13f                  # imm = 0x13F
pushq %rax
callq 0x143da
addq $0x10, %rsp
xorl %ebp, %ebp
jmp 0x198b2
cmpl $0x15, %ecx
sete %cl
testq %r14, %r14
setne %dl
testb %cl, %dl
movq 0x48(%rsp), %r12
je 0x19c3c
cmpb $0x28, (%rax)
jne 0x19c3c
cmpb $0x0, 0x1(%rax)
je 0x19d69
movq %rbp, %rdi
movq 0x38(%rsp), %rsi
movq %r15, %rdx
callq 0x1e938
movq %rax, %rbp
cmpl $0x0, (%r15)
jne 0x19b98
cmpb $0x1, 0xf(%rsp)
jne 0x19d09
testq %r14, %r14
je 0x19e2a
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x59920(%rip), %rax     # 0x735a4
leaq 0x5a18a(%rip), %rcx     # 0x73e15
movq %r15, %rdi
movl $0x1b, %esi
movq %r12, %rdx
pushq $0x163                  # imm = 0x163
jmp 0x199f0
movq 0x58(%rsp), %rbp
movq 0x30(%rsp), %rcx
movq (%rbp), %r8
addq $0x8, %rbp
movq 0x18(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %r9
pushq %r15
pushq %r14
callq 0x43706
addq $0x10, %rsp
cmpl $0x0, (%r15)
jne 0x19b96
movq %rax, %rbx
leaq 0x60(%rsp), %rdx
movq %r12, %rdi
movq %rbp, %rsi
movq %r15, %rcx
callq 0x360be
cmpl $0x0, (%r15)
je 0x19df5
movq %rbx, %rdi
callq 0x2b166
jmp 0x19b96
cmpl $0x3, %r13d
ja 0x19f45
movl %r13d, %eax
leaq 0x59877(%rip), %rcx     # 0x73594
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testq %r14, %r14
je 0x19f63
movq 0x30(%rsp), %rcx
movq 0x40(%rsp), %rdx
movq (%rdx), %r8
addq $0x8, %rdx
subq $0x8, %rsp
movq 0x20(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %r9
pushq %r15
pushq %r14
movq 0x28(%rsp), %rbx
pushq %rbx
callq 0x363cc
addq $0x20, %rsp
xorl %ebp, %ebp
jmp 0x199ff
movq 0x30(%rsp), %rcx
movq %r12, %rsi
movq 0x40(%rsp), %r12
movq (%r12), %r8
addq $0x8, %r12
movq %rbp, %rdi
movq %r12, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %r9
pushq %r15
pushq %r14
callq 0x366a0
addq $0x10, %rsp
movq %rbp, %r13
movq %rax, %rbp
cmpl $0x0, (%r15)
jne 0x199ff
leaq 0x60(%rsp), %rdx
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rcx
callq 0x360be
cmpl $0x0, (%r15)
jne 0x199ff
movq 0x148(%rbp), %rcx
leaq 0x60(%rsp), %r12
movq %r13, %rdi
movq 0x38(%rsp), %rsi
movq %r12, %rdx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x2a40f
movq %r12, %rdi
callq 0x2f56e
jmp 0x199ff
movq 0x148(%rbx), %rcx
leaq 0x60(%rsp), %rbp
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x18c9f
movq %rbx, %rdi
callq 0x2b166
movq %rbp, %rdi
callq 0x2f56e
jmp 0x19b96
cmpl $0x3, %r13d
je 0x19e7f
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rax
cmpb $0x1, 0xe0(%rax)
jne 0x19e7f
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5974b(%rip), %rax     # 0x735a4
leaq 0x59fb5(%rip), %rcx     # 0x73e15
movq %r15, %rdi
movl $0x6c, %esi
movq %r12, %rdx
pushq $0x169                  # imm = 0x169
pushq %rax
callq 0x143da
addq $0x10, %rsp
jmp 0x1993a
xorl %r8d, %r8d
cmpl $0x3, %r13d
sete %r8b
movq 0x18(%rsp), %rdi
movq %r12, %rsi
movq 0x50(%rsp), %rdx
movq %rbp, %rcx
jmp 0x19bd3
movq 0x30(%rsp), %rcx
movq 0x40(%rsp), %rdx
movq (%rdx), %r8
addq $0x8, %rdx
subq $0x8, %rsp
movq 0x20(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %r9
pushq %r15
pushq %r14
movq 0x28(%rsp), %rbx
pushq %rbx
callq 0x364d2
jmp 0x19f3c
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x596bd(%rip), %rax     # 0x735a4
leaq 0x59f27(%rip), %rcx     # 0x73e15
movq %r15, %rdi
movl $0x20, %esi
movq %r12, %rdx
pushq $0x18f                  # imm = 0x18F
pushq %rax
callq 0x143da
addq $0x10, %rsp
jmp 0x19b98
movq 0x30(%rsp), %rcx
movq 0x40(%rsp), %rdx
movq (%rdx), %r8
addq $0x8, %rdx
subq $0x8, %rsp
movq 0x20(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %r9
pushq %r15
pushq %r14
movq 0x28(%rsp), %rbx
pushq %rbx
callq 0x3644f
addq $0x20, %rsp
jmp 0x19c11
leaq 0x59658(%rip), %rdx     # 0x735a4
movq %r15, %rdi
movl $0xf, %esi
movl $0x192, %ecx            # imm = 0x192
callq 0x145a4
jmp 0x19b98
movq 0x40(%rsp), %r12
movq 0x298(%r12), %rax
leaq 0x60(%rsp), %rdx
movq %rax, (%rdx)
movq (%r12), %rax
movq %rax, 0x18(%rdx)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rdx)
addq $0x8, %r12
movq %r12, 0x8(%rdx)
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %rbp, %rcx
movq %r15, %r8
callq 0x16f6c
jmp 0x19938