{

int intLeft = 0, intBottom = 0, intRight = 0, intTop = 0;

int emptyIntersection = 0;

// check on horizontal overlap

if (r1.pt1.x <= r2.pt1.x)

{

intLeft = r2.pt1.x;

if (r1.pt2.x < r2.pt1.x)

emptyIntersection = 1;

else

intRight = (r1.pt2.x < r2.pt2.x)?r1.pt2.x:r2.pt2.

}

else

{

intLeft = r1.pt1.x;

if (r2.pt2.x< r1.pt1.x)

emptyIntersection = 1;

else

intRight = (r1.pt2.x < r2.pt2.x)?r1.pt2.x:r2.pt2.

}

// check on vertical overlap

if (r1.pt1.y<= r2.pt1.y)

{

intBottom = r2.pt1.y;

if (r1Top < r2.left)

emptyIntersection = 1;

else

intTop = (r1.pt2.y < r2.pt2.y)?r1.pt2.y:r2.pt2.

}

else

{

intBottom = r1.pt1.y;

if (r2.pt2.y< r1.pt1.x)

emptyIntersection = 1;

else

intTop = (r1.pt2.y < r2.pt2.y)?r1.pt2.y:r2.pt2.

}

if (emptyIntersection)

intLeft = intBottom = intTop = intRight = 0;

return makeRectangle(makePoint(in

}