Fix gracelib bugs reported by C compiler
Fix copying error in loopinvariant sample