// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_at
void subtilis_riscos_arm_at(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_section_t *arm_s = user_data;
	subtilis_ir_inst_t *at = &s->ops[start]->op.instr;
	const size_t os_tab = 256 + 31 + 0x20000;

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

	dest = 0;
	op2 = subtilis_arm_ir_to_arm_reg(at->operands[0].reg);

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, 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;

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

	dest = 0;
	op2 = subtilis_arm_ir_to_arm_reg(at->operands[1].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;
	subtilis_riscos_handle_graphics_error(arm_s, s, err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
movq $0x2011f, -0x48(%rbp)   # imm = 0x2011F
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %r9
movl $0xe, %esi
movl $0x2011f, %edx          # imm = 0x2011F
xorl %r8d, %r8d
movl %r8d, %ecx
callq 0x71f20
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa488b
jmp 0xa49a7
movq $0x0, -0x28(%rbp)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x6fe90
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movq -0x20(%rbp), %rax
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %rax, (%rsp)
callq 0x71fa0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa48d7
jmp 0xa49a7
movq -0x38(%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 0xa4904
jmp 0xa49a7
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xa4260
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa4923
jmp 0xa49a7
movq $0x0, -0x28(%rbp)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x6fe90
movq %rax, -0x30(%rbp)
movq -0x38(%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 0xa496c
jmp 0xa49a7
movq -0x38(%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 0xa4996
jmp 0xa49a7
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xa4260
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)