stack[ssize++] = new StackEntry(j, middle + m, last, (check & 2) | (next & 1)); middle -= m; last = i; next <<= 1; stack[ssize++] = new StackEntry(first, middle - m, i, (check & 1) | (next & 2)); first = j; middle += m;
stack[ssize++] = new StackEntry(0, a, b, 0); stack[ssize++] = new StackEntry(isaD - 1, first, last, -2); if (a - first <= last - b) { if (1 < a - first) { stack[ssize++] = new StackEntry(isaD, b, last, trLog(last - b)); last = a; limit = trLog(a - first); } else if (1 < last - b) { stack[ssize++] = new StackEntry(isaD, first, a, trLog(a - first)); first = b; limit = trLog(last - b); stack[ssize++] = new StackEntry(isaD, a, last, -3); isaD += 1; last = a; limit = next; } else { if (1 < last - a) { stack[ssize++] = new StackEntry(isaD + 1, first, a, next); first = a; limit = -3; } else { if (last - b <= b - a) { if (1 < a - first) { stack[ssize++] = new StackEntry(isaD + 1, a, b, next); stack[ssize++] = new StackEntry(isaD, b, last, limit); last = a; } else if (1 < last - b) { stack[ssize++] = new StackEntry(isaD + 1, a, b, next); first = b; } else if (1 < b - a) {
stack[ssize++] = new StackEntry(0, a, b, 0); stack[ssize++] = new StackEntry(isaD - 1, first, last, -2); if (a - first <= last - b) { if (1 < a - first) { stack[ssize++] = new StackEntry(isaD, b, last, trLog(last - b)); last = a; limit = trLog(a - first); } else if (1 < last - b) { stack[ssize++] = new StackEntry(isaD, first, a, trLog(a - first)); first = b; limit = trLog(last - b); stack[ssize++] = new StackEntry(isaD, a, last, -3); isaD += 1; last = a; limit = next; } else { if (1 < last - a) { stack[ssize++] = new StackEntry(isaD + 1, first, a, next); first = a; limit = -3; } else { if (last - b <= b - a) { if (1 < a - first) { stack[ssize++] = new StackEntry(isaD + 1, a, b, next); stack[ssize++] = new StackEntry(isaD, b, last, limit); last = a; } else if (1 < last - b) { stack[ssize++] = new StackEntry(isaD + 1, a, b, next); first = b; } else if (1 < b - a) {
stack[ssize++] = new StackEntry(0, a, b, 0); stack[ssize++] = new StackEntry(isaD - 1, first, last, -2); if (a - first <= last - b) { if (1 < a - first) { stack[ssize++] = new StackEntry(isaD, b, last, trLog(last - b)); last = a; limit = trLog(a - first); } else if (1 < last - b) { stack[ssize++] = new StackEntry(isaD, first, a, trLog(a - first)); first = b; limit = trLog(last - b); stack[ssize++] = new StackEntry(isaD, a, last, -3); isaD += 1; last = a; limit = next; } else { if (1 < last - a) { stack[ssize++] = new StackEntry(isaD + 1, first, a, next); first = a; limit = -3; } else { if (last - b <= b - a) { if (1 < a - first) { stack[ssize++] = new StackEntry(isaD + 1, a, b, next); stack[ssize++] = new StackEntry(isaD, b, last, limit); last = a; } else if (1 < last - b) { stack[ssize++] = new StackEntry(isaD + 1, a, b, next); first = b; } else if (1 < b - a) {
stack[ssize++] = new StackEntry(0, a, b, 0); stack[ssize++] = new StackEntry(isaD - 1, first, last, -2); if (a - first <= last - b) { if (1 < a - first) { stack[ssize++] = new StackEntry(isaD, b, last, trLog(last - b)); last = a; limit = trLog(a - first); } else if (1 < last - b) { stack[ssize++] = new StackEntry(isaD, first, a, trLog(a - first)); first = b; limit = trLog(last - b); stack[ssize++] = new StackEntry(isaD, a, last, -3); isaD += 1; last = a; limit = next; } else { if (1 < last - a) { stack[ssize++] = new StackEntry(isaD + 1, first, a, next); first = a; limit = -3; } else { if (last - b <= b - a) { if (1 < a - first) { stack[ssize++] = new StackEntry(isaD + 1, a, b, next); stack[ssize++] = new StackEntry(isaD, b, last, limit); last = a; } else if (1 < last - b) { stack[ssize++] = new StackEntry(isaD + 1, a, b, next); first = b; } else if (1 < b - a) {
stack[ssize++] = new StackEntry(a, last, depth, -1); last = a; depth += 1; stack[ssize++] = new StackEntry(first, a, depth + 1, ssLog(a - first)); first = a; limit = -1; stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); stack[ssize++] = new StackEntry(c, last, depth, limit); last = a; } else if (a - first <= c - b) { stack[ssize++] = new StackEntry(c, last, depth, limit); stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); last = a; } else { stack[ssize++] = new StackEntry(c, last, depth, limit); stack[ssize++] = new StackEntry(first, a, depth, limit); first = b; last = c; stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); stack[ssize++] = new StackEntry(first, a, depth, limit); first = c; } else if (last - c <= c - b) { stack[ssize++] = new StackEntry(first, a, depth, limit); stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); first = c; } else {
stack[ssize++] = new StackEntry(a, last, depth, -1); last = a; depth += 1; stack[ssize++] = new StackEntry(first, a, depth + 1, ssLog(a - first)); first = a; limit = -1; stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); stack[ssize++] = new StackEntry(c, last, depth, limit); last = a; } else if (a - first <= c - b) { stack[ssize++] = new StackEntry(c, last, depth, limit); stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); last = a; } else { stack[ssize++] = new StackEntry(c, last, depth, limit); stack[ssize++] = new StackEntry(first, a, depth, limit); first = b; last = c; stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); stack[ssize++] = new StackEntry(first, a, depth, limit); first = c; } else if (last - c <= c - b) { stack[ssize++] = new StackEntry(first, a, depth, limit); stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); first = c; } else {
stack[ssize++] = new StackEntry(a, last, depth, -1); last = a; depth += 1; stack[ssize++] = new StackEntry(first, a, depth + 1, ssLog(a - first)); first = a; limit = -1; stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); stack[ssize++] = new StackEntry(c, last, depth, limit); last = a; } else if (a - first <= c - b) { stack[ssize++] = new StackEntry(c, last, depth, limit); stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); last = a; } else { stack[ssize++] = new StackEntry(c, last, depth, limit); stack[ssize++] = new StackEntry(first, a, depth, limit); first = b; last = c; stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); stack[ssize++] = new StackEntry(first, a, depth, limit); first = c; } else if (last - c <= c - b) { stack[ssize++] = new StackEntry(first, a, depth, limit); stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); first = c; } else {
stack[ssize++] = new StackEntry(b, last, limit, 0); last = a; } else { stack[ssize++] = new StackEntry(first, a, limit, 0); first = b; } else {
stack[ssize++] = new StackEntry(b, last, limit, 0); last = a; } else { stack[ssize++] = new StackEntry(first, a, limit, 0); first = b; } else {
stack[ssize++] = new StackEntry(b, last, limit, 0); last = a; } else { stack[ssize++] = new StackEntry(first, a, limit, 0); first = b; } else {
stack[ssize++] = new StackEntry(b, last, limit, 0); last = a; } else { stack[ssize++] = new StackEntry(first, a, limit, 0); first = b; } else {
stack[ssize++] = new StackEntry(a, last, depth, -1); last = a; depth += 1; stack[ssize++] = new StackEntry(first, a, depth + 1, ssLog(a - first)); first = a; limit = -1; stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); stack[ssize++] = new StackEntry(c, last, depth, limit); last = a; } else if (a - first <= c - b) { stack[ssize++] = new StackEntry(c, last, depth, limit); stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); last = a; } else { stack[ssize++] = new StackEntry(c, last, depth, limit); stack[ssize++] = new StackEntry(first, a, depth, limit); first = b; last = c; stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); stack[ssize++] = new StackEntry(first, a, depth, limit); first = c; } else if (last - c <= c - b) { stack[ssize++] = new StackEntry(first, a, depth, limit); stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); first = c; } else {
stack[ssize++] = new StackEntry(j, middle + m, last, (check & 2) | (next & 1)); middle -= m; last = i; next <<= 1; stack[ssize++] = new StackEntry(first, middle - m, i, (check & 1) | (next & 2)); first = j; middle += m;
stack[ssize++] = new StackEntry(j, middle + m, last, (check & 2) | (next & 1)); middle -= m; last = i; next <<= 1; stack[ssize++] = new StackEntry(first, middle - m, i, (check & 1) | (next & 2)); first = j; middle += m;
stack[ssize++] = new StackEntry(j, middle + m, last, (check & 2) | (next & 1)); middle -= m; last = i; next <<= 1; stack[ssize++] = new StackEntry(first, middle - m, i, (check & 1) | (next & 2)); first = j; middle += m;
stack[ssize++] = new StackEntry(j, middle + m, last, (check & 2) | (next & 1)); middle -= m; last = i; next <<= 1; stack[ssize++] = new StackEntry(first, middle - m, i, (check & 1) | (next & 2)); first = j; middle += m;
stack[ssize++] = new StackEntry(0, a, b, 0); stack[ssize++] = new StackEntry(isaD - 1, first, last, -2); if (a - first <= last - b) { if (1 < a - first) { stack[ssize++] = new StackEntry(isaD, b, last, trLog(last - b)); last = a; limit = trLog(a - first); } else if (1 < last - b) { stack[ssize++] = new StackEntry(isaD, first, a, trLog(a - first)); first = b; limit = trLog(last - b); stack[ssize++] = new StackEntry(isaD, a, last, -3); isaD += 1; last = a; limit = next; } else { if (1 < last - a) { stack[ssize++] = new StackEntry(isaD + 1, first, a, next); first = a; limit = -3; } else { if (last - b <= b - a) { if (1 < a - first) { stack[ssize++] = new StackEntry(isaD + 1, a, b, next); stack[ssize++] = new StackEntry(isaD, b, last, limit); last = a; } else if (1 < last - b) { stack[ssize++] = new StackEntry(isaD + 1, a, b, next); first = b; } else if (1 < b - a) {
stack[ssize++] = new StackEntry(a, last, depth, -1); last = a; depth += 1; stack[ssize++] = new StackEntry(first, a, depth + 1, ssLog(a - first)); first = a; limit = -1; stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); stack[ssize++] = new StackEntry(c, last, depth, limit); last = a; } else if (a - first <= c - b) { stack[ssize++] = new StackEntry(c, last, depth, limit); stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); last = a; } else { stack[ssize++] = new StackEntry(c, last, depth, limit); stack[ssize++] = new StackEntry(first, a, depth, limit); first = b; last = c; stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); stack[ssize++] = new StackEntry(first, a, depth, limit); first = c; } else if (last - c <= c - b) { stack[ssize++] = new StackEntry(first, a, depth, limit); stack[ssize++] = new StackEntry(b, c, depth + 1, ssLog(c - b)); first = c; } else {
stack[ssize++] = new StackEntry(b, last, limit, 0); last = a; } else { stack[ssize++] = new StackEntry(first, a, limit, 0); first = b; } else {