// File: /workspace/github_c_makefile_star2_O1/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
movq $0x0, (%rbp)
movq %rsi, %rdi
callq 0x14ba1
movq %rax, %rbx
movq 0x48(%r12), %rdi
callq 0x2d00a
movq %rax, 0x8(%rsp)
movq 0x48(%r12), %rdi
callq 0x2d00a
movq %rax, (%rsp)
movq 0x68(%r12), %rdi
leaq 0x28b38(%rip), %rsi     # 0x74b88
movq %rbp, %rdx
movq %r15, %rcx
callq 0x2ea12
movq %rax, 0x20(%rsp)
cmpl $0x0, (%r15)
jne 0x4c16e
movq 0x48(%r12), %rdi
movl $0x3d, %esi
movq %r14, %rdx
xorl %ecx, %ecx
movq %r15, %r8
callq 0x2c00f
cmpl $0x0, (%r15)
jne 0x4c16e
decq %rbx
movq 0x48(%r12), %rdi
movq %rbx, 0x18(%rsp)
movl %ebx, %ebx
movl $0x41, %esi
movq %rax, %rbp
movq %r14, %rdx
movq %rbx, %rcx
movq %r15, %r8
callq 0x2c00f
cmpl $0x0, (%r15)
jne 0x4c16e
movq 0x48(%r12), %rdi
movl $0x26, %esi
movq %rbp, %rdx
movq %rax, %rcx
movq %r15, %r8
callq 0x2c00f
cmpl $0x0, (%r15)
jne 0x4c16e
movq 0x48(%r12), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq 0x8(%rsp), %rcx
movq (%rsp), %r8
movq %r15, %r9
callq 0x2c0c2
cmpl $0x0, (%r15)
jne 0x4c16e
movq 0x48(%r12), %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
callq 0x2d017
cmpl $0x0, (%r15)
jne 0x4c16e
movq 0x48(%r12), %rdi
movl $0x1b, %esi
movq %r14, %rdx
movq %rbx, %rcx
movq %r15, %r8
callq 0x2c1ac
cmpl $0x0, (%r15)
jne 0x4c16e
movq 0x48(%r12), %rdi
movq (%rsp), %rsi
movq %r15, %rdx
callq 0x2d017
cmpl $0x0, (%r15)
jne 0x4c16e
movq %r13, %rdi
callq 0x14dfb
movq %r12, %rdi
movq %rax, %rsi
movq 0x18(%rsp), %rdx
movq %r15, %rcx
callq 0x4829f
cmpl $0x0, (%r15)
je 0x4c189
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 0x4c17a