// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/arch/arm32/vfp_gen.c
// Function: prv_check_divbyzero
static void prv_check_divbyzero(subtilis_arm_section_t *arm_s,
				subtilis_ir_section_t *s,
				subtilis_arm_reg_t res, int32_t error_code,
				subtilis_error_t *err)
{
	subtilis_arm_reg_t status;
	subtilis_arm_reg_t dest;
	subtilis_arm_instr_t *instr;
	subtilis_arm_data_instr_t *datai;
	subtilis_arm_br_instr_t *br;
	size_t label = arm_s->label_counter++;

	dest = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);
	status = subtilis_arm_ir_to_arm_reg(arm_s->reg_counter++);

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

	subtilis_arm_add_cmp_imm(arm_s, SUBTILIS_ARM_INSTR_TST,
				 SUBTILIS_ARM_CCODE_AL, status, 2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	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;

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

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

	datai = &instr->operands.data;
	datai->ccode = SUBTILIS_ARM_CCODE_AL;
	datai->dest = status;
	datai->op1 = status;
	datai->op2.type = SUBTILIS_ARM_OP2_I32;
	datai->op2.op.integer = 2;

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

	subtilis_arm_section_add_label(arm_s, label, err);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r14
movq (%rdi), %rdi
movq 0x10(%r14), %r15
leaq 0x1(%r15), %rax
movq %rax, 0x10(%r14)
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4b224
movq %rax, %rbp
movq (%r14), %rdi
leaq 0x1(%rdi), %rax
movq %rax, (%r14)
callq 0x4b224
movq %rax, %r12
pushq $0x7c
popq %rsi
pushq $0xe
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rdi
movq %rax, %r8
movq %rbx, %r9
callq 0x58964
cmpl $0x0, (%rbx)
jne 0x65d02
pushq $0x8
popq %rsi
pushq $0xe
popq %rdx
pushq $0x2
popq %r8
movq %r14, %rdi
movq %r12, %rcx
movq %rbx, %r9
callq 0x4c88e
cmpl $0x0, (%rbx)
jne 0x65d02
pushq $0x16
popq %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x4b93b
cmpl $0x0, (%rbx)
jne 0x65d02
andl $0x0, 0x8(%rax)
movb $0x0, 0xc(%rax)
andl $0x0, 0x10(%rax)
movq %r15, 0x18(%rax)
pushq $0xe
popq %rdx
pushq $0x12
popq %r8
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rcx
movq %rbx, %r9
callq 0x4e16d
xorl %eax, %eax
cmpl %eax, (%rbx)
jne 0x65d02
pushq $0xe
popq %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x4b93b
cmpl $0x0, (%rbx)
jne 0x65d02
movl $0xe, 0x8(%rax)
movq %r12, 0x10(%rax)
movq %r12, 0x18(%rax)
movl $0x1, 0x20(%rax)
movl $0x2, 0x28(%rax)
pushq $0x7b
popq %rsi
pushq $0xe
popq %rdx
pushq $0x1
popq %rcx
movq %r14, %rdi
movq %r12, %r8
movq %rbx, %r9
callq 0x58964
cmpl $0x0, (%rbx)
je 0x65d11
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4b78f