import Foreign
import Foreign.C
import Char
import Monad

main = haskellFunc

haskellFunc :: IO ()
haskellFunc = allocaBytes 100 $ \ptr -> do
  pokeArray ptr (replicate 100 68)
  cFunc ptr
  elems <- peekArray 100 ptr
  putStrLn (reverse (map (chr . fromIntegral) elems))

foreign import ccall safe "membug.h cFunc" cFunc :: Ptr CChar -> IO ()

foreign export ccall "haskellFunc" haskellFunc :: IO ()


