My guess: since overflowing int is UB, and the only value of n that stops the recursion is zero, the compiler assumes that n must be zero and checks accordingly.
That doesn’t explain why it uses test dil, 1 instead of test dil, dil or cmp 0 or whatever.
The compiler cannot assume that much, because the argument is a signed integer (negative integers will not overflow and do have well-defined behaviour).
That doesn’t explain why it uses test dil, 1 instead of test dil, dil or cmp 0 or whatever.