// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x133f0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x331c6
jmp 0x33424
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x780be(%rip), %rsi     # 0xab29c
callq 0x12140
cmpl $0x0, %eax
je 0x33232
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x15, %esi
leaq 0x776f4(%rip), %rdx     # 0xaa902
leaq 0x78061(%rip), %rcx     # 0xab276
leaq 0x778f4(%rip), %rax     # 0xaab10
movq %rax, (%rsp)
movl $0x18e, 0x8(%rsp)       # imm = 0x18E
callq 0x156d0
jmp 0x33424
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x40(%rbp), %rdx
movq -0x18(%rbp), %r8
movl $0x3, %ecx
callq 0x255b0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x3325e
jmp 0x33424
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x133f0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x33280
jmp 0x33409
cmpq $0x0, -0x20(%rbp)
jne 0x332bc
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %ecx
movl $0x49, %esi
leaq 0x77864(%rip), %r8      # 0xaab10
movl $0x19c, %r9d            # imm = 0x19C
callq 0x15930
jmp 0x33409
cmpq $0x1, -0x20(%rbp)
jne 0x332f8
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %ecx
movl $0x44, %esi
leaq 0x77828(%rip), %r8      # 0xaab10
movl $0x1a2, %r9d            # imm = 0x1A2
callq 0x15930
jmp 0x33409
cmpq $0x2, -0x20(%rbp)
jne 0x33321
movq -0x18(%rbp), %rsi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x37800
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x3331f
jmp 0x33409
jmp 0x33321
movq -0x10(%rbp), %rdi
callq 0x12d70
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x3334c
movq -0x28(%rbp), %rdi
leaq 0x772d2(%rip), %rsi     # 0xaa614
callq 0x12140
cmpl $0x0, %eax
je 0x33390
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %r8
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl 0x38(%rax), %r9d
movl $0x14, %esi
leaq 0x77f00(%rip), %rcx     # 0xab276
leaq 0x77793(%rip), %rax     # 0xaab10
movq %rax, (%rsp)
movl $0x1af, 0x8(%rsp)       # imm = 0x1AF
callq 0x156d0
jmp 0x33409
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x24a20
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x333b0
jmp 0x33409
movq -0x38(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x333ea
movq -0x38(%rbp), %rax
cmpl $0x0, 0x148(%rax)
jne 0x333ea
movq -0x38(%rbp), %rdi
callq 0x36ee0
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %r8
callq 0x69650
jmp 0x33424
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %r8
movq -0x18(%rbp), %r9
callq 0x698d0
jmp 0x33424
movq -0x40(%rbp), %rdi
callq 0x36ee0
movq -0x38(%rbp), %rdi
callq 0x36ee0
movq -0x30(%rbp), %rdi
callq 0x36ee0
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)