cmd/cgo: avoid worklist nondeterminism.

+ Regression test.

Fixes issue 9026.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://codereview.appspot.com/162490043
misc/cgo/test: fix bad C test code that fails on some configurations

LGTM=rsc
R=rsc
CC=golang-codereviews
https://codereview.appspot.com/169800043