revised generate.c main()