xattr seems to be problematic with some files like compiled scripts. It always returns an error saying the file does not exists. (Maybe because it has a resource fork containing unexpected contents?)
I thought about another way to deal with this problem: compare the current icon to the default icon.
use framework "Foundation"
use framework "AppKit"
use scripting additions
set thePath to "/SomeFilePath"
set theURL to current application's NSURL's fileURLWithPath:thePath
set {hasResult, theUTI} to (theURL's getResourceValue:(reference) forKey:"NSURLTypeIdentifierKey" |error|:(missing value))
set theWorkspace to current application's NSWorkspace's sharedWorkspace()
set defaultIcon to (theWorkspace's iconForFileType:theUTI)'s TIFFRepresentation()
set thisIcon to (theWorkspace's iconForFile:thePath)'s TIFFRepresentation()
return (defaultIcon's isEqualToData:thisIcon)