Improve C program which makes several system calls