FFX (Flow Fact in XML) format

Content

16 Appendix B: Example – output of oRange tool

The code below is an example of output of the oRange tool. By this time, oRange does not support the whole FFX format but, thanks to the concept of freedom, this is not a problem for other tool using its output. oRange only supports the FFX element that allows to obtain a maximum of precision in its results.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<flowfacts>
    <function name="main" executed="true" extern="false">
        <call name="icrc" numcall="2" line="120" source="crc.c" executed="true" extern="false">
            <function name="icrc">
                <conditional> <condition line="80" source="crc.c" executed="true"> </condition>
                    <case cond="1"  executed="true">
                        <loop loopId="2" line="82" source="crc.c" exact="false" maxcount="256" totalcount="256">
                            <call name="icrc1" numcall="1" line="83" source="crc.c" executed="true" extern="false">
                                <function name="icrc1">
                                    <loop loopId="1" line="62" source="crc.c" exact="false" maxcount="8" totalcount="2048">
                                        <conditional> <condition line="63" source="crc.c" executed="true"> </condition>
                                            <case cond="1"  executed="true">
                                            </case>
                                            <case cond="0" executed="true">
                                            </case>
                                        </conditional>
                                    </loop>
                                </function>
                            </call>
                        </loop>
                    </case>
                    <case cond="0" executed="false">
                    </case>
                </conditional>
                <conditional> <condition line="87" source="crc.c" executed="true"> </condition>
                    <case cond="1"  executed="true">
                    </case>
                    <case cond="0" executed="false">
                        <conditional> <condition line="88" source="crc.c" executed="true"> </condition>
                            <case cond="1"  executed="false">
                            </case>
                            <case cond="0" executed="true">
                            </case>
                        </conditional>
                    </case>
                </conditional>
                <loop loopId="3" line="93" source="crc.c" exact="true" maxcount="40" totalcount="40">
                    <conditional> <condition line="94" source="crc.c" executed="true"> </condition>
                        <case cond="1"  executed="true">
                        </case>
                        <case cond="0" executed="true">
                        </case>
                    </conditional>
                </loop>
                <conditional> <condition line="102" source="crc.c" executed="true"> </condition>
                    <case cond="1"  executed="true">
                    </case>
                    <case cond="0" executed="false">
                    </case>
                </conditional>
            </function>
        </call>
        <call name="icrc" numcall="3" line="123" source="crc.c" executed="true" extern="false">
            <function name="icrc">
                <conditional> <condition line="80" source="crc.c" executed="true"> </condition>
                    <case cond="1"  executed="false">
                        <loop loopId="2" line="82" source="crc.c" exact="false" maxcount="0" totalcount="0">
                            <call name="icrc1" numcall="1" line="83" source="crc.c" executed="false" extern="false">
                                <function name="icrc1">
                                    <loop loopId="1" line="62" source="crc.c" exact="false" maxcount="0" totalcount="0">
                                        <conditional> <condition line="63" source="crc.c" executed="true"> </condition>
                                            <case cond="1"  executed="true">
                                            </case>
                                            <case cond="0" executed="true">
                                            </case>
                                        </conditional>
                                    </loop>
                                </function>
                            </call>
                        </loop>
                    </case>
                    <case cond="0" executed="true">
                    </case>
                </conditional>
                <conditional> <condition line="87" source="crc.c" executed="true"> </condition>
                    <case cond="1"  executed="true">
                    </case>
                    <case cond="0" executed="false">
                        <conditional> <condition line="88" source="crc.c" executed="true"> </condition>
                            <case cond="1"  executed="false">
                            </case>
                            <case cond="0" executed="true">
                            </case>
                        </conditional>
                    </case>
                </conditional>
                <loop loopId="3" line="93" source="crc.c" exact="true" maxcount="42" totalcount="42">
                    <conditional> <condition line="94" source="crc.c" executed="true"> </condition>
                        <case cond="1"  executed="true">
                        </case>
                        <case cond="0" executed="true">
                        </case>
                    </conditional>
                </loop>
                <conditional> <condition line="102" source="crc.c" executed="true"> </condition>
                    <case cond="1"  executed="true">
                    </case>
                    <case cond="0" executed="false">
                    </case>
                </conditional>
            </function>
        </call>
    </function>
</flowfacts>

This FFX example above is obtained from the C source file below:

typedef unsigned char uchar;
#define LOBYTE(x) ((uchar)((x) & 0xFF))
#define HIBYTE(x) ((uchar)((x) >> 8))

unsigned char lin[256] = "asdffeagewaHAFEFaeDsFEawFdsFaefaeerdjgp";

unsigned short icrc1(unsigned short crc, unsigned char onech)
{
	int i;
	unsigned short ans=(crc^onech << 8);

	for (i=0;i<8;i++) {
		if (ans & 0x8000)
			ans = (ans <<= 1) ^ 4129;
		else
			ans <<= 1;
	}
	return ans;
}

unsigned short icrc(unsigned short crc, unsigned long len,
		    short jinit, int jrev)
{
  unsigned short icrc1(unsigned short crc, unsigned char onech);
  static unsigned short icrctb[256],init=0;
  static uchar rchr[256];
  unsigned short tmp1, tmp2, j,cword=crc;
  static uchar it[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};

  if (!init) {
    init=1;
    for (j=0;j<=255;j++) {
      icrctb[j]=icrc1(j << 8,(uchar)0);
      rchr[j]=(uchar)(it[j & 0xF] << 4 | it[j >> 4]);
    }
  }
  if (jinit >= 0) cword=((uchar) jinit) | (((uchar) jinit) << 8);
  else if (jrev < 0)
    cword=rchr[HIBYTE(cword)] | rchr[LOBYTE(cword)] << 8;
#ifdef DEBUG
  printf("len = %d\n", len);
#endif
  for (j=1;j<=len;j++) {
    if (jrev < 0) {
      tmp1 = rchr[lin[j]]^ HIBYTE(cword);
    }
    else {
      tmp1 = lin[j]^ HIBYTE(cword);
    }
    cword = icrctb[tmp1] ^ LOBYTE(cword) << 8;
  }
  if (jrev >= 0) {
    tmp2 = cword;
  }
  else {
    tmp2 = rchr[HIBYTE(cword)] | rchr[LOBYTE(cword)] << 8;
  }
  return (tmp2 );
}


int main(void)
{

  unsigned short i1,i2;
  unsigned long n;

  n=40;
  lin[n+1]=0;
  i1=icrc(0,n,(short)0,1);
  lin[n+1]=HIBYTE(i1);
  lin[n+2]=LOBYTE(i1);
  i2=icrc(i1,n+2,(short)0,1);
  return 0;
}