Use intrinsics rather than inline assembly where possible