// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/frontend/parser_rec.c
// Function: subtilis_parser_rec_field_lvalue
size_t subtilis_parser_rec_field_lvalue(subtilis_parser_t *p,
					subtilis_token_t *t,
					const subtilis_type_t *type,
					size_t mem_reg, size_t loc,
					subtilis_type_t *dst_type,
					subtilis_error_t *err)
{
	size_t id;
	const subtilis_type_t *field_type;
	const subtilis_type_rec_t *rec;
	const char *tbuf;
	const char *obkt = NULL;
	const char *cbkt = NULL;

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

		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 SIZE_MAX;
		}

		rec = &type->params.rec;
		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 SIZE_MAX;
		}

		loc += (size_t)subtilis_type_rec_field_offset_id(rec, id);
		field_type = &rec->field_types[id];
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;
		tbuf = subtilis_token_get_text(t);
		if (field_type->type != SUBTILIS_TYPE_REC)
			break;
		type = field_type;
	} while ((t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, "."));

	if (subtilis_type_if_is_array(field_type)) {
		obkt = "(";
		cbkt = ")";
	} else if (subtilis_type_if_is_vector(field_type)) {
		obkt = "{";
		cbkt = "}";
	}

	if (obkt) {
		tbuf = subtilis_token_get_text(t);
		if ((t->type != SUBTILIS_TOKEN_OPERATOR) ||
		    strcmp(tbuf, obkt)) {
			subtilis_error_set_exp_expected(
			    err, obkt, p->l->stream->name, p->l->line);
			return SIZE_MAX;
		}
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;
		tbuf = subtilis_token_get_text(t);
		if ((t->type != SUBTILIS_TOKEN_OPERATOR) ||
		    strcmp(tbuf, cbkt)) {
			subtilis_error_set_exp_expected(
			    err, cbkt, p->l->stream->name, p->l->line);
			return SIZE_MAX;
		}
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return SIZE_MAX;
	}

	subtilis_type_copy(dst_type, field_type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return SIZE_MAX;

	return subtilis_reference_get_pointer(p, mem_reg, loc, err);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x20(%rsp)
movq %r8, %r14
movq %rcx, 0x18(%rsp)
movq %rdx, %r12
movq %rsi, %rbp
movq %rdi, 0x8(%rsp)
movq 0x60(%rsp), %rbx
movq %rbx, 0x10(%rsp)
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x12eda
cmpl $0x0, (%rbx)
jne 0x29adc
movq %rbp, %rdi
callq 0x12ad0
movq %rax, %r13
cmpl $0x6, (%rbp)
jne 0x299db
leaq 0x8(%r12), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x2feeb
cmpq $-0x1, %rax
je 0x29a0e
movq %rax, %rbx
movq %r15, %rdi
movq %rax, %rsi
callq 0x30118
movl %eax, %r15d
imulq $0x148, %rbx, %r13      # imm = 0x148
addq 0x18(%r12), %r13
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %rbp, %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x12eda
cmpl $0x0, (%rbx)
jne 0x29adc
movl %r15d, %eax
addq %rax, %r14
movq %rbp, %rdi
callq 0x12ad0
cmpl $0x16, (%r13)
jne 0x299a1
cmpl $0x2, (%rbp)
jne 0x299a1
movq %rax, %rdi
leaq 0x49b73(%rip), %rsi     # 0x73504
callq 0x12160
movq %r13, %r12
testl %eax, %eax
je 0x298e3
movq %r13, %rdi
callq 0x377f7
testb %al, %al
je 0x299bd
leaq 0x4a139(%rip), %r15     # 0x73aed
leaq 0x4a857(%rip), %r12     # 0x74212
jmp 0x299d7
movq %r13, %rdi
callq 0x37815
testb %al, %al
je 0x29a43
leaq 0x49c4b(%rip), %r15     # 0x7361b
leaq 0x4cc7a(%rip), %r12     # 0x76651
xorl %eax, %eax
jmp 0x29a4b
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4a0e0(%rip), %rax     # 0x73ad2
leaq 0x4a3fc(%rip), %rcx     # 0x73df5
movq %rbx, %rdi
movl $0x12, %esi
movq %r13, %rdx
pushq $0x120                  # imm = 0x120
jmp 0x29ad2
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4a0ad(%rip), %rax     # 0x73ad2
leaq 0x4a3c9(%rip), %rcx     # 0x73df5
movq 0x10(%rsp), %rdi
movl $0x69, %esi
movq %r13, %rdx
pushq $0x128                  # imm = 0x128
jmp 0x29ad2
movb $0x1, %al
xorl %r12d, %r12d
xorl %r15d, %r15d
testb %al, %al
je 0x29a87
movq 0x20(%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x2fa5f
cmpl $0x0, (%rbx)
jne 0x29adc
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r14, %rdx
movq %rbx, %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4d763
movq %rbp, %rdi
callq 0x12ad0
cmpl $0x2, (%rbp)
jne 0x29aa4
movq %rax, %rdi
movq %r12, %rsi
callq 0x12160
testl %eax, %eax
je 0x29af2
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4a017(%rip), %rax     # 0x73ad2
leaq 0x4a333(%rip), %rcx     # 0x73df5
movq %rbx, %rdi
movl $0x15, %esi
movq %r12, %rdx
pushq $0x144                  # imm = 0x144
pushq %rax
callq 0x1442a
addq $0x10, %rsp
movq $-0x1, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x12eda
cmpl $0x0, (%rbx)
jne 0x29adc
movq %rbp, %rdi
callq 0x12ad0
cmpl $0x2, (%rbp)
jne 0x29b27
movq %rax, %rdi
movq %r15, %rsi
callq 0x12160
testl %eax, %eax
je 0x29b5a
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x49f94(%rip), %rax     # 0x73ad2
leaq 0x4a2b0(%rip), %rcx     # 0x73df5
movq %rbx, %rdi
movl $0x15, %esi
movq %r15, %rdx
pushq $0x14e                  # imm = 0x14E
jmp 0x29ad2
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x12eda
cmpl $0x0, (%rbx)
jne 0x29adc
jmp 0x29a4f