reentrant functions for pairs.c
simplified recursive struct declaration