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


/*
 * Sample usage:
 * $ gcc -Wall -std=gnu99 -g -o count_large count_large.c
 * $ count_large 1000
 * 0
 * $ ./fibo 2
 * 0 1
 */

// TODO: Implement a helper named check_permissions that matches the prototype below.
int check_permissions(char *perm, char *req) {
    char p[3];
    p[0] = req[0];
    p[1] = req[1];
    p[2] = req[2];

    for (int i ; i < 3; i++) {
        // handle r
        if (p[0] == perm[i*3]) {p[0] = '-';}
        else if (i < 2) {p[0] = req[(i+1)*3];}
        // handle w
        if (p[1] == perm[i*3 + 1]) {p[1] = '-';}
        else if (i < 2) {p[0] = req[(i+1)*3 + 1];}
        // handle x
        if (p[2] == perm[i*3 + 2]) {p[2] = '-';}
        else if (i < 2) {p[0] = req[(i+1)*2 + 2];}
        // check if permissions are all meet
        if (p[0] == '-' && p[1] == '-' && p[2] == '-') {
            return 0;
        }
    }
    return 1;
};


int main(int argc, char** argv) {
    if (!(argc == 2 || argc == 3)) {
        fprintf(stderr, "USAGE: count_large size [permissions]\n");
        return 1;
    }
    int count = 0;
    int n, di, size;
    char req[9], p[10], user[31], group[31], m[31], d[31], y[31], f[31];

    // TODO: Process command line arguments.
    n = strtol(argv[1], NULL, 10);
    if (argc == 3) {req = argv[2];}

    // TODO: Call check_permissions as part of your solution to count the files to
    // compute and print the correct value.
    scanf("%s", &f);

    while (scanf("%s %d %s %s %d %s %s %s %s", 
        p, &di, user, group, &size, m, d, y, f) != EOF) {
        if (argc == 3 && !check_permissions(p+1, req) && n < size ) {
            count++;
        } else if (n < size){
            count++;
        }
    }
    printf('%d/n', count);

    return 0;
}
a C program called count_large. The program will inspect the output from the ls -l command and print the number of files larger than a specified size.