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

	tbuf = subtilis_token_get_text(t);
	if ((t->type == SUBTILIS_TOKEN_OPERATOR) && !strcmp(tbuf, ")")) {
		subtilis_rec_type_deref(p, type, mem_reg, loc, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;

		subtilis_rec_type_zero(p, type, mem_reg, loc, false, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;

		subtilis_lexer_get(p->l, t, err);
		return;
	}

	rec = &type->params.rec;

	for (id = 0; id < rec->num_fields; id++) {
		field_type = &rec->field_types[id];
		offset = subtilis_type_rec_field_offset_id(rec, id);
		if (subtilis_type_if_is_numeric(field_type) ||
		    field_type->type == SUBTILIS_TYPE_FN) {
			e = subtilis_parser_priority7(p, t, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			e = subtilis_type_if_coerce_type(p, e, field_type, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			subtilis_type_if_assign_to_mem(p, mem_reg, loc + offset,
						       e, err);
		} else if (field_type->type == SUBTILIS_TYPE_STRING) {
			e = subtilis_parser_priority7(p, t, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
			subtilis_type_if_assign_to_mem(p, mem_reg, loc + offset,
						       e, err);
		} else if (subtilis_type_if_is_array(field_type) ||
			   subtilis_type_if_is_vector(field_type)) {
			prv_array_field_reset(p, t, &rec->fields[id],
					      field_type, mem_reg, loc + offset,
					      err);
		} else if (field_type->type == SUBTILIS_TYPE_REC) {
			tbuf = subtilis_token_get_text(t);
			if ((t->type != SUBTILIS_TOKEN_OPERATOR) ||
			    strcmp(tbuf, "(")) {
				subtilis_error_set_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;

			prv_rec_reset(p, t, field_type, mem_reg, loc + offset,
				      err);
		} else {
			subtilis_error_set_assertion_failed(err);
			return;
		}

		if (err->type != SUBTILIS_ERROR_OK)
			return;

		tbuf = subtilis_token_get_text(t);
		if (t->type == SUBTILIS_TOKEN_OPERATOR) {
			if (!strcmp(tbuf, ",")) {
				if (id < rec->num_fields - 1) {
					subtilis_lexer_get(p->l, t, err);
					if (err->type != SUBTILIS_ERROR_OK)
						return;
				}
				continue;
			}
			if (!strcmp(tbuf, ")"))
				break;
		}
		subtilis_error_set_expected(err, ", or )", tbuf,
					    p->l->stream->name, p->l->line);
		return;
	}

	if (strcmp(tbuf, ")")) {
		subtilis_error_set_expected(err, ")", tbuf, p->l->stream->name,
					    p->l->line);
		return;
	}

	/*
	 * I could add a type_if interface for this, a reset method.
	 * The main motivation would be to avoid de-allocing and re-allocing
	 * arrays, or vectors when their size hasn't changed, that have a
	 * single owner.  We'd have to do a ref count check though and since
	 * we know the heap will have a block of the correct size, allocation
	 * should be fast, so it's not worth the effort.
	 */

	for (id = id + 1; id < rec->num_fields; id++) {
		field_type = &rec->field_types[id];
		offset = subtilis_type_rec_field_offset_id(rec, id);
		if (subtilis_type_if_is_reference(field_type)) {
			subtilis_reference_type_deref(p, mem_reg, offset + loc,
						      err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
		} else if (field_type->type == SUBTILIS_TYPE_REC) {
			subtilis_rec_type_deref(p, field_type, mem_reg,
						offset + loc, err);
			if (err->type != SUBTILIS_ERROR_OK)
				return;
		}
		subtilis_rec_type_init_field(p, field_type, &rec->fields[id],
					     mem_reg, offset + loc, false, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	subtilis_lexer_get(p->l, t, err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x357b5
movq -0x38(%rbp), %rdi
leaq 0x75410(%rip), %rsi     # 0xaab51
callq 0x12140
cmpl $0x0, %eax
jne 0x357b5
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x62a00
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x35772
jmp 0x35c76
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r9
xorl %r8d, %r8d
callq 0x62290
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x3579c
jmp 0x35c76
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x133f0
jmp 0x35c76
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0x35afe
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x148, -0x40(%rbp), %rcx # imm = 0x148
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3efb0
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rdi
callq 0x49d10
testb $0x1, %al
jne 0x35818
movq -0x50(%rbp), %rax
cmpl $0x9, (%rax)
jne 0x35886
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x24550
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x3583b
jmp 0x35c76
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x4a2e0
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x35862
jmp 0x35c76
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl -0x54(%rbp), %eax
addq %rax, %rdx
movq -0x60(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x47f20
jmp 0x35a19
movq -0x50(%rbp), %rax
cmpl $0x7, (%rax)
jne 0x358d6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x24550
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x358b2
jmp 0x35c76
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl -0x54(%rbp), %eax
addq %rax, %rdx
movq -0x60(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x47f20
jmp 0x35a17
movq -0x50(%rbp), %rdi
callq 0x49ff0
testb $0x1, %al
jne 0x358f2
movq -0x50(%rbp), %rdi
callq 0x4a040
testb $0x1, %al
jne 0x358f2
jmp 0x3592e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rdx
imulq $0x18, -0x40(%rbp), %rax
addq %rax, %rdx
movq -0x50(%rbp), %rcx
movq -0x20(%rbp), %r8
movq -0x28(%rbp), %r9
movl -0x54(%rbp), %eax
addq %rax, %r9
movq -0x30(%rbp), %rax
movq %rax, (%rsp)
callq 0x36350
jmp 0x35a15
movq -0x50(%rbp), %rax
cmpl $0x16, (%rax)
jne 0x359f4
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x35966
movq -0x38(%rbp), %rdi
leaq 0x75940(%rip), %rsi     # 0xab29c
callq 0x12140
cmpl $0x0, %eax
je 0x359ad
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0x7590c(%rip), %rdx     # 0xab29c
leaq 0x7519f(%rip), %rax     # 0xaab36
movq %rax, (%rsp)
movl $0x31c, 0x8(%rsp)       # imm = 0x31C
callq 0x156d0
jmp 0x35c76
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x133f0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x359cf
jmp 0x35c76
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movl -0x54(%rbp), %eax
addq %rax, %r8
movq -0x30(%rbp), %r9
callq 0x35700
jmp 0x35a13
movq -0x30(%rbp), %rdi
movl $0xf, %esi
leaq 0x75132(%rip), %rdx     # 0xaab36
movl $0x326, %ecx            # imm = 0x326
callq 0x158e0
jmp 0x35c76
jmp 0x35a15
jmp 0x35a17
jmp 0x35a19
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x35a27
jmp 0x35c76
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x35aa6
movq -0x38(%rbp), %rdi
leaq 0x74b61(%rip), %rsi     # 0xaa5a9
callq 0x12140
cmpl $0x0, %eax
jne 0x35a8d
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
movq 0x20(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x35a8b
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x133f0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x35a89
jmp 0x35c76
jmp 0x35a8b
jmp 0x35aed
movq -0x38(%rbp), %rdi
leaq 0x750b9(%rip), %rsi     # 0xaab51
callq 0x12140
cmpl $0x0, %eax
jne 0x35aa4
jmp 0x35afe
jmp 0x35aa6
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0x7507c(%rip), %rdx     # 0xaab4c
leaq 0x7505f(%rip), %rax     # 0xaab36
movq %rax, (%rsp)
movl $0x33b, 0x8(%rsp)       # imm = 0x33B
callq 0x156d0
jmp 0x35c76
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x357c9
movq -0x38(%rbp), %rdi
leaq 0x75048(%rip), %rsi     # 0xaab51
callq 0x12140
cmpl $0x0, %eax
je 0x35b5a
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0x75014(%rip), %rdx     # 0xaab51
leaq 0x74ff2(%rip), %rax     # 0xaab36
movq %rax, (%rsp)
movl $0x341, 0x8(%rsp)       # imm = 0x341
callq 0x156d0
jmp 0x35c76
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0x35c62
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x148, -0x40(%rbp), %rcx # imm = 0x148
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3efb0
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rdi
callq 0x4a090
testb $0x1, %al
jne 0x35bae
jmp 0x35bd8
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x54(%rbp), %eax
movl %eax, %edx
addq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x6df60
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x35bd6
jmp 0x35c76
jmp 0x35c0e
movq -0x50(%rbp), %rax
cmpl $0x16, (%rax)
jne 0x35c0c
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x54(%rbp), %eax
movl %eax, %ecx
addq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x62a00
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x35c0a
jmp 0x35c76
jmp 0x35c0c
jmp 0x35c0e
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rdx
imulq $0x18, -0x40(%rbp), %rax
addq %rax, %rdx
movq -0x20(%rbp), %rcx
movl -0x54(%rbp), %eax
movl %eax, %r8d
addq -0x28(%rbp), %r8
movq -0x30(%rbp), %rax
xorl %r9d, %r9d
movq %rax, (%rsp)
callq 0x61fd0
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0x35c4f
jmp 0x35c76
jmp 0x35c51
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x35b66
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x133f0
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)