// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/arch/arm32/assembler.c
// Function: prv_parse_def
static void prv_parse_def(subtilis_arm_ass_context_t *c, subtilis_error_t *err)
{
	const char *tbuf;
	subtilis_arm_ass_def_t *new_defs;
	size_t new_max_defs;
	const char *id_name;
	subtilis_arm_exp_val_t *val1 = NULL;
	subtilis_arm_exp_val_t *val2 = NULL;

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

	tbuf = subtilis_token_get_text(c->t);
	if (c->t->type != SUBTILIS_TOKEN_IDENTIFIER) {
		subtilis_error_set_expected(err, "identifier", tbuf,
					    c->l->stream->name, c->l->line);
		goto cleanup;
	}

	tbuf = subtilis_token_get_text(c->t);
	val1 = subtilis_arm_exp_process_id(c, tbuf, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if (val1->type != SUBTILIS_ARM_EXP_TYPE_ID) {
		subtilis_error_set_expected(err, "identifier",
					    subtilis_arm_exp_type_name(val1),
					    c->l->stream->name, c->l->line);
		goto cleanup;
	}

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

	tbuf = subtilis_token_get_text(c->t);
	if (c->t->type != SUBTILIS_TOKEN_OPERATOR || strcmp(tbuf, "=")) {
		subtilis_error_set_expected(err, "=", tbuf, c->l->stream->name,
					    c->l->line);
		goto cleanup;
	}

	val2 = subtilis_arm_exp_val_get(c, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if (c->def_count == c->max_defs) {
		new_max_defs = c->max_defs + SUBTILIS_CONFIG_CONSTANT_POOL_GRAN;
		new_defs = realloc(c->defs, sizeof(*new_defs) * new_max_defs);
		if (!new_defs) {
			subtilis_error_set_oom(err);
			goto cleanup;
		}
		c->defs = new_defs;
		c->max_defs = new_max_defs;
	}

	id_name = subtilis_buffer_get_string(&val1->val.buf);
	c->defs[c->def_count].name =
	    malloc(subtilis_buffer_get_size(&val1->val.buf));
	if (!c->defs[c->def_count].name) {
		subtilis_error_set_oom(err);
		goto cleanup;
	}
	strcpy(c->defs[c->def_count].name, id_name);
	c->defs[c->def_count++].val = val2;
	val2 = NULL;

cleanup:

	subtilis_arm_exp_val_free(val2);
	subtilis_arm_exp_val_free(val1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
movq 0x8(%rdi), %rdi
movq 0x10(%r15), %rsi
movq %r14, %rdx
callq 0x12eda
cmpl $0x0, (%r14)
je 0x6505d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r15), %rdi
callq 0x12ad0
movq 0x10(%r15), %rdi
cmpl $0x6, (%rdi)
jne 0x6510a
callq 0x12ad0
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x6981a
cmpl $0x0, (%r14)
jne 0x6504e
movq %rax, %rbx
cmpl $0x9, (%rax)
jne 0x65162
movq 0x8(%r15), %rdi
movq 0x10(%r15), %rsi
movq %r14, %rdx
callq 0x12eda
cmpl $0x0, (%r14)
jne 0x6504e
movq 0x10(%r15), %rdi
callq 0x12ad0
movq %rax, %r12
movq 0x10(%r15), %rax
cmpl $0x2, (%rax)
jne 0x650da
leaq 0xe53a(%rip), %rsi      # 0x73604
movq %r12, %rdi
callq 0x12160
testl %eax, %eax
je 0x651a1
movq 0x8(%r15), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x11c23(%rip), %rax     # 0x76d10
leaq 0xe510(%rip), %rdx      # 0x73604
movq %r14, %rdi
movl $0x1d, %esi
movq %r12, %rcx
pushq $0xfa7                  # imm = 0xFA7
pushq %rax
jmp 0x65196
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x11bf3(%rip), %r10     # 0x76d10
leaq 0x11c0e(%rip), %rdx     # 0x76d32
movq %r14, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0xf90                  # imm = 0xF90
pushq %r10
callq 0x1442a
addq $0x10, %rsp
xorl %ebx, %ebx
xorl %r12d, %r12d
movq %r12, %rdi
callq 0x69167
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x69167
movq %rbx, %rdi
callq 0x69abf
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x11b93(%rip), %r10     # 0x76d10
leaq 0x11bae(%rip), %rdx     # 0x76d32
movq %r14, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0xf9c                  # imm = 0xF9C
pushq %r10
callq 0x1442a
addq $0x10, %rsp
jmp 0x65141
movq %r15, %rdi
movq %r14, %rsi
callq 0x69a84
cmpl $0x0, (%r14)
jne 0x6504e
movq %rax, %r12
movq 0x60(%r15), %r13
cmpq %r13, 0x58(%r15)
jne 0x651e4
addq $0x20, %r13
movq 0x50(%r15), %rdi
movq %r13, %rsi
shlq $0x4, %rsi
callq 0x12210
testq %rax, %rax
je 0x65255
movq %rax, 0x50(%r15)
movq %r13, 0x60(%r15)
movq %rbx, %rbp
addq $0x8, %rbp
movq %rbp, %rdi
callq 0x14dfb
movq %rax, (%rsp)
movq %rbp, %rdi
callq 0x14ba1
movq %rax, %rdi
callq 0x121d0
movq 0x50(%r15), %rcx
movq 0x58(%r15), %rbp
movq %rbp, %r13
shlq $0x4, %r13
movq %rax, (%rcx,%r13)
testq %rax, %rax
je 0x6523f
movq %rax, %rdi
movq (%rsp), %rsi
movq %rcx, %r14
callq 0x12070
incq %rbp
movq %rbp, 0x58(%r15)
movq %r12, 0x8(%r14,%r13)
jmp 0x65141
leaq 0x11aca(%rip), %rdx     # 0x76d10
movq %r14, %rdi
movl $0x1, %esi
movl $0xfbe, %ecx            # imm = 0xFBE
jmp 0x65269
leaq 0x11ab4(%rip), %rdx     # 0x76d10
movq %r14, %rdi
movl $0x1, %esi
movl $0xfb3, %ecx            # imm = 0xFB3
callq 0x145f4
jmp 0x65144