// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: prv_deref
static void prv_deref(subtilis_ir_section_t *s, subtilis_arm_section_t *arm_s,
		      subtilis_error_t *err)
{
	size_t label;
	subtilis_arm_instr_t *instr;
	subtilis_arm_br_instr_t *br;
	subtilis_arm_reg_t ptr = 0;
	subtilis_arm_reg_t block = 2;
	subtilis_arm_reg_t count = 3;

	/*
	 * Subtract 8 from the memory address provided by program
	 */

	label = arm_s->label_counter++;

	subtilis_arm_add_sub_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, block,
				 ptr, 8, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_LDR,
				   SUBTILIS_ARM_CCODE_AL, count, block, 0,
				   false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_sub_imm(arm_s, SUBTILIS_ARM_CCODE_AL, true, count,
				 count, 1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_STR,
				   SUBTILIS_ARM_CCODE_AL, count, block, 0,
				   false, err);

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_B, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	br = &instr->operands.br;
	br->ccode = SUBTILIS_ARM_CCODE_NE;
	br->link = false;
	br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
	br->target.label = label;

	prv_load_heap_pointer(arm_s, ptr, 1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	/*
	 * R1 - contains the start of the heap
	 * R2 - block contains the start of the block
	 */

	subtilis_arm_heap_free(arm_s, 1, 2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_section_add_label(arm_s, label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 15, 14,
				 err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x2, -0x40(%rbp)
movq $0x3, -0x48(%rbp)
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x10(%rcx)
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %r9
movq -0x38(%rbp), %r10
movq -0x18(%rbp), %rax
movl $0x2, %esi
movl $0x4, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
movq %r10, (%rsp)
movl $0x8, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x71640
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa8b29
jmp 0xa8cbd
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %r8
movq -0x18(%rbp), %rax
movl $0x12, %esi
movl $0xe, %edx
xorl %r9d, %r9d
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x72030
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa8b65
jmp 0xa8cbd
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %r9
movq -0x48(%rbp), %r10
movq -0x18(%rbp), %rax
movl $0x2, %esi
movl $0x4, %edx
movl $0xe, %ecx
movl $0x1, %r8d
movq %r10, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x71640
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa8bae
jmp 0xa8cbd
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %r8
movq -0x18(%rbp), %rax
movl $0x13, %esi
movl $0xe, %edx
xorl %r9d, %r9d
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x72030
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x16, %esi
callq 0x70b50
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa8c00
jmp 0xa8cbd
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl $0x1, (%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x30(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x18(%rbp), %rcx
movl $0x1, %edx
callq 0xa6830
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa8c56
jmp 0xa8cbd
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x1, %esi
movl $0x2, %edx
callq 0x908d0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa8c78
jmp 0xa8cbd
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x70850
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa8c94
jmp 0xa8cbd
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movl $0xf, %r8d
movl $0xe, %r9d
movq %rax, (%rsp)
callq 0x71fa0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)