// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %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
testl $0x7fff, %r9d           # imm = 0x7FFF
jne 0x10a65
leaq (,%r15,2), %rax
testq %rax, %rax
jne 0x10a8b
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
movzwl %di, %edi
cmpl $0x7fff, %edi           # imm = 0x7FFF
jne 0x10ba6
testq %rax, %r14
jne 0x10a8b
jmp 0x10ceb
movl %esi, %r13d
andl %eax, %r13d
testw %di, %di
je 0x10a9b
movzwl %di, %eax
cmpl $0x7fff, %eax           # imm = 0x7FFF
jne 0x10ab6
leaq (,%r14,2), %rax
testq %rax, %rax
je 0x10b99
movq %r15, %rdi
movq %r14, %rdx
callq 0xff00
jmp 0x10cba
testq %r14, %r14
je 0x10cc9
bsrq %r14, %rcx
xorq $0x3f, %rcx
shlq %cl, %r14
movl $0x1, %eax
subl %ecx, %eax
testl %r13d, %r13d
je 0x10ac2
movq %r8, 0x8(%rsp)
jmp 0x10ae4
testq %r15, %r15
je 0x10b99
movq %r8, 0x8(%rsp)
bsrq %r15, %rcx
xorq $0x3f, %rcx
shlq %cl, %r15
movl $0x1, %r13d
subl %ecx, %r13d
subl %eax, %r13d
movzwl %dx, %eax
shrl $0xf, %eax
movl %eax, 0x4(%rsp)
movq %r15, %rax
shlq $0x3f, %rax
xorl %ebx, %ebx
xorl %ecx, %ecx
cmpq %r15, %r14
setbe %cl
movabsq $-0x100000000, %rbp     # imm = 0xFFFFFFFF00000000
cmovbeq %rax, %rbx
movq %rcx, 0x20(%rsp)
shrq %cl, %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0xba2b
movq %rax, %r12
movq %r14, %rsi
shrq $0x20, %rsi
movq %rax, %rdx
shrq $0x20, %rdx
movl %r14d, %edi
movl %r12d, %ecx
movq %rdx, %rax
movq %rdi, 0x10(%rsp)
imulq %rdi, %rax
imulq %rsi, %rcx
movq %rsi, 0x18(%rsp)
imulq %rsi, %rdx
xorl %esi, %esi
addq %rax, %rcx
setae %sil
shlq $0x20, %rsi
movq %rcx, %rdi
shrq $0x20, %rdi
movq %r12, %r8
imulq %r14, %r8
movq %rbx, %rax
subq %r8, %rax
sbbq $0x0, %r15
addq %rdx, %rdi
subq %rdi, %r15
addq %rsi, %r15
shlq $0x20, %rcx
addq %rbp, %r15
cmpq %rcx, %r8
sbbq $0x0, %r15
js 0x10bb1
movq %rax, %rbp
jmp 0x10bd7
andl $0x8000, %edx           # imm = 0x8000
xorl %eax, %eax
jmp 0x10cba
orl $0x7fff, %edx           # imm = 0x7FFF
jmp 0x10ce6
movl $0x1, %ecx
subq %r12, %rcx
imulq %r14, %rcx
addq %rcx, %rbx
decq %r12
leaq (%rax,%r14), %rbp
cmpq %rax, %rbx
leaq (%rbx,%r14), %rbx
adcq $0x0, %r15
movq %rbp, %rax
js 0x10bc0
movq 0x20(%rsp), %rax
leal (%rax,%r13), %r15d
addl $0x3ffe, %r15d          # imm = 0x3FFE
movq %rbp, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0xba2b
leaq (%rax,%rax), %rcx
cmpq $0x8, %rcx
ja 0x10c9a
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %esi
movq 0x10(%rsp), %r8
imulq %rdx, %r8
movq 0x18(%rsp), %rcx
imulq %rcx, %rsi
imulq %rcx, %rdx
xorl %edi, %edi
addq %r8, %rsi
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
cmovbq %rcx, %rdi
movq %rsi, %r8
shrq $0x20, %r8
shlq $0x20, %rsi
movq %rax, %r9
imulq %r14, %r9
movq %r9, %rcx
negq %rcx
sbbq $0x0, %rbp
addq %rdx, %r8
subq %r8, %rbp
addq %rdi, %rbp
cmpq %rsi, %r9
sbbq $0x0, %rbp
jns 0x10c84
movl $0x1, %edx
subq %rax, %rdx
imulq %r14, %rdx
decq %rax
cmpq %rcx, %rdx
leaq (%rcx,%r14), %rcx
leaq (%rdx,%r14), %rdx
adcq $0x0, %rbp
js 0x10c6e
xorl %ebp, %ebp
movq 0x8(%rsp), %r9
movl 0x4(%rsp), %esi
xorl %edx, %edx
orq %rcx, %rbp
setne %dl
orq %rdx, %rax
jmp 0x10ca3
movq 0x8(%rsp), %r9
movl 0x4(%rsp), %esi
movsbl 0x3(%r9), %edi
movzbl %sil, %esi
movl %r15d, %edx
movq %r12, %rcx
movq %rax, %r8
callq 0x10615
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r13d, %eax
orq %r15, %rax
je 0x10ceb
orb $0x4, 0x2(%r8)
orl $0x7fff, %edx           # imm = 0x7FFF
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
incq %rax
jmp 0x10cba
orb $0x1, 0x2(%r8)
movw $0xffff, %dx            # imm = 0xFFFF
movabsq $-0x4000000000000000, %rax # imm = 0xC000000000000000
jmp 0x10cba