// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_origin
void subtilis_riscos_arm_origin(subtilis_ir_section_t *s, size_t start,
				void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t dest;
	subtilis_arm_reg_t op2;
	subtilis_arm_instr_t *instr;
	subtilis_arm_data_instr_t *mov;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *origin = &s->ops[start]->op.instr;
	const size_t vdu = 256 + 0x20000;
	size_t i;

	/* read_mask = 0 */
	/* write_mask = 0 */
	subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_AL, vdu + 29, 0, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_riscos_handle_graphics_error(arm_s, s, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	for (i = 0; i < 2; i++) {
		dest = 0;
		op2 = subtilis_arm_ir_to_arm_reg(origin->operands[i].reg);

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

		/* OS_WriteC */
		/* read_mask = 0x1 = r0 */
		/* write_mask = 0 */
		subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_VC, 0 + 0x20000,
				     1, 0, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;

		instr = subtilis_arm_section_add_instr(
		    arm_s, SUBTILIS_ARM_INSTR_MOV, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		mov = &instr->operands.data;

		mov->status = false;
		mov->ccode = SUBTILIS_ARM_CCODE_VC;
		mov->dest = dest;
		mov->op2.type = SUBTILIS_ARM_OP2_SHIFTED;
		mov->op2.op.shift.type = SUBTILIS_ARM_SHIFT_LSR;
		mov->op2.op.shift.reg =
		    subtilis_arm_ir_to_arm_reg(origin->operands[i].reg);
		mov->op2.op.shift.shift_reg = false;
		mov->op2.op.shift.shift.integer = 8;

		/* OS_WriteC */
		/* read_mask = 0x1 = r0 */
		/* write_mask = 0 */
		subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_VC, 0 + 0x20000,
				     1, 0, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;

		subtilis_riscos_handle_graphics_error(arm_s, s, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq $0x8, %rax
movq %rax, -0x50(%rbp)
movq $0x20100, -0x58(%rbp)   # imm = 0x20100
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %r9
movl $0xe, %esi
movl $0x2011d, %edx          # imm = 0x2011D
xorl %r8d, %r8d
movl %r8d, %ecx
callq 0x71f20
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4bcb
jmp 0xa4d68
movq -0x48(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xa4260
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4bea
jmp 0xa4d68
movq $0x0, -0x60(%rbp)
cmpq $0x2, -0x60(%rbp)
jae 0xa4d68
movq $0x0, -0x28(%rbp)
movq -0x50(%rbp), %rax
movq -0x60(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdi
callq 0x6fe90
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movq -0x20(%rbp), %rax
movl $0xd, %esi
movl $0x7, %edx
xorl %ecx, %ecx
movq %rax, (%rsp)
callq 0x71fa0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4c4e
jmp 0xa4d68
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %r9
movl $0x7, %esi
movl $0x20000, %edx          # imm = 0x20000
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x71f20
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4c7b
jmp 0xa4d68
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0xd, %esi
callq 0x70b50
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4c9f
jmp 0xa4d68
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x40(%rbp), %rax
movl $0x7, (%rax)
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
movl $0x2, 0x18(%rax)
movq -0x40(%rbp), %rax
movl $0x2, 0x28(%rax)
movq -0x50(%rbp), %rax
movq -0x60(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdi
callq 0x6fe90
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x40(%rbp), %rax
movb $0x0, 0x38(%rax)
movq -0x40(%rbp), %rax
movl $0x8, 0x30(%rax)
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %r9
movl $0x7, %esi
movl $0x20000, %edx          # imm = 0x20000
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x71f20
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4d39
jmp 0xa4d68
movq -0x48(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xa4260
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4d55
jmp 0xa4d68
jmp 0xa4d57
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0xa4bf2
addq $0x70, %rsp
popq %rbp
retq
nop