// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/arch/arm32/arm_expression.c
// Function: prv_mid_str
static subtilis_arm_exp_val_t *prv_mid_str(subtilis_arm_ass_context_t *c,
					   subtilis_error_t *err)
{
	const char *tbuf;
	int32_t string_len;
	const char *seed_string;
	int32_t start;
	subtilis_arm_exp_val_t *ret_val = NULL;
	subtilis_arm_exp_val_t *str = NULL;
	subtilis_arm_exp_val_t *count = 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;
	}

	str = subtilis_arm_exp_val_get(c, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if (str->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, ",")) {
		subtilis_error_set_expected(err, ",", tbuf, c->l->stream->name,
					    c->l->line);
		goto cleanup;
	}

	count = subtilis_arm_exp_val_get(c, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	start = prv_exp_to_int(c, count, err);
	subtilis_arm_exp_val_free(count);
	if (err->type != SUBTILIS_ERROR_OK)
		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, ",")) {
		count = subtilis_arm_exp_val_get(c, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		length = prv_exp_to_int(c, count, err);
		subtilis_arm_exp_val_free(count);
		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;

	string_len = subtilis_buffer_get_size(&str->val.buf) - 1;
	if ((string_len == 0) || (start < 0) || (length == 0)) {
		ret_val = subtilis_arm_exp_new_str_str("", err);
	} else {
		seed_string = subtilis_buffer_get_string(&str->val.buf);
		if (length < 0 || length >= (string_len - start)) {
			ret_val = subtilis_arm_exp_new_str_str(
			    &seed_string[start], err);
		} else {
			subtilis_buffer_delete(&str->val.buf, 0, start, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;
			if (start + length < string_len)
				subtilis_buffer_delete(
				    &str->val.buf, length,
				    string_len - (start + length), err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;
			subtilis_buffer_zero_terminate(&str->val.buf, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;

			ret_val = subtilis_arm_exp_new_str(&str->val.buf, err);
		}
	}

cleanup:

	subtilis_arm_exp_val_free(str);

	return ret_val;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movl $0xffffffff, -0x54(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0x133f0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x9da3e
movq $0x0, -0x8(%rbp)
jmp 0x9de96
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x12d70
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq 0xd842(%rip), %rsi      # 0xab29c
callq 0x12140
cmpl $0x0, %eax
je 0x9dab5
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0xce72(%rip), %rdx      # 0xaa902
leaq 0x10969(%rip), %rax     # 0xae400
movq %rax, (%rsp)
movl $0x4b6, 0x8(%rsp)       # imm = 0x4B6
callq 0x156d0
movq $0x0, -0x8(%rbp)
jmp 0x9de96
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x9b4f0
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x9dad4
jmp 0x9de85
movq -0x48(%rbp), %rax
cmpl $0x8, (%rax)
je 0x9db14
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x30(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x38(%rax), %ecx
movl $0x4a, %esi
leaq 0x108fc(%rip), %r8      # 0xae400
movl $0x4c0, %r9d            # imm = 0x4C0
callq 0x15930
jmp 0x9de85
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x12d70
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
cmpl $0x2, (%rax)
jne 0x9db47
movq -0x20(%rbp), %rdi
leaq 0xca6c(%rip), %rsi      # 0xaa5a9
callq 0x12140
cmpl $0x0, %eax
je 0x9db90
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0xca36(%rip), %rdx      # 0xaa5a9
leaq 0x10886(%rip), %rax     # 0xae400
movq %rax, (%rsp)
movl $0x4c7, 0x8(%rsp)       # imm = 0x4C7
callq 0x156d0
jmp 0x9de85
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x9b4f0
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x9dbaf
jmp 0x9de85
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x9e330
movl %eax, -0x34(%rbp)
movq -0x50(%rbp), %rdi
callq 0x9a4c0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x9dbda
jmp 0x9de85
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x12d70
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
cmpl $0x2, (%rax)
jne 0x9dc22
movq -0x20(%rbp), %rdi
leaq 0xcf4e(%rip), %rsi      # 0xaab51
callq 0x12140
cmpl $0x0, %eax
je 0x9dc6b
movq -0x20(%rbp), %rdi
leaq 0xc991(%rip), %rsi      # 0xaa5a9
callq 0x12140
cmpl $0x0, %eax
je 0x9dc6b
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x38(%rax), %r9d
movl $0x1d, %esi
leaq 0xcefe(%rip), %rdx      # 0xaab4c
leaq 0x107ab(%rip), %rax     # 0xae400
movq %rax, (%rsp)
movl $0x4d8, 0x8(%rsp)       # imm = 0x4D8
callq 0x156d0
jmp 0x9de85
movq -0x20(%rbp), %rdi
leaq 0xc933(%rip), %rsi      # 0xaa5a9
callq 0x12140
cmpl $0x0, %eax
jne 0x9dd4c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x9b4f0
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x9dca3
jmp 0x9de85
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x9e330
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rdi
callq 0x9a4c0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x9dcce
jmp 0x9de85
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x12d70
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
cmpl $0x2, (%rax)
jne 0x9dd01
movq -0x20(%rbp), %rdi
leaq 0xce5a(%rip), %rsi      # 0xaab51
callq 0x12140
cmpl $0x0, %eax
je 0x9dd4a
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x38(%rax), %r9d
movl $0x16, %esi
leaq 0xd549(%rip), %rcx      # 0xab276
leaq 0x106cc(%rip), %rax     # 0xae400
movq %rax, (%rsp)
movl $0x4ea, 0x8(%rsp)       # imm = 0x4EA
callq 0x156d0
jmp 0x9de85
jmp 0x9dd4c
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0x133f0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x9dd73
jmp 0x9de85
movq -0x48(%rbp), %rdi
addq $0x8, %rdi
callq 0x16270
subq $0x1, %rax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x9dd99
cmpl $0x0, -0x34(%rbp)
jl 0x9dd99
cmpl $0x0, -0x54(%rbp)
jne 0x9ddb2
movq -0x18(%rbp), %rsi
leaq 0xd4d2(%rip), %rdi      # 0xab276
callq 0x9a3f0
movq %rax, -0x40(%rbp)
jmp 0x9de83
movq -0x48(%rbp), %rdi
addq $0x8, %rdi
callq 0x16760
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x54(%rbp)
jl 0x9ddd6
movl -0x54(%rbp), %eax
movl -0x24(%rbp), %ecx
subl -0x34(%rbp), %ecx
cmpl %ecx, %eax
jl 0x9ddf3
movq -0x30(%rbp), %rdi
movslq -0x34(%rbp), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x9a3f0
movq %rax, -0x40(%rbp)
jmp 0x9de81
movq -0x48(%rbp), %rdi
addq $0x8, %rdi
movslq -0x34(%rbp), %rdx
movq -0x18(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
callq 0x16450
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x9de17
jmp 0x9de85
movl -0x34(%rbp), %eax
addl -0x54(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x9de45
movq -0x48(%rbp), %rdi
addq $0x8, %rdi
movslq -0x54(%rbp), %rsi
movl -0x24(%rbp), %eax
movl -0x34(%rbp), %ecx
addl -0x54(%rbp), %ecx
subl %ecx, %eax
movslq %eax, %rdx
movq -0x18(%rbp), %rcx
callq 0x16450
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x9de50
jmp 0x9de85
movq -0x48(%rbp), %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rsi
callq 0x16560
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x9de6c
jmp 0x9de85
movq -0x48(%rbp), %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rsi
callq 0x9a510
movq %rax, -0x40(%rbp)
jmp 0x9de83
jmp 0x9de85
movq -0x48(%rbp), %rdi
callq 0x9a4c0
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq