abc/src/proof/acec/acecFadds.c
// find chain length (for each MAJ, how many FADDs are rooted in its first input)
find chain length (for each MAJ, how many FADDs are rooted in its first input)
find chain length ( for each MAJ how many FADDs are rooted in its first input )
int Gia_ManFindChains_rec( Gia_Man_t * p, int iMaj, Vec_Int_t * vFadds, Vec_Int_t * vMap, Vec_Int_t * vLength )
{
    assert( Vec_IntEntry(vMap, iMaj) >= 0 ); 
    if ( Vec_IntEntry(vLength, iMaj) >= 0 )
        return Vec_IntEntry(vLength, iMaj);
    assert( Gia_ObjIsAnd(Gia_ManObj(p, iMaj)) );
    {
        int iFadd = Vec_IntEntry( vMap, iMaj );
        int iXor0 = Vec_IntEntry( vFadds, 5*iFadd+0 );
        int iXor1 = Vec_IntEntry( vFadds, 5*iFadd+1 );
        int iXor2 = Vec_IntEntry( vFadds, 5*iFadd+2 );
        int iLen0 = Vec_IntEntry( vMap, iXor0 ) == -1 ? 0 : Gia_ManFindChains_rec( p, iXor0, vFadds, vMap, vLength );
        int iLen1 = Vec_IntEntry( vMap, iXor1 ) == -1 ? 0 : Gia_ManFindChains_rec( p, iXor1, vFadds, vMap, vLength );
        int iLen2 = Vec_IntEntry( vMap, iXor2 ) == -1 ? 0 : Gia_ManFindChains_rec( p, iXor2, vFadds, vMap, vLength );
        int iLen = Abc_MaxInt( iLen0, Abc_MaxInt(iLen1, iLen2) );
        if ( iLen0 < iLen )
        {
            if ( iLen == iLen1 )
            {
                ABC_SWAP( int, Vec_IntArray(vFadds)[5*iFadd+0], Vec_IntArray(vFadds)[5*iFadd+1] );
            }
            else if ( iLen == iLen2 )
            {
                ABC_SWAP( int, Vec_IntArray(vFadds)[5*iFadd+0], Vec_IntArray(vFadds)[5*iFadd+2] );
            }
        }
        Vec_IntWriteEntry( vLength, iMaj, iLen + 1 );
        return iLen + 1;
    }
}
int Gia_ManFindChains_rec ( Gia_Man_t * p , int iMaj , Vec_Int_t * vFadds , Vec_Int_t * vMap , Vec_Int_t * vLength ) { assert ( Vec_IntEntry ( vMap , iMaj ) >= 0 ) ; if ( Vec_IntEntry ( vLength , iMaj ) >= 0 ) return Vec_IntEntry ( vLength , iMaj ) ; assert ( Gia_ObjIsAnd ( Gia_ManObj ( p , iMaj ) ) ) ; { int iFadd = Vec_IntEntry ( vMap , iMaj ) ; int iXor0 = Vec_IntEntry ( vFadds , 5 * iFadd + 0 ) ; int iXor1 = Vec_IntEntry ( vFadds , 5 * iFadd + 1 ) ; int iXor2 = Vec_IntEntry ( vFadds , 5 * iFadd + 2 ) ; int iLen0 = Vec_IntEntry ( vMap , iXor0 ) == -1 ? 0 : Gia_ManFindChains_rec ( p , iXor0 , vFadds , vMap , vLength ) ; int iLen1 = Vec_IntEntry ( vMap , iXor1 ) == -1 ? 0 : Gia_ManFindChains_rec ( p , iXor1 , vFadds , vMap , vLength ) ; int iLen2 = Vec_IntEntry ( vMap , iXor2 ) == -1 ? 0 : Gia_ManFindChains_rec ( p , iXor2 , vFadds , vMap , vLength ) ; int iLen = Abc_MaxInt ( iLen0 , Abc_MaxInt ( iLen1 , iLen2 ) ) ; if ( iLen0 < iLen ) { if ( iLen == iLen1 ) { ABC_SWAP ( int , Vec_IntArray ( vFadds ) [ 5 * iFadd + 0 ] , Vec_IntArray ( vFadds ) [ 5 * iFadd + 1 ] ) ; } else if ( iLen == iLen2 ) { ABC_SWAP ( int , Vec_IntArray ( vFadds ) [ 5 * iFadd + 0 ] , Vec_IntArray ( vFadds ) [ 5 * iFadd + 2 ] ) ; } } Vec_IntWriteEntry ( vLength , iMaj , iLen + 1 ) ; return iLen + 1 ; } }
find chain length (for each MAJ, how many FADDs are rooted in its first input)
find chain length ( for each MAJ how many FADDs are rooted in its first input )
// MAJ