// File: /workspace/github_c_makefile_star2_O2/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 0x12e0e
cmpl $0x0, (%r14)
jne 0x6626b
movq 0x10(%r12), %rdi
callq 0x12a25
cmpb $0x28, (%rax)
jne 0x66239
cmpb $0x0, 0x1(%rax)
je 0x6627f
movq 0x8(%r12), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xad17(%rip), %r10      # 0x70f64
leaq 0x765e(%rip), %rdx      # 0x6d8b2
pushq $0x1d
popq %rsi
movq %r14, %rdi
movq %rax, %rcx
pushq $0x42f                  # imm = 0x42F
pushq %r10
callq 0x140cd
popq %rax
popq %rcx
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 0x647a2
cmpl $0x0, (%r14)
jne 0x6626b
movq %rax, %rbx
cmpl $0x8, (%rax)
jne 0x6635c
movq 0x10(%r12), %rdi
callq 0x12a25
movq 0x10(%r12), %rsi
cmpl $0x2, (%rsi)
jne 0x66388
movzbl (%rax), %ecx
cmpl $0x29, %ecx
je 0x66382
cmpl $0x2c, %ecx
jne 0x66388
cmpb $0x0, 0x1(%rax)
jne 0x66388
movq %r12, %rdi
movq %r14, %rsi
callq 0x647a2
movq %rax, %r13
cmpl $0x0, (%r14)
jne 0x663bd
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x660a6
cmpl $0x0, (%r14)
jne 0x663bd
movl %eax, %ebp
movq 0x10(%r12), %rdi
callq 0x12a25
movq 0x10(%r12), %rsi
cmpl $0x2, (%rsi)
jne 0x66328
cmpb $0x29, (%rax)
jne 0x66328
cmpb $0x0, 0x1(%rax)
je 0x663d8
movq 0x8(%r12), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xac28(%rip), %r10      # 0x70f64
leaq 0x7a82(%rip), %rcx      # 0x6ddc5
pushq $0x16
popq %rsi
movq %r14, %rdi
movq %rax, %rdx
pushq $0x452                  # imm = 0x452
pushq %r10
callq 0x140cd
popq %rax
popq %rcx
jmp 0x663bd
movq 0x8(%r12), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0xabf5(%rip), %r8       # 0x70f64
pushq $0x4a
popq %rsi
movq %r14, %rdi
movl $0x439, %r9d            # imm = 0x439
callq 0x142c0
jmp 0x663ba
cmpb $0x0, 0x1(%rax)
je 0x663d2
movq 0x8(%r12), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0xabc8(%rip), %r10      # 0x70f64
leaq 0xac1a(%rip), %rdx      # 0x70fbd
pushq $0x1d
popq %rsi
movq %r14, %rdi
movq %rax, %rcx
pushq $0x441                  # imm = 0x441
pushq %r10
callq 0x140cd
popq %rax
popq %rcx
xorl %r13d, %r13d
movq %r13, %rdi
callq 0x63ee7
movq %rbx, %rdi
callq 0x63ee7
jmp 0x6626b
pushq $0x1
popq %rbp
xorl %r13d, %r13d
movq 0x8(%r12), %rdi
movq %r14, %rdx
callq 0x12e0e
cmpl $0x0, (%r14)
jne 0x663bd
movq %r13, %rdi
callq 0x63ee7
movl %ebp, (%r15)
jmp 0x6626d