what are these values :
long xy_max = 470;
long xy_min = 550;
These are the limits for the values to use in the "if" statements.
They are backwards, as you can tell (max < min), but that's really just semantics.
What happens is a set of if statements check to see if the accelerometer x and y outputs are greater than (in this case) the min, or less than the x, and light up the led's accordingly.