I have lots (billions) of points in 2D which I can preprocess and I would like to answer queries which are of the following form:
Given all four corners of a rectang
What you need is some sort of binary space partitioning data structure. That'll get you a list of candidates for which you could do the real "point in polygon" test.
I'd advise you to make sure that this is something you really ought to be coding on your own. For example, many DBs have this sort of functionality built in. Does your data actually reside in a DB? Could it? (no sense in reinventing wheels...)
You can see a great answer for the Point in Polygon problem here: How can I determine whether a 2D Point is within a Polygon?