function median(a, b, c, d, e) {
if (a >= b) { /* 1st comparision */
a = a + b; b = a - b; a = a - b; // swap
}
if (c >= d) { /* 2nd comparision */
c = c + d; d = c - d; c = c - d;
}
// now we have: a < b, c < d
if (b >= d) { /* 3rd comparision */
a = a + c; c = a - c; a = a - c;
b = b + d; d = b - d; b = b - d;
}
// now d > (a and b and c) => d is not median
if (c >= e) { /* 4th comparision */
c = c + e; e = c - e; c = c - e;
}
// now we have: a < b, c < e
if (b > e) { /* 5th comparision */
if (a > e) return a; else return e; /* 6th comparision */
} else { // => e is not median
if (b > c) return b; else return c; /* 6th comparision */
}
}