-- script.lua

-- This works coz LuaJIT automatically loads the jit module.
if type(jit) == 'table' then
  io.write('script.lua is being run by ' .. jit.version .. ' under ' .. jit.os .. ' on a ' .. jit.arch .. '\n')
else
  io.write('script.lua is being run by Lua version ' .. _VERSION .. '\n')
end

-- Receives a table, returns the sum of its components.
io.write("The table the script received has:\n");
x = 0
for i = 1, #foo do
  print(i, foo[i])
  x = x + foo[i]
end
io.write("Returning data back to C\n");
return x