int shared;

void thread_fn(void) {
	while (compare_and_swap(&shared, 0, 1) != 0)
		intentional_busy_wait();

	atomic_write(&shared, 0);
}

int main(void) {
	thread_new(&thread_fn);

	while (compare_and_swap(&shared, 0, 1) != 0)
		intentional_busy_wait();

	atomic_write(&shared, 0);

	return 0;
}
