Where to put the PID windup guard?
Integrator anti-windup is a measure you need to take because of output saturation or other limits in the system, and such limits are nonlinear behavior.  When you start doing nonlinear control, a lot of the nice, clear, procedural things that we're taught in undergraduate control theory classes don't entirely apply.

In general you should apply integrator anti-windup to just the integrator term, although you may also need to apply limiting to the output term before it's applied to a DAC (assuming you're doing the work in software).  There are a lot of ways to do this.  My preference is to either limit the integrator state to certain bounds by itself:

// (Calculate integrator_state)
if (integrator_state &gt; integrator_max) {integrator_state = integrator_max;}
if (integrator_state &lt; integrator_min) {integrator_state = integrator_min;}


Or to calculate a candidate output, then trim the integrator state:

output_candidate = integrator_state + error * prop_gain;
if (output_candidate &gt; output_max) {
  integrator_state = output_max - error * prop_gain;
} else if (output_candidate &lt; output_min) {
  integrator_state = output_min - error * prop_gain;
}
// Re-calculate the actual output, possibly with a D term


The method that @Chu mentions would work, if you remember to only apply it when the integrator is being pulled to excess, not pulled back (but my first method is equivalent).  Another method that is used often is to hold the integrator term at zero when the error is large, then allow integrator action when the error gets below some threshold, or if you're doing a motion controller that knows when a "move" starts to set the integrator at zero at the start of a move and hold it there for some finite time.  I'm not a big fan of either of those methods, but others are.

Because you're venturing into nonlinear control, even if you're so far in the shallow end of the pool you can lie down without drowning, there are options on options on options, and there's no one right way to do it.  Moreover, you can't find an answer by analysis -- you have to either implement the real system and give it a whirl, or make a simulation and try your algorithm out on that.