// File: /workspace/github_c_makefile_star2_O3/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 0x12edc
cmpl $0x0, (%r14)
jne 0x18f45
movq %r13, %rdi
callq 0x12ad0
movq %rax, %r12
cmpl $0x6, (%r13)
jne 0x18f51
leaq 0x8(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2fc17
cmpq $-0x1, %rax
je 0x18f83
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2fe6a
movl %eax, %ebx
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %r13, %rsi
movq 0x10(%rsp), %r12
movq %r12, %rdx
callq 0x12edc
cmpl $0x0, (%r12)
jne 0x18f45
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), %eax
cmpl $0x16, %eax
jne 0x18da9
cmpl $0x2, (%r13)
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %rdi
jne 0x18e4c
cmpb $0x2e, (%r12)
jne 0x18e4c
cmpb $0x0, 0x1(%r12)
je 0x18ccb
jmp 0x18e4c
cmpl $0x7, %eax
movq 0x10(%rsp), %r14
je 0x18fb9
cmpl $0x9, %eax
jne 0x18e4c
movq %r13, %rdi
callq 0x12ad0
cmpl $0x2, (%r13)
jne 0x191a1
movzbl (%rax), %ecx
cmpl $0x3d, %ecx
je 0x19197
cmpl $0x28, %ecx
jne 0x191a1
cmpb $0x0, 0x1(%rax)
jne 0x191a1
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq 0x18(%rsp), %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x36372
cmpl $0x0, (%r14)
jne 0x18f45
movq %rax, %r14
movq 0x148(%rax), %rcx
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %r8
callq 0x1c086
movq %r14, %rdi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b166
movq %rbp, %rdi
callq 0x376b5
testb %al, %al
je 0x18ec5
movq %rbx, 0x20(%rsp)
movq %r15, 0x38(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rbp, 0x28(%rsp)
movq %r13, %rdi
callq 0x12ad0
movq %rax, %r15
cmpl $0x2, (%r13)
jne 0x18e94
cmpb $0x28, (%r15)
jne 0x18e94
cmpb $0x0, 0x1(%r15)
je 0x1908d
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5a6f9(%rip), %rax     # 0x735a4
leaq 0x5b380(%rip), %rdx     # 0x74232
movq %r14, %rdi
movl $0x1d, %esi
movq %r15, %rcx
pushq $0x37c                  # imm = 0x37C
pushq %rax
jmp 0x18f3c
movq %rbp, %rdi
callq 0x376d3
testb %al, %al
je 0x19033
movq %rbx, 0x20(%rsp)
movq %r15, 0x38(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rbp, 0x28(%rsp)
movq %r13, %rdi
callq 0x12ad0
cmpl $0x2, (%r13)
jne 0x18f0c
cmpb $0x7b, (%rax)
jne 0x18f0c
cmpb $0x0, 0x1(%rax)
je 0x19228
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x5a681(%rip), %r10     # 0x735a4
leaq 0x5d767(%rip), %rdx     # 0x76691
movq %r14, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0x396                  # imm = 0x396
pushq %r10
callq 0x143da
addq $0x10, %rsp
addq $0x98, %rsp
jmp 0x1921d
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5a63c(%rip), %rax     # 0x735a4
leaq 0x5aea6(%rip), %rcx     # 0x73e15
movq 0x10(%rsp), %rdi
movl $0x12, %esi
movq %r12, %rdx
pushq $0x3ba                  # imm = 0x3BA
jmp 0x18fb3
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5a60a(%rip), %rax     # 0x735a4
leaq 0x5ae74(%rip), %rcx     # 0x73e15
movq 0x10(%rsp), %rdi
movl $0x69, %esi
movq %r12, %rdx
pushq $0x3c1                  # imm = 0x3C1
pushq %rax
jmp 0x19211
movq %r13, %rdi
callq 0x12ad0
cmpl $0x2, (%r13)
jne 0x191e1
movzbl (%rax), %ecx
cmpl $0x2b, %ecx
je 0x191d1
cmpl $0x3d, %ecx
jne 0x191e1
cmpb $0x0, 0x1(%rax)
jne 0x191e1
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1ec4c
cmpl $0x0, (%r14)
jne 0x18f45
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 0x35ef0
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x19fab
cmpl $0x0, (%r14)
jne 0x18f45
movl %eax, %ecx
movq 0x8(%rsp), %rax
movq (%rax), %rdi
cmpl $0x3, %ecx
jne 0x190e2
movq 0x30(%rdi), %r8
movl 0x38(%rdi), %r9d
leaq 0x5a535(%rip), %rax     # 0x735a4
leaq 0x5ad9f(%rip), %rcx     # 0x73e15
movq 0x10(%rsp), %rdi
movl $0x14, %esi
movq %r12, %rdx
pushq $0x3f7                  # imm = 0x3F7
jmp 0x18fb3
leaq 0x40(%rsp), %rdx
movl $0xa, %ecx
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %r8
callq 0x1f0d1
cmpl $0x0, (%r14)
je 0x1926a
movq (%rbx), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x5a4de(%rip), %rax     # 0x735a4
leaq 0x5b165(%rip), %rdx     # 0x74232
movq %r14, %rdi
movl $0x1d, %esi
movq %r15, %rcx
pushq $0x384                  # imm = 0x384
jmp 0x18ec2
movq %r13, %rsi
movl %ecx, %r14d
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x12edc
cmpl $0x0, (%rbx)
jne 0x18f45
movq %r13, %rdi
callq 0x12ad0
cmpl $0x16, (%rbp)
jne 0x1911b
cmpb $0x28, (%rax)
jne 0x1911b
cmpb $0x0, 0x1(%rax)
je 0x1935e
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x1e938
cmpl $0x0, (%rbx)
jne 0x18f45
movq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x37860
cmpl $0x0, (%rbx)
jne 0x18f45
movq %rax, %r12
testl %r14d, %r14d
je 0x1938c
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 0x36372
cmpl $0x0, (%rbx)
je 0x1939d
movq %r12, %rdi
jmp 0x18e36
cmpb $0x0, 0x1(%rax)
je 0x1928a
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x5a3ec(%rip), %r10     # 0x735a4
leaq 0x5ac56(%rip), %rcx     # 0x73e15
movq %r14, %rdi
movl $0x14, %esi
movq %rax, %rdx
pushq $0x31c                  # imm = 0x31C
jmp 0x1920f
cmpb $0x3d, 0x1(%rax)
jne 0x191e1
cmpb $0x0, 0x2(%rax)
je 0x192cb
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x5a3ac(%rip), %r10     # 0x735a4
leaq 0x5ac16(%rip), %rcx     # 0x73e15
movq %r14, %rdi
movl $0x14, %esi
movq %rax, %rdx
pushq $0x301                  # imm = 0x301
pushq %r10
callq 0x143da
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1f564
movq %rax, 0x40(%rsp)
cmpl $0x0, (%r14)
jne 0x18f45
leaq 0x20(%rsp), %rdx
leaq 0x40(%rsp), %rcx
testq %rax, %rax
je 0x19310
movl $0x1, %r8d
movq 0x8(%rsp), %rdi
movq %r13, %rsi
jmp 0x1927d
leaq 0x20(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %r8
movq %r14, %r9
callq 0x1a093
jmp 0x18f45
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1ec4c
cmpl $0x0, (%r14)
jne 0x18f45
movq %rax, %r14
cmpq $0x0, 0x160(%rax)
je 0x19320
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x1d3d0
jmp 0x1933b
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1ec4c
cmpl $0x0, (%r14)
jne 0x18f45
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 0x4bec6
movq 0x8(%rsp), %rdi
movq %r13, %rsi
xorl %r8d, %r8d
jmp 0x1927d
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x37860
movq %rax, %r14
cmpl $0x0, (%rbx)
jne 0x18f45
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
movq %r14, %rcx
movq 0x10(%rsp), %r8
jmp 0x193e3
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 0x2a40f
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %r13
jmp 0x193d7
cmpl $0x1, %r14d
jne 0x193bb
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2ba37
jmp 0x193d1
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x36de4
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 0x362c6