Semi-infinite flags. II: Local and global intersection cohomology of quasimaps spaces Flattenings of projective curves, singularities of Schubert stratifications of Grassmannians and flag varieties, and bifurcations of Weierstrass points of algebraic curves 