// File: /workspace/github_c_makefile_star2_O2/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, %r14
movq %r8, %r15
movq %rcx, 0x18(%rsp)
movq %rdx, %rbp
movq %rsi, %r13
movq %r9, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
movq (%rdi), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x12e0e
cmpl $0x0, (%r14)
jne 0x189ea
movq %r13, %rdi
callq 0x12a25
movq %rax, %r12
cmpl $0x6, (%r13)
jne 0x189f6
leaq 0x8(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2e2d7
cmpq $-0x1, %rax
je 0x18a26
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2e515
movl %eax, %ebx
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %r13, %rsi
movq 0x10(%rsp), %r12
movq %r12, %rdx
callq 0x12e0e
cmpl $0x0, (%r12)
jne 0x189ea
movl %ebx, %eax
addq %rax, %r15
movq %r13, %rdi
callq 0x12a25
movq %rax, %r12
imulq $0x148, %r14, %rax      # imm = 0x148
movq 0x18(%rbp), %rcx
movq 0x20(%rbp), %rdx
leaq (%rcx,%rax), %rbp
imulq $0x18, %r14, %rsi
movq (%rdx,%rsi), %rbx
movl (%rcx,%rax), %eax
cmpl $0x16, %eax
jne 0x18854
cmpl $0x2, (%r13)
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %rdi
jne 0x188f7
cmpb $0x2e, (%r12)
jne 0x188f7
cmpb $0x0, 0x1(%r12)
je 0x18776
jmp 0x188f7
cmpl $0x7, %eax
movq 0x10(%rsp), %r14
je 0x18a5a
cmpl $0x9, %eax
jne 0x188f7
movq %r13, %rdi
callq 0x12a25
cmpl $0x2, (%r13)
jne 0x18bf7
movzbl (%rax), %ecx
cmpl $0x3d, %ecx
je 0x18bed
cmpl $0x28, %ecx
jne 0x18bf7
cmpb $0x0, 0x1(%rax)
jne 0x18bf7
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq 0x18(%rsp), %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x343a4
cmpl $0x0, (%r14)
jne 0x189ea
movq %rax, %r14
movq 0x148(%rax), %rcx
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %r8
callq 0x1bae2
movq %r14, %rdi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x29d88
movq %rbp, %rdi
callq 0x357cc
testb %al, %al
je 0x1896e
movq %rbx, 0x20(%rsp)
movq %r15, 0x38(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rbp, 0x28(%rsp)
movq %r13, %rdi
callq 0x12a25
movq %rax, %r15
cmpl $0x2, (%r13)
jne 0x1893f
cmpb $0x28, (%r15)
jne 0x1893f
cmpb $0x0, 0x1(%r15)
je 0x18ae7
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x54c4e(%rip), %rax     # 0x6d5a4
leaq 0x55885(%rip), %rdx     # 0x6e1e2
pushq $0x1d
popq %rsi
movq %r14, %rdi
movq %r15, %rcx
pushq $0x37c                  # imm = 0x37C
pushq %rax
jmp 0x189e3
movq %rbp, %rdi
callq 0x357ea
testb %al, %al
je 0x18a93
movq %rbx, 0x20(%rsp)
movq %r15, 0x38(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rbp, 0x28(%rsp)
movq %r13, %rdi
callq 0x12a25
cmpl $0x2, (%r13)
jne 0x189b5
cmpb $0x7b, (%rax)
jne 0x189b5
cmpb $0x0, 0x1(%rax)
je 0x18c7a
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x54bd8(%rip), %r10     # 0x6d5a4
leaq 0x57c2e(%rip), %rdx     # 0x70601
pushq $0x1d
popq %rsi
movq %r14, %rdi
movq %rax, %rcx
pushq $0x396                  # imm = 0x396
pushq %r10
callq 0x140cd
popq %rax
popq %rcx
addq $0x98, %rsp
jmp 0x18c6f
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x54b97(%rip), %rax     # 0x6d5a4
leaq 0x553b1(%rip), %rcx     # 0x6ddc5
pushq $0x12
popq %rsi
movq 0x10(%rsp), %rdi
movq %r12, %rdx
pushq $0x3ba                  # imm = 0x3BA
jmp 0x18a54
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x54b67(%rip), %rax     # 0x6d5a4
leaq 0x55381(%rip), %rcx     # 0x6ddc5
pushq $0x69
popq %rsi
movq 0x10(%rsp), %rdi
movq %r12, %rdx
pushq $0x3c1                  # imm = 0x3C1
pushq %rax
jmp 0x18c63
movq %r13, %rdi
callq 0x12a25
cmpl $0x2, (%r13)
jne 0x18c35
movzbl (%rax), %ecx
cmpl $0x2b, %ecx
je 0x18c25
cmpl $0x3d, %ecx
jne 0x18c35
cmpb $0x0, 0x1(%rax)
jne 0x18c35
movb $0x1, %bl
jmp 0x18d22
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x198e0
cmpl $0x0, (%r14)
jne 0x189ea
movl %eax, %ecx
movq 0x8(%rsp), %rax
movq (%rax), %rdi
cmpl $0x3, %ecx
jne 0x18b38
movq 0x30(%rdi), %r8
movl 0x38(%rdi), %r9d
leaq 0x54ad9(%rip), %rax     # 0x6d5a4
leaq 0x552f3(%rip), %rcx     # 0x6ddc5
pushq $0x14
popq %rsi
movq 0x10(%rsp), %rdi
movq %r12, %rdx
pushq $0x3f7                  # imm = 0x3F7
jmp 0x18a54
leaq 0x40(%rsp), %rdx
pushq $0xa
popq %rcx
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %r8
callq 0x1e437
cmpl $0x0, (%r14)
je 0x18cb8
movq (%rbx), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x54a86(%rip), %rax     # 0x6d5a4
leaq 0x556bd(%rip), %rdx     # 0x6e1e2
pushq $0x1d
popq %rsi
movq %r14, %rdi
movq %r15, %rcx
pushq $0x384                  # imm = 0x384
jmp 0x1896b
movq %r13, %rsi
movl %ecx, %r14d
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x12e0e
cmpl $0x0, (%rbx)
jne 0x189ea
movq %r13, %rdi
callq 0x12a25
cmpl $0x16, (%rbp)
jne 0x18b71
cmpb $0x28, (%rax)
jne 0x18b71
cmpb $0x0, 0x1(%rax)
je 0x18dd7
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x1dccf
cmpl $0x0, (%rbx)
jne 0x189ea
movq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x35977
cmpl $0x0, (%rbx)
jne 0x189ea
movq %rax, %r12
testl %r14d, %r14d
je 0x18e05
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq 0x18(%rsp), %r13
movq %r13, %rdx
movq %r15, %rcx
movq 0x10(%rsp), %rbx
movq %rbx, %r8
callq 0x343a4
cmpl $0x0, (%rbx)
je 0x18e16
movq %r12, %rdi
jmp 0x188e1
cmpb $0x0, 0x1(%rax)
je 0x18cd8
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x54996(%rip), %r10     # 0x6d5a4
leaq 0x551b0(%rip), %rcx     # 0x6ddc5
pushq $0x14
popq %rsi
movq %r14, %rdi
movq %rax, %rdx
pushq $0x31c                  # imm = 0x31C
jmp 0x18c61
cmpb $0x3d, 0x1(%rax)
jne 0x18c35
cmpb $0x0, 0x2(%rax)
je 0x18d20
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x54958(%rip), %r10     # 0x6d5a4
leaq 0x55172(%rip), %rcx     # 0x6ddc5
pushq $0x14
popq %rsi
movq %r14, %rdi
movq %rax, %rdx
pushq $0x301                  # imm = 0x301
pushq %r10
callq 0x140cd
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1e894
movq %rax, 0x40(%rsp)
cmpl $0x0, (%r14)
jne 0x189ea
xorl %r8d, %r8d
testq %rax, %rax
setne %r8b
leaq 0x20(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
jmp 0x18ccb
leaq 0x20(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %r8
movq %r14, %r9
callq 0x199b2
jmp 0x189ea
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1dfd5
cmpl $0x0, (%r14)
jne 0x189ea
movq %rax, %r14
cmpq $0x0, 0x160(%rax)
je 0x18d99
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x1cc3c
jmp 0x18db4
xorl %ebx, %ebx
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1dfd5
cmpl $0x0, (%r14)
jne 0x189ea
testb %bl, %bl
je 0x18d6e
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq 0x18(%rsp), %rdx
movq %r15, %rcx
movq %rax, %r8
movq 0x10(%rsp), %r9
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x33f4e
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
movq %rax, %rcx
movq 0x10(%rsp), %r8
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x493b7
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x35977
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x189ea
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
movq %r14, %rcx
movq 0x10(%rsp), %r8
jmp 0x18e5c
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq 0x18(%rsp), %rcx
movq %r15, %r8
movq 0x10(%rsp), %r9
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x290ba
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %r13
jmp 0x18e50
cmpl $0x1, %r14d
jne 0x18e34
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2a5db
jmp 0x18e4a
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x34e98
movq %rax, %r12
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %rbx, %r8
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x34300