a lava emulator write by c