// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/frontend/parser_assignment.c
// Function: prv_assign_array_or_vector_field
static void prv_assign_array_or_vector_field(subtilis_parser_t *p,
					     subtilis_token_t *t,
					     const subtilis_array_desc_t *d,
					     subtilis_exp_t **indices,
					     size_t dims, subtilis_error_t *err)
/* clang-format on */

{
	const char *tbuf;
	size_t i;
	subtilis_exp_t *e = NULL;
	subtilis_assign_type_t at;

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

	tbuf = subtilis_token_get_text(t);
	at = prv_get_ass_op(p, t, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

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

	switch (at) {
	case SUBTILIS_ASSIGN_TYPE_EQUAL:
		if (dims == 0)
			/* We're assigning an array reference */
			subtilis_parser_array_assign_reference(p, t, d, e, err);
		else
			subtilis_type_if_indexed_write(p, d->name, d->t, d->reg,
						       d->loc, e, indices, dims,
						       err);
		e = NULL;
		break;
	case SUBTILIS_ASSIGN_TYPE_PLUS_EQUAL:
		subtilis_type_if_indexed_add(p, d->name, d->t, d->reg, d->loc,
					     e, indices, dims, err);
		e = NULL;
		break;
	case SUBTILIS_ASSIGN_TYPE_MINUS_EQUAL:
		subtilis_type_if_indexed_sub(p, d->name, d->t, d->reg, d->loc,
					     e, indices, dims, err);
		e = NULL;
		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 $0x18, %rsp
movq %r9, %r15
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %rbp
movq %rdi, %r13
movq (%rdi), %rdi
movq %r9, %rdx
callq 0x12e0e
cmpl $0x0, (%r15)
jne 0x19a4d
movq %r12, 0x8(%rsp)
movq %rbp, %rdi
callq 0x12a25
movq %rax, %r12
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x198e0
cmpl $0x0, (%r15)
jne 0x19a4d
testq %rbx, %rbx
sete %dl
leal -0x1(%rax), %ecx
cmpl $0x2, %ecx
setb %cl
andb %dl, %cl
cmpb $0x1, %cl
jne 0x19a7d
movq (%r13), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x53b74(%rip), %rax     # 0x6d5a4
leaq 0x53bbf(%rip), %rdx     # 0x6d5f6
pushq $0x1d
popq %rsi
movq %r15, %rdi
movq %r12, %rcx
pushq $0x348                  # imm = 0x348
pushq %rax
callq 0x140cd
popq %rax
popq %rcx
xorl %r12d, %r12d
movq %r12, %rdi
callq 0x29d88
xorl %r15d, %r15d
cmpq %r15, %rbx
je 0x19a6e
movq (%r14,%r15,8), %rdi
callq 0x29d88
incq %r15
jmp 0x19a5b
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, 0x10(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x1dfd5
movq %rax, %r12
cmpl $0x0, (%r15)
jne 0x19a50
movq 0x10(%rsp), %rax
cmpl $0x2, %eax
je 0x19b0d
cmpl $0x1, %eax
je 0x19ae3
testl %eax, %eax
jne 0x19b3e
testq %rbx, %rbx
je 0x19b5a
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq 0x18(%rax), %r8
subq $0x8, %rsp
movq %r13, %rdi
movq %r12, %r9
pushq %r15
pushq %rbx
pushq %r14
callq 0x343fa
jmp 0x19b35
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq 0x18(%rax), %r8
subq $0x8, %rsp
movq %r13, %rdi
movq %r12, %r9
pushq %r15
pushq %rbx
pushq %r14
callq 0x34477
jmp 0x19b35
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq 0x18(%rax), %r8
subq $0x8, %rsp
movq %r13, %rdi
movq %r12, %r9
pushq %r15
pushq %rbx
pushq %r14
callq 0x344f4
addq $0x20, %rsp
jmp 0x19a4d
leaq 0x53a5f(%rip), %rdx     # 0x6d5a4
pushq $0xf
popq %rsi
movq %r15, %rdi
movl $0x366, %ecx            # imm = 0x366
callq 0x1429e
jmp 0x19a50
movq %r13, %rdi
movq %rbp, %rsi
movq 0x8(%rsp), %rdx
movq %r12, %rcx
movq %r15, %r8
callq 0x16d6b
jmp 0x19a4d
nopl (%rax)