// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_assignment.c
// Function: prv_assign_field
static void prv_assign_field(subtilis_parser_t *p, subtilis_token_t *t,
			     const subtilis_type_t *type, size_t reg,
			     size_t loc, subtilis_error_t *err)
{
	const char *tbuf;
	size_t id;
	const subtilis_type_rec_t *rec;
	subtilis_assign_type_t at;
	subtilis_exp_t *e;
	subtilis_exp_t *e1;
	subtilis_array_desc_t desc;
	const char *var_name;
	size_t offset = loc;

	do {
		rec = &type->params.rec;
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;

		tbuf = subtilis_token_get_text(t);
		if (t->type != SUBTILIS_TOKEN_IDENTIFIER) {
			subtilis_error_set_id_expected(
			    err, tbuf, p->l->stream->name, p->l->line);
			return;
		}

		id = subtilis_type_rec_find_field(rec, tbuf);
		if (id == SIZE_MAX) {
			subtilis_error_set_unknown_field(
			    err, tbuf, p->l->stream->name, p->l->line);
			return;
		}
		offset += subtilis_type_rec_field_offset_id(rec, id);
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		tbuf = subtilis_token_get_text(t);

		type = &rec->field_types[id];
		var_name = rec->fields[id].name;
		if (type->type != SUBTILIS_TYPE_REC)
			break;
	} while ((type->type == SUBTILIS_TYPE_REC) &&
		 (t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, "."));

	if (type->type == SUBTILIS_TYPE_STRING) {
		prv_assign_string_field(p, t, type, reg, offset, err);
		return;
	}

	if (type->type == SUBTILIS_TYPE_FN) {
		prv_assign_fn_field(p, t, type, reg, offset, err);
		return;
	}

	if (subtilis_type_if_is_array(type)) {
		desc.name = var_name;
		desc.loc = offset;
		desc.reg = reg;
		desc.t = type;
		prv_assign_array_field(p, t, &desc, err);
		return;
	}

	if (subtilis_type_if_is_vector(type)) {
		desc.name = var_name;
		desc.loc = offset;
		desc.reg = reg;
		desc.t = type;
		prv_assign_vector_field(p, t, &desc, err);
		return;
	}

	/*
	 * Otherwise it's a numeric value or a REC
	 */

	at = prv_get_ass_op(p, t, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if (at == SUBTILIS_ASSIGN_TYPE_CREATE_EQUAL) {
		subtilis_error_set_assignment_op_expected(
		    err, tbuf, p->l->stream->name, p->l->line);
		return;
	}

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

	tbuf = subtilis_token_get_text(t);
	if ((type->type == SUBTILIS_TYPE_REC) && !strcmp(tbuf, "(")) {
		subtilis_parser_rec_reset(p, t, type, reg, offset, err);
		return;
	}

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

	e = subtilis_type_if_coerce_type(p, e, type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if (at != SUBTILIS_ASSIGN_TYPE_EQUAL) {
		e1 = subtilis_type_if_load_from_mem(p, type, reg, offset, err);
		if (err->type != SUBTILIS_ERROR_OK) {
			subtilis_exp_delete(e);
			return;
		}
		if (at == SUBTILIS_ASSIGN_TYPE_PLUS_EQUAL)
			e = subtilis_exp_add(p, e1, e, err);
		else
			e = subtilis_type_if_sub(p, e1, e, err);
	}

	subtilis_type_if_assign_to_mem(p, reg, offset, e, err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %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 -0x28(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -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 0x1c49c
jmp 0x1c8e7
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x6, (%rax)
je 0x1c4f9
movq -0x30(%rbp), %rdi
movq -0x38(%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 $0x12, %esi
leaq 0x8ed9a(%rip), %rcx     # 0xab276
leaq 0x8e0d9(%rip), %rax     # 0xaa5bc
movq %rax, (%rsp)
movl $0x3ba, 0x8(%rsp)       # imm = 0x3BA
callq 0x156d0
jmp 0x1c8e7
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x3ec80
movq %rax, -0x40(%rbp)
cmpq $-0x1, -0x40(%rbp)
jne 0x1c558
movq -0x30(%rbp), %rdi
movq -0x38(%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 $0x69, %esi
leaq 0x8ed3b(%rip), %rcx     # 0xab276
leaq 0x8e07a(%rip), %rax     # 0xaa5bc
movq %rax, (%rsp)
movl $0x3c1, 0x8(%rsp)       # imm = 0x3C1
callq 0x156d0
jmp 0x1c8e7
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3efb0
movl %eax, %eax
addq -0x90(%rbp), %rax
movq %rax, -0x90(%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 0x1c597
jmp 0x1c8e7
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x148, -0x40(%rbp), %rcx # imm = 0x148
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x16, (%rax)
je 0x1c5e0
jmp 0x1c630
jmp 0x1c5e2
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpl $0x16, (%rcx)
movb %al, -0x91(%rbp)
jne 0x1c622
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpl $0x2, (%rcx)
movb %al, -0x91(%rbp)
jne 0x1c622
movq -0x38(%rbp), %rdi
leaq 0x8df06(%rip), %rsi     # 0xaa515
callq 0x12140
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
testb $0x1, %al
jne 0x1c46e
movq -0x18(%rbp), %rax
cmpl $0x7, (%rax)
jne 0x1c65e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x90(%rbp), %r8
movq -0x30(%rbp), %r9
callq 0x1d9a0
jmp 0x1c8e7
movq -0x18(%rbp), %rax
cmpl $0x9, (%rax)
jne 0x1c68c
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x90(%rbp), %r8
movq -0x30(%rbp), %r9
callq 0x1dad0
jmp 0x1c8e7
movq -0x18(%rbp), %rdi
callq 0x49ff0
testb $0x1, %al
jne 0x1c69b
jmp 0x1c6db
movq -0x88(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rcx
leaq -0x80(%rbp), %rdx
callq 0x1dc70
jmp 0x1c8e7
movq -0x18(%rbp), %rdi
callq 0x4a040
testb $0x1, %al
jne 0x1c6ea
jmp 0x1c72a
movq -0x88(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rcx
leaq -0x80(%rbp), %rdx
callq 0x1dda0
jmp 0x1c8e7
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 0x1c74c
jmp 0x1c8e7
cmpl $0x3, -0x4c(%rbp)
jne 0x1c799
movq -0x30(%rbp), %rdi
movq -0x38(%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 $0x14, %esi
leaq 0x8eafa(%rip), %rcx     # 0xab276
leaq 0x8de39(%rip), %rax     # 0xaa5bc
movq %rax, (%rsp)
movl $0x3f7, 0x8(%rsp)       # imm = 0x3F7
callq 0x156d0
jmp 0x1c8e7
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 0x1c7bb
jmp 0x1c8e7
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x16, (%rax)
jne 0x1c80b
movq -0x38(%rbp), %rdi
leaq 0x8eac0(%rip), %rsi     # 0xab29c
callq 0x12140
cmpl $0x0, %eax
jne 0x1c80b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x90(%rbp), %r8
movq -0x30(%rbp), %r9
callq 0x35690
jmp 0x1c8e7
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x24550
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1c82e
jmp 0x1c8e7
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x4a2e0
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1c855
jmp 0x1c8e7
cmpl $0x0, -0x4c(%rbp)
je 0x1c8cb
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x90(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x48080
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1c88f
movq -0x58(%rbp), %rdi
callq 0x36ee0
jmp 0x1c8e7
cmpl $0x1, -0x4c(%rbp)
jne 0x1c8b0
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x37bd0
movq %rax, -0x58(%rbp)
jmp 0x1c8c9
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x492c0
movq %rax, -0x58(%rbp)
jmp 0x1c8cb
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x47f20
addq $0xb0, %rsp
popq %rbp
retq