LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_gettime
void subtilis_riscos_arm_gettime(subtilis_ir_section_t *s, size_t start,
				 void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t one;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *origin = &s->ops[start]->op.instr;
	size_t ir_dest = origin->operands[0].reg;
	subtilis_arm_reg_t dest = subtilis_arm_ir_to_arm_reg(ir_dest);

	/*
	 * TOOD: Need to check for stack overflow.
	 */

	subtilis_arm_add_data_imm(arm_s, SUBTILIS_ARM_INSTR_SUB,
				  SUBTILIS_ARM_CCODE_AL, false, 1, 13, 8, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

	/* OS_Word */
	/* read_mask = 0x3 = r0, r1 */
	/* write_mask = 0 */
	subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_AL, 0x07 + 0x20000, 3, 0,
			     err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	one = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	subtilis_arm_gen_sete_load_reg(arm_s, s, SUBTILIS_ARM_CCODE_VS, one,
				       err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_LDR,
				   SUBTILIS_ARM_CCODE_VC, dest, 1, 0, false,
				   err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r12
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %rax
movq 0x10(%rax), %rdi
callq 0x4efba
movq %rax, %r15
movl $0x1, %r8d
movl $0xd, %r9d
movq %r14, %rdi
movl $0x2, %esi
movl $0xe, %edx
xorl %ecx, %ecx
pushq %rbx
pushq $0x8
callq 0x50297
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6f18e
movq %r14, %rdi
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq $0x1
callq 0x50130
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6f18e
movl $0x20007, %edx          # imm = 0x20007
movq %r14, %rdi
movl $0xe, %esi
movl $0x3, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
jne 0x6f18e
movq (%r14), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4efba
movq %r14, %rdi
movq %r12, %rsi
movl $0x6, %edx
movq %rax, %rcx
movq %rbx, %r8
callq 0x52560
cmpl $0x0, (%rbx)
je 0x6f19a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl $0x1, %r8d
movq %r14, %rdi
movl $0x12, %esi
movl $0x7, %edx
movq %r15, %rcx
xorl %r9d, %r9d
pushq %rbx
pushq $0x0
callq 0x50516
addq $0x18, %rsp
jmp 0x6f192
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_wait
void subtilis_riscos_arm_wait(subtilis_ir_section_t *s, size_t start,
			      void *user_data, subtilis_error_t *err)
{
	subtilis_arm_section_t *arm_s = user_data;

	subtilis_arm_add_mov_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, 0, 19,
				 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_riscos_handle_graphics_error(arm_s, s, err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rcx, %rbx
movq %rdx, %r15
movq %rdi, %r14
movq %rdx, %rdi
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq $0x13
callq 0x50130
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6f335
movl $0x20006, %edx          # imm = 0x20006
movq %r15, %rdi
movl $0xe, %esi
movl $0x1, %ecx
movl $0x6, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
je 0x6f33b
popq %rbx
popq %r14
popq %r15
retq
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x6e975
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_get
void subtilis_riscos_arm_get(subtilis_ir_section_t *s, size_t start,
			     void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t one;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *get = &s->ops[start]->op.instr;
	size_t ir_dest = get->operands[0].reg;
	subtilis_arm_reg_t dest = subtilis_arm_ir_to_arm_reg(ir_dest);

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

	one = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	subtilis_arm_gen_sete_load_reg(arm_s, s, SUBTILIS_ARM_CCODE_VS, one,
				       err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_VC, false, dest, 0,
				 err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, %rbx
movq %rdi, %r12
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %rax
movq 0x10(%rax), %rdi
callq 0x4efba
movq %rax, %r15
movl $0x20004, %edx          # imm = 0x20004
movq %rbx, %rdi
movl $0xe, %esi
xorl %ecx, %ecx
movl $0x1, %r8d
movq %r14, %r9
callq 0x50463
cmpl $0x0, (%r14)
jne 0x6f3df
movq (%rbx), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%rbx)
callq 0x4efba
movq %rbx, %rdi
movq %r12, %rsi
movl $0x6, %edx
movq %rax, %rcx
movq %r14, %r8
callq 0x52560
cmpl $0x0, (%r14)
jne 0x6f3df
movq %r14, (%rsp)
movq %rbx, %rdi
movl $0xd, %esi
movl $0x7, %edx
xorl %ecx, %ecx
movq %r15, %r8
xorl %r9d, %r9d
callq 0x504b3
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_inkey
void subtilis_riscos_arm_inkey(subtilis_ir_section_t *s, size_t start,
			       void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t one;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *inkey = &s->ops[start]->op.instr;
	size_t ir_dest = inkey->operands[0].reg;
	subtilis_arm_reg_t dest = subtilis_arm_ir_to_arm_reg(ir_dest);
	size_t ir_op1 = inkey->operands[1].reg;
	subtilis_arm_reg_t op1 = subtilis_arm_ir_to_arm_reg(ir_op1);

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

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 1, op1,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

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

	one = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	subtilis_arm_gen_sete_load_reg(arm_s, s, SUBTILIS_ARM_CCODE_VS, one,
				       err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_VC, true, dest, 1,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_arm_add_mvn_imm(arm_s, SUBTILIS_ARM_CCODE_NE, false, dest, 0,
				 err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r12
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r13
movq 0x10(%r13), %rdi
callq 0x4efba
movq %rax, %r15
movq 0x18(%r13), %rdi
callq 0x4efba
movq %rax, %r13
movq %r14, %rdi
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq $0x81
callq 0x50130
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6f781
subq $0x8, %rsp
movl $0x1, %r8d
movq %r14, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %r13, %r9
pushq %rbx
callq 0x504b3
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6f781
movl $0x2, %r9d
movq %r14, %rdi
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
pushq %rbx
pushq $0xff
callq 0x50130
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6f781
movl $0x20006, %edx          # imm = 0x20006
movq %r14, %rdi
movl $0xe, %esi
movl $0x7, %ecx
movl $0x6, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
jne 0x6f781
movq (%r14), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4efba
movq %r14, %rdi
movq %r12, %rsi
movl $0x6, %edx
movq %rax, %rcx
movq %rbx, %r8
callq 0x52560
cmpl $0x0, (%rbx)
jne 0x6f781
subq $0x8, %rsp
movl $0x1, %r9d
movq %r14, %rdi
movl $0xd, %esi
movl $0x7, %edx
movl $0x1, %ecx
movq %r15, %r8
pushq %rbx
callq 0x504b3
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6f781
movq %r14, %rdi
movl $0xf, %esi
movl $0xd, %edx
movl $0x1, %ecx
xorl %r8d, %r8d
movq %r15, %r9
pushq %rbx
pushq $0x0
callq 0x50130
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_os_byte_id
void subtilis_riscos_arm_os_byte_id(subtilis_ir_section_t *s, size_t start,
				    void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t one;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *getto = &s->ops[start]->op.instr;
	size_t ir_dest = getto->operands[0].reg;
	subtilis_arm_reg_t dest = subtilis_arm_ir_to_arm_reg(ir_dest);

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

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

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

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

	one = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	subtilis_arm_gen_sete_load_reg(arm_s, s, SUBTILIS_ARM_CCODE_VS, one,
				       err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_VC, false, dest, 1,
				 err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r12
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %rax
movq 0x10(%rax), %rdi
callq 0x4efba
movq %rax, %r15
movq %r14, %rdi
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq $0x81
callq 0x50130
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6f88a
movl $0x1, %r9d
movq %r14, %rdi
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
pushq %rbx
pushq $0x0
callq 0x50130
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6f88a
movl $0x2, %r9d
movq %r14, %rdi
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
pushq %rbx
pushq $0xff
callq 0x50130
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6f88a
movl $0x20006, %edx          # imm = 0x20006
movq %r14, %rdi
movl $0xe, %esi
movl $0x7, %ecx
movl $0x6, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
jne 0x6f88a
movq (%r14), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4efba
movq %r14, %rdi
movq %r12, %rsi
movl $0x6, %edx
movq %rax, %rcx
movq %rbx, %r8
callq 0x52560
cmpl $0x0, (%rbx)
je 0x6f896
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
subq $0x8, %rsp
movl $0x1, %r9d
movq %r14, %rdi
movl $0xd, %esi
movl $0x7, %edx
xorl %ecx, %ecx
movq %r15, %r8
pushq %rbx
callq 0x504b3
addq $0x18, %rsp
jmp 0x6f88e
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_vdui
void subtilis_riscos_arm_vdui(subtilis_ir_section_t *s, size_t start,
			      void *user_data, subtilis_error_t *err)
{
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *vdu = &s->ops[start]->op.instr;
	size_t ch = vdu->operands[0].integer & 0xff;

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

	subtilis_riscos_handle_graphics_error(arm_s, s, err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %rax
movzbl 0x10(%rax), %edx
orq $0x20100, %rdx          # imm = 0x20100
movq %r14, %rdi
movl $0xe, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
je 0x6f8ff
popq %rbx
popq %r14
popq %r15
retq
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x6e975
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_vdu
void subtilis_riscos_arm_vdu(subtilis_ir_section_t *s, size_t start,
			     void *user_data, subtilis_error_t *err)
{
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *vdu = &s->ops[start]->op.instr;
	size_t ir_src = vdu->operands[0].reg;
	subtilis_arm_reg_t src = subtilis_arm_ir_to_arm_reg(ir_src);

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 0, src,
				 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_AL, 0x0 + 0x20000, 1, 0,
			     err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_riscos_handle_graphics_error(arm_s, s, err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %rax
movq 0x10(%rax), %rdi
callq 0x4efba
movq %rbx, (%rsp)
movq %r14, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rax, %r9
callq 0x504b3
cmpl $0x0, (%rbx)
jne 0x6f97a
movl $0x20000, %edx          # imm = 0x20000
movq %r14, %rdi
movl $0xe, %esi
movl $0x1, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
je 0x6f984
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x6e975
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_point_tint
void subtilis_riscos_arm_point_tint(subtilis_ir_section_t *s, size_t start,
				    void *user_data, size_t res_reg,
				    subtilis_error_t *err)
{
	subtilis_arm_reg_t x;
	subtilis_arm_reg_t y;
	subtilis_arm_reg_t dest;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *plot = &s->ops[start]->op.instr;

	x = subtilis_arm_ir_to_arm_reg(plot->operands[1].reg);
	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 0, x,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	y = subtilis_arm_ir_to_arm_reg(plot->operands[2].reg);
	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 1, y,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	/* OS_ReadPoint */
	/* read_mask = 0x3 = r0, r1 */
	/* write_mask = 0x1c = r2, r3, r4 */
	subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_AL, 0x32 + 0x20000, 3,
			     0x1C, 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 = subtilis_arm_ir_to_arm_reg(plot->operands[0].reg);
	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_VC, false, dest,
				 res_reg, err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %r8, %r14
movq %rcx, %rbx
movq %rdx, %r15
movq %rdi, %r12
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r13
movq 0x18(%r13), %rdi
callq 0x4efba
movq %r14, (%rsp)
movq %r15, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rax, %r9
callq 0x504b3
cmpl $0x0, (%r14)
jne 0x6fa7e
movq 0x20(%r13), %rdi
callq 0x4efba
movq %r14, (%rsp)
movl $0x1, %r8d
movq %r15, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %rax, %r9
callq 0x504b3
cmpl $0x0, (%r14)
jne 0x6fa7e
movl $0x20032, %edx          # imm = 0x20032
movq %r15, %rdi
movl $0xe, %esi
movl $0x3, %ecx
movl $0x1c, %r8d
movq %r14, %r9
callq 0x50463
cmpl $0x0, (%r14)
jne 0x6fa7e
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x6e975
cmpl $0x0, (%r14)
jne 0x6fa7e
movq 0x10(%r13), %rdi
callq 0x4efba
movq %r14, (%rsp)
movq %r15, %rdi
movl $0xd, %esi
movl $0x7, %edx
xorl %ecx, %ecx
movq %rax, %r8
movq %rbx, %r9
callq 0x504b3
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_ref
void subtilis_riscos_arm_ref(subtilis_ir_section_t *s, size_t start,
			     void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t count;
	subtilis_arm_reg_t block;
	subtilis_ir_inst_t *ref = &s->ops[start]->op.instr;
	subtilis_arm_section_t *arm_s = user_data;

	/*
	 * Subtract 8 from the memory address provided by program
	 */

	block = subtilis_arm_ir_to_arm_reg(ref->operands[0].reg);
	count = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_LDR,
				   SUBTILIS_ARM_CCODE_AL, count, block, -8,
				   false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_add_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, count,
				 count, 1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_STR,
				   SUBTILIS_ARM_CCODE_AL, count, block, -8,
				   false, err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %rax
movq 0x10(%rax), %rdi
callq 0x4efba
movq %rax, %r15
movq (%r14), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4efba
movq %rax, %r12
movq %r14, %rdi
movl $0x12, %esi
movl $0xe, %edx
movq %rax, %rcx
movq %r15, %r8
movl $0xfffffff8, %r9d       # imm = 0xFFFFFFF8
pushq %rbx
pushq $0x0
callq 0x50516
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x6fe4d
subq $0x8, %rsp
movq %r14, %rdi
movl $0x4, %esi
movl $0x2, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
movq %r12, %r9
pushq %rbx
pushq $0x1
pushq %r12
callq 0x4fd3f
addq $0x20, %rsp
cmpl $0x0, (%rbx)
je 0x6fe59
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %r14, %rdi
movl $0x13, %esi
movl $0xe, %edx
movq %r12, %rcx
movq %r15, %r8
movl $0xfffffff8, %r9d       # imm = 0xFFFFFFF8
pushq %rbx
pushq $0x0
callq 0x50516
addq $0x18, %rsp
jmp 0x6fe51
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_getref
void subtilis_riscos_arm_getref(subtilis_ir_section_t *s, size_t start,
				void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t count;
	subtilis_arm_reg_t ptr;
	subtilis_arm_reg_t block;
	subtilis_ir_inst_t *getref = &s->ops[start]->op.instr;
	subtilis_arm_section_t *arm_s = user_data;

	count = subtilis_arm_ir_to_arm_reg(getref->operands[0].reg);
	ptr = subtilis_arm_ir_to_arm_reg(getref->operands[1].reg);
	block = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);

	/*
	 * Subtract 8 from the memory address provided by program
	 */

	subtilis_arm_add_sub_imm(arm_s, SUBTILIS_ARM_CCODE_AL, false, block,
				 ptr, 8, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_LDR,
				   SUBTILIS_ARM_CCODE_AL, count, block, 0,
				   false, err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %rbx
movq %rdx, %r14
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r12
movq 0x10(%r12), %rdi
callq 0x4efba
movq %rax, %r15
movq 0x18(%r12), %rdi
callq 0x4efba
movq %rax, %r13
movq (%r14), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4efba
movq %rax, %r12
subq $0x8, %rsp
movq %r14, %rdi
movl $0x2, %esi
movl $0x4, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
movq %rax, %r9
pushq %rbx
pushq $0x8
pushq %r13
callq 0x4fd3f
addq $0x20, %rsp
cmpl $0x0, (%rbx)
jne 0x6ff14
movq %r14, %rdi
movl $0x12, %esi
movl $0xe, %edx
movq %r15, %rcx
movq %r12, %r8
xorl %r9d, %r9d
pushq %rbx
pushq $0x0
callq 0x50516
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_tcol
void subtilis_riscos_tcol(subtilis_ir_section_t *s, size_t start,
			  void *user_data, subtilis_error_t *err)
{
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *tcol = &s->ops[start]->op.instr;
	size_t col;

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

	col = subtilis_arm_ir_to_arm_reg(tcol->operands[0].reg);
	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_VC, false, 0, col,
				 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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r12
movl $0x20111, %edx          # imm = 0x20111
movq %r14, %rdi
movl $0xe, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
jne 0x6ffa5
movq 0x10(%r12), %rdi
callq 0x4efba
movq %rbx, (%rsp)
movq %r14, %rdi
movl $0xd, %esi
movl $0x7, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rax, %r9
callq 0x504b3
cmpl $0x0, (%rbx)
jne 0x6ffa5
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)
je 0x6ffb1
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x6e975
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_palette
void subtilis_riscos_palette(subtilis_ir_section_t *s, size_t start,
			     void *user_data, subtilis_error_t *err)
{
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *tcol = &s->ops[start]->op.instr;
	size_t col;
	size_t i;

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

	col = subtilis_arm_ir_to_arm_reg(tcol->operands[0].reg);
	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_VC, false, 0, col,
				 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;

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

	for (i = 1; i < 4; i++) {
		col = subtilis_arm_ir_to_arm_reg(tcol->operands[i].reg);
		subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_VC, false, 0,
					 col, 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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r12
movl $0x20113, %edx          # imm = 0x20113
movq %r14, %rdi
movl $0xe, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
jne 0x70075
movq 0x10(%r12), %rdi
callq 0x4efba
movq %rbx, (%rsp)
movq %r14, %rdi
movl $0xd, %esi
movl $0x7, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rax, %r9
callq 0x504b3
cmpl $0x0, (%rbx)
jne 0x70075
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 0x70075
movl $0x20110, %edx          # imm = 0x20110
movq %r14, %rdi
movl $0x7, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
je 0x70083
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
xorl %r13d, %r13d
movq 0x18(%r12,%r13,8), %rdi
callq 0x4efba
movq %rbx, (%rsp)
movq %r14, %rdi
movl $0xd, %esi
movl $0x7, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rax, %r9
callq 0x504b3
cmpl $0x0, (%rbx)
jne 0x70075
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 0x70075
incq %r13
cmpq $0x3, %r13
jne 0x70086
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x6e975
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_i32_to_dec
void subtilis_riscos_arm_i32_to_dec(subtilis_ir_section_t *s, size_t start,
				    void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t dest;
	subtilis_arm_reg_t buffer;
	subtilis_arm_reg_t val;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *to_deci = &s->ops[start]->op.instr;

	dest = subtilis_arm_ir_to_arm_reg(to_deci->operands[0].reg);
	val = subtilis_arm_ir_to_arm_reg(to_deci->operands[1].reg);
	buffer = subtilis_arm_ir_to_arm_reg(to_deci->operands[2].reg);

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

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 1, buffer,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

	/* OS_ConvertInteger4 */
	/* read_mask = 0x7 = r0, r1, r2 */
	/* write_mask = 0x7 = r0, r1, r2 */
	subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_AL, 0xdc, 0x7, 0x7, err);

	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_data_imm(arm_s, SUBTILIS_ARM_INSTR_RSB,
				  SUBTILIS_ARM_CCODE_AL, false, dest, 2, 12,
				  err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %rbx
movq %rdx, %r14
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r12
movq 0x10(%r12), %rdi
callq 0x4efba
movq %rax, %r15
movq 0x18(%r12), %rdi
callq 0x4efba
movq %rax, %r13
movq 0x20(%r12), %rdi
callq 0x4efba
movq %rax, %r12
subq $0x8, %rsp
movq %r14, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r13, %r9
pushq %rbx
callq 0x504b3
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x70203
subq $0x8, %rsp
movl $0x1, %r8d
movq %r14, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %r12, %r9
pushq %rbx
callq 0x504b3
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x70203
movl $0x2, %r9d
movq %r14, %rdi
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
pushq %rbx
pushq $0xc
callq 0x50130
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x70203
movl $0xdc, %edx
movq %r14, %rdi
movl $0xe, %esi
movl $0x7, %ecx
movl $0x7, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
jne 0x70203
movl $0x2, %r9d
movq %r14, %rdi
movl $0x3, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %r15, %r8
pushq %rbx
pushq $0xc
callq 0x50297
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_i32_to_hex
void subtilis_riscos_arm_i32_to_hex(subtilis_ir_section_t *s, size_t start,
				    void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t dest;
	subtilis_arm_reg_t buffer;
	subtilis_arm_reg_t val;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *to_hexi = &s->ops[start]->op.instr;

	dest = subtilis_arm_ir_to_arm_reg(to_hexi->operands[0].reg);
	val = subtilis_arm_ir_to_arm_reg(to_hexi->operands[1].reg);
	buffer = subtilis_arm_ir_to_arm_reg(to_hexi->operands[2].reg);

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

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 1, buffer,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

	/* OS_ConvertHex8 */
	/* read_mask = 0x7 = r0, r1, r2 */
	/* write_mask = 0x7 = r0, r1, r2 */
	subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_AL, 0xd4, 0x7, 0x7, err);

	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_data_imm(arm_s, SUBTILIS_ARM_INSTR_RSB,
				  SUBTILIS_ARM_CCODE_AL, false, dest, 2, 11,
				  err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %rbx
movq %rdx, %r14
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r12
movq 0x10(%r12), %rdi
callq 0x4efba
movq %rax, %r15
movq 0x18(%r12), %rdi
callq 0x4efba
movq %rax, %r13
movq 0x20(%r12), %rdi
callq 0x4efba
movq %rax, %r12
subq $0x8, %rsp
movq %r14, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r13, %r9
pushq %rbx
callq 0x504b3
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x70317
subq $0x8, %rsp
movl $0x1, %r8d
movq %r14, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %r12, %r9
pushq %rbx
callq 0x504b3
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x70317
movl $0x2, %r9d
movq %r14, %rdi
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
pushq %rbx
pushq $0xb
callq 0x50130
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x70317
movl $0xd4, %edx
movq %r14, %rdi
movl $0xe, %esi
movl $0x7, %ecx
movl $0x7, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
jne 0x70317
movl $0x2, %r9d
movq %r14, %rdi
movl $0x3, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %r15, %r8
pushq %rbx
pushq $0xb
callq 0x50297
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_heap_free_space
void subtilis_riscos_arm_heap_free_space(subtilis_ir_section_t *s, size_t start,
					 void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t heap_start;
	subtilis_arm_reg_t result;
	subtilis_arm_reg_t scratch;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *free_space = &s->ops[start]->op.instr;

	heap_start = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	result = subtilis_arm_ir_to_arm_reg(free_space->operands[0].reg);
	scratch = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);

	prv_load_heap_pointer(arm_s, scratch, heap_start, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_heap_free_space(arm_s, heap_start, result, err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r12
movq (%rdx), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%rdx)
callq 0x4efba
movq %rax, %r15
movq 0x10(%r12), %rdi
callq 0x4efba
movq %rax, %r12
movq (%r14), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4efba
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x703a3
cmpl $0x0, (%rbx)
je 0x70387
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x62a54
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_block_free_space
void subtilis_riscos_arm_block_free_space(subtilis_ir_section_t *s,
					  size_t start, void *user_data,
					  subtilis_error_t *err)
{
	subtilis_arm_reg_t total;
	subtilis_arm_reg_t space_used;
	subtilis_arm_instr_t *instr;
	subtilis_arm_data_instr_t *datai;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *block_space = &s->ops[start]->op.instr;
	subtilis_arm_reg_t dest =
	    subtilis_arm_ir_to_arm_reg(block_space->operands[0].reg);
	subtilis_arm_reg_t block =
	    subtilis_arm_ir_to_arm_reg(block_space->operands[1].reg);

	total = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	space_used = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_LDR,
				   SUBTILIS_ARM_CCODE_AL, space_used, block, -4,
				   false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_LDR,
				   SUBTILIS_ARM_CCODE_AL, total, block, -16,
				   false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_SUB, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	datai = &instr->operands.data;
	datai->ccode = SUBTILIS_ARM_CCODE_AL;
	datai->status = false;
	datai->dest = dest;
	datai->op1 = total;
	datai->op2.type = SUBTILIS_ARM_OP2_REG;
	datai->op2.op.reg = space_used;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r15
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r12
movq 0x10(%r12), %rdi
callq 0x4efba
movq %rax, %r14
movq 0x18(%r12), %rdi
callq 0x4efba
movq %rax, %rbp
movq (%r15), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r15)
callq 0x4efba
movq %rax, %r12
movq (%r15), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r15)
callq 0x4efba
movq %rax, %r13
movq %r15, %rdi
movl $0x12, %esi
movl $0xe, %edx
movq %rax, %rcx
movq %rbp, %r8
movl $0xfffffffc, %r9d       # imm = 0xFFFFFFFC
pushq %rbx
pushq $0x0
callq 0x50516
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x704f3
movq %r15, %rdi
movl $0x12, %esi
movl $0xe, %edx
movq %r12, %rcx
movq %rbp, %r8
movl $0xfffffff0, %r9d       # imm = 0xFFFFFFF0
pushq %rbx
pushq $0x0
callq 0x50516
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x704f3
movq %r15, %rdi
movl $0x2, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
jne 0x704f3
movl $0xe, 0x8(%rax)
movb $0x0, 0xc(%rax)
movq %r14, 0x10(%rax)
movq %r12, 0x18(%rax)
movl $0x0, 0x20(%rax)
movq %r13, 0x28(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_arm_block_adjust
void subtilis_riscos_arm_block_adjust(subtilis_ir_section_t *s, size_t start,
				      void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t new_space_used;
	subtilis_arm_reg_t space_used;
	subtilis_arm_instr_t *instr;
	subtilis_arm_data_instr_t *datai;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *block_adjust = &s->ops[start]->op.instr;
	subtilis_arm_reg_t block =
	    subtilis_arm_ir_to_arm_reg(block_adjust->operands[0].reg);
	subtilis_arm_reg_t increment =
	    subtilis_arm_ir_to_arm_reg(block_adjust->operands[1].reg);

	space_used = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	new_space_used = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_LDR,
				   SUBTILIS_ARM_CCODE_AL, space_used, block, -4,
				   false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	instr =
	    subtilis_arm_section_add_instr(arm_s, SUBTILIS_ARM_INSTR_ADD, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	datai = &instr->operands.data;
	datai->ccode = SUBTILIS_ARM_CCODE_AL;
	datai->status = false;
	datai->dest = new_space_used;
	datai->op1 = space_used;
	datai->op2.type = SUBTILIS_ARM_OP2_REG;
	datai->op2.op.reg = increment;

	subtilis_arm_add_stran_imm(arm_s, SUBTILIS_ARM_INSTR_STR,
				   SUBTILIS_ARM_CCODE_AL, new_space_used, block,
				   -4, false, err);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r12
movq 0x10(%r12), %rdi
callq 0x4efba
movq %rax, %r15
movq 0x18(%r12), %rdi
callq 0x4efba
movq %rax, %r12
movq (%r14), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4efba
movq %rax, %r13
movq (%r14), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4efba
movq %rax, %rbp
movq %r14, %rdi
movl $0x12, %esi
movl $0xe, %edx
movq %r13, %rcx
movq %r15, %r8
movl $0xfffffffc, %r9d       # imm = 0xFFFFFFFC
pushq %rbx
pushq $0x0
callq 0x50516
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x70598
movq %r14, %rdi
movl $0x4, %esi
movq %rbx, %rdx
callq 0x4f6e2
cmpl $0x0, (%rbx)
je 0x705a7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xe, 0x8(%rax)
movb $0x0, 0xc(%rax)
movq %rbp, 0x10(%rax)
movq %r13, 0x18(%rax)
xorl %r10d, %r10d
movl %r10d, 0x20(%rax)
movq %r12, 0x28(%rax)
movq %r14, %rdi
movl $0x13, %esi
movl $0xe, %edx
movq %rbp, %rcx
movq %r15, %r8
movl $0xfffffffc, %r9d       # imm = 0xFFFFFFFC
pushq %rbx
pushq %r10
callq 0x50516
addq $0x18, %rsp
jmp 0x7059c
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_sys_check
bool subtilis_riscos_sys_check(size_t call_id, uint32_t *in_regs,
			       uint32_t *out_regs, bool *handle_errors,
			       const subtilis_arm_swi_t *swi_list,
			       size_t swi_count)
{
	subtilis_arm_swi_t *found;

	if (call_id & 0x20000) {
		*handle_errors = true;
		call_id &= ~0x20000;
	} else {
		*handle_errors = false;
	}

	if (call_id >= 0x100 && call_id <= 0x1ff) {
		*in_regs = 0;
		return true;
	}

	found = bsearch(&call_id, &swi_list[0], swi_count, sizeof(*found),
			prv_sys_num_lookup);

	if (!found)
		return false;

	*in_regs = found->in_regs;
	*out_regs = found->out_regs;

	return true;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %rax
andq $-0x20001, %rax         # imm = 0xFFFDFFFF
movl %edi, %edx
shrl $0x11, %edx
andb $0x1, %dl
movq %rax, (%rsp)
movb %dl, (%rcx)
andq $-0x20100, %rdi         # imm = 0xFFFDFF00
cmpq $0x100, %rdi            # imm = 0x100
jne 0x70626
movl $0x0, (%r14)
jmp 0x70653
leaq 0x34(%rip), %rax        # 0x70661
movq %rsp, %rdi
movl $0x18, %ecx
movq %r8, %rsi
movq %r9, %rdx
movq %rax, %r8
callq 0x122a0
testq %rax, %rax
je 0x7065d
movl 0x10(%rax), %ecx
movl %ecx, (%r14)
movl 0x14(%rax), %eax
movl %eax, (%rbx)
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r14
retq
xorl %eax, %eax
jmp 0x70655
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: prv_open_file
static void prv_open_file(subtilis_ir_section_t *s, size_t start,
			  void *user_data, int32_t code, int32_t bits,
			  subtilis_error_t *err)
{
	subtilis_arm_reg_t dest;
	subtilis_arm_reg_t buffer;
	subtilis_arm_reg_t one;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *openf = &s->ops[start]->op.instr;

	dest = subtilis_arm_ir_to_arm_reg(openf->operands[0].reg);
	buffer = subtilis_arm_ir_to_arm_reg(openf->operands[1].reg);

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

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 1, buffer,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	/* OS_Find */
	/* read_mask = 0x3 = r0, r1 */
	/* write_mask = 0x1 = r0 */
	subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_AL, 0x20000 + 0xd, 0x3,
			     0x1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	one = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	subtilis_arm_gen_sete_load_reg(arm_s, s, SUBTILIS_ARM_CCODE_VS, one,
				       err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_VC, false, dest, 0,
				 err);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r14
movl %r8d, %ebp
movl %ecx, %r15d
movq %rdx, %rbx
movq %rdi, %r12
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r13
movq 0x10(%r13), %rdi
callq 0x4efba
movq %rax, 0x10(%rsp)
movq 0x18(%r13), %rdi
callq 0x4efba
movq %rax, %r13
orl %ebp, %r15d
movq %r14, 0x8(%rsp)
movl %r15d, (%rsp)
movq %rbx, %rdi
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x50130
cmpl $0x0, (%r14)
jne 0x70968
movq %r14, (%rsp)
movl $0x1, %r8d
movq %rbx, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %r13, %r9
callq 0x504b3
cmpl $0x0, (%r14)
jne 0x70968
movl $0x2000d, %edx          # imm = 0x2000D
movq %rbx, %rdi
movl $0xe, %esi
movl $0x3, %ecx
movl $0x1, %r8d
movq %r14, %r9
callq 0x50463
cmpl $0x0, (%r14)
jne 0x70968
movq (%rbx), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%rbx)
callq 0x4efba
movq %rbx, %rdi
movq %r12, %rsi
movl $0x6, %edx
movq %rax, %rcx
movq %r14, %r8
callq 0x52560
cmpl $0x0, (%r14)
jne 0x70968
movq %r14, (%rsp)
movq %rbx, %rdi
movl $0xd, %esi
movl $0x7, %edx
xorl %ecx, %ecx
movq 0x10(%rsp), %r8
xorl %r9d, %r9d
callq 0x504b3
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_close
void subtilis_riscos_close(subtilis_ir_section_t *s, size_t start,
			   void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t handle;
	subtilis_arm_reg_t one;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *closef = &s->ops[start]->op.instr;

	handle = subtilis_arm_ir_to_arm_reg(closef->operands[0].reg);

	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_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 1, handle,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	/* OS_Find */
	/* read_mask = 0x3 = r0, r1 */
	/* write_mask = 0x1 = r0 */
	subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_AL, 0x20000 + 0xd, 0x3,
			     0x1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	one = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	subtilis_arm_gen_sete_load_reg(arm_s, s, SUBTILIS_ARM_CCODE_VS, one,
				       err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %rax
movq 0x10(%rax), %rdi
callq 0x4efba
movq %rax, %r12
movq %r14, %rdi
movl $0xd, %esi
movl $0xf, %edx
movl $0xe, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rbx
pushq $0x0
callq 0x50130
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x70a3b
subq $0x8, %rsp
movl $0x1, %r8d
movq %r14, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %r12, %r9
pushq %rbx
callq 0x504b3
addq $0x10, %rsp
cmpl $0x0, (%rbx)
jne 0x70a3b
movl $0x2000d, %edx          # imm = 0x2000D
movq %r14, %rdi
movl $0xe, %esi
movl $0x3, %ecx
movl $0x1, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
je 0x70a47
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq (%r14), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4efba
movq %r14, %rdi
movq %r15, %rsi
movl $0x6, %edx
movq %rax, %rcx
movq %rbx, %r8
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x52560
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_bget
void subtilis_riscos_bget(subtilis_ir_section_t *s, size_t start,
			  void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t dest;
	subtilis_arm_reg_t handle;
	subtilis_arm_reg_t one;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *bget = &s->ops[start]->op.instr;

	dest = subtilis_arm_ir_to_arm_reg(bget->operands[0].reg);
	handle = subtilis_arm_ir_to_arm_reg(bget->operands[1].reg);

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 1, handle,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	/* OS_BGet */
	/* read_mask = 0x2 = r1 */
	/* write_mask = 0x1 = r0 */
	subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_AL, 0xa, 0x2, 0x1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	one = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	subtilis_arm_gen_sete_load_reg(arm_s, s, SUBTILIS_ARM_CCODE_CS, one,
				       err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_CC, false, dest, 0,
				 err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rcx, %r14
movq %rdx, %rbx
movq %rdi, %r12
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r13
movq 0x10(%r13), %rdi
callq 0x4efba
movq %rax, %r15
movq 0x18(%r13), %rdi
callq 0x4efba
movq %r14, (%rsp)
movl $0x1, %r8d
movq %rbx, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %rax, %r9
callq 0x504b3
cmpl $0x0, (%r14)
jne 0x70b40
movl $0xa, %edx
movq %rbx, %rdi
movl $0xe, %esi
movl $0x2, %ecx
movl $0x1, %r8d
movq %r14, %r9
callq 0x50463
cmpl $0x0, (%r14)
jne 0x70b40
movq (%rbx), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%rbx)
callq 0x4efba
movq %rbx, %rdi
movq %r12, %rsi
movl $0x2, %edx
movq %rax, %rcx
movq %r14, %r8
callq 0x52560
cmpl $0x0, (%r14)
jne 0x70b40
movq %r14, (%rsp)
movq %rbx, %rdi
movl $0xd, %esi
movl $0x3, %edx
xorl %ecx, %ecx
movq %r15, %r8
xorl %r9d, %r9d
callq 0x504b3
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/markdryan[P]subtilis/backends/riscos_common/riscos_arm.c
// Function: subtilis_riscos_bput
void subtilis_riscos_bput(subtilis_ir_section_t *s, size_t start,
			  void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t data;
	subtilis_arm_reg_t handle;
	subtilis_arm_reg_t one;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *bget = &s->ops[start]->op.instr;

	data = subtilis_arm_ir_to_arm_reg(bget->operands[0].reg);
	handle = subtilis_arm_ir_to_arm_reg(bget->operands[1].reg);

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

	subtilis_arm_add_mov_reg(arm_s, SUBTILIS_ARM_CCODE_AL, false, 1, handle,
				 err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	/* OS_BPut */
	/* read_mask = 0x3 = r1 */
	/* write_mask = 0x0 = r0 */
	subtilis_arm_add_swi(arm_s, SUBTILIS_ARM_CCODE_AL, 0x20000 + 0xb, 0x3,
			     0x0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	one = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	subtilis_arm_gen_sete_load_reg(arm_s, s, SUBTILIS_ARM_CCODE_VS, one,
				       err);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r12
movq 0x10(%r12), %rdi
callq 0x4efba
movq %rax, %r13
movq 0x18(%r12), %rdi
callq 0x4efba
movq %rax, %r12
movq %rbx, (%rsp)
movq %r14, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r13, %r9
callq 0x504b3
cmpl $0x0, (%rbx)
jne 0x70bf1
movq %rbx, (%rsp)
movl $0x1, %r8d
movq %r14, %rdi
movl $0xd, %esi
movl $0xe, %edx
xorl %ecx, %ecx
movq %r12, %r9
callq 0x504b3
cmpl $0x0, (%rbx)
jne 0x70bf1
movl $0x2000b, %edx          # imm = 0x2000B
movq %r14, %rdi
movl $0xe, %esi
movl $0x3, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x50463
cmpl $0x0, (%rbx)
je 0x70bff
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq (%r14), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4efba
movq %r14, %rdi
movq %r15, %rsi
movl $0x6, %edx
movq %rax, %rcx
movq %rbx, %r8
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x52560