// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/arch/arm32/vfp_gen.c
// Function: subtilis_vfp_gen_movrrdi32
void subtilis_vfp_gen_movrrdi32(subtilis_ir_section_t *s, size_t start,
				void *user_data, subtilis_error_t *err)
{
	subtilis_arm_reg_t dest;
	subtilis_arm_reg_t src;
	subtilis_arm_reg_t fpscr;
	subtilis_arm_reg_t tmp;
	subtilis_arm_reg_t fpscr_mod;
	subtilis_arm_section_t *arm_s = user_data;
	subtilis_ir_inst_t *instr = &s->ops[start]->op.instr;

	dest = subtilis_arm_ir_to_arm_reg(instr->operands[0].reg);
	src = subtilis_arm_ir_to_dreg(instr->operands[1].reg);
	tmp = subtilis_arm_ir_to_dreg(s->freg_counter++);
	fpscr = subtilis_arm_ir_to_dreg(s->reg_counter++);
	fpscr_mod = subtilis_arm_ir_to_dreg(s->reg_counter++);

	subtilis_vfp_add_sysreg(arm_s, SUBTILIS_VFP_INSTR_FMRX,
				SUBTILIS_ARM_CCODE_AL,
				SUBTILIS_VFP_SYSREG_FPSCR, fpscr, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_data_imm(arm_s, SUBTILIS_ARM_INSTR_BIC,
				  SUBTILIS_ARM_CCODE_AL, false, fpscr_mod,
				  fpscr, 3 << 22, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_arm_add_data_imm(arm_s, SUBTILIS_ARM_INSTR_ORR,
				  SUBTILIS_ARM_CCODE_AL, false, fpscr_mod,
				  fpscr_mod, 2 << 22, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_vfp_add_sysreg(arm_s, SUBTILIS_VFP_INSTR_FMXR,
				SUBTILIS_ARM_CCODE_AL,
				SUBTILIS_VFP_SYSREG_FPSCR, fpscr_mod, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_vfp_add_tran(arm_s, SUBTILIS_VFP_INSTR_FTOSID,
			      SUBTILIS_ARM_CCODE_AL, true, tmp, src, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_vfp_add_sysreg(arm_s, SUBTILIS_VFP_INSTR_FMXR,
				SUBTILIS_ARM_CCODE_AL,
				SUBTILIS_VFP_SYSREG_FPSCR, fpscr, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_vfp_add_cptran(arm_s, SUBTILIS_VFP_INSTR_FMRS,
				SUBTILIS_ARM_CCODE_AL, true, dest, tmp, err);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
movq 0x48(%rdi), %rax
movq (%rax,%rsi,8), %r12
movq 0x10(%r12), %rdi
callq 0x4b224
movq %rax, (%rsp)
movq 0x18(%r12), %rdi
callq 0x4b78a
movq %rax, %rbp
movq 0x20(%r15), %rdi
leaq 0x1(%rdi), %rax
movq %rax, 0x20(%r15)
callq 0x4b78a
movq %rax, %r12
movq 0x18(%r15), %rdi
leaq 0x1(%rdi), %rax
movq %rax, 0x18(%r15)
callq 0x4b78a
movq %rax, %r13
movq 0x18(%r15), %rdi
leaq 0x1(%rdi), %rax
movq %rax, 0x18(%r15)
callq 0x4b78a
movq %rax, %r15
pushq $0x7c
popq %rsi
pushq $0xe
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rdi
movq %r13, %r8
movq %rbx, %r9
callq 0x58964
cmpl $0x0, (%rbx)
jne 0x656ac
pushq $0xe
popq %rdx
movq %r14, %rdi
movl %edx, %esi
xorl %ecx, %ecx
movq %r15, %r8
movq %r13, %r9
pushq %rbx
pushq $0xc00000               # imm = 0xC00000
callq 0x4c367
popq %rax
popq %rcx
cmpl $0x0, (%rbx)
jne 0x656ac
pushq $0xc
popq %rsi
pushq $0xe
popq %rdx
movq %r14, %rdi
xorl %ecx, %ecx
movq %r15, %r8
movq %r15, %r9
pushq %rbx
pushq $0x800000               # imm = 0x800000
callq 0x4c367
popq %rax
popq %rcx
cmpl $0x0, (%rbx)
jne 0x656ac
pushq $0x7b
popq %rsi
pushq $0xe
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rdi
movq %r15, %r8
movq %rbx, %r9
callq 0x58964
cmpl $0x0, (%rbx)
jne 0x656ac
subq $0x8, %rsp
pushq $0x54
popq %rsi
pushq $0xe
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rdi
movq %r12, %r8
movq %rbp, %r9
pushq %rbx
callq 0x58813
popq %rax
popq %rcx
cmpl $0x0, (%rbx)
jne 0x656ac
pushq $0x7b
popq %rsi
pushq $0xe
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rdi
movq %r13, %r8
movq %rbx, %r9
callq 0x58964
cmpl $0x0, (%rbx)
je 0x656bb
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subq $0x8, %rsp
pushq $0x5e
popq %rsi
pushq $0xe
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rdi
movq 0x8(%rsp), %r8
movq %r12, %r9
pushq %rbx
callq 0x58853
addq $0x18, %rsp
jmp 0x656b0