 roundAndPackFloatx80(

     int8 roundingPrecision, flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1

 STATUS_PARAM)

{

    int8 roundingMode;

    flag roundNearestEven, increment, isTiny;

    int64 roundIncrement, roundMask, roundBits;



    roundingMode = STATUS(float_rounding_mode);

    roundNearestEven = ( roundingMode == float_round_nearest_even );

    if ( roundingPrecision == 80 ) goto precision80;

    if ( roundingPrecision == 64 ) {

        roundIncrement = LIT64( 0x0000000000000400 );

        roundMask = LIT64( 0x00000000000007FF );

    }

    else if ( roundingPrecision == 32 ) {

        roundIncrement = LIT64( 0x0000008000000000 );

        roundMask = LIT64( 0x000000FFFFFFFFFF );

    }

    else {

        goto precision80;

    }

    zSig0 |= ( zSig1 != 0 );

    if ( ! roundNearestEven ) {

        if ( roundingMode == float_round_to_zero ) {

            roundIncrement = 0;

        }

        else {

            roundIncrement = roundMask;

            if ( zSign ) {

                if ( roundingMode == float_round_up ) roundIncrement = 0;

            }

            else {

                if ( roundingMode == float_round_down ) roundIncrement = 0;

            }

        }

    }

    roundBits = zSig0 & roundMask;

    if ( 0x7FFD <= (uint32_t) ( zExp - 1 ) ) {

        if (    ( 0x7FFE < zExp )

             || ( ( zExp == 0x7FFE ) && ( zSig0 + roundIncrement < zSig0 ) )

           ) {

            goto overflow;

        }

        if ( zExp <= 0 ) {

            if ( STATUS(flush_to_zero) ) return packFloatx80( zSign, 0, 0 );

            isTiny =

                   ( STATUS(float_detect_tininess) == float_tininess_before_rounding )

                || ( zExp < 0 )

                || ( zSig0 <= zSig0 + roundIncrement );

            shift64RightJamming( zSig0, 1 - zExp, &zSig0 );

            zExp = 0;

            roundBits = zSig0 & roundMask;

            if ( isTiny && roundBits ) float_raise( float_flag_underflow STATUS_VAR);

            if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;

            zSig0 += roundIncrement;

            if ( (int64_t) zSig0 < 0 ) zExp = 1;

            roundIncrement = roundMask + 1;

            if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {

                roundMask |= roundIncrement;

            }

            zSig0 &= ~ roundMask;

            return packFloatx80( zSign, zExp, zSig0 );

        }

    }

    if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;

    zSig0 += roundIncrement;

    if ( zSig0 < roundIncrement ) {

        ++zExp;

        zSig0 = LIT64( 0x8000000000000000 );

    }

    roundIncrement = roundMask + 1;

    if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {

        roundMask |= roundIncrement;

    }

    zSig0 &= ~ roundMask;

    if ( zSig0 == 0 ) zExp = 0;

    return packFloatx80( zSign, zExp, zSig0 );

 precision80:

    increment = ( (int64_t) zSig1 < 0 );

    if ( ! roundNearestEven ) {

        if ( roundingMode == float_round_to_zero ) {

            increment = 0;

        }

        else {

            if ( zSign ) {

                increment = ( roundingMode == float_round_down ) && zSig1;

            }

            else {

                increment = ( roundingMode == float_round_up ) && zSig1;

            }

        }

    }

    if ( 0x7FFD <= (uint32_t) ( zExp - 1 ) ) {

        if (    ( 0x7FFE < zExp )

             || (    ( zExp == 0x7FFE )

                  && ( zSig0 == LIT64( 0xFFFFFFFFFFFFFFFF ) )

                  && increment

                )

           ) {

            roundMask = 0;

 overflow:

            float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR);

            if (    ( roundingMode == float_round_to_zero )

                 || ( zSign && ( roundingMode == float_round_up ) )

                 || ( ! zSign && ( roundingMode == float_round_down ) )

               ) {

                return packFloatx80( zSign, 0x7FFE, ~ roundMask );

            }

            return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );

        }

        if ( zExp <= 0 ) {

            isTiny =

                   ( STATUS(float_detect_tininess) == float_tininess_before_rounding )

                || ( zExp < 0 )

                || ! increment

                || ( zSig0 < LIT64( 0xFFFFFFFFFFFFFFFF ) );

            shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 );

            zExp = 0;

            if ( isTiny && zSig1 ) float_raise( float_flag_underflow STATUS_VAR);

            if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;

            if ( roundNearestEven ) {

                increment = ( (int64_t) zSig1 < 0 );

            }

            else {

                if ( zSign ) {

                    increment = ( roundingMode == float_round_down ) && zSig1;

                }

                else {

                    increment = ( roundingMode == float_round_up ) && zSig1;

                }

            }

            if ( increment ) {

                ++zSig0;

                zSig0 &=

                    ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );

                if ( (int64_t) zSig0 < 0 ) zExp = 1;

            }

            return packFloatx80( zSign, zExp, zSig0 );

        }

    }

    if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;

    if ( increment ) {

        ++zSig0;

        if ( zSig0 == 0 ) {

            ++zExp;

            zSig0 = LIT64( 0x8000000000000000 );

        }

        else {

            zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );

        }

    }

    else {

        if ( zSig0 == 0 ) zExp = 0;

    }

    return packFloatx80( zSign, zExp, zSig0 );



}

 roundAndPackFloatx80(

     int8 roundingPrecision, flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1

 STATUS_PARAM)

{

    int8 roundingMode;

    flag roundNearestEven, increment, isTiny;

    int64 roundIncrement, roundMask, roundBits;



    roundingMode = STATUS(float_rounding_mode);

    roundNearestEven = ( roundingMode == float_round_nearest_even );

    if ( roundingPrecision == 80 ) goto precision80;

    if ( roundingPrecision == 64 ) {

        roundIncrement = LIT64( 0x0000000000000400 );

        roundMask = LIT64( 0x00000000000007FF );

    }

    else if ( roundingPrecision == 32 ) {

        roundIncrement = LIT64( 0x0000008000000000 );

        roundMask = LIT64( 0x000000FFFFFFFFFF );

    }

    else {

        goto precision80;

    }

    zSig0 |= ( zSig1 != 0 );

    if ( ! roundNearestEven ) {

        if ( roundingMode == float_round_to_zero ) {

            roundIncrement = 0;

        }

        else {

            roundIncrement = roundMask;

            if ( zSign ) {

                if ( roundingMode == float_round_up ) roundIncrement = 0;

            }

            else {

                if ( roundingMode == float_round_down ) roundIncrement = 0;

            }

        }

    }

    roundBits = zSig0 & roundMask;

    if ( 0x7FFD <= (uint32_t) ( zExp - 1 ) ) {

        if (    ( 0x7FFE < zExp )

             || ( ( zExp == 0x7FFE ) && ( zSig0 + roundIncrement < zSig0 ) )

           ) {

            goto overflow;

        }

        if ( zExp <= 0 ) {

            if ( STATUS(flush_to_zero) ) return packFloatx80( zSign, 0, 0 );

            isTiny =

                   ( STATUS(float_detect_tininess) == float_tininess_before_rounding )

                || ( zExp < 0 )

                || ( zSig0 <= zSig0 + roundIncrement );

            shift64RightJamming( zSig0, 1 - zExp, &zSig0 );

            zExp = 0;

            roundBits = zSig0 & roundMask;

            if ( isTiny && roundBits ) float_raise( float_flag_underflow STATUS_VAR);

            if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;

            zSig0 += roundIncrement;

            if ( (int64_t) zSig0 < 0 ) zExp = 1;

            roundIncrement = roundMask + 1;

            if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {

                roundMask |= roundIncrement;

            }

            zSig0 &= ~ roundMask;

            return packFloatx80( zSign, zExp, zSig0 );

        }

    }

    if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;

    zSig0 += roundIncrement;

    if ( zSig0 < roundIncrement ) {

        ++zExp;

        zSig0 = LIT64( 0x8000000000000000 );

    }

    roundIncrement = roundMask + 1;

    if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {

        roundMask |= roundIncrement;

    }

    zSig0 &= ~ roundMask;

    if ( zSig0 == 0 ) zExp = 0;

    return packFloatx80( zSign, zExp, zSig0 );

 precision80:

    increment = ( (int64_t) zSig1 < 0 );

    if ( ! roundNearestEven ) {

        if ( roundingMode == float_round_to_zero ) {

            increment = 0;

        }

        else {

            if ( zSign ) {

                increment = ( roundingMode == float_round_down ) && zSig1;

            }

            else {

                increment = ( roundingMode == float_round_up ) && zSig1;

            }

        }

    }

    if ( 0x7FFD <= (uint32_t) ( zExp - 1 ) ) {

        if (    ( 0x7FFE < zExp )

             || (    ( zExp == 0x7FFE )

                  && ( zSig0 == LIT64( 0xFFFFFFFFFFFFFFFF ) )

                  && increment

                )

           ) {

            roundMask = 0;

 overflow:

            float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR);

            if (    ( roundingMode == float_round_to_zero )

                 || ( zSign && ( roundingMode == float_round_up ) )

                 || ( ! zSign && ( roundingMode == float_round_down ) )

               ) {

                return packFloatx80( zSign, 0x7FFE, ~ roundMask );

            }

            return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );

        }

        if ( zExp <= 0 ) {

            isTiny =

                   ( STATUS(float_detect_tininess) == float_tininess_before_rounding )

                || ( zExp < 0 )

                || ! increment

                || ( zSig0 < LIT64( 0xFFFFFFFFFFFFFFFF ) );

            shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 );

            zExp = 0;

            if ( isTiny && zSig1 ) float_raise( float_flag_underflow STATUS_VAR);

            if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;

            if ( roundNearestEven ) {

                increment = ( (int64_t) zSig1 < 0 );

            }

            else {

                if ( zSign ) {

                    increment = ( roundingMode == float_round_down ) && zSig1;

                }

                else {

                    increment = ( roundingMode == float_round_up ) && zSig1;

                }

            }

            if ( increment ) {

                ++zSig0;

                zSig0 &=

                    ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );

                if ( (int64_t) zSig0 < 0 ) zExp = 1;

            }

            return packFloatx80( zSign, zExp, zSig0 );

        }

    }

    if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;

    if ( increment ) {

        ++zSig0;

        if ( zSig0 == 0 ) {

            ++zExp;

            zSig0 = LIT64( 0x8000000000000000 );

        }

        else {

            zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );

        }

    }

    else {

        if ( zSig0 == 0 ) zExp = 0;

    }

    return packFloatx80( zSign, zExp, zSig0 );



}

            if ( STATUS(flush_to_zero) ) return packFloatx80( zSign, 0, 0 );
 FUNC_0(

     int8 VAR_0, flag VAR_1, int32 VAR_2, uint64_t VAR_3, uint64_t VAR_4

 STATUS_PARAM)

{

    int8 roundingMode;

    flag roundNearestEven, increment, isTiny;

    int64 roundIncrement, roundMask, roundBits;



    roundingMode = STATUS(float_rounding_mode);

    roundNearestEven = ( roundingMode == float_round_nearest_even );

    if ( VAR_0 == 80 ) goto precision80;

    if ( VAR_0 == 64 ) {

        roundIncrement = LIT64( 0x0000000000000400 );

        roundMask = LIT64( 0x00000000000007FF );

    }

    else if ( VAR_0 == 32 ) {

        roundIncrement = LIT64( 0x0000008000000000 );

        roundMask = LIT64( 0x000000FFFFFFFFFF );

    }

    else {

        goto precision80;

    }

    VAR_3 |= ( VAR_4 != 0 );

    if ( ! roundNearestEven ) {

        if ( roundingMode == float_round_to_zero ) {

            roundIncrement = 0;

        }

        else {

            roundIncrement = roundMask;

            if ( VAR_1 ) {

                if ( roundingMode == float_round_up ) roundIncrement = 0;

            }

            else {

                if ( roundingMode == float_round_down ) roundIncrement = 0;

            }

        }

    }

    roundBits = VAR_3 & roundMask;

    if ( 0x7FFD <= (uint32_t) ( VAR_2 - 1 ) ) {

        if (    ( 0x7FFE < VAR_2 )

             || ( ( VAR_2 == 0x7FFE ) && ( VAR_3 + roundIncrement < VAR_3 ) )

           ) {

            goto overflow;

        }

        if ( VAR_2 <= 0 ) {

            if ( STATUS(flush_to_zero) ) return packFloatx80( VAR_1, 0, 0 );

            isTiny =

                   ( STATUS(float_detect_tininess) == float_tininess_before_rounding )

                || ( VAR_2 < 0 )

                || ( VAR_3 <= VAR_3 + roundIncrement );

            shift64RightJamming( VAR_3, 1 - VAR_2, &VAR_3 );

            VAR_2 = 0;

            roundBits = VAR_3 & roundMask;

            if ( isTiny && roundBits ) float_raise( float_flag_underflow STATUS_VAR);

            if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;

            VAR_3 += roundIncrement;

            if ( (int64_t) VAR_3 < 0 ) VAR_2 = 1;

            roundIncrement = roundMask + 1;

            if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {

                roundMask |= roundIncrement;

            }

            VAR_3 &= ~ roundMask;

            return packFloatx80( VAR_1, VAR_2, VAR_3 );

        }

    }

    if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact;

    VAR_3 += roundIncrement;

    if ( VAR_3 < roundIncrement ) {

        ++VAR_2;

        VAR_3 = LIT64( 0x8000000000000000 );

    }

    roundIncrement = roundMask + 1;

    if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {

        roundMask |= roundIncrement;

    }

    VAR_3 &= ~ roundMask;

    if ( VAR_3 == 0 ) VAR_2 = 0;

    return packFloatx80( VAR_1, VAR_2, VAR_3 );

 precision80:

    increment = ( (int64_t) VAR_4 < 0 );

    if ( ! roundNearestEven ) {

        if ( roundingMode == float_round_to_zero ) {

            increment = 0;

        }

        else {

            if ( VAR_1 ) {

                increment = ( roundingMode == float_round_down ) && VAR_4;

            }

            else {

                increment = ( roundingMode == float_round_up ) && VAR_4;

            }

        }

    }

    if ( 0x7FFD <= (uint32_t) ( VAR_2 - 1 ) ) {

        if (    ( 0x7FFE < VAR_2 )

             || (    ( VAR_2 == 0x7FFE )

                  && ( VAR_3 == LIT64( 0xFFFFFFFFFFFFFFFF ) )

                  && increment

                )

           ) {

            roundMask = 0;

 overflow:

            float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR);

            if (    ( roundingMode == float_round_to_zero )

                 || ( VAR_1 && ( roundingMode == float_round_up ) )

                 || ( ! VAR_1 && ( roundingMode == float_round_down ) )

               ) {

                return packFloatx80( VAR_1, 0x7FFE, ~ roundMask );

            }

            return packFloatx80( VAR_1, 0x7FFF, LIT64( 0x8000000000000000 ) );

        }

        if ( VAR_2 <= 0 ) {

            isTiny =

                   ( STATUS(float_detect_tininess) == float_tininess_before_rounding )

                || ( VAR_2 < 0 )

                || ! increment

                || ( VAR_3 < LIT64( 0xFFFFFFFFFFFFFFFF ) );

            shift64ExtraRightJamming( VAR_3, VAR_4, 1 - VAR_2, &VAR_3, &VAR_4 );

            VAR_2 = 0;

            if ( isTiny && VAR_4 ) float_raise( float_flag_underflow STATUS_VAR);

            if ( VAR_4 ) STATUS(float_exception_flags) |= float_flag_inexact;

            if ( roundNearestEven ) {

                increment = ( (int64_t) VAR_4 < 0 );

            }

            else {

                if ( VAR_1 ) {

                    increment = ( roundingMode == float_round_down ) && VAR_4;

                }

                else {

                    increment = ( roundingMode == float_round_up ) && VAR_4;

                }

            }

            if ( increment ) {

                ++VAR_3;

                VAR_3 &=

                    ~ ( ( (uint64_t) ( VAR_4<<1 ) == 0 ) & roundNearestEven );

                if ( (int64_t) VAR_3 < 0 ) VAR_2 = 1;

            }

            return packFloatx80( VAR_1, VAR_2, VAR_3 );

        }

    }

    if ( VAR_4 ) STATUS(float_exception_flags) |= float_flag_inexact;

    if ( increment ) {

        ++VAR_3;

        if ( VAR_3 == 0 ) {

            ++VAR_2;

            VAR_3 = LIT64( 0x8000000000000000 );

        }

        else {

            VAR_3 &= ~ ( ( (uint64_t) ( VAR_4<<1 ) == 0 ) & roundNearestEven );

        }

    }

    else {

        if ( VAR_3 == 0 ) VAR_2 = 0;

    }

    return packFloatx80( VAR_1, VAR_2, VAR_3 );



}

FUNC_0(
int8 VAR_0, flag VAR_1, int32 VAR_2, uint64_t VAR_3, uint64_t VAR_4
STATUS_PARAM)
{ int8 roundingMode; flag roundNearestEven, increment, isTiny; int64 roundIncrement, roundMask, roundBits; roundingMode = STATUS(float_rounding_mode); roundNearestEven = ( roundingMode == float_round_nearest_even ); if ( VAR_0 == 80 ) goto precision80; if ( VAR_0 == 64 ) { roundIncrement = LIT64( 0x0000000000000400 ); roundMask = LIT64( 0x00000000000007FF ); } else if ( VAR_0 == 32 ) { roundIncrement = LIT64( 0x0000008000000000 ); roundMask = LIT64( 0x000000FFFFFFFFFF ); } else { goto precision80; } VAR_3 |= ( VAR_4 != 0 ); if ( ! roundNearestEven ) { if ( roundingMode == float_round_to_zero ) { roundIncrement = 0; } else { roundIncrement = roundMask; if ( VAR_1 ) { if ( roundingMode == float_round_up ) roundIncrement = 0; } else { if ( roundingMode == float_round_down ) roundIncrement = 0; } } } roundBits = VAR_3 & roundMask; if ( 0x7FFD <= (uint32_t) ( VAR_2 - 1 ) ) { if (    ( 0x7FFE < VAR_2 )
|| ( ( VAR_2 == 0x7FFE ) && ( VAR_3 + roundIncrement < VAR_3 ) )
) { goto overflow; } if ( VAR_2 <= 0 ) { if ( STATUS(flush_to_zero) ) return packFloatx80( VAR_1, 0, 0 ); isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
|| ( VAR_2 < 0 )
|| ( VAR_3 <= VAR_3 + roundIncrement ); shift64RightJamming( VAR_3, 1 - VAR_2, &VAR_3 ); VAR_2 = 0; roundBits = VAR_3 & roundMask; if ( isTiny && roundBits ) float_raise( float_flag_underflow STATUS_VAR); if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact; VAR_3 += roundIncrement; if ( (int64_t) VAR_3 < 0 ) VAR_2 = 1; roundIncrement = roundMask + 1; if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) { roundMask |= roundIncrement; } VAR_3 &= ~ roundMask; return packFloatx80( VAR_1, VAR_2, VAR_3 ); } } if ( roundBits ) STATUS(float_exception_flags) |= float_flag_inexact; VAR_3 += roundIncrement; if ( VAR_3 < roundIncrement ) { ++VAR_2; VAR_3 = LIT64( 0x8000000000000000 ); } roundIncrement = roundMask + 1; if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) { roundMask |= roundIncrement; } VAR_3 &= ~ roundMask; if ( VAR_3 == 0 ) VAR_2 = 0; return packFloatx80( VAR_1, VAR_2, VAR_3 ); precision80:
increment = ( (int64_t) VAR_4 < 0 ); if ( ! roundNearestEven ) { if ( roundingMode == float_round_to_zero ) { increment = 0; } else { if ( VAR_1 ) { increment = ( roundingMode == float_round_down ) && VAR_4; } else { increment = ( roundingMode == float_round_up ) && VAR_4; } } } if ( 0x7FFD <= (uint32_t) ( VAR_2 - 1 ) ) { if (    ( 0x7FFE < VAR_2 )
|| (    ( VAR_2 == 0x7FFE )
&& ( VAR_3 == LIT64( 0xFFFFFFFFFFFFFFFF ) )
&& increment
)
) { roundMask = 0; overflow:
float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR); if (    ( roundingMode == float_round_to_zero )
|| ( VAR_1 && ( roundingMode == float_round_up ) )
|| ( ! VAR_1 && ( roundingMode == float_round_down ) )
) { return packFloatx80( VAR_1, 0x7FFE, ~ roundMask ); } return packFloatx80( VAR_1, 0x7FFF, LIT64( 0x8000000000000000 ) ); } if ( VAR_2 <= 0 ) { isTiny =
( STATUS(float_detect_tininess) == float_tininess_before_rounding )
|| ( VAR_2 < 0 )
|| ! increment
|| ( VAR_3 < LIT64( 0xFFFFFFFFFFFFFFFF ) ); shift64ExtraRightJamming( VAR_3, VAR_4, 1 - VAR_2, &VAR_3, &VAR_4 ); VAR_2 = 0; if ( isTiny && VAR_4 ) float_raise( float_flag_underflow STATUS_VAR); if ( VAR_4 ) STATUS(float_exception_flags) |= float_flag_inexact; if ( roundNearestEven ) { increment = ( (int64_t) VAR_4 < 0 ); } else { if ( VAR_1 ) { increment = ( roundingMode == float_round_down ) && VAR_4; } else { increment = ( roundingMode == float_round_up ) && VAR_4; } } if ( increment ) { ++VAR_3; VAR_3 &=
~ ( ( (uint64_t) ( VAR_4<<1 ) == 0 ) & roundNearestEven ); if ( (int64_t) VAR_3 < 0 ) VAR_2 = 1; } return packFloatx80( VAR_1, VAR_2, VAR_3 ); } } if ( VAR_4 ) STATUS(float_exception_flags) |= float_flag_inexact; if ( increment ) { ++VAR_3; if ( VAR_3 == 0 ) { ++VAR_2; VAR_3 = LIT64( 0x8000000000000000 ); } else { VAR_3 &= ~ ( ( (uint64_t) ( VAR_4<<1 ) == 0 ) & roundNearestEven ); } } else { if ( VAR_3 == 0 ) VAR_2 = 0; } return packFloatx80( VAR_1, VAR_2, VAR_3 ); }