// File: /workspace/github_c_makefile_star2_O1/mbitsnbites[P]SoftFP/./softfp_template.h
// Function: div_sf64
F_UINT div_sf(F_UINT a, F_UINT b, RoundingModeEnum rm,
              uint32_t *pfflags)
{
    uint32_t a_sign, b_sign, r_sign;
    int32_t a_exp, b_exp, r_exp;
    F_UINT a_mant, b_mant, r_mant, r;

    a_sign = a >> (F_SIZE - 1);
    b_sign = b >> (F_SIZE - 1);
    r_sign = a_sign ^ b_sign;
    a_exp = (a >> MANT_SIZE) & EXP_MASK;
    b_exp = (b >> MANT_SIZE) & EXP_MASK;
    a_mant = a & MANT_MASK;
    b_mant = b & MANT_MASK;
    if (a_exp == EXP_MASK) {
        if (a_mant != 0 || isnan_sf(b)) {
            if (issignan_sf(a) || issignan_sf(b)) {
                *pfflags |= FFLAG_INVALID_OP;
            }
            return F_QNAN;
        } else if (b_exp == EXP_MASK) {
            *pfflags |= FFLAG_INVALID_OP;
            return F_QNAN;
        } else {
            return pack_sf(r_sign, EXP_MASK, 0);
        }
    } else if (b_exp == EXP_MASK) {
        if (b_mant != 0) {
            if (issignan_sf(a) || issignan_sf(b)) {
                *pfflags |= FFLAG_INVALID_OP;
            }
            return F_QNAN;
        } else {
            return pack_sf(r_sign, 0, 0);
        }
    }

    if (b_exp == 0) {
        if (b_mant == 0) { 
            /* zero */
            if (a_exp == 0 && a_mant == 0) {
                *pfflags |= FFLAG_INVALID_OP;
                return F_QNAN;
            } else {
                *pfflags |= FFLAG_DIVIDE_ZERO;
                return pack_sf(r_sign, EXP_MASK, 0);
            }
        }
        b_mant = normalize_subnormal_sf(&b_exp, b_mant);
    } else {
        b_mant |= (F_UINT)1 << MANT_SIZE;
    }
    if (a_exp == 0) {
        if (a_mant == 0)
            return pack_sf(r_sign, 0, 0); /* zero */
        a_mant = normalize_subnormal_sf(&a_exp, a_mant);
    } else {
        a_mant |= (F_UINT)1 << MANT_SIZE;
    }
    r_exp = a_exp - b_exp + (1 << (EXP_SIZE - 1)) - 1;
    r_mant = divrem_u(&r, a_mant, 0, b_mant << 2);
    if (r != 0)
        r_mant |= 1;
    return normalize_sf(r_sign, r_exp, r_mant, rm, pfflags);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movl %edx, %ebp
movabsq $0xfffffffffffff, %rdx  # imm = 0xFFFFFFFFFFFFF
movq %rsi, %rbx
xorq %rdi, %rbx
movq %rdi, %r13
shrq $0x34, %r13
movl $0x7ff, %ecx            # imm = 0x7FF
andl %ecx, %r13d
movq %rsi, %rax
shrq $0x34, %rax
andl %ecx, %eax
movq %rdi, %r15
andq %rdx, %r15
movq %rsi, %r12
andq %rdx, %r12
cmpl %ecx, %r13d
jne 0x6a33
movabsq $0x7ff0000000000000, %rcx # imm = 0x7FF0000000000000
testq %r15, %r15
jne 0x6a83
movq %rsi, %rdx
notq %rdx
testq %rdx, %rcx
setne %dl
testq %r12, %r12
sete %r8b
orb %dl, %r8b
je 0x6a83
cmpl $0x7ff, %eax            # imm = 0x7FF
jne 0x6bb7
movabsq $0x7ff8000000000000, %rbx # imm = 0x7FF8000000000000
jmp 0x6ab3
testl %eax, %eax
je 0x6ac9
cmpl $0x7ff, %eax            # imm = 0x7FF
jne 0x6aec
testq %r12, %r12
je 0x6b7d
movabsq $0x7ff8000000000000, %rbx # imm = 0x7FF8000000000000
andq %rbx, %rdi
movabsq $0x7ff0000000000000, %rax # imm = 0x7FF0000000000000
cmpq %rax, %rdi
setne %cl
testq %r15, %r15
sete %dl
orb %cl, %dl
andq %rbx, %rsi
cmpq %rax, %rsi
setne %al
testb %al, %dl
je 0x6ab3
jmp 0x6ab7
movabsq $0x7ff8000000000000, %rbx # imm = 0x7FF8000000000000
andq %rbx, %rdi
cmpq %rcx, %rdi
sete %al
testq %r15, %r15
setne %dl
testb %dl, %al
jne 0x6ab3
andq %rbx, %rsi
cmpq %rcx, %rsi
setne %al
testq %r12, %r12
sete %cl
orb %al, %cl
jne 0x6ab7
orb $0x10, (%r14)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x6b8f
bsrq %r12, %rsi
xorl $0x3f, %esi
movl $0xfffffff5, %ecx       # imm = 0xFFFFFFF5
addl %esi, %ecx
movl $0xc, %eax
subl %esi, %eax
shlq %cl, %r12
jmp 0x6af2
addq %rdx, %r12
incq %r12
testl %r13d, %r13d
je 0x6aff
addq %rdx, %r15
incq %r15
jmp 0x6b1e
testq %r15, %r15
je 0x6b7d
bsrq %r15, %rdx
xorl $0x3f, %edx
movl $0xfffffff5, %ecx       # imm = 0xFFFFFFF5
addl %edx, %ecx
movl $0xc, %r13d
subl %edx, %r13d
shlq %cl, %r15
subl %eax, %r13d
shrq $0x3f, %rbx
addl $0x3ff, %r13d           # imm = 0x3FF
shlq $0x2, %r12
xorl %edi, %edi
movq %r15, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x15870
movq %rax, %rcx
movq %rdx, %rsi
mulq %r12
imulq %r12, %rsi
addq %rsi, %rdx
negq %rax
sbbq %rdx, %r15
xorl %edx, %edx
orq %rax, %r15
setne %dl
orq %rcx, %rdx
movl %ebx, %edi
movl %r13d, %esi
movl %ebp, %ecx
movq %r14, %r8
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x62d8
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq %rax, %rbx
jmp 0x6ab7
testl %r13d, %r13d
setne %cl
testq %r15, %r15
setne %dl
movl (%r14), %eax
orb %cl, %dl
jne 0x6bcc
movabsq $0x7ff8000000000000, %rbx # imm = 0x7FF8000000000000
orl $0x10, %eax
movl %eax, (%r14)
jmp 0x6ab7
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq %rax, %rbx
orq %rcx, %rbx
jmp 0x6ab7
orl $0x8, %eax
movl %eax, (%r14)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq %rax, %rbx
movabsq $0x7ff0000000000000, %rax # imm = 0x7FF0000000000000
orq %rax, %rbx
jmp 0x6ab7