// File: /workspace/github_c_makefile_star2_O2/mbitsnbites[P]SoftFP/softfloat.c
// Function: floatx80_div
floatx80 floatx80_div(floatx80 a, floatx80 b, float_status *status)
{
    flag aSign, bSign, zSign;
    int32 aExp, bExp, zExp;
    uint64_t aSig, bSig, zSig0, zSig1;
    uint64_t rem0, rem1, rem2, term0, term1, term2;
    floatx80 z;

    aSig = extractFloatx80Frac( a );
    aExp = extractFloatx80Exp( a );
    aSign = extractFloatx80Sign( a );
    bSig = extractFloatx80Frac( b );
    bExp = extractFloatx80Exp( b );
    bSign = extractFloatx80Sign( b );
    zSign = aSign ^ bSign;
    if ( aExp == 0x7FFF ) {
        if ((uint64_t)(aSig << 1)) {
            return propagateFloatx80NaN(a, b, status);
        }
        if ( bExp == 0x7FFF ) {
            if ((uint64_t)(bSig << 1)) {
                return propagateFloatx80NaN(a, b, status);
            }
            goto invalid;
        }
        return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
    }
    if ( bExp == 0x7FFF ) {
        if ((uint64_t)(bSig << 1)) {
            return propagateFloatx80NaN(a, b, status);
        }
        return packFloatx80( zSign, 0, 0 );
    }
    if ( bExp == 0 ) {
        if ( bSig == 0 ) {
            if ( ( aExp | aSig ) == 0 ) {
 invalid:
                float_raise(float_flag_invalid, status);
                z.low = floatx80_default_nan_low;
                z.high = floatx80_default_nan_high;
                return z;
            }
            float_raise(float_flag_divbyzero, status);
            return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
        }
        normalizeFloatx80Subnormal( bSig, &bExp, &bSig );
    }
    if ( aExp == 0 ) {
        if ( aSig == 0 ) return packFloatx80( zSign, 0, 0 );
        normalizeFloatx80Subnormal( aSig, &aExp, &aSig );
    }
    zExp = aExp - bExp + 0x3FFE;
    rem1 = 0;
    if ( bSig <= aSig ) {
        shift128Right( aSig, 0, 1, &aSig, &rem1 );
        ++zExp;
    }
    zSig0 = estimateDiv128To64( aSig, rem1, bSig );
    mul64To128( bSig, zSig0, &term0, &term1 );
    sub128( aSig, rem1, term0, term1, &rem0, &rem1 );
    while ( (int64_t) rem0 < 0 ) {
        --zSig0;
        add128( rem0, rem1, 0, bSig, &rem0, &rem1 );
    }
    zSig1 = estimateDiv128To64( rem1, 0, bSig );
    if ( (uint64_t) ( zSig1<<1 ) <= 8 ) {
        mul64To128( bSig, zSig1, &term1, &term2 );
        sub128( rem1, 0, term1, term2, &rem1, &rem2 );
        while ( (int64_t) rem1 < 0 ) {
            --zSig1;
            add128( rem1, rem2, 0, bSig, &rem1, &rem2 );
        }
        zSig1 |= ( ( rem1 | rem2 ) != 0 );
    }
    return roundAndPackFloatx80(status->floatx80_rounding_precision,
                                zSign, zExp, zSig0, zSig1, status);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rdi, %r15
movl $0x7fff, %eax           # imm = 0x7FFF
movl %ecx, %edi
andl %eax, %edi
movl %ecx, %edx
xorl %esi, %edx
movl %esi, %r9d
notl %r9d
testw $0x7fff, %r9w           # imm = 0x7FFF
jne 0xf6a0
leaq (,%r15,2), %rax
testq %rax, %rax
jne 0xf6c8
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
cmpw $0x7fff, %di            # imm = 0x7FFF
jne 0xf838
testq %rax, %r14
jne 0xf6c8
jmp 0xf861
movl %esi, %ebp
andl %eax, %ebp
pushq $0x1
popq %rax
testw %di, %di
je 0xf6d8
movzwl %di, %edi
cmpl $0x7fff, %edi           # imm = 0x7FFF
jne 0xf6f0
leaq (,%r14,2), %rax
testq %rax, %rax
je 0xf82e
movq %r15, %rdi
movq %r14, %rdx
callq 0xec53
jmp 0xf81f
testq %r14, %r14
je 0xf840
bsrq %r14, %rcx
xorq $0x3f, %rcx
shlq %cl, %r14
movl %eax, %edi
subl %ecx, %edi
testl %ebp, %ebp
je 0xf6ff
movl %edi, 0xc(%rsp)
movq %r8, 0x10(%rsp)
jmp 0xf720
testq %r15, %r15
je 0xf82e
movl %edi, 0xc(%rsp)
movq %r8, 0x10(%rsp)
bsrq %r15, %rcx
xorq $0x3f, %rcx
shlq %cl, %r15
subl %ecx, %eax
movl %eax, %ebp
movzwl %dx, %eax
shrl $0xf, %eax
movl %eax, 0x24(%rsp)
movq %r15, %rax
shlq $0x3f, %rax
xorl %r13d, %r13d
xorl %ebx, %ebx
cmpq %r15, %r14
setbe %bl
cmovbeq %rax, %r13
movl %ebx, %ecx
shrq %cl, %r15
orl $0x3ffe, %ebx           # imm = 0x3FFE
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0xadbc
movq %rax, %r12
leaq 0x28(%rsp), %rdx
leaq 0x18(%rsp), %rcx
movq %r14, %rdi
movq %rax, %rsi
callq 0xd0a6
leaq 0x18(%rsp), %rax
subq (%rax), %r13
leaq 0x28(%rsp), %rax
sbbq (%rax), %r15
movl 0xc(%rsp), %eax
testq %r15, %r15
jns 0xf796
decq %r12
addq %r14, %r13
adcq $0x0, %r15
jmp 0xf785
subl %eax, %ebp
addl %ebx, %ebp
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0xadbc
movq %rax, %r15
addq %rax, %rax
cmpq $0x8, %rax
ja 0xf803
leaq 0x18(%rsp), %rdx
leaq 0x30(%rsp), %rbx
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rcx
callq 0xd0a6
xorl %eax, %eax
xorl %ecx, %ecx
subq (%rbx), %rcx
sbbq %rax, %rax
leaq 0x18(%rsp), %rdx
subq (%rdx), %rax
addq %r13, %rax
movq 0x10(%rsp), %r9
testq %rax, %rax
jns 0xf7f6
decq %r15
addq %r14, %rcx
adcq $0x0, %rax
jmp 0xf7e5
xorl %edx, %edx
orq %rax, %rcx
setne %dl
orq %rdx, %r15
jmp 0xf808
movq 0x10(%rsp), %r9
movsbl 0x3(%r9), %edi
movzbl 0x24(%rsp), %esi
movl %ebp, %edx
movq %r12, %rcx
movq %r15, %r8
callq 0xf265
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
andl $0x8000, %edx           # imm = 0x8000
xorl %eax, %eax
jmp 0xf81f
orl $0x7fff, %edx           # imm = 0x7FFF
jmp 0xf85c
movl %ebp, %eax
orq %r15, %rax
je 0xf861
orb $0x4, 0x2(%r8)
orl $0x7fff, %edx           # imm = 0x7FFF
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
incq %rax
jmp 0xf81f
orb $0x1, 0x2(%r8)
movw $0xffff, %dx            # imm = 0xFFFF
movabsq $-0x4000000000000000, %rax # imm = 0xC000000000000000
jmp 0xf81f