// File: /workspace/github_c_makefile_star2_O3/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 0x12edc
cmpl $0x0, (%r14)
jne 0x6b492
movq 0x10(%r12), %rdi
callq 0x12ad0
cmpb $0x28, (%rax)
jne 0x6b45c
cmpb $0x0, 0x1(%rax)
je 0x6b4a6
movq 0x8(%r12), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xbb84(%rip), %r10      # 0x76ff4
leaq 0x847f(%rip), %rdx      # 0x738f6
movq %r14, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0x42f                  # imm = 0x42F
pushq %r10
callq 0x143da
addq $0x10, %rsp
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
movq %r14, %rsi
callq 0x69632
cmpl $0x0, (%r14)
jne 0x6b492
movq %rax, %rbx
cmpl $0x8, (%rax)
jne 0x6b587
movq 0x10(%r12), %rdi
callq 0x12ad0
movq 0x10(%r12), %rsi
cmpl $0x2, (%rsi)
jne 0x6b5b5
movzbl (%rax), %ecx
cmpl $0x29, %ecx
je 0x6b5af
cmpl $0x2c, %ecx
jne 0x6b5b5
cmpb $0x0, 0x1(%rax)
jne 0x6b5b5
movq %r12, %rdi
movq %r14, %rsi
callq 0x69632
movq %rax, %r13
cmpl $0x0, (%r14)
jne 0x6b5ee
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x6b2c1
cmpl $0x0, (%r14)
jne 0x6b5ee
movl %eax, %ebp
movq 0x10(%r12), %rdi
callq 0x12ad0
movq 0x10(%r12), %rsi
cmpl $0x2, (%rsi)
jne 0x6b54f
cmpb $0x29, (%rax)
jne 0x6b54f
cmpb $0x0, 0x1(%rax)
je 0x6b60b
movq 0x8(%r12), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xba91(%rip), %r10      # 0x76ff4
leaq 0x88ab(%rip), %rcx      # 0x73e15
movq %r14, %rdi
movl $0x16, %esi
movq %rax, %rdx
pushq $0x452                  # imm = 0x452
pushq %r10
callq 0x143da
addq $0x10, %rsp
jmp 0x6b5ee
movq 0x8(%r12), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0xba5a(%rip), %r8       # 0x76ff4
movq %r14, %rdi
movl $0x4a, %esi
movl $0x439, %r9d            # imm = 0x439
callq 0x145c8
jmp 0x6b5eb
cmpb $0x0, 0x1(%rax)
je 0x6b603
movq 0x8(%r12), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xba2b(%rip), %r10      # 0x76ff4
leaq 0xba7d(%rip), %rdx      # 0x7704d
movq %r14, %rdi
movl $0x1d, %esi
movq %rax, %rcx
pushq $0x441                  # imm = 0x441
pushq %r10
callq 0x143da
addq $0x10, %rsp
xorl %r13d, %r13d
movq %r13, %rdi
callq 0x68d41
movq %rbx, %rdi
callq 0x68d41
jmp 0x6b492
movl $0x1, %ebp
xorl %r13d, %r13d
movq 0x8(%r12), %rdi
movq %r14, %rdx
callq 0x12edc
cmpl $0x0, (%r14)
jne 0x6b5ee
movq %r13, %rdi
callq 0x68d41
movl %ebp, (%r15)
jmp 0x6b494