Semiclassical analysis of a quasi-exactly solvable system: second harmonic generation