// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r9, (%rsp)
movq %r8, %r15
movq %rcx, 0x10(%rsp)
movq %rdx, %rbp
movq %rsi, %r13
movq %rdi, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %r13, %rsi
movq (%rsp), %rbx
movq %rbx, %rdx
callq 0x12eda
cmpl $0x0, (%rbx)
jne 0x192c4
movq %r13, %rdi
callq 0x12ad0
movq %rax, %r12
cmpl $0x6, (%r13)
jne 0x19020
leaq 0x8(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2feeb
cmpq $-0x1, %rax
je 0x19051
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x30118
movl %eax, %ebx
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %r13, %rsi
movq (%rsp), %r12
movq %r12, %rdx
callq 0x12eda
cmpl $0x0, (%r12)
jne 0x192c4
movl %ebx, %eax
addq %rax, %r15
movq %r13, %rdi
callq 0x12ad0
movq %rax, %r12
imulq $0x148, %r14, %rax      # imm = 0x148
movq 0x18(%rbp), %rcx
movq 0x20(%rbp), %rdx
leaq (%rcx,%rax), %rbp
leaq (%r14,%r14,2), %rsi
movq (%rdx,%rsi,8), %rbx
movl (%rcx,%rax), %r14d
cmpl $0x16, %r14d
jne 0x18e9f
cmpl $0x2, (%r13)
jne 0x18e8a
movq %r12, %rdi
leaq 0x5a687(%rip), %rsi     # 0x73504
callq 0x12160
testl %eax, %eax
je 0x18db6
cmpl $0x9, %r14d
je 0x18eaf
cmpl $0x7, %r14d
je 0x18f23
jmp 0x18f9a
cmpl $0x7, %r14d
je 0x18f23
cmpl $0x9, %r14d
jne 0x18f9a
movq %r13, %rdi
callq 0x12ad0
movq %rax, %r14
cmpl $0x2, (%r13)
jne 0x18eef
leaq 0x5b34a(%rip), %rsi     # 0x74212
movq %r14, %rdi
callq 0x12160
testl %eax, %eax
je 0x191c6
leaq 0x5a725(%rip), %rsi     # 0x73604
movq %r14, %rdi
callq 0x12160
testl %eax, %eax
je 0x19222
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5a6a6(%rip), %rax     # 0x735ac
leaq 0x5aee8(%rip), %rcx     # 0x73df5
movq (%rsp), %rdi
movl $0x14, %esi
movq %r14, %rdx
pushq $0x31c                  # imm = 0x31C
jmp 0x19080
movq %r13, %rdi
callq 0x12ad0
movq %rax, %r14
cmpl $0x2, (%r13)
jne 0x18f66
leaq 0x5a6c8(%rip), %rsi     # 0x73604
movq %r14, %rdi
callq 0x12160
movl %eax, %r12d
testl %eax, %eax
je 0x19118
leaq 0x5a686(%rip), %rsi     # 0x735dc
movq %r14, %rdi
callq 0x12160
testl %eax, %eax
je 0x19118
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5a62f(%rip), %rax     # 0x735ac
leaq 0x5ae71(%rip), %rcx     # 0x73df5
movq (%rsp), %rdi
movl $0x14, %esi
movq %r14, %rdx
pushq $0x301                  # imm = 0x301
jmp 0x19080
movq %rbp, %rdi
callq 0x377f7
testb %al, %al
je 0x19092
movq %rbx, 0x20(%rsp)
movq %r15, 0x38(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rbp, 0x28(%rsp)
movq %r13, %rdi
callq 0x12ad0
movq %rax, %r15
cmpl $0x2, (%r13)
movq 0x8(%rsp), %r14
jne 0x18ff1
leaq 0x5b231(%rip), %rsi     # 0x74212
movq %r15, %rdi
callq 0x12160
testl %eax, %eax
je 0x1926c
movq (%r14), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5a5a9(%rip), %rax     # 0x735ac
leaq 0x5b208(%rip), %rdx     # 0x74212
movq (%rsp), %rdi
movl $0x1d, %esi
movq %r15, %rcx
pushq $0x37c                  # imm = 0x37C
jmp 0x192ba
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5a575(%rip), %rax     # 0x735ac
leaq 0x5adb7(%rip), %rcx     # 0x73df5
movq (%rsp), %rdi
movl $0x12, %esi
movq %r12, %rdx
pushq $0x3ba                  # imm = 0x3BA
jmp 0x19080
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5a544(%rip), %rax     # 0x735ac
leaq 0x5ad86(%rip), %rcx     # 0x73df5
movq (%rsp), %rdi
movl $0x69, %esi
movq %r12, %rdx
pushq $0x3c1                  # imm = 0x3C1
pushq %rax
callq 0x1442a
addq $0xa8, %rsp
jmp 0x192cb
movq %rbp, %rdi
callq 0x37815
testb %al, %al
je 0x19168
movq %rbx, 0x20(%rsp)
movq %r15, 0x38(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rbp, 0x28(%rsp)
movq %r13, %rdi
callq 0x12ad0
movq %rax, %r14
cmpl $0x2, (%r13)
jne 0x190e4
leaq 0x5d57d(%rip), %rsi     # 0x76651
movq %r14, %rdi
callq 0x12160
testl %eax, %eax
je 0x192d6
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5a4b1(%rip), %rax     # 0x735ac
leaq 0x5d54f(%rip), %rdx     # 0x76651
movq (%rsp), %rdi
movl $0x1d, %esi
movq %r14, %rcx
pushq $0x396                  # imm = 0x396
jmp 0x192ba
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq (%rsp), %rbx
movq %rbx, %rdx
callq 0x1eb88
cmpl $0x0, (%rbx)
jne 0x192c4
testl %r12d, %r12d
je 0x193d0
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
movq %rax, %rcx
movq (%rsp), %r8
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4bf09
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq (%rsp), %rbx
movq %rbx, %rdx
callq 0x1a046
cmpl $0x0, (%rbx)
jne 0x192c4
movl %eax, %r14d
movq 0x8(%rsp), %rax
movq (%rax), %rdi
cmpl $0x3, %r14d
jne 0x19316
movq 0x30(%rdi), %r8
movl 0x38(%rdi), %r9d
leaq 0x5a403(%rip), %rax     # 0x735ac
leaq 0x5ac45(%rip), %rcx     # 0x73df5
movq (%rsp), %rdi
movl $0x14, %esi
movq %r12, %rdx
pushq $0x3f7                  # imm = 0x3F7
jmp 0x19080
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq 0x10(%rsp), %rdx
movq %r15, %rcx
movq (%rsp), %rbx
movq %rbx, %r8
callq 0x364c2
cmpl $0x0, (%rbx)
jne 0x192c4
movq %rax, %r14
movq 0x148(%rax), %rcx
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq (%rsp), %r8
callq 0x1c019
movq %r14, %rdi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b4c3
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq (%rsp), %rbx
movq %rbx, %rdx
callq 0x1eb88
cmpl $0x0, (%rbx)
jne 0x192c4
movq %rax, %r14
cmpq $0x0, 0x160(%rax)
je 0x1941d
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq (%rsp), %rbx
movq %rbx, %rcx
callq 0x1d2a6
jmp 0x19437
leaq 0x40(%rsp), %rdx
movl $0xa, %ecx
movq %r14, %rdi
movq %r13, %rsi
movq (%rsp), %rbx
movq %rbx, %r8
callq 0x1f017
cmpl $0x0, (%rbx)
je 0x193fd
movq (%r14), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5a309(%rip), %rax     # 0x735ac
leaq 0x5af68(%rip), %rdx     # 0x74212
movq %rbx, %rdi
movl $0x1d, %esi
movq %r15, %rcx
pushq $0x384                  # imm = 0x384
pushq %rax
callq 0x1442a
addq $0x10, %rsp
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
movq (%rsp), %rbx
movq %rbx, %rdx
callq 0x1f50f
movq %rax, 0x40(%rsp)
cmpl $0x0, (%rbx)
jne 0x192c4
xorl %r8d, %r8d
testq %rax, %rax
setne %r8b
leaq 0x20(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movq %r14, %rdi
movq %r13, %rsi
jmp 0x19410
movq %r13, %rsi
movq (%rsp), %rbx
movq %rbx, %rdx
callq 0x12eda
cmpl $0x0, (%rbx)
jne 0x192c4
movq %r13, %rdi
callq 0x12ad0
cmpl $0x16, (%rbp)
jne 0x1934f
leaq 0x5aed3(%rip), %rsi     # 0x74212
movq %rax, %rdi
callq 0x12160
testl %eax, %eax
je 0x1946a
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq (%rsp), %rbx
movq %rbx, %rdx
callq 0x1e874
cmpl $0x0, (%rbx)
jne 0x192c4
movq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %rbp, %rdx
movq (%rsp), %rbx
movq %rbx, %rcx
callq 0x379c3
cmpl $0x0, (%rbx)
jne 0x192c4
movq %rax, %r12
testl %r14d, %r14d
je 0x19497
movl %r14d, 0x1c(%rsp)
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq 0x10(%rsp), %r13
movq %r13, %rdx
movq %r15, %rcx
movq (%rsp), %rbx
movq %rbx, %r8
callq 0x364c2
cmpl $0x0, (%rbx)
je 0x194a7
movq %r12, %rdi
jmp 0x1920c
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq 0x10(%rsp), %rdx
movq %r15, %rcx
movq %rax, %r8
movq (%rsp), %r9
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36040
leaq 0x20(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movq %r14, %rdi
movq %r13, %rsi
movq %rax, %r8
movq %rbx, %r9
callq 0x1a11b
jmp 0x192c4
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq (%rsp), %rbx
movq %rbx, %rcx
callq 0x379c3
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x192c4
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
movq %r14, %rcx
movq (%rsp), %r8
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36416
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
movq %r15, %r8
movq (%rsp), %r9
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2a721
movq (%rsp), %rbx
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %r13
jmp 0x194d5
cmpl $0x1, 0x1c(%rsp)
jne 0x194c1
movq %r14, %rdi
movq %rax, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2bdbb
jmp 0x194d2
movq %r14, %rdi
movq %rax, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x36f23
movq %rax, %r12
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %rbx, %r8
jmp 0x19454