The Debug WASM build overwrites prog with 0. This seems to be related with creating an instance of the foo struct as this behaviour does not occur when I comment out the var foo = ... line.
$ zig build-lib test2.zig -target wasm32-freestanding -dynamic
$ node test2.js
The result is 12
The result is 49
The result is 0