// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_get_to
void subtilis_riscos_arm_get_to(subtilis_ir_section_t *s, size_t start,
				void *user_data, subtilis_error_t *err)
{
	size_t label;
	subtilis_arm_reg_t one;
	subtilis_arm_br_instr_t *br;
	subtilis_arm_instr_t *instr;
	subtilis_arm_data_instr_t *datai;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *getto = &s->ops[start]->op.instr;
	size_t ir_dest = getto->operands[0].reg;
	subtilis_arm_reg_t dest = subtilis_arm_ir_to_arm_reg(ir_dest);
	size_t ir_op1 = getto->operands[1].reg;
	subtilis_arm_reg_t op1 = subtilis_arm_ir_to_arm_reg(ir_op1);

	subtilis_arm_add_mov_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, 0, 129,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_data_imm(arm_s, SUBTILIS_ARM_INSTR_AND,
				  SUBTILIS_ARM_CCODE_AL, false, 1, op1, 0xff,
				  err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, 2, 0xff,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_AND, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	datai = &instr->operands.data;
	datai->status = false;
	datai->ccode = SUBTILIS_ARM_CCODE_AL;
	datai->dest = 2;
	datai->op1 = 2;
	datai->op2.type = SUBTILIS_ARM_OP2_SHIFTED;
	datai->op2.op.shift.shift_reg = false;
	datai->op2.op.shift.reg = op1;
	datai->op2.op.shift.type = SUBTILIS_ARM_SHIFT_LSR;
	datai->op2.op.shift.shift.integer = 8;

	/* OS_Byte */
	/* read_mask = 7 = r0, r1, r2  */
	/* write_mask = 6 = r1, r2 */
	subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_AL, 0x6 + 0x20000, 7, 6,
			     err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	one = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	subtilis_arm_gen_sete_load_reg(arm_s, s, SUBTILIS_ARM_CCODE_VS, one,
				       err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	label = arm_s->label_counter++;
	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_VS;
	br->link = false;
	br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
	br->target.label = label;

	subtilis_arm_add_cmp_imm(arm_s, SUBTILIS_ARM_INSTR_CMP,
				 SUBTILIS_ARM_CCODE_AL, 2, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_EQ, false, dest, 1,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mvn_imm(arm_s, SUBTILIS_ARM_CCODE_NE, false, dest, 0,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_section_add_label(arm_s, label, err);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r12
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r13
movq 0x10(%r13), %rdi
callq 0x4c214
movq %rax, %r15
movq 0x18(%r13), %rdi
callq 0x4c214
movq %rax, %r13
pushq $0xd
popq %rsi
pushq $0xf
popq %rdx
pushq $0xe
popq %rcx
movq %r14, %rdi
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq $0x81
callq 0x4d213
popq %rax
popq %rcx
cmpl $0x0, (%rbx)
jne 0x6a264
pushq $0xe
popq %rdx
pushq $0x1
popq %r8
movq %r14, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
movq %r13, %r9
pushq %rbx
pushq $0xff
callq 0x4d357
popq %rax
popq %rcx
cmpl $0x0, (%rbx)
jne 0x6a264
pushq $0xd
popq %rsi
pushq $0xf
popq %rdx
pushq $0xe
popq %rcx
pushq $0x2
popq %rbp
movq %r14, %rdi
xorl %r8d, %r8d
movq %rbp, %r9
pushq %rbx
pushq $0xff
callq 0x4d213
popq %rax
popq %rcx
cmpl $0x0, (%rbx)
jne 0x6a264
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x4c92b
cmpl $0x0, (%rbx)
jne 0x6a264
xorl %ecx, %ecx
movb %cl, 0xc(%rax)
movl $0xe, 0x8(%rax)
movq %rbp, 0x10(%rax)
movq %rbp, 0x18(%rax)
pushq $0x2
popq %rdx
movl %edx, 0x20(%rax)
movb %cl, 0x40(%rax)
movq %r13, 0x28(%rax)
movl %edx, 0x30(%rax)
movl $0x8, 0x38(%rax)
pushq $0xe
popq %rsi
pushq $0x7
popq %rcx
pushq $0x6
popq %r8
movl $0x20006, %edx          # imm = 0x20006
movq %r14, %rdi
movq %rbx, %r9
callq 0x4d4d9
cmpl $0x0, (%rbx)
jne 0x6a264
movq (%r14), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4c214
pushq $0x6
popq %rdx
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rcx
movq %rbx, %r8
callq 0x4f21a
cmpl $0x0, (%rbx)
jne 0x6a264
movq 0x10(%r14), %r12
leaq 0x1(%r12), %rax
movq %rax, 0x10(%r14)
pushq $0x16
popq %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x4c92b
cmpl $0x0, (%rbx)
jne 0x6a264
movl $0x6, 0x8(%rax)
movb $0x0, 0xc(%rax)
andl $0x0, 0x10(%rax)
movq %r12, 0x18(%rax)
pushq $0xa
popq %rsi
pushq $0xe
popq %rdx
pushq $0x2
popq %rcx
movq %r14, %rdi
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x4d87e
cmpl $0x0, (%rbx)
jne 0x6a264
subq $0x8, %rsp
pushq $0xd
popq %rsi
pushq $0x1
popq %r9
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r15, %r8
pushq %rbx
callq 0x4d518
popq %rax
popq %rcx
cmpl $0x0, (%rbx)
jne 0x6a264
subq $0x10, %rsp
movq %rbx, 0x8(%rsp)
andl $0x0, (%rsp)
pushq $0xf
popq %rsi
pushq $0xd
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rdi
xorl %r8d, %r8d
movq %r15, %r9
callq 0x4d213
popq %rax
popq %rcx
cmpl $0x0, (%rbx)
je 0x6a273
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4c77f