// File: /workspace/github_c_makefile_star2_O3/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, %r13
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 0x12edc
cmpl $0x0, (%rbx)
jne 0x29821
movq %rbp, %rdi
callq 0x12ad0
movq %rax, %r12
cmpl $0x6, (%rbp)
jne 0x297b7
leaq 0x8(%r13), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x2fc17
cmpq $-0x1, %rax
je 0x297e7
movq %rax, %rbx
movq %r15, %rdi
movq %rax, %rsi
callq 0x2fe6a
movl %eax, %r15d
imulq $0x148, %rbx, %r12      # imm = 0x148
addq 0x18(%r13), %r12
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %rbp, %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x12edc
cmpl $0x0, (%rbx)
jne 0x29821
movl %r15d, %eax
addq %rax, %r14
movq %rbp, %rdi
callq 0x12ad0
cmpl $0x16, (%r12)
jne 0x2972c
cmpl $0x2, (%rbp)
jne 0x2972c
cmpb $0x2e, (%rax)
jne 0x2972c
cmpb $0x0, 0x1(%rax)
movq %r12, %r13
je 0x29678
movq %r12, %rdi
callq 0x376b5
testb %al, %al
je 0x29748
leaq 0x4a3c6(%rip), %r15     # 0x73b05
leaq 0x4aaec(%rip), %r13     # 0x74232
jmp 0x29766
movq %r12, %rdi
callq 0x376d3
testb %al, %al
je 0x298bb
leaq 0x49f3b(%rip), %r15     # 0x7369a
leaq 0x4cf2b(%rip), %r13     # 0x76691
movq %rbp, %rdi
callq 0x12ad0
cmpl $0x2, (%rbp)
jne 0x29787
movq %rax, %rdi
movq %r13, %rsi
callq 0x12160
testl %eax, %eax
je 0x29837
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4a34c(%rip), %rax     # 0x73aea
leaq 0x4a670(%rip), %rcx     # 0x73e15
movq %rbx, %rdi
movl $0x15, %esi
movq %r13, %rdx
pushq $0x144                  # imm = 0x144
jmp 0x29817
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4a31c(%rip), %rax     # 0x73aea
leaq 0x4a640(%rip), %rcx     # 0x73e15
movq %rbx, %rdi
movl $0x12, %esi
movq %r12, %rdx
pushq $0x120                  # imm = 0x120
jmp 0x29817
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4a2ec(%rip), %rax     # 0x73aea
leaq 0x4a610(%rip), %rcx     # 0x73e15
movq 0x10(%rsp), %rdi
movl $0x69, %esi
movq %r12, %rdx
pushq $0x128                  # imm = 0x128
pushq %rax
callq 0x143da
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 0x12edc
cmpl $0x0, (%rbx)
jne 0x29821
movq %rbp, %rdi
callq 0x12ad0
cmpl $0x2, (%rbp)
jne 0x2986c
movq %rax, %rdi
movq %r15, %rsi
callq 0x12160
testl %eax, %eax
je 0x2989f
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4a267(%rip), %rax     # 0x73aea
leaq 0x4a58b(%rip), %rcx     # 0x73e15
movq %rbx, %rdi
movl $0x15, %esi
movq %r15, %rdx
pushq $0x14e                  # imm = 0x14E
jmp 0x29817
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x12edc
cmpl $0x0, (%rbx)
jne 0x29821
movq 0x20(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x2f78a
cmpl $0x0, (%rbx)
jne 0x29821
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 0x4d71f