abc/src/bool/lucky/lucky.c
// compare F with  F1 = (F with changed phase in one of the vars).
// keeps smaller.
// same for all vars in F.
// returns: if pInOnt changed(minimized) by function return 1 if not 0
compare F with  F1 = (F with changed phase in one of the vars).
keeps smaller.
same for all vars in F.
returns: if pInOnt changed(minimized) by function return 1 if not 0
compare F with F1 = ( F with changed phase in one of the vars ) . keeps smaller . same for all vars in F . returns : if pInOnt changed ( minimized ) by function return 1 if not 0
int minimalFlip(word* pInOut, word* pMinimal, word* PDuplicat, int  nVars, unsigned* p_uCanonPhase)
{
    int i;
    unsigned minTemp = *p_uCanonPhase;
    int blockSize = Kit_TruthWordNum_64bit( nVars )*sizeof(word);
    memcpy(pMinimal, pInOut, blockSize);
    memcpy(PDuplicat, pInOut, blockSize);       
    Kit_TruthChangePhase_64bit( pInOut, nVars, 0 );
    *p_uCanonPhase ^= (unsigned)1;
    for(i=1;i<nVars;i++)
    {
        if( memCompare(pMinimal,pInOut,nVars) == 1)
        {
            memcpy(pMinimal, pInOut, blockSize);
            minTemp = *p_uCanonPhase;
        }
        else
        {
            memcpy(pInOut, pMinimal, blockSize);
            *p_uCanonPhase = minTemp;
        }
        Kit_TruthChangePhase_64bit( pInOut, nVars, i );
        *p_uCanonPhase ^= (1 << i);
    }
    if( memCompare(pMinimal,pInOut,nVars) == -1)
    {
        memcpy(pInOut, pMinimal, blockSize);
        *p_uCanonPhase = minTemp;
    }
    if(memcmp(pInOut,PDuplicat,blockSize) == 0) 
        return 0;
    else
        return 1;
}
int minimalFlip ( word * pInOut , word * pMinimal , word * PDuplicat , int nVars , unsigned * p_uCanonPhase ) { int i ; unsigned minTemp = * p_uCanonPhase ; int blockSize = Kit_TruthWordNum_64bit ( nVars ) * sizeof ( word ) ; memcpy ( pMinimal , pInOut , blockSize ) ; memcpy ( PDuplicat , pInOut , blockSize ) ; Kit_TruthChangePhase_64bit ( pInOut , nVars , 0 ) ; * p_uCanonPhase ^= ( unsigned ) 1 ; for ( i = 1 ; i < nVars ; i ++ ) { if ( memCompare ( pMinimal , pInOut , nVars ) == 1 ) { memcpy ( pMinimal , pInOut , blockSize ) ; minTemp = * p_uCanonPhase ; } else { memcpy ( pInOut , pMinimal , blockSize ) ; * p_uCanonPhase = minTemp ; } Kit_TruthChangePhase_64bit ( pInOut , nVars , i ) ; * p_uCanonPhase ^= ( 1 << i ) ; } if ( memCompare ( pMinimal , pInOut , nVars ) == -1 ) { memcpy ( pInOut , pMinimal , blockSize ) ; * p_uCanonPhase = minTemp ; } if ( memcmp ( pInOut , PDuplicat , blockSize ) == 0 ) return 0 ; else return 1 ; }
compare F with  F1 = (F with changed phase in one of the vars).
compare F with F1 = ( F with changed phase in one of the vars ) .
//////////////need one more unsigned!!!!!!!!!!!!!