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

    aSig1 = extractFloat128Frac1( a );
    aSig0 = extractFloat128Frac0( a );
    aExp = extractFloat128Exp( a );
    aSign = extractFloat128Sign( a );
    if ( aExp == 0x7FFF ) {
        if (aSig0 | aSig1) {
            return propagateFloat128NaN(a, a, status);
        }
        if ( ! aSign ) return a;
        goto invalid;
    }
    if ( aSign ) {
        if ( ( aExp | aSig0 | aSig1 ) == 0 ) return a;
 invalid:
        float_raise(float_flag_invalid, status);
        z.low = float128_default_nan_low;
        z.high = float128_default_nan_high;
        return z;
    }
    if ( aExp == 0 ) {
        if ( ( aSig0 | aSig1 ) == 0 ) return packFloat128( 0, 0, 0, 0 );
        normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 );
    }
    zExp = ( ( aExp - 0x3FFF )>>1 ) + 0x3FFE;
    aSig0 |= LIT64( 0x0001000000000000 );
    zSig0 = estimateSqrt32( aExp, aSig0>>17 );
    shortShift128Left( aSig0, aSig1, 13 - ( 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 & 0x1FFF ) <= 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 );
    }
    shift128ExtraRightJamming( zSig0, zSig1, 0, 14, &zSig0, &zSig1, &zSig2 );
    return roundAndPackFloat128(0, zExp, zSig0, zSig1, zSig2, status);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq %rdi, %rax
movabsq $0xffffffffffff, %rbx   # imm = 0xFFFFFFFFFFFF
movq %rdi, 0x18(%rsp)
movq %rsi, %rdi
andq %rbx, %rdi
movq %rdi, 0x10(%rsp)
movq %rsi, %rcx
shrq $0x30, %rcx
movl $0x7fff, %r8d           # imm = 0x7FFF
movl %ecx, %edx
andl %r8d, %edx
movl %edx, 0xc(%rsp)
cmpl %r8d, %edx
jne 0x13a11
orq %rax, %rdi
je 0x13c62
movq %rax, %rdi
movq %rax, %rdx
movq %rsi, %rcx
movq %r14, %r8
callq 0x12261
jmp 0x13c5d
testq %rsi, %rsi
js 0x13c69
testl %edx, %edx
jne 0x13a41
movq %rdi, %rcx
orq %rax, %rcx
je 0x13c9a
leaq 0xc(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0x18(%rsp), %r8
movq %rax, %rsi
callq 0x11f08
movq %r14, 0x20(%rsp)
movslq 0xc(%rsp), %r12
leal -0x3fff(%r12), %ebp
incq %rbx
orq 0x10(%rsp), %rbx
sarl %ebp
movq %rbx, 0x10(%rsp)
movq %rbx, %rsi
shrq $0x11, %rsi
movq %r12, %rdi
callq 0xc1a8
movq 0x18(%rsp), %r13
andb $0x1, %r12b
xorb $0xd, %r12b
movq %r13, %r15
movl %r12d, %ecx
shlq %cl, %r15
movl %eax, %r14d
movq %r15, 0x18(%rsp)
shlq %cl, %rbx
negb %r12b
movl %r12d, %ecx
shrq %cl, %r13
orq %rbx, %r13
movabsq $0x100000000, %rbx      # imm = 0x100000000
movq %r13, 0x10(%rsp)
movq %r14, %rdx
shlq $0x20, %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0xb99f
shlq $0x1e, %r14
addq %rax, %r14
leaq (%r14,%r14), %rax
movq %r14, %rcx
shrq $0x20, %rcx
movl %r14d, %edx
imulq %rcx, %rdx
imulq %rcx, %rcx
movq %rdx, %rsi
shrq $0x1f, %rsi
movl %esi, %edi
andq %rbx, %rsi
shlq $0x21, %rdx
movq %r14, %r8
imulq %r14, %r8
subq %r8, %r15
sbbq $0x0, %r13
addq %rcx, %rdi
addq %rsi, %rdi
subq %rdi, %r13
cmpq %rdx, %r8
sbbq $0x0, %r13
js 0x13b11
movq %rax, %r12
jmp 0x13b2d
decq %r14
leaq -0x2(%rax), %r12
movq %r14, %rcx
shrq $0x3f, %rcx
decq %rax
addq %rax, %r15
adcq %rcx, %r13
movq %r12, %rax
js 0x13b11
addl $0x3ffe, %ebp           # imm = 0x3FFE
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0xb99f
movl %eax, %ecx
andl $0x1ffe, %ecx           # imm = 0x1FFE
cmpl $0x5, %ecx
ja 0x13c39
cmpq $0x1, %rax
adcq $0x0, %rax
movq %r12, %r9
shrq $0x20, %r9
movq %rax, %rdx
shrq $0x20, %rdx
movl %r12d, %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 %r12, %r8
movq %r8, %rcx
negq %rcx
sbbq $0x0, %r15
addq %r9, %r11
subq %r11, %r15
addq %r10, %r15
shlq $0x20, %rsi
imulq %rdx, %rdi
imulq %rdx, %rdx
movq %rdi, %r9
shrq $0x1f, %r9
andq %r9, %rbx
movl %r9d, %r9d
addq %rdx, %r9
shlq $0x21, %rdi
movq %rax, %rdx
imulq %rax, %rdx
cmpq %rdi, %rdx
adcq %rbx, %r9
xorl %edi, %edi
subq %r9, %rcx
setb %dil
cmpq %rsi, %r8
sbbq $0x0, %r15
negq %rdx
sbbq $0x0, %rcx
sbbq %rdi, %r15
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
addq %r15, %rsi
jns 0x13c2b
leaq -0x1(,%rax,2), %rdi
decq %rax
movq %rax, %r8
shrq $0x3f, %r8
orq %r12, %r8
addq %rdi, %rdx
adcq %r8, %rcx
adcq $0x0, %rsi
addq $-0x2, %rdi
testq %rsi, %rsi
js 0x13c0b
orq %rcx, %rsi
xorl %ecx, %ecx
orq %rdx, %rsi
setne %cl
orq %rcx, %rax
movq %r14, %rcx
shldq $0x32, %rax, %rcx
shlq $0x32, %rax
shrq $0xe, %r14
xorl %edi, %edi
movl %ebp, %esi
movq %r14, %rdx
movq %rax, %r8
movq 0x20(%rsp), %r9
callq 0x12d7b
movq %rdx, %rsi
jmp 0x13c88
testq %rsi, %rsi
jns 0x13c88
jmp 0x13c77
andl $0x7fff, %ecx           # imm = 0x7FFF
orq %rax, %rcx
orq %rdi, %rcx
je 0x13c88
orb $0x1, 0x2(%r14)
movabsq $0x7fff800000000000, %rsi # imm = 0x7FFF800000000000
xorl %eax, %eax
movq %rsi, %rdx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
xorl %esi, %esi
jmp 0x13c88