#include #include static void* worker(void* arg) { return (void*)((intptr_t)arg * 2); } // Returns (input * 2) computed inside a spawned pthread. int pthread_double(int x) { pthread_t tid; if (pthread_create(&tid, NULL, worker, (void*)(intptr_t)x) != 0) return -1; void* ret = NULL; if (pthread_join(tid, &ret) != 0) return -2; return (int)(intptr_t)ret; }