// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/string_type.c
// Function: prv_right_const
static subtilis_exp_t *prv_right_const(subtilis_parser_t *p,
				       const subtilis_buffer_t *str,
				       size_t size_reg, subtilis_error_t *err)
{
	size_t id;
	size_t ptr;
	size_t src_reg;
	subtilis_ir_operand_t op0;
	subtilis_ir_operand_t op1;
	const subtilis_symbol_t *s;
	subtilis_ir_operand_t zero_len;
	subtilis_ir_operand_t gt_zero;
	subtilis_ir_operand_t getp;
	char *tmp_name = NULL;
	size_t buf_size = subtilis_buffer_get_size(str) - 1;

	zero_len.label = subtilis_ir_section_new_label(p->current);
	gt_zero.label = subtilis_ir_section_new_label(p->current);
	getp.label = subtilis_ir_section_new_label(p->current);

	id = prv_left_right_const(p, str, size_reg, &s, &tmp_name, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return NULL;

	op1.reg = size_reg;
	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  op1, gt_zero, zero_len, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	subtilis_reference_type_set_size(p, SUBTILIS_IR_REG_LOCAL, s->loc,
					 size_reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_no_reg(p->current, SUBTILIS_OP_INSTR_JMP,
					     getp, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	op1.integer = (int32_t)id;
	src_reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_LCA, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	op0.reg = src_reg;
	op1.reg = size_reg;
	src_reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_SUB_I32, op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_string_init_from_lca(p, SUBTILIS_IR_REG_LOCAL, s->loc, src_reg,
				      size_reg, true, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	ptr = subtilis_reference_get_pointer(p, SUBTILIS_IR_REG_LOCAL, s->loc,
					     err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	return subtilis_exp_new_tmp_var(&subtilis_type_string, ptr, tmp_name,
					err);

cleanup:
	free(tmp_name);
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x18(%rbp), %rdi
callq 0x16270
subq $0x1, %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %r9
leaq -0x58(%rbp), %rcx
leaq -0x78(%rbp), %r8
callq 0x6b450
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6874e
movq $0x0, -0x8(%rbp)
jmp 0x68980
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r9
movq -0x50(%rbp), %rdx
movq -0x68(%rbp), %rcx
movq -0x60(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68786
jmp 0x6896f
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x60(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x687a9
jmp 0x6896f
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rax
movq (%rax), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movl $0x2, %esi
callq 0x6dc50
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x687d4
jmp 0x6896f
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rcx
movq -0x70(%rbp), %rdx
movl $0x45, %esi
callq 0x38540
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x687fc
jmp 0x6896f
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x68(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6881f
jmp 0x6896f
movq -0x30(%rbp), %rax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rcx
movq -0x50(%rbp), %rdx
movl $0x7d, %esi
callq 0x38490
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68852
jmp 0x6896f
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x80(%rbp), %rax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x9, %esi
callq 0x38230
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68891
jmp 0x6896f
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x2, %esi
callq 0x38230
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x688d1
jmp 0x6896f
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rax
movq (%rax), %rdx
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %r8
movq -0x28(%rbp), %rax
movl $0x2, %esi
movl $0x1, %r9d
movq %rax, (%rsp)
callq 0x66160
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68907
jmp 0x6896f
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x70(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x68927
jmp 0x6896f
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rax
movq (%rax), %rdx
movq -0x28(%rbp), %rcx
movl $0x2, %esi
callq 0x6d920
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6894f
jmp 0x6896f
movq -0x38(%rbp), %rax
movl %eax, %esi
movq -0x78(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq 0x431fc(%rip), %rdi     # 0xabb60
callq 0x375f0
movq %rax, -0x8(%rbp)
jmp 0x68980
movq -0x78(%rbp), %rdi
callq 0x12290
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)