Part A:
#include <stdio.h>
#include <unistd.h>
#include <getopt.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include "cachelab.h"
typedef enum{
false,true} bool;
typedef struct {
bool valid;
int tag;
int time;
} block;
block** cache=NULL;
int hit=0,miss=0,eviction=0;
bool h= false, v= false;
int s,E,b;
int S,B;
int clock=0;
void getblock(__uint64_t addr,unsigned size){
B=pow(2,b);
__uint64_t limit=addr+size;
while(addr<limit){
int set=(addr>>b)&((int)(pow(2,s)-1));
int tag=addr>>(b+s);
int i=0;
clock++;
for(;i<E;i++){
if(cache[set][i].valid==true){
if(cache[set][i].tag==tag){
hit++;
cache[set][i].time=clock;
if(v) printf("hit ");
break;
}
}
else{
if(v) printf("miss ");
miss++;
cache[set][i].tag=tag;
cache[set][i].valid=true;
cache[set][i].time=clock;
break;
}
}
if(i==E){
if(v) printf("miss ");
miss++;
int mintime=INT_MAX,minloc;
for(int i=0;i<E;i++