// File: /workspace/github_c_makefile_star2_O2/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 0x12e0e
cmpl $0x0, (%rbx)
je 0x273f0
addq $0x18, %rsp
jmp 0x27438
movq %r15, %rdi
callq 0x12a25
cmpb $0x28, (%rax)
jne 0x27403
cmpb $0x0, 0x1(%rax)
je 0x27440
movq (%r14), %rax
movq 0x30(%rax), %r8
movl 0x38(%rax), %r9d
leaq 0x4666d(%rip), %rax     # 0x6da82
leaq 0x46496(%rip), %rdx     # 0x6d8b2
leaq 0x469a2(%rip), %rcx     # 0x6ddc5
pushq $0x15
popq %rsi
movq %rbx, %rdi
pushq $0x18e                  # imm = 0x18E
pushq %rax
callq 0x140cd
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rsp, %rdx
pushq $0x3
popq %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %r8
callq 0x1e658
cmpl $0x0, (%rbx)
jne 0x273ea
movq %rax, %r12
movq (%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x12e0e
cmpl $0x0, (%rbx)
jne 0x27525
cmpq $0x2, %r12
je 0x274c7
cmpq $0x1, %r12
je 0x274a3
testq %r12, %r12
jne 0x274dc
movq (%r14), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x465ed(%rip), %r8      # 0x6da82
pushq $0x49
popq %rsi
movq %rbx, %rdi
movl $0x19c, %r9d            # imm = 0x19C
jmp 0x274c0
movq (%r14), %rax
movq 0x30(%rax), %rdx
movl 0x38(%rax), %ecx
leaq 0x465ce(%rip), %r8      # 0x6da82
pushq $0x44
popq %rsi
movq %rbx, %rdi
movl $0x1a2, %r9d            # imm = 0x1A2
callq 0x142c0
jmp 0x27525
pushq $-0x1
popq %rdi
movq %rbx, %rsi
callq 0x2a369
movq %rax, 0x10(%rsp)
cmpl $0x0, (%rbx)
jne 0x27525
movq %r15, %rdi
callq 0x12a25
cmpl $0x2, (%r15)
jne 0x274f5
cmpb $0x3d, (%rax)
jne 0x274f5
cmpb $0x0, 0x1(%rax)
je 0x27547
movq (%r14), %rcx
movq 0x30(%rcx), %r8
movl 0x38(%rcx), %r9d
leaq 0x4657b(%rip), %r10     # 0x6da82
leaq 0x468b7(%rip), %rcx     # 0x6ddc5
pushq $0x14
popq %rsi
movq %rbx, %rdi
movq %rax, %rdx
pushq $0x1af                  # imm = 0x1AF
pushq %r10
callq 0x140cd
popq %rax
popq %rcx
movq (%rsp), %rdi
callq 0x29d88
movq 0x8(%rsp), %rdi
callq 0x29d88
movq 0x10(%rsp), %rdi
callq 0x29d88
jmp 0x273ea
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x1dfd5
cmpl $0x0, (%rbx)
jne 0x27525
movq %rax, %r15
movq 0x8(%rsp), %rdx
cmpl $0x1, (%rdx)
jne 0x27570
cmpl $0x0, 0x148(%rdx)
je 0x2758c
movq (%rsp), %rsi
movq 0x10(%rsp), %rcx
movq %r14, %rdi
movq %r15, %r8
movq %rbx, %r9
callq 0x48226
jmp 0x273ea
movq %rdx, %rdi
callq 0x29d88
movq (%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rcx
movq %rbx, %r8
callq 0x48099
jmp 0x273ea