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

int main(int argc, char *argv[]) {
    int thread_count = 4;
    if (argc > 1) {
        thread_count = (int)strtol(argv[1], NULL, 10);
    }

    printf("Before the parallel region: one thread\n");

#   pragma omp parallel num_threads(thread_count)
    {
        int my_rank = omp_get_thread_num();
        int team_size = omp_get_num_threads();
        printf("Hello from thread %d of %d\n", my_rank, team_size);
    }

    printf("After the parallel region: one thread again\n");
    return 0;
}
