// File: /workspace/github_c_makefile_star2_O0/mbitsnbites[P]SoftFP/./softfp_template.h
// Function: div_sf32
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
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movl -0x8(%rbp), %eax
shrl $0x1f, %eax
movl %eax, -0x1c(%rbp)
movl -0xc(%rbp), %eax
shrl $0x1f, %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
xorl -0x20(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x8(%rbp), %eax
shrl $0x17, %eax
andl $0xff, %eax
movl %eax, -0x28(%rbp)
movl -0xc(%rbp), %eax
shrl $0x17, %eax
andl $0xff, %eax
movl %eax, -0x2c(%rbp)
movl -0x8(%rbp), %eax
andl $0x7fffff, %eax         # imm = 0x7FFFFF
movl %eax, -0x34(%rbp)
movl -0xc(%rbp), %eax
andl $0x7fffff, %eax         # imm = 0x7FFFFF
movl %eax, -0x38(%rbp)
cmpl $0xff, -0x28(%rbp)
jne 0x78d6
cmpl $0x0, -0x34(%rbp)
jne 0x786e
movl -0xc(%rbp), %edi
callq 0x6c50
cmpl $0x0, %eax
je 0x789f
movl -0x8(%rbp), %edi
callq 0x6c00
cmpl $0x0, %eax
jne 0x7888
movl -0xc(%rbp), %edi
callq 0x6c00
cmpl $0x0, %eax
je 0x7893
movq -0x18(%rbp), %rax
movl (%rax), %ecx
orl $0x10, %ecx
movl %ecx, (%rax)
movl $0x7fc00000, -0x4(%rbp) # imm = 0x7FC00000
jmp 0x7a21
cmpl $0xff, -0x2c(%rbp)
jne 0x78bf
movq -0x18(%rbp), %rax
movl (%rax), %ecx
orl $0x10, %ecx
movl %ecx, (%rax)
movl $0x7fc00000, -0x4(%rbp) # imm = 0x7FC00000
jmp 0x7a21
movl -0x24(%rbp), %edi
movl $0xff, %esi
xorl %edx, %edx
callq 0x7160
movl %eax, -0x4(%rbp)
jmp 0x7a21
cmpl $0xff, -0x2c(%rbp)
jne 0x792a
cmpl $0x0, -0x38(%rbp)
je 0x7916
movl -0x8(%rbp), %edi
callq 0x6c00
cmpl $0x0, %eax
jne 0x78ff
movl -0xc(%rbp), %edi
callq 0x6c00
cmpl $0x0, %eax
je 0x790a
movq -0x18(%rbp), %rax
movl (%rax), %ecx
orl $0x10, %ecx
movl %ecx, (%rax)
movl $0x7fc00000, -0x4(%rbp) # imm = 0x7FC00000
jmp 0x7a21
movl -0x24(%rbp), %edi
xorl %edx, %edx
movl %edx, %esi
callq 0x7160
movl %eax, -0x4(%rbp)
jmp 0x7a21
jmp 0x792c
cmpl $0x0, -0x2c(%rbp)
jne 0x798e
cmpl $0x0, -0x38(%rbp)
jne 0x797d
cmpl $0x0, -0x28(%rbp)
jne 0x795b
cmpl $0x0, -0x34(%rbp)
jne 0x795b
movq -0x18(%rbp), %rax
movl (%rax), %ecx
orl $0x10, %ecx
movl %ecx, (%rax)
movl $0x7fc00000, -0x4(%rbp) # imm = 0x7FC00000
jmp 0x7a21
movq -0x18(%rbp), %rax
movl (%rax), %ecx
orl $0x8, %ecx
movl %ecx, (%rax)
movl -0x24(%rbp), %edi
movl $0xff, %esi
xorl %edx, %edx
callq 0x7160
movl %eax, -0x4(%rbp)
jmp 0x7a21
movl -0x38(%rbp), %esi
leaq -0x2c(%rbp), %rdi
callq 0x7190
movl %eax, -0x38(%rbp)
jmp 0x7999
movl -0x38(%rbp), %eax
orl $0x800000, %eax         # imm = 0x800000
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x79c7
cmpl $0x0, -0x34(%rbp)
jne 0x79b6
movl -0x24(%rbp), %edi
xorl %edx, %edx
movl %edx, %esi
callq 0x7160
movl %eax, -0x4(%rbp)
jmp 0x7a21
movl -0x34(%rbp), %esi
leaq -0x28(%rbp), %rdi
callq 0x7190
movl %eax, -0x34(%rbp)
jmp 0x79d2
movl -0x34(%rbp), %eax
orl $0x800000, %eax         # imm = 0x800000
movl %eax, -0x34(%rbp)
movl -0x28(%rbp), %eax
subl -0x2c(%rbp), %eax
addl $0x80, %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x34(%rbp), %esi
movl -0x38(%rbp), %ecx
shll $0x2, %ecx
leaq -0x40(%rbp), %rdi
xorl %edx, %edx
callq 0x7a30
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x7a09
movl -0x3c(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x24(%rbp), %edi
movl -0x30(%rbp), %esi
movl -0x3c(%rbp), %edx
movl -0x10(%rbp), %ecx
movq -0x18(%rbp), %r8
callq 0x6eb0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)