1 #  define EXTERN(type, array)  extern type array[]
2 typedef unsigned char  uch;
3 typedef unsigned short ush;
4 EXTERN(uch, window);
5 EXTERN(ush, prev);
6 #ifndef WSIZE
7 #  define WSIZE 0x8000
8 #endif
9 #define MIN_MATCH  3
10 #define MAX_MATCH  258
11 #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
12 #define MAX_DIST  (WSIZE-MIN_LOOKAHEAD)
13 #define near
14 typedef unsigned IPos;
15 unsigned near max_chain_length;
16 extern unsigned near strstart;
17 unsigned int near prev_length;
18 #define NIL 0
19 unsigned near good_match;
20 int near nice_match;
21 #define WMASK     (WSIZE-1)
longest_match(IPos cur_match)22 int longest_match(IPos cur_match)
23 {
24     unsigned chain_length = max_chain_length;
25     register uch *scan = window + strstart;
26     register uch *match;
27     register int len;
28     int best_len = prev_length;
29     IPos limit = strstart > (IPos)MAX_DIST ? strstart - (IPos)MAX_DIST : NIL;
30     register uch *strend = window + strstart + MAX_MATCH;
31     register uch scan_end   = scan[best_len];
32     if (prev_length >= good_match) {
33     }
34     do {
35         if (match[best_len]   != scan_end  ||
36             *++match          != scan[1])      continue;
37         do {
38         } while (*++scan == *++match && *++scan == *++match &&
39                  scan < strend);
40         len = MAX_MATCH - (int)(strend - scan);
41         if (len > best_len) {
42             best_len = len;
43             if (len >= nice_match) break;
44         }
45     } while ((cur_match = prev[cur_match & WMASK]) > limit
46 	     && --chain_length != 0);
47     return best_len;
48 }
49 
50 /* { dg-final { scan-tree-dump-times "number of SCoPs: 0" 1 "graphite"} } */
51 /* { dg-final { cleanup-tree-dump "graphite" } } */
52