// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movq %rdx, %rbx
movq %rdi, %r15
movabsq $0xffffffffffff, %r13   # imm = 0xFFFFFFFFFFFF
movq %rdi, 0x8(%rsp)
movq %rsi, %rdi
andq %r13, %rdi
movq %rdi, 0x10(%rsp)
movq %rsi, %rcx
shrq $0x30, %rcx
movl $0x7fff, %edx           # imm = 0x7FFF
movl %ecx, %eax
andl %edx, %eax
movl %eax, 0x4(%rsp)
cmpl %edx, %eax
jne 0x139f1
orq %r15, %rdi
je 0x13c42
movq %r15, %rdi
movq %r15, %rdx
movq %rsi, %rcx
movq %rbx, %r8
callq 0x122b1
jmp 0x13c3a
testq %rsi, %rsi
js 0x13c49
testl %eax, %eax
jne 0x13a35
movq %rdi, %rax
orq %r15, %rax
je 0x13c7d
leaq 0x4(%rsp), %r14
leaq 0x10(%rsp), %r12
leaq 0x8(%rsp), %rbp
movq %r15, %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %rbp, %r8
callq 0x11f34
movl (%r14), %eax
movq (%r12), %rdi
movq (%rbp), %r15
leal -0x3fff(%rax), %ebp
sarl %ebp
incq %r13
orq %rdi, %r13
movslq %eax, %r14
movq %r13, %rsi
shrq $0x11, %rsi
movq %r14, %rdi
callq 0xc279
andb $0x1, %r14b
xorb $0xd, %r14b
movq %r15, %r12
movl %r14d, %ecx
shlq %cl, %r12
shlq %cl, %r13
negb %r14b
movl %r14d, %ecx
shrq %cl, %r15
movl %eax, %r14d
orq %r13, %r15
movq %r14, %rdx
shlq $0x20, %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0xba2b
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
movabsq $0x100000000, %r8       # imm = 0x100000000
andq %r8, %rsi
shlq $0x21, %rdx
movq %r14, %r8
imulq %r14, %r8
subq %r8, %r12
sbbq $0x0, %r15
addq %rcx, %rdi
addq %rsi, %rdi
subq %rdi, %r15
cmpq %rdx, %r8
sbbq $0x0, %r15
js 0x13ae6
movq %rax, %r13
jmp 0x13b02
decq %r14
leaq -0x2(%rax), %r13
movq %r14, %rcx
shrq $0x3f, %rcx
decq %rax
addq %rax, %r12
adcq %rcx, %r15
movq %r13, %rax
js 0x13ae6
addl $0x3ffe, %ebp           # imm = 0x3FFE
movq %r12, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0xba2b
movl %eax, %ecx
andl $0x1ffe, %ecx           # imm = 0x1FFE
cmpl $0x5, %ecx
ja 0x13c18
cmpq $0x1, %rax
adcq $0x0, %rax
movq %r13, %r9
shrq $0x20, %r9
movq %rax, %rdx
shrq $0x20, %rdx
movl %r13d, %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 %r13, %r8
movq %r8, %rcx
negq %rcx
sbbq $0x0, %r12
addq %r9, %r11
subq %r11, %r12
addq %r10, %r12
shlq $0x20, %rsi
imulq %rdx, %rdi
imulq %rdx, %rdx
movq %rdi, %r9
shrq $0x1f, %r9
movabsq $0x100000000, %r10      # imm = 0x100000000
andq %r9, %r10
movl %r9d, %r9d
addq %rdx, %r9
shlq $0x21, %rdi
movq %rax, %rdx
imulq %rax, %rdx
cmpq %rdi, %rdx
adcq %r10, %r9
xorl %edi, %edi
subq %r9, %rcx
setb %dil
cmpq %rsi, %r8
sbbq $0x0, %r12
negq %rdx
sbbq $0x0, %rcx
sbbq %rdi, %r12
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
addq %r12, %rsi
jns 0x13c0a
leaq -0x1(,%rax,2), %rdi
decq %rax
movq %rax, %r8
shrq $0x3f, %r8
orq %r13, %r8
addq %rdi, %rdx
adcq %r8, %rcx
adcq $0x0, %rsi
addq $-0x2, %rdi
testq %rsi, %rsi
js 0x13bea
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 %rbx, %r9
callq 0x12ddf
movq %rax, %r15
movq %rdx, %rsi
jmp 0x13c68
testq %rsi, %rsi
jns 0x13c68
jmp 0x13c57
andl $0x7fff, %ecx           # imm = 0x7FFF
orq %r15, %rcx
orq %rdi, %rcx
je 0x13c68
orb $0x1, 0x2(%rbx)
movabsq $0x7fff800000000000, %rsi # imm = 0x7FFF800000000000
xorl %r15d, %r15d
movq %r15, %rax
movq %rsi, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
xorl %esi, %esi
jmp 0x13c68