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

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

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

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

	loc += (size_t)subtilis_type_rec_field_offset_id(rec, id);
	field_type = &rec->field_types[id];

	if ((subtilis_type_if_is_numeric(field_type) ||
	     field_type->type == SUBTILIS_TYPE_FN)) {
		e = subtilis_type_if_load_from_mem(p, field_type, mem_reg, loc,
						   err);
		if (err->type != SUBTILIS_ERROR_OK)
			return NULL;
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
	} else if ((field_type->type == SUBTILIS_TYPE_STRING) ||
		   (field_type->type == SUBTILIS_TYPE_REC)) {
		reg = subtilis_reference_get_pointer(p, mem_reg, loc, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return NULL;
		e = subtilis_exp_new_var(field_type, reg, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return NULL;
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
	} else if (subtilis_type_if_is_array(field_type)) {
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return NULL;
		if ((t->type != SUBTILIS_TOKEN_OPERATOR) || strcmp(tbuf, "(")) {
			subtilis_error_set_exp_expected(
			    err, "(", p->l->stream->name, p->l->line);
			return NULL;
		}
		e = subtils_parser_read_array_with_type(
		    p, t, field_type, mem_reg, loc, rec->fields[id].name, err);
	} else if (subtilis_type_if_is_vector(field_type)) {
		subtilis_lexer_get(p->l, t, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return NULL;
		if ((t->type != SUBTILIS_TOKEN_OPERATOR) || strcmp(tbuf, "{")) {
			subtilis_error_set_exp_expected(
			    err, "{", p->l->stream->name, p->l->line);
			return NULL;
		}
		e = subtils_parser_read_vector_with_type(
		    p, t, field_type, mem_reg, loc, rec->fields[id].name, err);
	} else {
		subtilis_error_set_assertion_failed(err);
	}

	return e;

cleanup:

	subtilis_exp_delete(e);
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x133f0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x349f5
movq $0x0, -0x8(%rbp)
jmp 0x34e0b
movq -0x18(%rbp), %rdi
callq 0x12d70
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x6, (%rax)
je 0x34a5a
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x12, %esi
leaq 0x76841(%rip), %rcx     # 0xab276
leaq 0x760fa(%rip), %rax     # 0xaab36
movq %rax, (%rsp)
movl $0x171, 0x8(%rsp)       # imm = 0x171
callq 0x156d0
movq $0x0, -0x8(%rbp)
jmp 0x34e0b
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x3ec80
movq %rax, -0x40(%rbp)
cmpq $-0x1, -0x40(%rbp)
jne 0x34acd
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x69, %esi
leaq 0x767ce(%rip), %rcx     # 0xab276
leaq 0x76087(%rip), %rax     # 0xaab36
movq %rax, (%rsp)
movl $0x179, 0x8(%rsp)       # imm = 0x179
callq 0x156d0
movq $0x0, -0x8(%rbp)
jmp 0x34e0b
movq -0x50(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3efb0
movl %eax, %eax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x148, -0x40(%rbp), %rcx # imm = 0x148
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x49d10
testb $0x1, %al
jne 0x34b11
movq -0x48(%rbp), %rax
cmpl $0x9, (%rax)
jne 0x34b6b
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
callq 0x48080
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x34b44
movq $0x0, -0x8(%rbp)
jmp 0x34e0b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x133f0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x34b66
jmp 0x34dfa
jmp 0x34df0
movq -0x48(%rbp), %rax
cmpl $0x7, (%rax)
je 0x34b81
movq -0x48(%rbp), %rax
cmpl $0x16, (%rax)
jne 0x34c04
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x6d920
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x34bb0
movq $0x0, -0x8(%rbp)
jmp 0x34e0b
movq -0x48(%rbp), %rdi
movq -0x60(%rbp), %rax
movl %eax, %esi
movq -0x38(%rbp), %rdx
callq 0x37590
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x34bdd
movq $0x0, -0x8(%rbp)
jmp 0x34e0b
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x133f0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x34bff
jmp 0x34dfa
jmp 0x34dee
movq -0x48(%rbp), %rdi
callq 0x49ff0
testb $0x1, %al
jne 0x34c16
jmp 0x34ced
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x133f0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x34c40
movq $0x0, -0x8(%rbp)
jmp 0x34e0b
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x34c5e
movq -0x58(%rbp), %rdi
leaq 0x76648(%rip), %rsi     # 0xab29c
callq 0x12140
cmpl $0x0, %eax
je 0x34cb0
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x15, %esi
leaq 0x76618(%rip), %rdx     # 0xab29c
leaq 0x765eb(%rip), %rcx     # 0xab276
leaq 0x75ea4(%rip), %rax     # 0xaab36
movq %rax, (%rsp)
movl $0x19a, 0x8(%rsp)       # imm = 0x19A
callq 0x156d0
movq $0x0, -0x8(%rbp)
jmp 0x34e0b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
imulq $0x18, -0x40(%rbp), %r9
addq %r9, %rax
movq (%rax), %r9
movq -0x38(%rbp), %rax
movq %rax, (%rsp)
callq 0x17b50
movq %rax, -0x68(%rbp)
jmp 0x34dec
movq -0x48(%rbp), %rdi
callq 0x4a040
testb $0x1, %al
jne 0x34cff
jmp 0x34dd0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x133f0
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0x34d29
movq $0x0, -0x8(%rbp)
jmp 0x34e0b
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x34d47
movq -0x58(%rbp), %rdi
leaq 0x788ce(%rip), %rsi     # 0xad60b
callq 0x12140
cmpl $0x0, %eax
je 0x34d96
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x15, %esi
leaq 0x7889e(%rip), %rdx     # 0xad60b
leaq 0x76502(%rip), %rcx     # 0xab276
leaq 0x75dbb(%rip), %rax     # 0xaab36
movq %rax, (%rsp)
movl $0x1a5, 0x8(%rsp)       # imm = 0x1A5
callq 0x156d0
movq $0x0, -0x8(%rbp)
jmp 0x34e0b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
imulq $0x18, -0x40(%rbp), %r9
addq %r9, %rax
movq (%rax), %r9
movq -0x38(%rbp), %rax
movq %rax, (%rsp)
callq 0x183b0
movq %rax, -0x68(%rbp)
jmp 0x34dea
movq -0x38(%rbp), %rdi
movl $0xf, %esi
leaq 0x75d56(%rip), %rdx     # 0xaab36
movl $0x1ab, %ecx            # imm = 0x1AB
callq 0x158e0
jmp 0x34dec
jmp 0x34dee
jmp 0x34df0
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x34e0b
movq -0x68(%rbp), %rdi
callq 0x36ee0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)