Language: C++

void toRectangle(P p1, P p2, Rectangle &r){
	r.ps[0] = {p1.x, p2.y};
	r.ps[1] = p2;
	r.ps[2] = p1;
	r.ps[3] = {p2.x, p1.y};
}

const double EPS = 1e-8;

double abs(double d){
	return (d>0)?d:-d;
}

// r1の各4点がr2の中にいくつあるか
int intersectionOfPoints(Rectangle r1, Rectangle r2){
	double ub_x = r2.ps[1].x, lb_x = r2.ps[0].x,
		ub_y = r2.ps[0].y, lb_y = r2.ps[2].y;

	int res = 0;
	for(int i=0;i<4;i++){
		P p = r1.ps[i];
		if((abs(p.x-lb_x) < EPS || (lb_x < p.x && p.x < ub_x) || abs(p.x-ub_x) < EPS) &&
			 (abs(p.y-lb_y) < EPS || (lb_y < p.y && p.y < ub_y) || abs(p.y-ub_x) < EPS)){
			res++;
		}
	}

	return res;
}

bool intersectionOfRectangles(Rectangle r1, Rectangle r2){
	int ior1 = intersectionOfPoints(r1, r2),
		ior2 = intersectionOfPoints(r2, r1);
	if(ior1 > 0 || ior2 > 0){
		return true;
	}
	return false;
}

int main(){
	P ps[4];
	Rectangle r[2];
	while(std::cin >> ps[0].x >> ps[0].y >> ps[1].x >> ps[1].y >> ps[2].x >> ps[2].y >> ps[3].x >> ps[3].y, !std::cin.eof()){
		toRectangle(ps[0], ps[1], r[0]);
		toRectangle(ps[2], ps[3], r[1]);

		if(intersectionOfRectangles(r[0], r[1])){
			std::cout << "YES" << std::endl;
		}else{
			std::cout << "NO" << std::endl;
		}
	}
}

Compiler output:
a.cc:1:6: error: variable or field 'toRectangle' declared void
    1 | void toRectangle(P p1, P p2, Rectangle &r){
      |      ^~~~~~~~~~~
a.cc:1:18: error: 'P' was not declared in this scope
    1 | void toRectangle(P p1, P p2, Rectangle &r){
      |                  ^
a.cc:1:24: error: 'P' was not declared in this scope
    1 | void toRectangle(P p1, P p2, Rectangle &r){
      |                        ^
a.cc:1:30: error: 'Rectangle' was not declared in this scope
    1 | void toRectangle(P p1, P p2, Rectangle &r){
      |                              ^~~~~~~~~
a.cc:1:41: error: 'r' was not declared in this scope
    1 | void toRectangle(P p1, P p2, Rectangle &r){
      |                                         ^
a.cc:15:26: error: 'Rectangle' was not declared in this scope
   15 | int intersectionOfPoints(Rectangle r1, Rectangle r2){
      |                          ^~~~~~~~~
a.cc:15:40: error: 'Rectangle' was not declared in this scope
   15 | int intersectionOfPoints(Rectangle r1, Rectangle r2){
      |                                        ^~~~~~~~~
a.cc:15:52: error: expression list treated as compound expression in initializer [-fpermissive]
   15 | int intersectionOfPoints(Rectangle r1, Rectangle r2){
      |                                                    ^
a.cc:31:31: error: 'Rectangle' was not declared in this scope
   31 | bool intersectionOfRectangles(Rectangle r1, Rectangle r2){
      |                               ^~~~~~~~~
a.cc:31:45: error: 'Rectangle' was not declared in this scope
   31 | bool intersectionOfRectangles(Rectangle r1, Rectangle r2){
      |                                             ^~~~~~~~~
a.cc:31:57: error: expression list treated as compound expression in initializer [-fpermissive]
   31 | bool intersectionOfRectangles(Rectangle r1, Rectangle r2){
      |                                                         ^
a.cc: In function 'int main()':
a.cc:41:9: error: 'P' was not declared in this scope
   41 |         P ps[4];
      |         ^
a.cc:42:9: error: 'Rectangle' was not declared in this scope
   42 |         Rectangle r[2];
      |         ^~~~~~~~~
a.cc:43:20: error: 'cin' is not a member of 'std'
   43 |         while(std::cin >> ps[0].x >> ps[0].y >> ps[1].x >> ps[1].y >> ps[2].x >> ps[2].y >> ps[3].x >> ps[3].y, !std::cin.eof()){
      |                    ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | void toRectangle(P p1, P p2, Rectangle &r){
a.cc:43:27: error: 'ps' was not declared in this scope
   43 |         while(std::cin >> ps[0].x >> ps[0].y >> ps[1].x >> ps[1].y >> ps[2].x >> ps[2].y >> ps[3].x >> ps[3].y, !std::cin.eof()){
      |                           ^~
a.cc:43:119: error: 'cin' is not a member of 'std'
   43 |         while(std::cin >> ps[0].x >> ps[0].y >> ps[1].x >> ps[1].y >> ps[2].x >> ps[2].y >> ps[3].x >> ps[3].y, !std::cin.eof()){
      |                                                                                                                       ^~~
a.cc:43:119: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:44:43: error: 'r' was not declared in this scope
   44 |                 toRectangle(ps[0], ps[1], r[0]);
      |                                           ^
a.cc:44:17: error: 'toRectangle' was not declared in this scope
   44 |                 toRectangle(ps[0], ps[1], r[0]);
      |                 ^~~~~~~~~~~
a.cc:47:55: error: 'intersectionOfRectangles' cannot be used as a function
   47 |                 if(intersectionOfRectangles(r[0], r[1])){
      |                                                       ^
a.cc:48:30: error: 'cout' is not a member of 'std'
   48 |                         std::cout << "YES" << std::endl;
      |                              ^~~~
a.cc:48:30: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:48:52: error: 'endl' is not a member of 'std'
   48 |                         std::cout << "YES" << std::endl;
      |                                                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | void toRectangle(P p1, P p2, Rectangle &r){
a.cc:50:30: error: 'cout' is not a member of 'std'
   50 |                         std::cout << "NO" << std::endl;
      |                              ^~~~
a.cc:50:30: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:50:51: error: 'endl' is not a member of 'std'
   50 |                         std::cout << "NO" << std::endl;
      |                                                   ^~~~
a.cc:50:51: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'