// File: /workspace/github_c_makefile_star2_O3/mbitsnbites[P]SoftFP/softfloat.c
// Function: float64_sqrt
float64 float64_sqrt(float64 a, float_status *status)
{
    flag aSign;
    int_fast16_t aExp, zExp;
    uint64_t aSig, zSig, doubleZSig;
    uint64_t rem0, rem1, term0, term1;
    a = float64_squash_input_denormal(a, status);

    aSig = extractFloat64Frac( a );
    aExp = extractFloat64Exp( a );
    aSign = extractFloat64Sign( a );
    if ( aExp == 0x7FF ) {
        if (aSig) {
            return propagateFloat64NaN(a, a, status);
        }
        if ( ! aSign ) return a;
        float_raise(float_flag_invalid, status);
        return float64_default_nan;
    }
    if ( aSign ) {
        if ( ( aExp | aSig ) == 0 ) return a;
        float_raise(float_flag_invalid, status);
        return float64_default_nan;
    }
    if ( aExp == 0 ) {
        if ( aSig == 0 ) return float64_zero;
        normalizeFloat64Subnormal( aSig, &aExp, &aSig );
    }
    zExp = ( ( aExp - 0x3FF )>>1 ) + 0x3FE;
    aSig |= LIT64( 0x0010000000000000 );
    zSig = estimateSqrt32( aExp, aSig>>21 );
    aSig <<= 9 - ( aExp & 1 );
    zSig = estimateDiv128To64( aSig, 0, zSig<<32 ) + ( zSig<<30 );
    if ( ( zSig & 0x1FF ) <= 5 ) {
        doubleZSig = zSig<<1;
        mul64To128( zSig, zSig, &term0, &term1 );
        sub128( aSig, 0, term0, term1, &rem0, &rem1 );
        while ( (int64_t) rem0 < 0 ) {
            --zSig;
            doubleZSig -= 2;
            add128( rem0, rem1, zSig>>63, doubleZSig | 1, &rem0, &rem1 );
        }
        zSig |= ( ( rem0 | rem1 ) != 0 );
    }
    return roundAndPackFloat64(0, zExp, zSig, status);

}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movabsq $0xfffffffffffff, %r14  # imm = 0xFFFFFFFFFFFFF
cmpb $0x0, 0x5(%rsi)
je 0xeea5
movabsq $0x7ff0000000000000, %rax # imm = 0x7FF0000000000000
testq %rax, %rdi
setne %al
testq %r14, %rdi
sete %cl
orb %al, %cl
jne 0xeea5
orb $0x40, 0x2(%rbx)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq %rax, %rdi
movq %rdi, %rax
andq %r14, %rax
movq %rdi, %r12
shrq $0x34, %r12
movl $0x7ff, %ecx            # imm = 0x7FF
andq %rcx, %r12
cmpq %rcx, %r12
jne 0xeede
testq %rax, %rax
je 0xf008
movq %rdi, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xdbdb
testq %rdi, %rdi
js 0xf00f
testq %r12, %r12
jne 0xef12
testq %rax, %rax
je 0xf031
bsrq %rax, %rcx
xorl $0x3f, %ecx
addl $0xf5, %ecx
movzbl %cl, %ecx
shlq %cl, %rax
movl $0x1, %edx
subl %ecx, %edx
movslq %edx, %r12
leaq -0x3ff(%r12), %r15
sarq %r15
addq $0x3fe, %r15            # imm = 0x3FE
incq %r14
orq %rax, %r14
movq %r14, %rsi
shrq $0x15, %rsi
movq %r12, %rdi
callq 0xc279
andb $0x1, %r12b
xorb $0x9, %r12b
movl %r12d, %ecx
shlq %cl, %r14
movl %eax, %r12d
movq %r12, %rdx
shlq $0x20, %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0xba2b
movq %r12, %rdx
shlq $0x1e, %rdx
addq %rax, %rdx
movl %eax, %ecx
andl $0x1fe, %ecx            # imm = 0x1FE
cmpl $0x5, %ecx
ja 0xeff0
movq %rdx, %rsi
shrq $0x20, %rsi
movl %edx, %edi
imulq %rsi, %rdi
imulq %rsi, %rsi
movq %rdi, %rcx
shrq $0x1f, %rcx
movabsq $0x100000000, %r8       # imm = 0x100000000
andq %rcx, %r8
movl %ecx, %r9d
shlq $0x21, %rdi
movq %rdx, %r10
imulq %rdx, %r10
movq %r10, %rcx
negq %rcx
sbbq $0x0, %r14
addq %rsi, %r9
addq %r8, %r9
subq %r9, %r14
cmpq %rdi, %r10
sbbq $0x0, %r14
jns 0xefe5
shlq $0x1f, %r12
leaq (%r12,%rax,2), %rax
decq %rax
decq %rdx
movq %rdx, %rsi
shrq $0x3f, %rsi
addq %rax, %rcx
adcq %rsi, %r14
addq $-0x2, %rax
testq %r14, %r14
js 0xefcc
xorl %eax, %eax
orq %rcx, %r14
setne %al
orq %rax, %rdx
xorl %edi, %edi
movq %r15, %rsi
movq %rbx, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xa25f
testq %rdi, %rdi
jns 0xf022
jmp 0xf014
orq %rax, %r12
je 0xf022
movabsq $0x7ff8000000000000, %rdi # imm = 0x7FF8000000000000
orb $0x1, 0x2(%rbx)
movq %rdi, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %edi, %edi
jmp 0xf022