// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/backends/riscos/riscos_arm2.c
// Function: prv_do_tint
static void prv_do_tint(subtilis_arm_section_t *arm_s, subtilis_arm_reg_t col,
			subtilis_arm_reg_t tint, uint32_t add,
			subtilis_error_t *err)
{
	size_t i;
	subtilis_arm_instr_t *instr;
	subtilis_arm_data_instr_t *datai;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_MOV, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	datai = &instr->operands.data;
	datai->status = false;
	datai->ccode = SUBTILIS_ARM_CCODE_VC;
	datai->dest = 0;
	datai->op2.type = SUBTILIS_ARM_OP2_SHIFTED;
	datai->op2.op.shift.reg = col;
	datai->op2.op.shift.shift_reg = false;
	datai->op2.op.shift.shift.integer = 7;
	datai->op2.op.shift.type = SUBTILIS_ARM_SHIFT_LSR;

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

	if (add != 0) {
		subtilis_arm_add_data_imm(arm_s, SUBTILIS_ARM_INSTR_ADD,
					  SUBTILIS_ARM_CCODE_VC, false, 0, 0,
					  add, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	/* read_mask = 0 */
	/* write_mask = 0 */
	subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_VC, 256 + 23 + 0x20000,
			     0, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	/* read_mask = 0 */
	/* write_mask = 0 */
	subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_VC, 256 + 17 + 0x20000,
			     0, 0, 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_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_VC, false, 0, tint,
				 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;

	for (i = 0; i < 6; i++) {
		subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_VC,
				     256 + 0x20000, 0, 0, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %rbx
movl %ecx, %r12d
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r14
pushq $0xd
popq %rsi
movq %r8, %rdx
callq 0x4c92b
cmpl $0x0, (%rbx)
jne 0x6880f
xorl %ecx, %ecx
movb %cl, 0xc(%rax)
pushq $0x7
popq %rdx
movl %edx, 0x8(%rax)
andq $0x0, 0x10(%rax)
pushq $0x2
popq %rsi
movl %esi, 0x20(%rax)
movq %r13, 0x28(%rax)
movb %cl, 0x40(%rax)
movl %edx, 0x38(%rax)
movl %esi, 0x30(%rax)
movq %r14, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq $0x1
callq 0x4d357
popq %rax
popq %rcx
cmpl $0x0, (%rbx)
je 0x6881e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r12d, %r12d
je 0x68843
pushq $0x4
popq %rsi
pushq $0x7
popq %rdx
movq %r14, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq %r12
callq 0x4d357
popq %rax
popq %rcx
cmpl $0x0, (%rbx)
jne 0x6880f
pushq $0x7
popq %rsi
movl $0x20117, %edx          # imm = 0x20117
movq %r14, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x4d4d9
cmpl $0x0, (%rbx)
jne 0x6880f
pushq $0x7
popq %rsi
movl $0x20111, %edx          # imm = 0x20111
movq %r14, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x4d4d9
cmpl $0x0, (%rbx)
jne 0x6880f
pushq $0x7
popq %rsi
pushq $0x1
popq %rcx
movl $0x20000, %edx          # imm = 0x20000
movq %r14, %rdi
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x4d4d9
cmpl $0x0, (%rbx)
jne 0x6880f
subq $0x8, %rsp
pushq $0xd
popq %rsi
pushq $0x7
popq %rdx
movq %r14, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
pushq %rbx
callq 0x4d518
popq %rax
popq %rcx
cmpl $0x0, (%rbx)
jne 0x6880f
pushq $0x7
popq %rsi
pushq $0x1
popq %rcx
movl $0x20000, %edx          # imm = 0x20000
movq %r14, %rdi
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x4d4d9
cmpl $0x0, (%rbx)
jne 0x6880f
pushq $0x7
popq %r15
pushq $0x7
popq %rbp
decq %r15
je 0x6880f
movl $0x20100, %edx          # imm = 0x20100
movq %r14, %rdi
movl %ebp, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x4d4d9
cmpl $0x0, (%rbx)
je 0x688ee
jmp 0x6880f