// File: /workspace/github_c_makefile_star2_O3/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 0x12edc
cmpl $0x0, (%rbx)
je 0x285e8
addq $0x18, %rsp
jmp 0x28632
movq %r15, %rdi
callq 0x12ad0
cmpb $0x28, (%rax)
jne 0x285fb
cmpb $0x0, 0x1(%rax)
je 0x2863a
movq (%r14), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4b4bd(%rip), %rax     # 0x73aca
leaq 0x4b2e2(%rip), %rdx     # 0x738f6
leaq 0x4b7fa(%rip), %rcx     # 0x73e15
movq %rbx, %rdi
movl $0x15, %esi
pushq $0x18e                  # imm = 0x18E
pushq %rax
callq 0x143da
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 0x1f31a
cmpl $0x0, (%rbx)
jne 0x285e2
movq %rax, %r12
movq (%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x12edc
cmpl $0x0, (%rbx)
jne 0x2872b
cmpq $0x2, %r12
je 0x286c7
cmpq $0x1, %r12
je 0x286a1
testq %r12, %r12
jne 0x286de
movq (%r14), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x4b439(%rip), %r8      # 0x73aca
movq %rbx, %rdi
movl $0x49, %esi
movl $0x19c, %r9d            # imm = 0x19C
jmp 0x286c0
movq (%r14), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x4b418(%rip), %r8      # 0x73aca
movq %rbx, %rdi
movl $0x44, %esi
movl $0x1a2, %r9d            # imm = 0x1A2
callq 0x145c8
jmp 0x2872b
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbx, %rsi
callq 0x2b7af
movq %rax, 0x10(%rsp)
cmpl $0x0, (%rbx)
jne 0x2872b
movq %r15, %rdi
callq 0x12ad0
cmpl $0x2, (%r15)
jne 0x286f7
cmpb $0x3d, (%rax)
jne 0x286f7
cmpb $0x0, 0x1(%rax)
je 0x2874d
movq (%r14), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x4b3c1(%rip), %r10     # 0x73aca
leaq 0x4b705(%rip), %rcx     # 0x73e15
movq %rbx, %rdi
movl $0x14, %esi
movq %rax, %rdx
pushq $0x1af                  # imm = 0x1AF
pushq %r10
callq 0x143da
addq $0x10, %rsp
movq (%rsp), %rdi
callq 0x2b166
movq 0x8(%rsp), %rdi
callq 0x2b166
movq 0x10(%rsp), %rdi
callq 0x2b166
jmp 0x285e2
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x1ec4c
cmpl $0x0, (%rbx)
jne 0x2872b
movq %rax, %r15
movq 0x8(%rsp), %rdx
cmpl $0x1, (%rdx)
jne 0x28776
cmpl $0x0, 0x148(%rdx)
je 0x28792
movq (%rsp), %rsi
movq 0x10(%rsp), %rcx
movq %r14, %rdi
movq %r15, %r8
movq %rbx, %r9
callq 0x4ac75
jmp 0x285e2
movq %rdx, %rdi
callq 0x2b166
movq (%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rcx
movq %rbx, %r8
callq 0x4aae0
jmp 0x285e2