// File: /workspace/github_c_makefile_star2_O3/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 0x12edc
cmpl $0x0, (%r14)
je 0x64f3c
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 0x64fda
callq 0x12ad0
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x693c8
cmpl $0x0, (%r14)
jne 0x64f2d
movq %rax, %rbx
cmpl $0x9, (%rax)
jne 0x65013
movq 0x8(%r15), %rdi
movq 0x10(%r15), %rsi
movq %r14, %rdx
callq 0x12edc
cmpl $0x0, (%r14)
jne 0x64f2d
movq 0x10(%r15), %rdi
callq 0x12ad0
movq 0x10(%r15), %rcx
cmpl $0x2, (%rcx)
jne 0x64fae
cmpb $0x3d, (%rax)
jne 0x64fae
cmpb $0x0, 0x1(%rax)
je 0x65071
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x11daf(%rip), %r10     # 0x76d70
leaq 0xe62e(%rip), %rdx      # 0x735f6
movq %r14, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0xfa7                  # imm = 0xFA7
jmp 0x65045
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x11d83(%rip), %r10     # 0x76d70
leaq 0x11d9e(%rip), %rdx     # 0x76d92
movq %r14, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0xf90                  # imm = 0xF90
pushq %r10
callq 0x143da
addq $0x10, %rsp
xorl %ebx, %ebx
jmp 0x65050
movq %rbx, %rdi
callq 0x6966d
movq 0x8(%r15), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x11d42(%rip), %r10     # 0x76d70
leaq 0x11d5d(%rip), %rdx     # 0x76d92
movq %r14, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0xf9c                  # imm = 0xF9C
pushq %r10
callq 0x143da
addq $0x10, %rsp
xorl %r12d, %r12d
movq %r12, %rdi
callq 0x68d41
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x68d41
movq %r15, %rdi
movq %r14, %rsi
callq 0x69632
cmpl $0x0, (%r14)
jne 0x64f2d
movq %rax, %r12
movq 0x58(%r15), %r13
cmpq 0x60(%r15), %r13
jne 0x650b4
addq $0x20, %r13
movq 0x50(%r15), %rdi
movq %r13, %rsi
shlq $0x4, %rsi
callq 0x12210
testq %rax, %rax
je 0x65125
movq %rax, 0x50(%r15)
movq %r13, 0x60(%r15)
movq %rbx, %rbp
addq $0x8, %rbp
movq %rbp, %rdi
callq 0x14db1
movq %rax, (%rsp)
movq %rbp, %rdi
callq 0x14b57
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 0x6510f
movq %rax, %rdi
movq (%rsp), %rsi
movq %rcx, %r14
callq 0x12070
incq %rbp
movq %rbp, 0x58(%r15)
movq %r12, 0x8(%r14,%r13)
jmp 0x65050
leaq 0x11c5a(%rip), %rdx     # 0x76d70
movq %r14, %rdi
movl $0x1, %esi
movl $0xfbe, %ecx            # imm = 0xFBE
jmp 0x65139
leaq 0x11c44(%rip), %rdx     # 0x76d70
movq %r14, %rdi
movl $0x1, %esi
movl $0xfb3, %ecx            # imm = 0xFB3
callq 0x145a4
jmp 0x65053