// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_testesc
void subtilis_riscos_arm_testesc(subtilis_ir_section_t *s, size_t start,
				 void *user_data, subtilis_error_t *err)
{
	size_t label;
	subtilis_arm_instr_t *instr;
	subtilis_arm_br_instr_t *br;
	subtilis_arm_section_t *arm_s = user_data;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_LDR,
				   SUBTILIS_ARM_CCODE_AL, 0, 12,
				   RISCOS_ARM_GLOBAL_ESC_FLAG, false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_cmp_imm(arm_s, SUBTILIS_ARM_INSTR_TEQ,
				 SUBTILIS_ARM_CCODE_AL, 0, 0, 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_EQ;
	br->link = false;
	br->link_type = SUBTILIS_ARM_BR_LINK_VOID;
	br->target.label = label;

	/* Clear escape variable */

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

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_STR,
				   SUBTILIS_ARM_CCODE_AL, 0, 12,
				   RISCOS_ARM_GLOBAL_ESC_FLAG, false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	/* Clear the escape condition */

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

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

	subtilis_arm_gen_sete(arm_s, s, SUBTILIS_ARM_CCODE_AL, 0,
			      SUBTILIS_ERROR_CODE_ESCAPE, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_section_add_label(arm_s, label, 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, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rax
movl $0x12, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movl $0xc, %r8d
movl $0xfffffffc, %r9d       # imm = 0xFFFFFFFC
xorl %r10d, %r10d
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x72030
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa5e12
jmp 0xa5fce
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %r9
movl $0x9, %esi
movl $0xe, %edx
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
callq 0x72620
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa5e3e
jmp 0xa5fce
movq -0x40(%rbp), %rcx
movq 0x10(%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x10(%rcx)
movq %rax, -0x28(%rbp)
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x16, %esi
callq 0x70b50
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa5e79
jmp 0xa5fce
movq -0x30(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
movq -0x38(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x38(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rax
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x71b10
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa5eea
jmp 0xa5fce
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rax
movl $0x13, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movl $0xc, %r8d
movl $0xfffffffc, %r9d       # imm = 0xFFFFFFFC
xorl %r10d, %r10d
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x72030
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa5f2c
jmp 0xa5fce
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rax
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
movl $0x7c, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x71b10
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa5f65
jmp 0xa5fce
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %r9
movl $0xe, %esi
movl $0x20006, %edx          # imm = 0x20006
movl $0x1, %ecx
movl $0x6, %r8d
callq 0x71f20
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa5f92
jmp 0xa5fce
movq -0x40(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x20(%rbp), %r9
movl $0xe, %edx
xorl %eax, %eax
movl %eax, %ecx
movl $0x11, %r8d
callq 0x75bc0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0xa5fbd
jmp 0xa5fce
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x70850
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)