// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x133f0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1deda
jmp 0x1e0e2
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x1d840
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1df09
jmp 0x1e0e2
cmpq $0x0, -0x28(%rbp)
jne 0x1df63
cmpl $0x1, -0x4c(%rbp)
je 0x1df1c
cmpl $0x2, -0x4c(%rbp)
jne 0x1df63
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0x8c6ce(%rip), %rdx     # 0xaa614
leaq 0x8c66f(%rip), %rax     # 0xaa5bc
movq %rax, (%rsp)
movl $0x348, 0x8(%rsp)       # imm = 0x348
callq 0x156d0
jmp 0x1e0e2
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x24a20
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1df86
jmp 0x1e0e2
movl -0x4c(%rbp), %eax
movl %eax, -0x50(%rbp)
testl %eax, %eax
je 0x1dfb1
jmp 0x1df92
movl -0x50(%rbp), %eax
subl $0x1, %eax
je 0x1e026
jmp 0x1dfa0
movl -0x50(%rbp), %eax
subl $0x2, %eax
je 0x1e076
jmp 0x1e0c6
cmpq $0x0, -0x28(%rbp)
jne 0x1dfd3
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x19710
jmp 0x1e019
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %r8
movq -0x48(%rbp), %r9
movq -0x20(%rbp), %r11
movq -0x28(%rbp), %r10
movq -0x30(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x48140
movq $0x0, -0x48(%rbp)
jmp 0x1e0e0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %r8
movq -0x48(%rbp), %r9
movq -0x20(%rbp), %r11
movq -0x28(%rbp), %r10
movq -0x30(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x48240
movq $0x0, -0x48(%rbp)
jmp 0x1e0e0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %r8
movq -0x48(%rbp), %r9
movq -0x20(%rbp), %r11
movq -0x28(%rbp), %r10
movq -0x30(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x48340
movq $0x0, -0x48(%rbp)
jmp 0x1e0e0
movq -0x30(%rbp), %rdi
movl $0xf, %esi
leaq 0x8c4e6(%rip), %rdx     # 0xaa5bc
movl $0x366, %ecx            # imm = 0x366
callq 0x158e0
jmp 0x1e0e2
movq -0x48(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x1e11c
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x36ee0
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x1e0f3
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)