static void slide(signed char *r, const uint8_t *a) {
  int i;
  int b;
  int k;
  for (i = 0; i < 256; ++i) {
    r[i] = 1 & (a[i >> 3] >> (i & 7));
  }
  for (i = 0; i < 256; ++i) {
    if (r[i]) {
      for (b = 1; b <= 6 && i + b < 256; ++b) {
        if (r[i + b]) {
          if (r[i] + (r[i + b] << b) <= 15) {
            r[i] += r[i + b] << b;
            r[i + b] = 0;
          } else if (r[i] - (r[i + b] << b) >= -15) {
            r[i] -= r[i + b] << b;
            for (k = i + b; k < 256; ++k) {
              if (!r[k]) {
                r[k] = 1;
                break;
              }
              r[k] = 0;
            }
          } else {
            break;
          }
        }
      }
    }
  }
}
['static void ge_double_scalarmult_vartime(ge_p2 *r, const uint8_t *a,\n                                         const ge_p3 *A, const uint8_t *b) {\n  signed char aslide[256];\n  signed char bslide[256];\n  ge_cached Ai[8];\n  ge_p1p1 t;\n  ge_p3 u;\n  ge_p3 A2;\n  int i;\n  slide(aslide, a);\n  slide(bslide, b);\n  ge_p3_to_cached(&Ai[0], A);\n  ge_p3_dbl(&t, A);\n  ge_p1p1_to_p3(&A2, &t);\n  ge_add(&t, &A2, &Ai[0]);\n  ge_p1p1_to_p3(&u, &t);\n  ge_p3_to_cached(&Ai[1], &u);\n  ge_add(&t, &A2, &Ai[1]);\n  ge_p1p1_to_p3(&u, &t);\n  ge_p3_to_cached(&Ai[2], &u);\n  ge_add(&t, &A2, &Ai[2]);\n  ge_p1p1_to_p3(&u, &t);\n  ge_p3_to_cached(&Ai[3], &u);\n  ge_add(&t, &A2, &Ai[3]);\n  ge_p1p1_to_p3(&u, &t);\n  ge_p3_to_cached(&Ai[4], &u);\n  ge_add(&t, &A2, &Ai[4]);\n  ge_p1p1_to_p3(&u, &t);\n  ge_p3_to_cached(&Ai[5], &u);\n  ge_add(&t, &A2, &Ai[5]);\n  ge_p1p1_to_p3(&u, &t);\n  ge_p3_to_cached(&Ai[6], &u);\n  ge_add(&t, &A2, &Ai[6]);\n  ge_p1p1_to_p3(&u, &t);\n  ge_p3_to_cached(&Ai[7], &u);\n  ge_p2_0(r);\n  for (i = 255; i >= 0; --i) {\n    if (aslide[i] || bslide[i]) {\n      break;\n    }\n  }\n  for (; i >= 0; --i) {\n    ge_p2_dbl(&t, r);\n    if (aslide[i] > 0) {\n      ge_p1p1_to_p3(&u, &t);\n      ge_add(&t, &u, &Ai[aslide[i] / 2]);\n    } else if (aslide[i] < 0) {\n      ge_p1p1_to_p3(&u, &t);\n      ge_sub(&t, &u, &Ai[(-aslide[i]) / 2]);\n    }\n    if (bslide[i] > 0) {\n      ge_p1p1_to_p3(&u, &t);\n      ge_madd(&t, &u, &Bi[bslide[i] / 2]);\n    } else if (bslide[i] < 0) {\n      ge_p1p1_to_p3(&u, &t);\n      ge_msub(&t, &u, &Bi[(-bslide[i]) / 2]);\n    }\n    ge_p1p1_to_p2(r, &t);\n  }\n}', 'static void slide(signed char *r, const uint8_t *a) {\n  int i;\n  int b;\n  int k;\n  for (i = 0; i < 256; ++i) {\n    r[i] = 1 & (a[i >> 3] >> (i & 7));\n  }\n  for (i = 0; i < 256; ++i) {\n    if (r[i]) {\n      for (b = 1; b <= 6 && i + b < 256; ++b) {\n        if (r[i + b]) {\n          if (r[i] + (r[i + b] << b) <= 15) {\n            r[i] += r[i + b] << b;\n            r[i + b] = 0;\n          } else if (r[i] - (r[i + b] << b) >= -15) {\n            r[i] -= r[i + b] << b;\n            for (k = i + b; k < 256; ++k) {\n              if (!r[k]) {\n                r[k] = 1;\n                break;\n              }\n              r[k] = 0;\n            }\n          } else {\n            break;\n          }\n        }\n      }\n    }\n  }\n}']