clang -lpthread prod_cons.c
./a.out
can show you the consumer starts before the producer finishes and continues until the end../a.out | grep cC
can show you when the consumer starts to decrement../a.out | grep fin
can show you the highest counter reached by the producer, the consumer finishes consuming at this point.
for i in {1..1000}; do ./a.out; done | sort | uniq -c