// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, %rbx
movl %ecx, %r12d
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r14
movl $0xd, %esi
movq %r8, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x6dce5
xorl %ecx, %ecx
movb %cl, 0xc(%rax)
movl $0x7, %edx
movl %edx, 0x8(%rax)
movq $0x0, 0x10(%rax)
movl $0x2, %esi
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 0x50297
addq $0x10, %rsp
cmpl $0x0, (%rbx)
je 0x6dcef
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
testl %r12d, %r12d
je 0x6dd1a
movq %r14, %rdi
movl $0x4, %esi
movl $0x7, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq %r12
callq 0x50297
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6dce5
movl $0x20117, %edx          # imm = 0x20117
movq %r14, %rdi
movl $0x7, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
jne 0x6dce5
movl $0x20111, %edx          # imm = 0x20111
movq %r14, %rdi
movl $0x7, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
jne 0x6dce5
movl $0x20000, %edx          # imm = 0x20000
movq %r14, %rdi
movl $0x7, %esi
movl $0x1, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
jne 0x6dce5
subq $0x8, %rsp
movq %r14, %rdi
movl $0xd, %esi
movl $0x7, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r15, %r9
pushq %rbx
callq 0x504b3
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6dce5
movl $0x20000, %edx          # imm = 0x20000
movq %r14, %rdi
movl $0x7, %esi
movl $0x1, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
jne 0x6dce5
movl $0x5, %r15d
movl $0x20100, %edx          # imm = 0x20100
movq %r14, %rdi
movl $0x7, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x50463
subq $0x1, %r15
setb %al
cmpl $0x0, (%rbx)
jne 0x6dce5
testb %al, %al
je 0x6ddd6
jmp 0x6dce5
nopl (%rax)