// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/arch/arm32/arm_expression.c
// Function: prv_left_right
static subtilis_arm_exp_val_t *prv_left_right(subtilis_arm_ass_context_t *c,
					      int32_t *len,
					      subtilis_error_t *err)
{
	const char *tbuf;
	subtilis_arm_exp_val_t *val = NULL;
	subtilis_arm_exp_val_t *val2 = NULL;
	int32_t length = 1;

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

	tbuf = subtilis_token_get_text(c->t);
	if (strcmp(tbuf, "(")) {
		subtilis_error_set_expected(err, "( ", tbuf, c->l->stream->name,
					    c->l->line);
		return NULL;
	}

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

	if (val->type != SUBTILIS_ARM_EXP_TYPE_STRING) {
		subtilis_error_set_const_string_expected(
		    err, c->l->stream->name, c->l->line);
		goto cleanup;
	}

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

	if (!strcmp(tbuf, ",")) {
		val2 = subtilis_arm_exp_val_get(c, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		length = prv_exp_to_int(c, val2, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

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

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

	subtilis_arm_exp_val_free(val2);

	*len = length;
	return val;

cleanup:

	subtilis_arm_exp_val_free(val2);
	subtilis_arm_exp_val_free(val);

	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movq 0x8(%rdi), %rdi
movq 0x10(%r12), %rsi
callq 0x12eda
cmpl $0x0, (%r14)
jne 0x6b9f7
movq 0x10(%r12), %rdi
callq 0x12ad0
movq %rax, %rbx
leaq 0x8935(%rip), %rsi      # 0x74212
movq %rax, %rdi
callq 0x12160
testl %eax, %eax
je 0x6b923
movq 0x8(%r12), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0xb693(%rip), %rax      # 0x76f90
leaq 0x7fbe(%rip), %rdx      # 0x738c2
movq %r14, %rdi
movl $0x1d, %esi
movq %rbx, %rcx
pushq $0x42f                  # imm = 0x42F
pushq %rax
callq 0x1442a
addq $0x10, %rsp
jmp 0x6b9f7
movq %r12, %rdi
movq %r14, %rsi
callq 0x69a84
cmpl $0x0, (%r14)
jne 0x6b9f7
movq %rax, %rbx
cmpl $0x8, (%rax)
jne 0x6b9be
movq 0x10(%r12), %rdi
callq 0x12ad0
movq %rax, %r13
movq 0x10(%r12), %rax
cmpl $0x2, (%rax)
jne 0x6b987
leaq 0x7c3a(%rip), %rsi      # 0x73598
movq %r13, %rdi
callq 0x12160
testl %eax, %eax
je 0x6ba3c
movl %eax, %ebp
leaq 0x8176(%rip), %rsi      # 0x73aed
movq %r13, %rdi
callq 0x12160
testl %eax, %eax
je 0x6ba0b
movq 0x8(%r12), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0xb5f5(%rip), %rax      # 0x76f90
leaq 0xb647(%rip), %rdx      # 0x76fe9
movq %r14, %rdi
movl $0x1d, %esi
movq %r13, %rcx
pushq $0x441                  # imm = 0x441
pushq %rax
callq 0x1442a
addq $0x10, %rsp
jmp 0x6b9e4
movq 0x8(%r12), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0xb5bf(%rip), %r8       # 0x76f90
movq %r14, %rdi
movl $0x4a, %esi
movl $0x439, %r9d            # imm = 0x439
callq 0x14618
xorl %r13d, %r13d
movq %r13, %rdi
callq 0x69167
movq %rbx, %rdi
callq 0x69167
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %ebp, %ebp
je 0x6ba3c
movl $0x1, %ebp
xorl %r13d, %r13d
movq 0x8(%r12), %rdi
movq 0x10(%r12), %rsi
movq %r14, %rdx
callq 0x12eda
cmpl $0x0, (%r14)
jne 0x6b9e7
movq %r13, %rdi
callq 0x69167
movl %ebp, (%r15)
jmp 0x6b9f9
movq %r12, %rdi
movq %r14, %rsi
callq 0x69a84
movq %rax, %r13
cmpl $0x0, (%r14)
jne 0x6b9e7
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x6b731
cmpl $0x0, (%r14)
jne 0x6b9e7
movl %eax, %ebp
movq 0x10(%r12), %rdi
callq 0x12ad0
movq %rax, %rdx
movq 0x10(%r12), %rax
cmpl $0x2, (%rax)
jne 0x6ba9c
leaq 0x8069(%rip), %rsi      # 0x73aed
movq %rdx, %rdi
movq %rdx, (%rsp)
callq 0x12160
movq (%rsp), %rdx
testl %eax, %eax
je 0x6ba17
movq 0x8(%r12), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0xb4e0(%rip), %rax      # 0x76f90
leaq 0x833e(%rip), %rcx      # 0x73df5
movq %r14, %rdi
movl $0x16, %esi
pushq $0x452                  # imm = 0x452
pushq %rax
callq 0x1442a
addq $0x10, %rsp
jmp 0x6b9e7