#include <stdio.h>
#include <stdlib.h>


// TODO: Implement a helper named check_permissions that matches the prototype below.

//int check_permissions(char *, char *);
int check_permissions(char *given_perms, char *req_perms){
  for(int i = 0; i < 9; i++){
    if (req_perms[i]!='-'){
      if(given_perms[i]!=req_perms[i]){
        return 1;
      }
    }
  }
  return 0;
}


int main(int argc, char** argv) {
    if (!(argc == 2 || argc == 3)) {
        fprintf(stderr, "USAGE: count_large size [permissions]\n");
        return 1;
    }
else{
    int count = 0;
    // TODO: Process command line arguments.
        char total[5];
    int totalnum;
    scanf("%s %d\n", total, &totalnum);
    char filetype;
    char perms[9];
  int misc0;
    char misc1[31];
    char misc2[31];
    int size;
    char month[31];
    int day;
    char time[5];
    char name[31];


    while(scanf("%c%s %d %s %s %d %s %d %s %s\n", &filetype, perms, &misc0, misc1, misc2, &size, month, &day, time, name)==10){
    // checking size of file is big enough
    int req_size = atoi(argv[0]);
    if(size > req_size && filetype != 'd'){
      //checking file is not a directory
        //checking required permissions, if applicable
        if (argc==2){
                count = count + 1;
        }
         // TODO: Call check_permissions as part of your solution to count the files to compute and print the correct value.

        else if(argc==3 && check_permissions(perms, argv[2])==0){
            count = count + 1;
        }
        else{
                count = count + 0;
        }

    }
      }
    printf("%d\n", count);
    return 0;
}
}

reasons for sanity check fail