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


int check_permissions(char *filter, char *permission){
    for(int i = 0; i<9;i++){
        if (filter[i] != '-'){
            if(filter[i] != permission[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;
    }
    char line[101];
    char permission[9];
    int size;
    int num = 0;
    int min = strtol(argv[1], NULL, 10);
    fgets(line, 101, stdin);
    while(fscanf(stdin, "%s %*d %*s %*s %d %*[^\n]", permission, &size) == 2){
        if((size > min) && (permission[0] != 'd')){
            if(argc == 3){
                if(check_permissions(argv[2], permission + 1) == 0){
                    num ++;
                }
            }else{
                num ++;
            }
        }
    };

    printf("%d\n", num);

    return 0;
}

second command-line argument which is a string of 9 characters that represent the required file permissions. Each position is either r,w,x or - as would be appropriate in that location in the file-permission field of the long format of ls output. If called with this option, your program will only count the files that have at least the permissions specified by this argument.