lib/PEG_GrammarExplorer/PEG_GrammarExplorer/PegSamples/C_KernighanRitchie2/input/binsrch_preprocessed.c
int BinSearchW(unsigned short key, unsigned short *r, unsigned n)
{
      int high, i, low;

      if (n > 1)
      {
            for (low = 0, high = n-1;  high - low > 1; )
            {
                  i = (high+low) / 2;
                  if (key == r[i])
                        return i;
                  else if (key < r[i])
                        high = i;
                  else  low  = i;
            }
            if (key == r[high])
                  return high;
            else if (key == r[low])
                  return low;
            else  return -1;
      }
      else if (r[0] == key)
            return 0;
      else  return -1;
}
/*
**  BinSearchW(): Search a word key
**
**  Arguments: 1 - Address to return the key position
**             2 - Key to find
**             3 - Pointer to the beginning of the array
**             4 - Number of elements in the array
**
**  Returns: Index if found, else -1
*/
Search a word key
Arguments: 1 - Address to return the key position
2 - Key to find
3 - Pointer to the beginning of the array
4 - Number of elements in the array

Index if found, else -1
Search a word key Arguments : 1 - Address to return the key position 2 - Key to find 3 - Pointer to the beginning of the array 4 - Number of elements in the array Index if found else - 1
int BinSearchW(unsigned short key, unsigned short *r, unsigned n)
{
      int high, i, low;
      if (n > 1)
      {
            for (low = 0, high = n-1;  high - low > 1; )
            {
                  i = (high+low) / 2;
                  if (key == r[i])
                        return i;
                  else if (key < r[i])
                        high = i;
                  else  low  = i;
            }
            if (key == r[high])
                  return high;
            else if (key == r[low])
                  return low;
            else  return -1;
      }
      else if (r[0] == key)
            return 0;
      else  return -1;
}
int BinSearchW ( unsigned short key , unsigned short * r , unsigned n ) { int high , i , low ; if ( n > 1 ) { for ( low = 0 , high = n - 1 ; high - low > 1 ; ) { i = ( high + low ) / 2 ; if ( key == r [ i ] ) return i ; else if ( key < r [ i ] ) high = i ; else low = i ; } if ( key == r [ high ] ) return high ; else if ( key == r [ low ] ) return low ; else return -1 ; } else if ( r [ 0 ] == key ) return 0 ; else return -1 ; }
BinSearchW(): Search a word key
Arguments: 1 - Address to return the key position
2 - Key to find
3 - Pointer to the beginning of the array
4 - Number of elements in the array
BinSearchW () : Search a word key Arguments : 1 - Address to return the key position 2 - Key to find 3 - Pointer to the beginning of the array 4 - Number of elements in the array