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


int check_permissions(char *given, char *needed){
    int same = 0;
    for(int i = 0; i < 9; i++){
        if(needed[i] != '-'){
            if(needed[i] != given[i]){
                same = 1;
                break;
            }
        }
    }
    return same;
}


int main(int argc, char** argv) {
    if (!(argc == 2 || argc == 3)) {
        fprintf(stderr, "USAGE: count_large size [permissions]\n");
        return 1;
    }

    int min_size = strtol(argv[1], NULL, 10);

    int num_filtered_files = 0;

    int eof = 1;
    int first = 0;

    char directory;
    char permissions[9];
    char idk[31];
    char username[31];
    char group_name[31];
    char s_size[31];
    char month[31];
    char date[31];
    char time[31];
    char filename[31];
    int size;

    while(0 < eof){
        if(first == 0){
            char s1[10];
            char s2[10];
            eof = scanf("%s %s", s1, s2);
            first = 1;
        }
        else{
            eof = scanf("%c%s%s%s%s%s%s%s%s%s", &directory, permissions, idk, username, group_name, s_size, month, date, time, filename);
        }
        if(eof == 0){
            break;
        }
        size = strtol(s_size, NULL, 10);
        if (directory == '-'){
            if(argc == 3 && min_size < size && check_permissions(permissions, argv[2]) == 0){
                num_filtered_files ++;
            }
            else if(min_size < size){
                num_filtered_files = num_filtered_files + 1;
            }

        }

    }

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

    return 0;
}

The main takes in a number and potentially a string in argv. min_size is supposed to be the number given in argv. Then, a "ls -l" of the current directory is given as the input. The first line is supposed to be skipped as it does not match the form of the listed files. The size of the file is first taken as a string, and then converted to an int. If the size of the file is greater than min_size, the num_filtered_files increases by 1. Finally num_filtered_files is printed.