trace file format : mode address mode 0 = read, 1 = write, 2 = end of file address 0..25400 trace count 132392 The trace is generated from running a program. The program is an interpreter. It interprets a language similar to Scheme (a LISP family). The interpreter is written in itself. The source code is about 600 lines. The interpreter executes the following program: (define power (x y) (if (= 0 y) 1 (if (= 1 y) x (* x (power x (- y 1)))))) (power 5 10) > 9765625 It executes 5^10 = 9765625. The following program will read the trace file properly. FILE *fi; void tread(){ int mode, ads, cnt; cnt = 0; fi = fopen("trace.txt","r"); fscanf(fi,"%d %d",&mode,&ads); while(mode != 2){ cnt++; fscanf(fi,"%d %d",&mode,&ads); // insert your code here } fclose(fi); printf("trace count %d\n",cnt); } You can read more about this interpreter in my public lecture "Beauty of programs" in my homepage.