// File: /workspace/github_c_makefile_star2_O3/mbitsnbites[P]SoftFP/softfloat.c
// Function: floatx80_sqrt
floatx80 floatx80_sqrt(floatx80 a, float_status *status)
{
    flag aSign;
    int32 aExp, zExp;
    uint64_t aSig0, aSig1, zSig0, zSig1, doubleZSig0;
    uint64_t rem0, rem1, rem2, rem3, term0, term1, term2, term3;
    floatx80 z;

    aSig0 = extractFloatx80Frac( a );
    aExp = extractFloatx80Exp( a );
    aSign = extractFloatx80Sign( a );
    if ( aExp == 0x7FFF ) {
        if ((uint64_t)(aSig0 << 1)) {
            return propagateFloatx80NaN(a, a, status);
        }
        if ( ! aSign ) return a;
        goto invalid;
    }
    if ( aSign ) {
        if ( ( aExp | aSig0 ) == 0 ) return a;
 invalid:
        float_raise(float_flag_invalid, status);
        z.low = floatx80_default_nan_low;
        z.high = floatx80_default_nan_high;
        return z;
    }
    if ( aExp == 0 ) {
        if ( aSig0 == 0 ) return packFloatx80( 0, 0, 0 );
        normalizeFloatx80Subnormal( aSig0, &aExp, &aSig0 );
    }
    zExp = ( ( aExp - 0x3FFF )>>1 ) + 0x3FFF;
    zSig0 = estimateSqrt32( aExp, aSig0>>32 );
    shift128Right( aSig0, 0, 2 + ( aExp & 1 ), &aSig0, &aSig1 );
    zSig0 = estimateDiv128To64( aSig0, aSig1, zSig0<<32 ) + ( zSig0<<30 );
    doubleZSig0 = zSig0<<1;
    mul64To128( zSig0, zSig0, &term0, &term1 );
    sub128( aSig0, aSig1, term0, term1, &rem0, &rem1 );
    while ( (int64_t) rem0 < 0 ) {
        --zSig0;
        doubleZSig0 -= 2;
        add128( rem0, rem1, zSig0>>63, doubleZSig0 | 1, &rem0, &rem1 );
    }
    zSig1 = estimateDiv128To64( rem1, 0, doubleZSig0 );
    if ( ( zSig1 & LIT64( 0x3FFFFFFFFFFFFFFF ) ) <= 5 ) {
        if ( zSig1 == 0 ) zSig1 = 1;
        mul64To128( doubleZSig0, zSig1, &term1, &term2 );
        sub128( rem1, 0, term1, term2, &rem1, &rem2 );
        mul64To128( zSig1, zSig1, &term2, &term3 );
        sub192( rem1, rem2, 0, 0, term2, term3, &rem1, &rem2, &rem3 );
        while ( (int64_t) rem1 < 0 ) {
            --zSig1;
            shortShift128Left( 0, zSig1, 1, &term2, &term3 );
            term3 |= 1;
            term2 |= doubleZSig0;
            add192( rem1, rem2, rem3, 0, term2, term3, &rem1, &rem2, &rem3 );
        }
        zSig1 |= ( ( rem1 | rem2 | rem3 ) != 0 );
    }
    shortShift128Left( 0, zSig1, 1, &zSig0, &zSig1 );
    zSig0 |= doubleZSig0;
    return roundAndPackFloatx80(status->floatx80_rounding_precision,
                                0, zExp, zSig0, zSig1, status);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
movl %esi, %ecx
movl %esi, %eax
notl %eax
testl $0x7fff, %eax           # imm = 0x7FFF
jne 0x11113
leaq (,%r14,2), %rax
testq %rax, %rax
je 0x111e4
movq %r14, %rdi
movl %ecx, %esi
movq %r14, %rdx
movq %rbx, %r8
callq 0xff00
jmp 0x1136a
andl $0x7fff, %esi           # imm = 0x7FFF
testw %cx, %cx
js 0x111f3
testl %esi, %esi
jne 0x11141
testq %r14, %r14
je 0x11383
bsrq %r14, %rcx
xorq $0x3f, %rcx
shlq %cl, %r14
movl $0x1, %esi
subl %ecx, %esi
movabsq $0x100000000, %r13      # imm = 0x100000000
leal -0x3fff(%rsi), %ebp
sarl %ebp
movslq %esi, %r15
movq %r14, %rsi
shrq $0x20, %rsi
movq %r15, %rdi
callq 0xc279
andb $0x1, %r15b
orb $0x2, %r15b
movq %r14, %r12
movl %r15d, %ecx
shrq %cl, %r12
negb %r15b
movl %r15d, %ecx
shlq %cl, %r14
movl %eax, %r15d
movq %r15, %rdx
shlq $0x20, %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0xba2b
shlq $0x1e, %r15
leaq (%r15,%rax), %rdx
leaq (%rdx,%rdx), %rcx
movq %rdx, %rsi
shrq $0x20, %rsi
movl %edx, %edi
imulq %rsi, %rdi
imulq %rsi, %rsi
movq %rdi, %r8
shrq $0x1f, %r8
movl %r8d, %r9d
andq %r13, %r8
shlq $0x21, %rdi
imulq %rdx, %rdx
subq %rdx, %r14
sbbq $0x0, %r12
addq %rsi, %r9
addq %r8, %r9
subq %r9, %r12
cmpq %rdi, %rdx
sbbq $0x0, %r12
js 0x11215
movq %rcx, %r15
jmp 0x1123a
testw %cx, %cx
movw $0x7fff, %cx            # imm = 0x7FFF
jns 0x1136f
jmp 0x111fe
movl %esi, %eax
orq %r14, %rax
je 0x1136f
orb $0x1, 0x2(%rbx)
movw $0xffff, %cx            # imm = 0xFFFF
movabsq $-0x4000000000000000, %r14 # imm = 0xC000000000000000
jmp 0x1136f
addq %r15, %rax
decq %rax
leaq -0x2(%rcx), %r15
movq %rax, %rdx
shrq $0x3f, %rdx
decq %rcx
addq %rcx, %r14
adcq %rdx, %r12
decq %rax
movq %r15, %rcx
testq %r12, %r12
js 0x1121b
addl $0x3fff, %ebp           # imm = 0x3FFF
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0xba2b
movabsq $0x3ffffffffffffffe, %rcx # imm = 0x3FFFFFFFFFFFFFFE
andq %rax, %rcx
cmpq $0x5, %rcx
ja 0x1134c
cmpq $0x1, %rax
adcq $0x0, %rax
movq %r15, %r9
shrq $0x20, %r9
movq %rax, %rdx
shrq $0x20, %rdx
movl %r15d, %ecx
andl $-0x2, %ecx
movl %eax, %edi
imulq %rdx, %rcx
movq %rdi, %rsi
imulq %r9, %rsi
imulq %rdx, %r9
xorl %r10d, %r10d
addq %rcx, %rsi
setae %r10b
shlq $0x20, %r10
movq %rsi, %r11
shrq $0x20, %r11
movq %rax, %r8
imulq %r15, %r8
movq %r8, %rcx
negq %rcx
sbbq $0x0, %r14
addq %r9, %r11
subq %r11, %r14
addq %r10, %r14
shlq $0x20, %rsi
imulq %rdx, %rdi
imulq %rdx, %rdx
movq %rdi, %r9
shrq $0x1f, %r9
andq %r9, %r13
movl %r9d, %r9d
addq %rdx, %r9
shlq $0x21, %rdi
movq %rax, %rdx
imulq %rax, %rdx
cmpq %rdi, %rdx
adcq %r13, %r9
xorl %edi, %edi
subq %r9, %rcx
setb %dil
cmpq %rsi, %r8
sbbq $0x0, %r14
negq %rdx
sbbq $0x0, %rcx
sbbq %rdi, %r14
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
addq %r14, %rsi
jns 0x1133e
leaq -0x1(,%rax,2), %rdi
decq %rax
movq %rax, %r8
shrq $0x3f, %r8
orq %r15, %r8
addq %rdi, %rdx
adcq %r8, %rcx
adcq $0x0, %rsi
addq $-0x2, %rdi
testq %rsi, %rsi
js 0x1131e
orq %rcx, %rsi
xorl %ecx, %ecx
orq %rdx, %rsi
setne %cl
orq %rcx, %rax
leaq (%rax,%rax), %r8
shrq $0x3f, %rax
orq %r15, %rax
movsbl 0x3(%rbx), %edi
xorl %esi, %esi
movl %ebp, %edx
movq %rax, %rcx
movq %rbx, %r9
callq 0x10615
movq %rax, %r14
movl %edx, %ecx
movq %r14, %rax
movl %ecx, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
xorl %ecx, %ecx
jmp 0x1136f