Line Segment Intersection

Given two line segments, determine whether they intersect.

Segment 1 is defined by endpoints $P_1 = (x_1, y_1)$ and $Q_1 = (x_2, y_2)$. Segment 2 is defined by endpoints $P_2 = (x_3, y_3)$ and $Q_2 = (x_4, y_4)$.

The input arg1 is an array of 8 numbers: [x1, y1, x2, y2, x3, y3, x4, y4].

Return 1 if the segments intersect (including the case where an endpoint lies on the other segment or the segments overlap collinearly on a shared interval), otherwise return 0.

Use exact orientation/cross-product arithmetic for integer coordinates.

Examples
Input: [1,2,3]
Output: 0
Hints

Line Segment Intersection

Given two line segments, determine whether they intersect.