Origin of the Bipolar Doping Behavior of SnO from X-ray Spectroscopy and Density Functional Theory