[guided]We now assemble the result using the Residue Theorem. Let us verify its hypotheses:
1. **Meromorphicity**: The function $g(z) f'(z)/f(z)$ is meromorphic on $\Omega$ with only simple poles (at the zeros and poles of $f$), as established in the previous steps.
2. **Curve conditions**: $\gamma$ is a simple positively-oriented closed piecewise $C^1$ curve in $\Omega$ that does not pass through any singularity of $g \cdot f'/f$ (since $\gamma$ avoids all zeros and poles of $f$ by hypothesis).
3. **Winding number condition**: $n(\gamma, z_0) = 0$ for all $z_0 \in \mathbb{C} \setminus \Omega$ is given by hypothesis. This ensures the Residue Theorem applies in the form involving winding numbers.
Since $\gamma$ is simple and positively oriented, the winding number $n(\gamma, w) = 1$ for every point $w$ in the interior of $\gamma$ (by the Jordan curve theorem). All zeros $z_1, \ldots, z_p$ and poles $w_1, \ldots, w_q$ of $f$ inside $\gamma$ are interior points, so $n(\gamma, z_j) = n(\gamma, w_j) = 1$.
The Residue Theorem gives:
\begin{align*}
\frac{1}{2\pi i}\oint_\gamma g(z)\frac{f'(z)}{f(z)}\,dz &= \sum_{j=1}^{p} n(\gamma, z_j)\operatorname{Res}\left(g \cdot \frac{f'}{f},\, z_j\right) + \sum_{j=1}^{q} n(\gamma, w_j)\operatorname{Res}\left(g \cdot \frac{f'}{f},\, w_j\right).
\end{align*}
Substituting the residues computed in Steps 1 and 2, and using $n(\gamma, z_j) = n(\gamma, w_j) = 1$:
\begin{align*}
&= \sum_{j=1}^{p} m_j \cdot g(z_j) + \sum_{j=1}^{q} (-k_j) \cdot g(w_j) \\
&= \sum_{\substack{z_0 \text{ zero of } f \\ \text{inside } \gamma}} \operatorname{ord}(f, z_0) \cdot g(z_0) - \sum_{\substack{z_0 \text{ pole of } f \\ \text{inside } \gamma}} m \cdot g(z_0),
\end{align*}
where $m$ is the order of the pole of $f$ at $z_0$. This completes the proof of the Generalized Argument Principle.
Note that setting $g \equiv 1$ recovers the standard Argument Principle: the integral counts the number of zeros minus the number of poles (with multiplicity). The generalization replaces the counting measure with a weighted sum, where the weight at each zero or pole is the value of the holomorphic function $g$ at that point.[/guided]