// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/frontend/string_type.c
// Function: prv_left_right_const
static size_t prv_left_right_const(subtilis_parser_t *p,
				   const subtilis_buffer_t *str,
				   size_t size_reg,
				   const subtilis_symbol_t **sym,
				   char **tmp_name, subtilis_error_t *err)
{
	subtilis_ir_operand_t less_zero;
	subtilis_ir_operand_t gt_len;
	subtilis_ir_operand_t condee;
	subtilis_ir_operand_t op0;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t full_string;
	subtilis_ir_operand_t partial;
	const subtilis_symbol_t *s;
	size_t id;
	char *tmp_name_local = NULL;
	size_t buf_size = subtilis_buffer_get_size(str) - 1;

	full_string.label = subtilis_ir_section_new_label(p->current);
	partial.label = subtilis_ir_section_new_label(p->current);

	s = subtilis_symbol_table_insert_tmp(p->local_st, &subtilis_type_string,
					     &tmp_name_local, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op0.reg = size_reg;
	op1.integer = 0;
	less_zero.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LTI_I32, op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op1.integer = buf_size;
	gt_len.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_GTEI_I32, op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_OR_I32, less_zero, gt_len, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  condee, full_string, partial, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, full_string.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op1.integer = buf_size;
	subtilis_ir_section_add_instr_no_reg2(
	    p->current, SUBTILIS_OP_INSTR_MOVI_I32, op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, partial.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	id = prv_add_string_constant(p, subtilis_buffer_get_string(str),
				     buf_size, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	*sym = s;
	*tmp_name = tmp_name_local;
	return id;

cleanup:

	free(tmp_name_local);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r15
movq %r8, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r12
leaq 0x10(%rsp), %rbp
andq $0x0, (%rbp)
movq %rsi, %rdi
callq 0x14804
movq %rax, %rbx
movq 0x48(%r12), %rdi
callq 0x2b774
movq %rax, 0x8(%rsp)
movq 0x48(%r12), %rdi
callq 0x2b774
movq %rax, (%rsp)
movq 0x68(%r12), %rdi
leaq 0x25664(%rip), %rsi     # 0x6eb58
movq %rbp, %rdx
movq %r15, %rcx
callq 0x2cee3
movq %rax, 0x20(%rsp)
cmpl $0x0, (%r15)
jne 0x49608
movq 0x48(%r12), %rdi
pushq $0x3d
popq %rsi
movq %r14, %rdx
xorl %ecx, %ecx
movq %r15, %r8
callq 0x2a819
cmpl $0x0, (%r15)
jne 0x49608
decq %rbx
movq 0x48(%r12), %rdi
movq %rbx, 0x18(%rsp)
movl %ebx, %ebx
pushq $0x41
popq %rsi
movq %rax, %rbp
movq %r14, %rdx
movq %rbx, %rcx
movq %r15, %r8
callq 0x2a819
cmpl $0x0, (%r15)
jne 0x49608
movq 0x48(%r12), %rdi
pushq $0x26
popq %rsi
movq %rbp, %rdx
movq %rax, %rcx
movq %r15, %r8
callq 0x2a819
cmpl $0x0, (%r15)
jne 0x49608
movq 0x48(%r12), %rdi
pushq $0x43
popq %rsi
movq %rax, %rdx
movq 0x8(%rsp), %rcx
movq (%rsp), %r8
movq %r15, %r9
callq 0x2a8c1
cmpl $0x0, (%r15)
jne 0x49608
movq 0x48(%r12), %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x2b781
cmpl $0x0, (%r15)
jne 0x49608
movq 0x48(%r12), %rdi
pushq $0x1b
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
movq %r15, %r8
callq 0x2a9a4
cmpl $0x0, (%r15)
jne 0x49608
movq 0x48(%r12), %rdi
movq (%rsp), %rsi
movq %r15, %rdx
callq 0x2b781
cmpl $0x0, (%r15)
jne 0x49608
movq %r13, %rdi
callq 0x14a53
movq %r12, %rdi
movq %rax, %rsi
movq 0x18(%rsp), %rdx
movq %r15, %rcx
callq 0x45901
cmpl $0x0, (%r15)
je 0x49623
movq 0x10(%rsp), %rdi
callq 0x122c0
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%rsp), %rcx
movq 0x20(%rsp), %rdx
movq %rdx, (%rcx)
movq 0x10(%rsp), %rcx
movq 0x30(%rsp), %rdx
movq %rcx, (%rdx)
jmp 0x49614