// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/frontend/parser_string.c
// Function: subtilis_parser_mid_str
void subtilis_parser_mid_str(subtilis_parser_t *p, subtilis_token_t *t,
			     subtilis_error_t *err)
{
	size_t args;
	const char *tbuf;
	subtilis_exp_t *e[3];
	subtilis_exp_t *value;

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

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

	args = subtilis_var_bracketed_args_have_b(p, t, e, 3, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

	if (args == 0) {
		subtilis_error_set_string_expected(err, p->l->stream->name,
						   p->l->line);
		goto cleanup;
	}

	if (args == 1) {
		subtilis_error_set_numeric_exp_expected(err, p->l->stream->name,
							p->l->line);
		goto cleanup;
	}

	if (args == 2) {
		e[2] = subtilis_exp_new_int32(-1, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
	}

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

	value = subtilis_parser_expression(p, t, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if ((e[1]->type.type == SUBTILIS_TYPE_CONST_INTEGER) &&
	    (e[1]->exp.ir_op.integer == 0)) {
		subtilis_exp_delete(e[1]);
		subtilis_string_type_left(p, e[0], e[2], value, err);
		return;
	}

	subtilis_string_type_mid(p, e[0], e[1], e[2], value, err);

	return;

cleanup:
	subtilis_exp_delete(e[0]);
	subtilis_exp_delete(e[1]);
	subtilis_exp_delete(e[2]);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq (%rdi), %rdi
callq 0x12eda
cmpl $0x0, (%rbx)
je 0x2882c
addq $0x18, %rsp
jmp 0x2887e
movq %r15, %rdi
callq 0x12ad0
leaq 0x4b9d7(%rip), %rsi     # 0x74212
movq %rax, %rdi
callq 0x12160
testl %eax, %eax
je 0x28886
movq (%r14), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4b253(%rip), %rax     # 0x73aac
leaq 0x4b062(%rip), %rdx     # 0x738c2
leaq 0x4b58e(%rip), %rcx     # 0x73df5
movq %rbx, %rdi
movl $0x15, %esi
pushq $0x18e                  # imm = 0x18E
pushq %rax
callq 0x1442a
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rsp, %rdx
movl $0x3, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %r8
callq 0x1f290
cmpl $0x0, (%rbx)
jne 0x28826
movq %rax, %r12
movq (%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x12eda
cmpl $0x0, (%rbx)
jne 0x28981
cmpq $0x2, %r12
je 0x28913
cmpq $0x1, %r12
je 0x288ed
testq %r12, %r12
jne 0x2892a
movq (%r14), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x4b1cf(%rip), %r8      # 0x73aac
movq %rbx, %rdi
movl $0x49, %esi
movl $0x19c, %r9d            # imm = 0x19C
jmp 0x2890c
movq (%r14), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x4b1ae(%rip), %r8      # 0x73aac
movq %rbx, %rdi
movl $0x44, %esi
movl $0x1a2, %r9d            # imm = 0x1A2
callq 0x14618
jmp 0x28981
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbx, %rsi
callq 0x2bb29
movq %rax, 0x10(%rsp)
cmpl $0x0, (%rbx)
jne 0x28981
movq %r15, %rdi
callq 0x12ad0
movq %rax, %r12
cmpl $0x2, (%r15)
jne 0x2894e
leaq 0x4acc2(%rip), %rsi     # 0x73604
movq %r12, %rdi
callq 0x12160
testl %eax, %eax
je 0x289a3
movq (%r14), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4b14c(%rip), %rax     # 0x73aac
leaq 0x4b48e(%rip), %rcx     # 0x73df5
movq %rbx, %rdi
movl $0x14, %esi
movq %r12, %rdx
pushq $0x1af                  # imm = 0x1AF
pushq %rax
callq 0x1442a
addq $0x10, %rsp
movq (%rsp), %rdi
callq 0x2b4c3
movq 0x8(%rsp), %rdi
callq 0x2b4c3
movq 0x10(%rsp), %rdi
callq 0x2b4c3
jmp 0x28826
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x1eb88
cmpl $0x0, (%rbx)
jne 0x28981
movq %rax, %r15
movq 0x8(%rsp), %rdx
cmpl $0x1, (%rdx)
jne 0x289cc
cmpl $0x0, 0x148(%rdx)
je 0x289e8
movq (%rsp), %rsi
movq 0x10(%rsp), %rcx
movq %r14, %rdi
movq %r15, %r8
movq %rbx, %r9
callq 0x4acdc
jmp 0x28826
movq %rdx, %rdi
callq 0x2b4c3
movq (%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rcx
movq %rbx, %r8
callq 0x4ab47
jmp 0x28826