LLVMFuzzerTestOneInput:
   30|    621|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   31|    621|    if (size < sizeof(inputArgs)) {
  ------------------
  |  Branch (31:9): [True: 8, False: 613]
  ------------------
   32|      8|        return 0;
   33|      8|    }
   34|    613|    const inputArgs *args = (const inputArgs *)data;
   35|       |
   36|    613|    H3_EXPORT(getResolution)(args->index);
  ------------------
  |  |   36|    613|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    613|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    613|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   37|    613|    H3_EXPORT(getBaseCellNumber)(args->index);
  ------------------
  |  |   36|    613|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    613|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    613|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   38|    613|    H3_EXPORT(isValidIndex)(args->index);
  ------------------
  |  |   36|    613|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    613|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    613|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   39|    613|    H3_EXPORT(isValidCell)(args->index);
  ------------------
  |  |   36|    613|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    613|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    613|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   40|    613|    H3_EXPORT(isPentagon)(args->index);
  ------------------
  |  |   36|    613|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    613|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    613|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   41|    613|    H3_EXPORT(isResClassIII)(args->index);
  ------------------
  |  |   36|    613|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    613|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    613|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   42|       |
   43|    613|    int faceCount;
   44|    613|    H3Error err = H3_EXPORT(maxFaceCount)(args->index, &faceCount);
  ------------------
  |  |   36|    613|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    613|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    613|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   45|    613|    if (!err && faceCount > 0) {
  ------------------
  |  Branch (45:9): [True: 613, False: 0]
  |  Branch (45:17): [True: 613, False: 0]
  ------------------
   46|    613|        int *out = calloc(faceCount, sizeof(int));
   47|    613|        H3_EXPORT(getIcosahedronFaces)(args->index, out);
  ------------------
  |  |   36|    613|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    613|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    613|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   48|    613|        free(out);
   49|    613|    }
   50|       |
   51|    613|    int digitOut;
   52|    613|    H3_EXPORT(getIndexDigit)(args->index, args->res, &digitOut);
  ------------------
  |  |   36|    613|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    613|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    613|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|       |
   54|    613|    return 0;
   55|    621|}

h3Index.c:_rotate60ccw:
  656|  2.64k|static inline Direction _rotate60ccw(Direction digit) {
  657|  2.64k|    switch (digit) {
  658|    502|        case K_AXES_DIGIT:
  ------------------
  |  Branch (658:9): [True: 502, False: 2.13k]
  ------------------
  659|    502|            return IK_AXES_DIGIT;
  660|    439|        case IK_AXES_DIGIT:
  ------------------
  |  Branch (660:9): [True: 439, False: 2.20k]
  ------------------
  661|    439|            return I_AXES_DIGIT;
  662|    351|        case I_AXES_DIGIT:
  ------------------
  |  Branch (662:9): [True: 351, False: 2.28k]
  ------------------
  663|    351|            return IJ_AXES_DIGIT;
  664|    325|        case IJ_AXES_DIGIT:
  ------------------
  |  Branch (664:9): [True: 325, False: 2.31k]
  ------------------
  665|    325|            return J_AXES_DIGIT;
  666|    439|        case J_AXES_DIGIT:
  ------------------
  |  Branch (666:9): [True: 439, False: 2.20k]
  ------------------
  667|    439|            return JK_AXES_DIGIT;
  668|    510|        case JK_AXES_DIGIT:
  ------------------
  |  Branch (668:9): [True: 510, False: 2.13k]
  ------------------
  669|    510|            return K_AXES_DIGIT;
  670|     74|        default:
  ------------------
  |  Branch (670:9): [True: 74, False: 2.56k]
  ------------------
  671|     74|            return digit;
  672|  2.64k|    }
  673|  2.64k|}
h3Index.c:_rotate60cw:
  680|  1.83k|static inline Direction _rotate60cw(Direction digit) {
  681|  1.83k|    switch (digit) {
  682|    225|        case K_AXES_DIGIT:
  ------------------
  |  Branch (682:9): [True: 225, False: 1.61k]
  ------------------
  683|    225|            return JK_AXES_DIGIT;
  684|    243|        case JK_AXES_DIGIT:
  ------------------
  |  Branch (684:9): [True: 243, False: 1.59k]
  ------------------
  685|    243|            return J_AXES_DIGIT;
  686|    119|        case J_AXES_DIGIT:
  ------------------
  |  Branch (686:9): [True: 119, False: 1.71k]
  ------------------
  687|    119|            return IJ_AXES_DIGIT;
  688|    165|        case IJ_AXES_DIGIT:
  ------------------
  |  Branch (688:9): [True: 165, False: 1.67k]
  ------------------
  689|    165|            return I_AXES_DIGIT;
  690|    277|        case I_AXES_DIGIT:
  ------------------
  |  Branch (690:9): [True: 277, False: 1.56k]
  ------------------
  691|    277|            return IK_AXES_DIGIT;
  692|    378|        case IK_AXES_DIGIT:
  ------------------
  |  Branch (692:9): [True: 378, False: 1.46k]
  ------------------
  693|    378|            return K_AXES_DIGIT;
  694|    431|        default:
  ------------------
  |  Branch (694:9): [True: 431, False: 1.40k]
  ------------------
  695|    431|            return digit;
  696|  1.83k|    }
  697|  1.83k|}
h3Index.c:_downAp7:
  512|  7.93k|static inline void _downAp7(CoordIJK *ijk) {
  513|       |    // res r unit vectors in res r+1
  514|  7.93k|    CoordIJK iVec = {3, 0, 1};
  515|  7.93k|    CoordIJK jVec = {1, 3, 0};
  516|  7.93k|    CoordIJK kVec = {0, 1, 3};
  517|       |
  518|  7.93k|    _ijkScale(&iVec, ijk->i);
  519|  7.93k|    _ijkScale(&jVec, ijk->j);
  520|  7.93k|    _ijkScale(&kVec, ijk->k);
  521|       |
  522|  7.93k|    _ijkAdd(&iVec, &jVec, ijk);
  523|  7.93k|    _ijkAdd(ijk, &kVec, ijk);
  524|       |
  525|  7.93k|    _ijkNormalize(ijk);
  526|  7.93k|}
h3Index.c:_ijkScale:
  155|  47.5k|static inline void _ijkScale(CoordIJK *c, int factor) {
  156|  47.5k|    c->i *= factor;
  157|  47.5k|    c->j *= factor;
  158|  47.5k|    c->k *= factor;
  159|  47.5k|}
h3Index.c:_ijkAdd:
  129|  42.8k|                           CoordIJK *sum) {
  130|  42.8k|    sum->i = h1->i + h2->i;
  131|  42.8k|    sum->j = h1->j + h2->j;
  132|  42.8k|    sum->k = h1->k + h2->k;
  133|  42.8k|}
h3Index.c:_upAp7r:
  494|    598|static inline void _upAp7r(CoordIJK *ijk) {
  495|       |    // convert to CoordIJ
  496|    598|    int i = ijk->i - ijk->k;
  497|    598|    int j = ijk->j - ijk->k;
  498|       |
  499|    598|    ijk->i = (int)lround((2 * i + j) * M_ONESEVENTH);
  ------------------
  |  |   54|    598|#define M_ONESEVENTH 0.14285714285714285714285714285714285
  ------------------
  500|    598|    ijk->j = (int)lround((3 * j - i) * M_ONESEVENTH);
  ------------------
  |  |   54|    598|#define M_ONESEVENTH 0.14285714285714285714285714285714285
  ------------------
  501|    598|    ijk->k = 0;
  502|    598|    _ijkNormalize(ijk);
  503|    598|}
h3Index.c:_downAp7r:
  534|  7.90k|static inline void _downAp7r(CoordIJK *ijk) {
  535|       |    // res r unit vectors in res r+1
  536|  7.90k|    CoordIJK iVec = {3, 1, 0};
  537|  7.90k|    CoordIJK jVec = {0, 3, 1};
  538|  7.90k|    CoordIJK kVec = {1, 0, 3};
  539|       |
  540|  7.90k|    _ijkScale(&iVec, ijk->i);
  541|  7.90k|    _ijkScale(&jVec, ijk->j);
  542|  7.90k|    _ijkScale(&kVec, ijk->k);
  543|       |
  544|  7.90k|    _ijkAdd(&iVec, &jVec, ijk);
  545|  7.90k|    _ijkAdd(ijk, &kVec, ijk);
  546|       |
  547|  7.90k|    _ijkNormalize(ijk);
  548|  7.90k|}
h3Index.c:_ijkNormalize:
  207|  27.5k|static inline void _ijkNormalize(CoordIJK *c) {
  208|       |    // remove any negative values
  209|  27.5k|    if (c->i < 0) {
  ------------------
  |  Branch (209:9): [True: 249, False: 27.3k]
  ------------------
  210|    249|        c->j -= c->i;
  211|    249|        c->k -= c->i;
  212|    249|        c->i = 0;
  213|    249|    }
  214|       |
  215|  27.5k|    if (c->j < 0) {
  ------------------
  |  Branch (215:9): [True: 191, False: 27.3k]
  ------------------
  216|    191|        c->i -= c->j;
  217|    191|        c->k -= c->j;
  218|    191|        c->j = 0;
  219|    191|    }
  220|       |
  221|  27.5k|    if (c->k < 0) {
  ------------------
  |  Branch (221:9): [True: 0, False: 27.5k]
  ------------------
  222|      0|        c->i -= c->k;
  223|      0|        c->j -= c->k;
  224|      0|        c->k = 0;
  225|      0|    }
  226|       |
  227|       |    // remove the min value if needed
  228|  27.5k|    int min = c->i;
  229|  27.5k|    if (c->j < min) min = c->j;
  ------------------
  |  Branch (229:9): [True: 18.8k, False: 8.69k]
  ------------------
  230|  27.5k|    if (c->k < min) min = c->k;
  ------------------
  |  Branch (230:9): [True: 7.94k, False: 19.6k]
  ------------------
  231|  27.5k|    if (min > 0) {
  ------------------
  |  Branch (231:9): [True: 18.0k, False: 9.55k]
  ------------------
  232|  18.0k|        c->i -= min;
  233|  18.0k|        c->j -= min;
  234|  18.0k|        c->k -= min;
  235|  18.0k|    }
  236|  27.5k|}
h3Index.c:_neighbor:
  602|  14.7k|static inline void _neighbor(CoordIJK *ijk, Direction digit) {
  603|  14.7k|    if (digit > CENTER_DIGIT && digit < NUM_DIGITS) {
  ------------------
  |  Branch (603:9): [True: 11.5k, False: 3.18k]
  |  Branch (603:33): [True: 11.1k, False: 420]
  ------------------
  604|  11.1k|        _ijkAdd(ijk, &UNIT_VECS[digit], ijk);
  605|  11.1k|        _ijkNormalize(ijk);
  606|  11.1k|    }
  607|  14.7k|}
faceijk.c:_ijkRotate60ccw:
  614|  3.90k|static inline void _ijkRotate60ccw(CoordIJK *ijk) {
  615|       |    // unit vector rotations
  616|  3.90k|    CoordIJK iVec = {1, 1, 0};
  617|  3.90k|    CoordIJK jVec = {0, 1, 1};
  618|  3.90k|    CoordIJK kVec = {1, 0, 1};
  619|       |
  620|  3.90k|    _ijkScale(&iVec, ijk->i);
  621|  3.90k|    _ijkScale(&jVec, ijk->j);
  622|  3.90k|    _ijkScale(&kVec, ijk->k);
  623|       |
  624|  3.90k|    _ijkAdd(&iVec, &jVec, ijk);
  625|  3.90k|    _ijkAdd(ijk, &kVec, ijk);
  626|       |
  627|  3.90k|    _ijkNormalize(ijk);
  628|  3.90k|}
faceijk.c:_ijkScale:
  155|  18.5k|static inline void _ijkScale(CoordIJK *c, int factor) {
  156|  18.5k|    c->i *= factor;
  157|  18.5k|    c->j *= factor;
  158|  18.5k|    c->k *= factor;
  159|  18.5k|}
faceijk.c:_ijkAdd:
  129|  16.5k|                           CoordIJK *sum) {
  130|  16.5k|    sum->i = h1->i + h2->i;
  131|  16.5k|    sum->j = h1->j + h2->j;
  132|  16.5k|    sum->k = h1->k + h2->k;
  133|  16.5k|}
faceijk.c:_ijkNormalize:
  207|  10.6k|static inline void _ijkNormalize(CoordIJK *c) {
  208|       |    // remove any negative values
  209|  10.6k|    if (c->i < 0) {
  ------------------
  |  Branch (209:9): [True: 0, False: 10.6k]
  ------------------
  210|      0|        c->j -= c->i;
  211|      0|        c->k -= c->i;
  212|      0|        c->i = 0;
  213|      0|    }
  214|       |
  215|  10.6k|    if (c->j < 0) {
  ------------------
  |  Branch (215:9): [True: 0, False: 10.6k]
  ------------------
  216|      0|        c->i -= c->j;
  217|      0|        c->k -= c->j;
  218|      0|        c->j = 0;
  219|      0|    }
  220|       |
  221|  10.6k|    if (c->k < 0) {
  ------------------
  |  Branch (221:9): [True: 0, False: 10.6k]
  ------------------
  222|      0|        c->i -= c->k;
  223|      0|        c->j -= c->k;
  224|      0|        c->k = 0;
  225|      0|    }
  226|       |
  227|       |    // remove the min value if needed
  228|  10.6k|    int min = c->i;
  229|  10.6k|    if (c->j < min) min = c->j;
  ------------------
  |  Branch (229:9): [True: 4.85k, False: 5.82k]
  ------------------
  230|  10.6k|    if (c->k < min) min = c->k;
  ------------------
  |  Branch (230:9): [True: 3.68k, False: 6.99k]
  ------------------
  231|  10.6k|    if (min > 0) {
  ------------------
  |  Branch (231:9): [True: 9.14k, False: 1.53k]
  ------------------
  232|  9.14k|        c->i -= min;
  233|  9.14k|        c->j -= min;
  234|  9.14k|        c->k -= min;
  235|  9.14k|    }
  236|  10.6k|}
faceijk.c:_downAp3:
  557|    609|static inline void _downAp3(CoordIJK *ijk) {
  558|       |    // res r unit vectors in res r+1
  559|    609|    CoordIJK iVec = {2, 0, 1};
  560|    609|    CoordIJK jVec = {1, 2, 0};
  561|    609|    CoordIJK kVec = {0, 1, 2};
  562|       |
  563|    609|    _ijkScale(&iVec, ijk->i);
  564|    609|    _ijkScale(&jVec, ijk->j);
  565|    609|    _ijkScale(&kVec, ijk->k);
  566|       |
  567|    609|    _ijkAdd(&iVec, &jVec, ijk);
  568|    609|    _ijkAdd(ijk, &kVec, ijk);
  569|       |
  570|    609|    _ijkNormalize(ijk);
  571|    609|}
faceijk.c:_downAp3r:
  579|    609|static inline void _downAp3r(CoordIJK *ijk) {
  580|       |    // res r unit vectors in res r+1
  581|    609|    CoordIJK iVec = {2, 1, 0};
  582|    609|    CoordIJK jVec = {0, 2, 1};
  583|    609|    CoordIJK kVec = {1, 0, 2};
  584|       |
  585|    609|    _ijkScale(&iVec, ijk->i);
  586|    609|    _ijkScale(&jVec, ijk->j);
  587|    609|    _ijkScale(&kVec, ijk->k);
  588|       |
  589|    609|    _ijkAdd(&iVec, &jVec, ijk);
  590|    609|    _ijkAdd(ijk, &kVec, ijk);
  591|       |
  592|    609|    _ijkNormalize(ijk);
  593|    609|}
faceijk.c:_downAp7r:
  534|    499|static inline void _downAp7r(CoordIJK *ijk) {
  535|       |    // res r unit vectors in res r+1
  536|    499|    CoordIJK iVec = {3, 1, 0};
  537|    499|    CoordIJK jVec = {0, 3, 1};
  538|    499|    CoordIJK kVec = {1, 0, 3};
  539|       |
  540|    499|    _ijkScale(&iVec, ijk->i);
  541|    499|    _ijkScale(&jVec, ijk->j);
  542|    499|    _ijkScale(&kVec, ijk->k);
  543|       |
  544|    499|    _ijkAdd(&iVec, &jVec, ijk);
  545|    499|    _ijkAdd(ijk, &kVec, ijk);
  546|       |
  547|    499|    _ijkNormalize(ijk);
  548|    499|}
faceijk.c:_setIJK:
  103|    119|static inline void _setIJK(CoordIJK *ijk, int i, int j, int k) {
  104|    119|    ijk->i = i;
  105|    119|    ijk->j = j;
  106|    119|    ijk->k = k;
  107|    119|}
faceijk.c:_ijkSub:
  143|    119|                           CoordIJK *diff) {
  144|    119|    diff->i = h1->i - h2->i;
  145|    119|    diff->j = h1->j - h2->j;
  146|    119|    diff->k = h1->k - h2->k;
  147|    119|}
faceijk.c:_ijkRotate60cw:
  635|    119|static inline void _ijkRotate60cw(CoordIJK *ijk) {
  636|       |    // unit vector rotations
  637|    119|    CoordIJK iVec = {1, 0, 1};
  638|    119|    CoordIJK jVec = {1, 1, 0};
  639|    119|    CoordIJK kVec = {0, 1, 1};
  640|       |
  641|    119|    _ijkScale(&iVec, ijk->i);
  642|    119|    _ijkScale(&jVec, ijk->j);
  643|    119|    _ijkScale(&kVec, ijk->k);
  644|       |
  645|    119|    _ijkAdd(&iVec, &jVec, ijk);
  646|    119|    _ijkAdd(ijk, &kVec, ijk);
  647|       |
  648|    119|    _ijkNormalize(ijk);
  649|    119|}

h3NeighborRotations:
  458|    682|                            H3Index *out) {
  459|    682|    H3Index current = origin;
  460|       |
  461|    682|    if (dir < CENTER_DIGIT || dir >= INVALID_DIGIT) {
  ------------------
  |  Branch (461:9): [True: 0, False: 682]
  |  Branch (461:31): [True: 0, False: 682]
  ------------------
  462|      0|        return E_FAILED;
  463|      0|    }
  464|       |    // Ensure that rotations is modulo'd by 6 before any possible addition,
  465|       |    // to protect against signed integer overflow.
  466|    682|    *rotations = *rotations % 6;
  467|    682|    for (int i = 0; i < *rotations; i++) {
  ------------------
  |  Branch (467:21): [True: 0, False: 682]
  ------------------
  468|      0|        dir = _rotate60ccw(dir);
  469|      0|    }
  470|       |
  471|    682|    int newRotations = 0;
  472|    682|    int oldBaseCell = H3_GET_BASE_CELL(current);
  ------------------
  |  |  118|    682|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|    682|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|    682|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|    682|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  473|    682|    if (NEVER(oldBaseCell < 0) || oldBaseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |  119|  1.36k|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 682]
  |  |  |  Branch (119:19): [True: 0, False: 682]
  |  |  ------------------
  ------------------
                  if (NEVER(oldBaseCell < 0) || oldBaseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |   81|    682|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (473:9): [Folded, False: 0]
  |  Branch (473:9): [Folded, False: 0]
  |  Branch (473:35): [True: 0, False: 682]
  ------------------
  474|       |        // Base cells less than zero can not be represented in an index
  475|      0|        return E_CELL_INVALID;
  476|      0|    }
  477|    682|    Direction oldLeadingDigit = _h3LeadingNonZeroDigit(current);
  478|       |
  479|       |    // Adjust the indexing digits and, if needed, the base cell.
  480|    682|    int r = H3_GET_RESOLUTION(current) - 1;
  ------------------
  |  |  129|    682|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    682|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    682|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    682|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  481|  3.00k|    while (true) {
  ------------------
  |  Branch (481:12): [True: 3.00k, Folded]
  ------------------
  482|  3.00k|        if (r == -1) {
  ------------------
  |  Branch (482:13): [True: 196, False: 2.81k]
  ------------------
  483|    196|            H3_SET_BASE_CELL(current, baseCellNeighbors[oldBaseCell][dir]);
  ------------------
  |  |  124|    196|    (h3) = (((h3)&H3_BC_MASK_NEGATIVE) | (((uint64_t)(bc)) << H3_BC_OFFSET))
  |  |  ------------------
  |  |  |  |   65|    196|#define H3_BC_MASK_NEGATIVE (~H3_BC_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   62|    196|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|    196|#define H3_BC_OFFSET 45
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (h3) = (((h3)&H3_BC_MASK_NEGATIVE) | (((uint64_t)(bc)) << H3_BC_OFFSET))
  |  |  ------------------
  |  |  |  |   38|    196|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  484|    196|            newRotations = baseCellNeighbor60CCWRots[oldBaseCell][dir];
  485|       |
  486|    196|            if (H3_GET_BASE_CELL(current) == INVALID_BASE_CELL) {
  ------------------
  |  |  118|    196|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|    196|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|    196|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|    196|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
                          if (H3_GET_BASE_CELL(current) == INVALID_BASE_CELL) {
  ------------------
  |  |   38|    196|#define INVALID_BASE_CELL 127
  ------------------
  |  Branch (486:17): [True: 7, False: 189]
  ------------------
  487|       |                // Adjust for the deleted k vertex at the base cell level.
  488|       |                // This edge actually borders a different neighbor.
  489|      7|                H3_SET_BASE_CELL(current,
  ------------------
  |  |  124|      7|    (h3) = (((h3)&H3_BC_MASK_NEGATIVE) | (((uint64_t)(bc)) << H3_BC_OFFSET))
  |  |  ------------------
  |  |  |  |   65|      7|#define H3_BC_MASK_NEGATIVE (~H3_BC_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   62|      7|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|      7|#define H3_BC_OFFSET 45
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (h3) = (((h3)&H3_BC_MASK_NEGATIVE) | (((uint64_t)(bc)) << H3_BC_OFFSET))
  |  |  ------------------
  |  |  |  |   38|      7|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  490|      7|                                 baseCellNeighbors[oldBaseCell][IK_AXES_DIGIT]);
  491|      7|                newRotations =
  492|      7|                    baseCellNeighbor60CCWRots[oldBaseCell][IK_AXES_DIGIT];
  493|       |
  494|       |                // perform the adjustment for the k-subsequence we're skipping
  495|       |                // over.
  496|      7|                current = _h3Rotate60ccw(current);
  497|      7|                *rotations = *rotations + 1;
  498|      7|            }
  499|       |
  500|    196|            break;
  501|  2.81k|        } else {
  502|  2.81k|            Direction oldDigit = H3_GET_INDEX_DIGIT(current, r + 1);
  ------------------
  |  |  141|  2.81k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  2.81k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  2.81k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  2.81k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  2.81k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  503|  2.81k|            Direction nextDir;
  504|  2.81k|            if (oldDigit == INVALID_DIGIT) {
  ------------------
  |  Branch (504:17): [True: 0, False: 2.81k]
  ------------------
  505|       |                // Only possible on invalid input
  506|      0|                return E_CELL_INVALID;
  507|  2.81k|            } else if (isResolutionClassIII(r + 1)) {
  ------------------
  |  Branch (507:24): [True: 1.56k, False: 1.24k]
  ------------------
  508|  1.56k|                H3_SET_INDEX_DIGIT(current, r + 1, NEW_DIGIT_II[oldDigit][dir]);
  ------------------
  |  |  162|  1.56k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.56k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.56k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.56k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.56k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.56k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.56k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.56k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.56k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  509|  1.56k|                nextDir = NEW_ADJUSTMENT_II[oldDigit][dir];
  510|  1.56k|            } else {
  511|  1.24k|                H3_SET_INDEX_DIGIT(current, r + 1,
  ------------------
  |  |  162|  1.24k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.24k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.24k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.24k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.24k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.24k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.24k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.24k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.24k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  512|  1.24k|                                   NEW_DIGIT_III[oldDigit][dir]);
  513|  1.24k|                nextDir = NEW_ADJUSTMENT_III[oldDigit][dir];
  514|  1.24k|            }
  515|       |
  516|  2.81k|            if (nextDir != CENTER_DIGIT) {
  ------------------
  |  Branch (516:17): [True: 2.32k, False: 486]
  ------------------
  517|  2.32k|                dir = nextDir;
  518|  2.32k|                r--;
  519|  2.32k|            } else {
  520|       |                // No more adjustment to perform
  521|    486|                break;
  522|    486|            }
  523|  2.81k|        }
  524|  3.00k|    }
  525|       |
  526|    682|    int newBaseCell = H3_GET_BASE_CELL(current);
  ------------------
  |  |  118|    682|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|    682|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|    682|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|    682|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  527|    682|    if (_isBaseCellPentagon(newBaseCell)) {
  ------------------
  |  Branch (527:9): [True: 390, False: 292]
  ------------------
  528|    390|        int alreadyAdjustedKSubsequence = 0;
  529|       |
  530|       |        // force rotation out of missing k-axes sub-sequence
  531|    390|        if (_h3LeadingNonZeroDigit(current) == K_AXES_DIGIT) {
  ------------------
  |  Branch (531:13): [True: 61, False: 329]
  ------------------
  532|     61|            if (oldBaseCell != newBaseCell) {
  ------------------
  |  Branch (532:17): [True: 23, False: 38]
  ------------------
  533|       |                // in this case, we traversed into the deleted
  534|       |                // k subsequence of a pentagon base cell.
  535|       |                // We need to rotate out of that case depending
  536|       |                // on how we got here.
  537|       |                // check for a cw/ccw offset face; default is ccw
  538|       |
  539|     23|                if (ALWAYS(_baseCellIsCwOffset(
  ------------------
  |  |  118|     23|#define ALWAYS(X) ((X) ? 1 : (assert(0), 0))
  |  |  ------------------
  |  |  |  Branch (118:19): [True: 23, False: 0]
  |  |  |  Branch (118:20): [True: 23, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (539:21): [Folded, False: 0]
  |  Branch (539:21): [Folded, False: 0]
  ------------------
  540|     23|                        newBaseCell,
  541|     23|                        baseCellData[oldBaseCell].homeFijk.face))) {
  542|     23|                    current = _h3Rotate60cw(current);
  543|     23|                } else {
  544|       |                    // See cwOffsetPent in testGridDisk.c for why this is
  545|       |                    // unreachable.
  546|      0|                    current = _h3Rotate60ccw(current);
  547|      0|                }
  548|     23|                alreadyAdjustedKSubsequence = 1;
  549|     38|            } else {
  550|       |                // In this case, we traversed into the deleted
  551|       |                // k subsequence from within the same pentagon
  552|       |                // base cell.
  553|     38|                if (oldLeadingDigit == CENTER_DIGIT) {
  ------------------
  |  Branch (553:21): [True: 0, False: 38]
  ------------------
  554|       |                    // Undefined: the k direction is deleted from here
  555|      0|                    return E_PENTAGON;
  556|     38|                } else if (oldLeadingDigit == JK_AXES_DIGIT) {
  ------------------
  |  Branch (556:28): [True: 15, False: 23]
  ------------------
  557|       |                    // Rotate out of the deleted k subsequence
  558|       |                    // We also need an additional change to the direction we're
  559|       |                    // moving in
  560|     15|                    current = _h3Rotate60ccw(current);
  561|     15|                    *rotations = *rotations + 1;
  562|     23|                } else if (oldLeadingDigit == IK_AXES_DIGIT) {
  ------------------
  |  Branch (562:28): [True: 23, False: 0]
  ------------------
  563|       |                    // Rotate out of the deleted k subsequence
  564|       |                    // We also need an additional change to the direction we're
  565|       |                    // moving in
  566|     23|                    current = _h3Rotate60cw(current);
  567|     23|                    *rotations = *rotations + 5;
  568|     23|                } else {
  569|       |                    // Could occur on invalid inputs that were already within
  570|       |                    // the deleted k subsequence
  571|      0|                    return E_FAILED;
  572|      0|                }
  573|     38|            }
  574|     61|        }
  575|       |
  576|    523|        for (int i = 0; i < newRotations; i++)
  ------------------
  |  Branch (576:25): [True: 133, False: 390]
  ------------------
  577|    133|            current = _h3RotatePent60ccw(current);
  578|       |
  579|       |        // Account for differing orientation of the base cells (this edge
  580|       |        // might not follow properties of some other edges.)
  581|    390|        if (oldBaseCell != newBaseCell) {
  ------------------
  |  Branch (581:13): [True: 75, False: 315]
  ------------------
  582|     75|            if (_isBaseCellPolarPentagon(newBaseCell)) {
  ------------------
  |  Branch (582:17): [True: 29, False: 46]
  ------------------
  583|       |                // 'polar' base cells behave differently because they have all
  584|       |                // i neighbors.
  585|     29|                if (oldBaseCell != 118 && oldBaseCell != 8 &&
  ------------------
  |  Branch (585:21): [True: 24, False: 5]
  |  Branch (585:43): [True: 18, False: 6]
  ------------------
  586|     18|                    _h3LeadingNonZeroDigit(current) != JK_AXES_DIGIT) {
  ------------------
  |  Branch (586:21): [True: 13, False: 5]
  ------------------
  587|     13|                    *rotations = *rotations + 1;
  588|     13|                }
  589|     46|            } else if (_h3LeadingNonZeroDigit(current) == IK_AXES_DIGIT &&
  ------------------
  |  Branch (589:24): [True: 18, False: 28]
  ------------------
  590|     18|                       !alreadyAdjustedKSubsequence) {
  ------------------
  |  Branch (590:24): [True: 6, False: 12]
  ------------------
  591|       |                // account for distortion introduced to the 5 neighbor by the
  592|       |                // deleted k subsequence.
  593|      6|                *rotations = *rotations + 1;
  594|      6|            }
  595|     75|        }
  596|    390|    } else {
  597|    523|        for (int i = 0; i < newRotations; i++)
  ------------------
  |  Branch (597:25): [True: 231, False: 292]
  ------------------
  598|    231|            current = _h3Rotate60ccw(current);
  599|    292|    }
  600|       |
  601|    682|    *rotations = (*rotations + newRotations) % 6;
  602|    682|    *out = current;
  603|       |
  604|    682|    return E_SUCCESS;
  605|    682|}
directionForNeighbor:
  615|     30|Direction directionForNeighbor(H3Index origin, H3Index destination) {
  616|     30|    bool isPent = H3_EXPORT(isPentagon)(origin);
  ------------------
  |  |   36|     30|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|     30|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|     30|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  617|       |    // Checks each neighbor, in order, to determine which direction the
  618|       |    // destination neighbor is located. Skips CENTER_DIGIT since that
  619|       |    // would be the origin; skips deleted K direction for pentagons.
  620|     30|    for (Direction direction = isPent ? J_AXES_DIGIT : K_AXES_DIGIT;
  ------------------
  |  Branch (620:32): [True: 30, False: 0]
  ------------------
  621|    123|         direction < NUM_DIGITS; direction++) {
  ------------------
  |  Branch (621:10): [True: 123, False: 0]
  ------------------
  622|    123|        H3Index neighbor;
  623|    123|        int rotations = 0;
  624|    123|        H3Error neighborError =
  625|    123|            h3NeighborRotations(origin, direction, &rotations, &neighbor);
  626|    123|        if (!neighborError && neighbor == destination) {
  ------------------
  |  Branch (626:13): [True: 123, False: 0]
  |  Branch (626:31): [True: 30, False: 93]
  ------------------
  627|     30|            return direction;
  628|     30|        }
  629|    123|    }
  630|      0|    return INVALID_DIGIT;
  631|     30|}

_isBaseCellPentagon:
  824|  9.98k|int _isBaseCellPentagon(int baseCell) {
  825|  9.98k|    if (baseCell < 0 || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |   81|  9.98k|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (825:9): [True: 0, False: 9.98k]
  |  Branch (825:25): [True: 13, False: 9.97k]
  ------------------
  826|       |        // Base cells less than zero can not be represented in an index
  827|     13|        return false;
  828|     13|    }
  829|  9.97k|    return baseCellData[baseCell].isPentagon;
  830|  9.98k|}
_isBaseCellPolarPentagon:
  834|    370|bool _isBaseCellPolarPentagon(int baseCell) {
  835|    370|    return baseCell == 4 || baseCell == 117;
  ------------------
  |  Branch (835:12): [True: 60, False: 310]
  |  Branch (835:29): [True: 65, False: 245]
  ------------------
  836|    370|}
_baseCellToFaceIjk:
  866|    776|void _baseCellToFaceIjk(int baseCell, FaceIJK *h) {
  867|    776|    *h = baseCellData[baseCell].homeFijk;
  868|    776|}
_baseCellToCCWrot60:
  877|    776|int _baseCellToCCWrot60(int baseCell, int face) {
  878|    776|    if (face < 0 || face >= NUM_ICOSA_FACES) return INVALID_ROTATIONS;
  ------------------
  |  |   79|    776|#define NUM_ICOSA_FACES 20
  ------------------
                  if (face < 0 || face >= NUM_ICOSA_FACES) return INVALID_ROTATIONS;
  ------------------
  |  |   49|      0|#define INVALID_ROTATIONS -1
  ------------------
  |  Branch (878:9): [True: 0, False: 776]
  |  Branch (878:21): [True: 0, False: 776]
  ------------------
  879|  1.29k|    for (int i = 0; i < 3; i++) {
  ------------------
  |  Branch (879:21): [True: 1.29k, False: 0]
  ------------------
  880|  3.24k|        for (int j = 0; j < 3; j++) {
  ------------------
  |  Branch (880:25): [True: 2.72k, False: 519]
  ------------------
  881|  8.90k|            for (int k = 0; k < 3; k++) {
  ------------------
  |  Branch (881:29): [True: 6.95k, False: 1.95k]
  ------------------
  882|  6.95k|                if (faceIjkBaseCells[face][i][j][k].baseCell == baseCell) {
  ------------------
  |  Branch (882:21): [True: 776, False: 6.17k]
  ------------------
  883|    776|                    return faceIjkBaseCells[face][i][j][k].ccwRot60;
  884|    776|                }
  885|  6.95k|            }
  886|  2.72k|        }
  887|  1.29k|    }
  888|      0|    return INVALID_ROTATIONS;
  ------------------
  |  |   49|      0|#define INVALID_ROTATIONS -1
  ------------------
  889|    776|}
_baseCellIsCwOffset:
  893|     23|bool _baseCellIsCwOffset(int baseCell, int testFace) {
  894|     23|    return baseCellData[baseCell].cwOffsetPent[0] == testFace ||
  ------------------
  |  Branch (894:12): [True: 12, False: 11]
  ------------------
  895|     11|           baseCellData[baseCell].cwOffsetPent[1] == testFace;
  ------------------
  |  Branch (895:12): [True: 11, False: 0]
  ------------------
  896|     23|}

getDirectedEdgeOrigin:
  156|    357|H3Error H3_EXPORT(getDirectedEdgeOrigin)(H3Index edge, H3Index *out) {
  157|    357|    if (H3_GET_MODE(edge) != H3_DIRECTEDEDGE_MODE) {
  ------------------
  |  |  107|    357|#define H3_GET_MODE(h3) ((int)((((h3)&H3_MODE_MASK) >> H3_MODE_OFFSET)))
  |  |  ------------------
  |  |  |  |   56|    357|#define H3_MODE_MASK ((uint64_t)(15) << H3_MODE_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|    357|#define H3_MODE_OFFSET 59
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_MODE(h3) ((int)((((h3)&H3_MODE_MASK) >> H3_MODE_OFFSET)))
  |  |  ------------------
  |  |  |  |   35|    357|#define H3_MODE_OFFSET 59
  |  |  ------------------
  ------------------
                  if (H3_GET_MODE(edge) != H3_DIRECTEDEDGE_MODE) {
  ------------------
  |  |   91|    357|#define H3_DIRECTEDEDGE_MODE 2
  ------------------
  |  Branch (157:9): [True: 337, False: 20]
  ------------------
  158|    337|        return E_DIR_EDGE_INVALID;
  159|    337|    }
  160|     20|    H3Index origin = edge;
  161|     20|    H3_SET_MODE(origin, H3_CELL_MODE);
  ------------------
  |  |  113|     20|    (h3) = (((h3)&H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET))
  |  |  ------------------
  |  |  |  |   59|     20|#define H3_MODE_MASK_NEGATIVE (~H3_MODE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|     20|#define H3_MODE_MASK ((uint64_t)(15) << H3_MODE_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   35|     20|#define H3_MODE_OFFSET 59
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (h3) = (((h3)&H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET))
  |  |  ------------------
  |  |  |  |   35|     20|#define H3_MODE_OFFSET 59
  |  |  ------------------
  ------------------
  162|     20|    H3_SET_RESERVED_BITS(origin, 0);
  ------------------
  |  |  149|     20|    (h3) = (((h3)&H3_RESERVED_MASK_NEGATIVE) | \
  |  |  ------------------
  |  |  |  |   77|     20|#define H3_RESERVED_MASK_NEGATIVE (~H3_RESERVED_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   74|     20|#define H3_RESERVED_MASK ((uint64_t)(7) << H3_RESERVED_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|     20|#define H3_RESERVED_OFFSET 56
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|     20|            (((uint64_t)(v)) << H3_RESERVED_OFFSET))
  |  |  ------------------
  |  |  |  |   44|     20|#define H3_RESERVED_OFFSET 56
  |  |  ------------------
  ------------------
  163|     20|    *out = origin;
  164|     20|    return E_SUCCESS;
  165|    357|}
isValidDirectedEdge:
  189|    567|int H3_EXPORT(isValidDirectedEdge)(H3Index edge) {
  190|    567|    Direction neighborDirection = H3_GET_RESERVED_BITS(edge);
  ------------------
  |  |  156|    567|    ((int)((((h3)&H3_RESERVED_MASK) >> H3_RESERVED_OFFSET)))
  |  |  ------------------
  |  |  |  |   74|    567|#define H3_RESERVED_MASK ((uint64_t)(7) << H3_RESERVED_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    567|#define H3_RESERVED_OFFSET 56
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   ((int)((((h3)&H3_RESERVED_MASK) >> H3_RESERVED_OFFSET)))
  |  |  ------------------
  |  |  |  |   44|    567|#define H3_RESERVED_OFFSET 56
  |  |  ------------------
  ------------------
  191|    567|    if (neighborDirection <= CENTER_DIGIT || neighborDirection >= NUM_DIGITS) {
  ------------------
  |  Branch (191:9): [True: 182, False: 385]
  |  Branch (191:46): [True: 28, False: 357]
  ------------------
  192|    210|        return 0;
  193|    210|    }
  194|       |
  195|    357|    H3Index origin;
  196|       |    // Note: This call is also checking for H3_DIRECTEDEDGE_MODE
  197|    357|    H3Error originResult = H3_EXPORT(getDirectedEdgeOrigin)(edge, &origin);
  ------------------
  |  |   36|    357|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    357|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    357|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|    357|    if (originResult) {
  ------------------
  |  Branch (198:9): [True: 337, False: 20]
  ------------------
  199|    337|        return 0;
  200|    337|    }
  201|     20|    if (H3_EXPORT(isPentagon)(origin) && neighborDirection == K_AXES_DIGIT) {
  ------------------
  |  |   36|     20|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|     20|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|     20|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (201:9): [True: 6, False: 14]
  |  Branch (201:42): [True: 1, False: 5]
  ------------------
  202|      1|        return 0;
  203|      1|    }
  204|       |
  205|     19|    return H3_EXPORT(isValidCell)(origin);
  ------------------
  |  |   36|     19|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|     19|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|     19|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  206|     20|}

_faceIjkPentToVerts:
  642|     19|void _faceIjkPentToVerts(FaceIJK *fijk, int *res, FaceIJK *fijkVerts) {
  643|       |    // the vertexes of an origin-centered pentagon in a Class II resolution on a
  644|       |    // substrate grid with aperture sequence 33r. The aperture 3 gets us the
  645|       |    // vertices, and the 3r gets us back to Class II.
  646|       |    // vertices listed ccw from the i-axes
  647|     19|    CoordIJK vertsCII[NUM_PENT_VERTS] = {
  648|     19|        {2, 1, 0},  // 0
  649|     19|        {1, 2, 0},  // 1
  650|     19|        {0, 2, 1},  // 2
  651|     19|        {0, 1, 2},  // 3
  652|     19|        {1, 0, 2},  // 4
  653|     19|    };
  654|       |
  655|       |    // the vertexes of an origin-centered pentagon in a Class III resolution on
  656|       |    // a substrate grid with aperture sequence 33r7r. The aperture 3 gets us the
  657|       |    // vertices, and the 3r7r gets us to Class II. vertices listed ccw from the
  658|       |    // i-axes
  659|     19|    CoordIJK vertsCIII[NUM_PENT_VERTS] = {
  660|     19|        {5, 4, 0},  // 0
  661|     19|        {1, 5, 0},  // 1
  662|     19|        {0, 5, 4},  // 2
  663|     19|        {0, 1, 5},  // 3
  664|     19|        {4, 0, 5},  // 4
  665|     19|    };
  666|       |
  667|       |    // get the correct set of substrate vertices for this resolution
  668|     19|    CoordIJK *verts;
  669|     19|    if (isResolutionClassIII(*res))
  ------------------
  |  Branch (669:9): [True: 19, False: 0]
  ------------------
  670|     19|        verts = vertsCIII;
  671|      0|    else
  672|      0|        verts = vertsCII;
  673|       |
  674|       |    // adjust the center point to be in an aperture 33r substrate grid
  675|       |    // these should be composed for speed
  676|     19|    _downAp3(&fijk->coord);
  677|     19|    _downAp3r(&fijk->coord);
  678|       |
  679|       |    // if res is Class III we need to add a cw aperture 7 to get to
  680|       |    // icosahedral Class II
  681|     19|    if (isResolutionClassIII(*res)) {
  ------------------
  |  Branch (681:9): [True: 19, False: 0]
  ------------------
  682|     19|        _downAp7r(&fijk->coord);
  683|     19|        *res += 1;
  684|     19|    }
  685|       |
  686|       |    // The center point is now in the same substrate grid as the origin
  687|       |    // cell vertices. Add the center point substate coordinates
  688|       |    // to each vertex to translate the vertices to that cell.
  689|    114|    for (int v = 0; v < NUM_PENT_VERTS; v++) {
  ------------------
  |  |   85|    114|#define NUM_PENT_VERTS 5
  ------------------
  |  Branch (689:21): [True: 95, False: 19]
  ------------------
  690|     95|        fijkVerts[v].face = fijk->face;
  691|     95|        _ijkAdd(&fijk->coord, &verts[v], &fijkVerts[v].coord);
  692|     95|        _ijkNormalize(&fijkVerts[v].coord);
  693|     95|    }
  694|     19|}
_faceIjkToVerts:
  819|    590|void _faceIjkToVerts(FaceIJK *fijk, int *res, FaceIJK *fijkVerts) {
  820|       |    // the vertexes of an origin-centered cell in a Class II resolution on a
  821|       |    // substrate grid with aperture sequence 33r. The aperture 3 gets us the
  822|       |    // vertices, and the 3r gets us back to Class II.
  823|       |    // vertices listed ccw from the i-axes
  824|    590|    CoordIJK vertsCII[NUM_HEX_VERTS] = {
  825|    590|        {2, 1, 0},  // 0
  826|    590|        {1, 2, 0},  // 1
  827|    590|        {0, 2, 1},  // 2
  828|    590|        {0, 1, 2},  // 3
  829|    590|        {1, 0, 2},  // 4
  830|    590|        {2, 0, 1}   // 5
  831|    590|    };
  832|       |
  833|       |    // the vertexes of an origin-centered cell in a Class III resolution on a
  834|       |    // substrate grid with aperture sequence 33r7r. The aperture 3 gets us the
  835|       |    // vertices, and the 3r7r gets us to Class II.
  836|       |    // vertices listed ccw from the i-axes
  837|    590|    CoordIJK vertsCIII[NUM_HEX_VERTS] = {
  838|    590|        {5, 4, 0},  // 0
  839|    590|        {1, 5, 0},  // 1
  840|    590|        {0, 5, 4},  // 2
  841|    590|        {0, 1, 5},  // 3
  842|    590|        {4, 0, 5},  // 4
  843|    590|        {5, 0, 1}   // 5
  844|    590|    };
  845|       |
  846|       |    // get the correct set of substrate vertices for this resolution
  847|    590|    CoordIJK *verts;
  848|    590|    if (isResolutionClassIII(*res))
  ------------------
  |  Branch (848:9): [True: 480, False: 110]
  ------------------
  849|    480|        verts = vertsCIII;
  850|    110|    else
  851|    110|        verts = vertsCII;
  852|       |
  853|       |    // adjust the center point to be in an aperture 33r substrate grid
  854|       |    // these should be composed for speed
  855|    590|    _downAp3(&fijk->coord);
  856|    590|    _downAp3r(&fijk->coord);
  857|       |
  858|       |    // if res is Class III we need to add a cw aperture 7 to get to
  859|       |    // icosahedral Class II
  860|    590|    if (isResolutionClassIII(*res)) {
  ------------------
  |  Branch (860:9): [True: 480, False: 110]
  ------------------
  861|    480|        _downAp7r(&fijk->coord);
  862|    480|        *res += 1;
  863|    480|    }
  864|       |
  865|       |    // The center point is now in the same substrate grid as the origin
  866|       |    // cell vertices. Add the center point substate coordinates
  867|       |    // to each vertex to translate the vertices to that cell.
  868|  4.13k|    for (int v = 0; v < NUM_HEX_VERTS; v++) {
  ------------------
  |  |   83|  4.13k|#define NUM_HEX_VERTS 6
  ------------------
  |  Branch (868:21): [True: 3.54k, False: 590]
  ------------------
  869|  3.54k|        fijkVerts[v].face = fijk->face;
  870|  3.54k|        _ijkAdd(&fijk->coord, &verts[v], &fijkVerts[v].coord);
  871|  3.54k|        _ijkNormalize(&fijkVerts[v].coord);
  872|  3.54k|    }
  873|    590|}
_adjustOverageClassII:
  888|  5.95k|                              int substrate) {
  889|  5.95k|    Overage overage = NO_OVERAGE;
  890|       |
  891|  5.95k|    CoordIJK *ijk = &fijk->coord;
  892|       |
  893|       |    // get the maximum dimension value; scale if a substrate grid
  894|  5.95k|    int maxDim = maxDimByCIIres[res];
  895|  5.95k|    if (substrate) maxDim *= 3;
  ------------------
  |  Branch (895:9): [True: 3.74k, False: 2.21k]
  ------------------
  896|       |
  897|       |    // check for overage
  898|  5.95k|    if (substrate && ijk->i + ijk->j + ijk->k == maxDim)  // on edge
  ------------------
  |  Branch (898:9): [True: 3.74k, False: 2.21k]
  |  Branch (898:22): [True: 222, False: 3.52k]
  ------------------
  899|    222|        overage = FACE_EDGE;
  900|  5.73k|    else if (ijk->i + ijk->j + ijk->k > maxDim)  // overage
  ------------------
  |  Branch (900:14): [True: 1.30k, False: 4.43k]
  ------------------
  901|  1.30k|    {
  902|  1.30k|        overage = NEW_FACE;
  903|       |
  904|  1.30k|        const FaceOrientIJK *fijkOrient;
  905|  1.30k|        if (ijk->k > 0) {
  ------------------
  |  Branch (905:13): [True: 887, False: 414]
  ------------------
  906|    887|            if (ijk->j > 0)  // jk "quadrant"
  ------------------
  |  Branch (906:17): [True: 308, False: 579]
  ------------------
  907|    308|                fijkOrient = &faceNeighbors[fijk->face][JK];
  ------------------
  |  |   57|    308|#define JK 3
  ------------------
  908|    579|            else  // ik "quadrant"
  909|    579|            {
  910|    579|                fijkOrient = &faceNeighbors[fijk->face][KI];
  ------------------
  |  |   55|    579|#define KI 2
  ------------------
  911|       |
  912|       |                // adjust for the pentagonal missing sequence
  913|    579|                if (pentLeading4) {
  ------------------
  |  Branch (913:21): [True: 119, False: 460]
  ------------------
  914|       |                    // translate origin to center of pentagon
  915|    119|                    CoordIJK origin;
  916|    119|                    _setIJK(&origin, maxDim, 0, 0);
  917|    119|                    CoordIJK tmp;
  918|    119|                    _ijkSub(ijk, &origin, &tmp);
  919|       |                    // rotate to adjust for the missing sequence
  920|    119|                    _ijkRotate60cw(&tmp);
  921|       |                    // translate the origin back to the center of the triangle
  922|    119|                    _ijkAdd(&tmp, &origin, ijk);
  923|    119|                }
  924|    579|            }
  925|    887|        } else  // ij "quadrant"
  926|    414|            fijkOrient = &faceNeighbors[fijk->face][IJ];
  ------------------
  |  |   53|    414|#define IJ 1
  ------------------
  927|       |
  928|  1.30k|        fijk->face = fijkOrient->face;
  929|       |
  930|       |        // rotate and translate for adjacent face
  931|  5.20k|        for (int i = 0; i < fijkOrient->ccwRot60; i++) _ijkRotate60ccw(ijk);
  ------------------
  |  Branch (931:25): [True: 3.90k, False: 1.30k]
  ------------------
  932|       |
  933|  1.30k|        CoordIJK transVec = fijkOrient->translate;
  934|  1.30k|        int unitScale = unitScaleByCIIres[res];
  935|  1.30k|        if (substrate) unitScale *= 3;
  ------------------
  |  Branch (935:13): [True: 227, False: 1.07k]
  ------------------
  936|  1.30k|        _ijkScale(&transVec, unitScale);
  937|  1.30k|        _ijkAdd(ijk, &transVec, ijk);
  938|  1.30k|        _ijkNormalize(ijk);
  939|       |
  940|       |        // overage points on pentagon boundaries can end up on edges
  941|  1.30k|        if (substrate && ijk->i + ijk->j + ijk->k == maxDim)  // on edge
  ------------------
  |  Branch (941:13): [True: 227, False: 1.07k]
  |  Branch (941:26): [True: 2, False: 225]
  ------------------
  942|      2|            overage = FACE_EDGE;
  943|  1.30k|    }
  944|       |
  945|  5.95k|    return overage;
  946|  5.95k|}
_adjustPentVertOverage:
  956|     95|Overage _adjustPentVertOverage(FaceIJK *fijk, int res) {
  957|     95|    int pentLeading4 = 0;
  958|     95|    Overage overage;
  959|    209|    do {
  960|    209|        overage = _adjustOverageClassII(fijk, res, pentLeading4, 1);
  961|    209|    } while (overage == NEW_FACE);
  ------------------
  |  Branch (961:14): [True: 114, False: 95]
  ------------------
  962|     95|    return overage;
  963|     95|}

getResolution:
   87|    613|int H3_EXPORT(getResolution)(H3Index h) { return H3_GET_RESOLUTION(h); }
  ------------------
  |  |  129|    613|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    613|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    613|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    613|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
getBaseCellNumber:
   98|  1.38k|int H3_EXPORT(getBaseCellNumber)(H3Index h) { return H3_GET_BASE_CELL(h); }
  ------------------
  |  |  118|  1.38k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.38k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.38k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.38k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
getIndexDigit:
  116|    613|H3Error H3_EXPORT(getIndexDigit)(H3Index h, int res, int *out) {
  117|    613|    if (res < 1 || res > MAX_H3_RES) {
  ------------------
  |  |   76|    354|#define MAX_H3_RES 15
  ------------------
  |  Branch (117:9): [True: 259, False: 354]
  |  Branch (117:20): [True: 344, False: 10]
  ------------------
  118|    603|        return E_RES_DOMAIN;
  119|    603|    }
  120|     10|    *out = H3_GET_INDEX_DIGIT(h, res);
  ------------------
  |  |  141|     10|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|     10|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|     10|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|     10|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|     10|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  121|     10|    return E_SUCCESS;
  122|    613|}
isValidCell:
  343|  1.59k|int H3_EXPORT(isValidCell)(H3Index h) {
  344|       |    /*
  345|       |    Look for bit patterns that would disqualify an H3Index from
  346|       |    being valid. If identified, exit early.
  347|       |
  348|       |    For reference the H3 index bit layout:
  349|       |
  350|       |    |   Region   | # bits |
  351|       |    |------------|--------|
  352|       |    | High       |      1 |
  353|       |    | Mode       |      4 |
  354|       |    | Reserved   |      3 |
  355|       |    | Resolution |      4 |
  356|       |    | Base Cell  |      7 |
  357|       |    | Digit 1    |      3 |
  358|       |    | Digit 2    |      3 |
  359|       |    | ...        |    ... |
  360|       |    | Digit 15   |      3 |
  361|       |
  362|       |    Speed benefits come from using bit manipulation instead of loops,
  363|       |    whenever possible.
  364|       |    */
  365|  1.59k|    if (!_hasGoodTopBits(h)) return false;
  ------------------
  |  Branch (365:9): [True: 980, False: 611]
  ------------------
  366|       |
  367|       |    // No need to check resolution; any 4 bits give a valid resolution.
  368|    611|    const int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|    611|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    611|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    611|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    611|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  369|       |
  370|       |    // Get base cell number and check that it is valid.
  371|    611|    const int bc = H3_GET_BASE_CELL(h);
  ------------------
  |  |  118|    611|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|    611|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|    611|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|    611|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  372|    611|    if (bc >= NUM_BASE_CELLS) return false;
  ------------------
  |  |   81|    611|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (372:9): [True: 4, False: 607]
  ------------------
  373|       |
  374|    607|    if (_hasAny7UptoRes(h, res)) return false;
  ------------------
  |  Branch (374:9): [True: 69, False: 538]
  ------------------
  375|    538|    if (!_hasAll7AfterRes(h, res)) return false;
  ------------------
  |  Branch (375:9): [True: 118, False: 420]
  ------------------
  376|    420|    if (_hasDeletedSubsequence(h, bc)) return false;
  ------------------
  |  Branch (376:9): [True: 28, False: 392]
  ------------------
  377|       |
  378|       |    // If no disqualifications were identified, the index is a valid H3 cell.
  379|    392|    return true;
  380|    420|}
isValidIndex:
  388|    613|int H3_EXPORT(isValidIndex)(H3Index h) {
  389|    613|    return H3_EXPORT(isValidCell)(h) || H3_EXPORT(isValidDirectedEdge)(h) ||
  ------------------
  |  |   36|    613|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    613|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    613|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  return H3_EXPORT(isValidCell)(h) || H3_EXPORT(isValidDirectedEdge)(h) ||
  ------------------
  |  |   36|    567|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    613|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    613|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (389:12): [True: 46, False: 567]
  |  Branch (389:41): [True: 5, False: 562]
  ------------------
  390|    562|           H3_EXPORT(isValidVertex)(h);
  ------------------
  |  |   36|    562|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    613|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    613|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (390:12): [True: 75, False: 487]
  ------------------
  391|    613|}
makeDirectChild:
  483|     13|H3Index makeDirectChild(H3Index h, int cellNumber) {
  484|     13|    int childRes = H3_GET_RESOLUTION(h) + 1;
  ------------------
  |  |  129|     13|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|     13|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|     13|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|     13|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  485|     13|    H3Index childH = H3_SET_RESOLUTION(h, childRes);
  ------------------
  |  |  135|     13|    (h3) = (((h3)&H3_RES_MASK_NEGATIVE) | (((uint64_t)(res)) << H3_RES_OFFSET))
  |  |  ------------------
  |  |  |  |   71|     13|#define H3_RES_MASK_NEGATIVE (~H3_RES_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   68|     13|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|     13|#define H3_RES_OFFSET 52
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (h3) = (((h3)&H3_RES_MASK_NEGATIVE) | (((uint64_t)(res)) << H3_RES_OFFSET))
  |  |  ------------------
  |  |  |  |   41|     13|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  486|     13|    H3_SET_INDEX_DIGIT(childH, childRes, cellNumber);
  ------------------
  |  |  162|     13|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|     13|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|     13|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|     13|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|     13|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|     13|            (((uint64_t)(digit))                                            \
  |  |  165|     13|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|     13|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|     13|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  487|     13|    return childH;
  488|     13|}
isResClassIII:
  838|    613|int H3_EXPORT(isResClassIII)(H3Index h) { return H3_GET_RESOLUTION(h) % 2; }
  ------------------
  |  |  129|    613|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    613|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    613|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    613|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
isPentagon:
  845|  3.79k|int H3_EXPORT(isPentagon)(H3Index h) {
  846|  3.79k|    return _isBaseCellPentagon(H3_GET_BASE_CELL(h)) &&
  ------------------
  |  |  118|  3.79k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  3.79k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  3.79k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  3.79k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  |  Branch (846:12): [True: 1.87k, False: 1.92k]
  ------------------
  847|  1.87k|           !_h3LeadingNonZeroDigit(h);
  ------------------
  |  Branch (847:12): [True: 193, False: 1.68k]
  ------------------
  848|  3.79k|}
_h3LeadingNonZeroDigit:
  855|  5.24k|Direction _h3LeadingNonZeroDigit(H3Index h) {
  856|  16.0k|    for (int r = 1; r <= H3_GET_RESOLUTION(h); r++)
  ------------------
  |  |  129|  16.0k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  16.0k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  16.0k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  16.0k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (856:21): [True: 15.4k, False: 561]
  ------------------
  857|  15.4k|        if (H3_GET_INDEX_DIGIT(h, r)) return H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  15.4k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  15.4k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  15.4k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  |  Branch (141:5): [True: 4.68k, False: 10.7k]
  |  |  ------------------
  |  |  142|  15.4k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  15.4k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
                      if (H3_GET_INDEX_DIGIT(h, r)) return H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  4.68k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  4.68k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  4.68k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  4.68k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  4.68k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  858|       |
  859|       |    // if we're here it's all 0's
  860|    561|    return CENTER_DIGIT;
  861|  5.24k|}
_h3RotatePent60ccw:
  867|    133|H3Index _h3RotatePent60ccw(H3Index h) {
  868|       |    // rotate in place; skips any leading 1 digits (k-axis)
  869|       |
  870|    133|    int foundFirstNonZeroDigit = 0;
  871|  1.08k|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    133|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    133|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    133|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    133|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (871:49): [True: 947, False: 133]
  ------------------
  872|       |        // rotate this digit
  873|    947|        H3_SET_INDEX_DIGIT(h, r, _rotate60ccw(H3_GET_INDEX_DIGIT(h, r)));
  ------------------
  |  |  162|    947|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|    947|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|    947|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|    947|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|    947|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|    947|            (((uint64_t)(digit))                                            \
  |  |  165|    947|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|    947|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|    947|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  874|       |
  875|       |        // look for the first non-zero digit so we
  876|       |        // can adjust for deleted k-axes sequence
  877|       |        // if necessary
  878|    947|        if (!foundFirstNonZeroDigit && H3_GET_INDEX_DIGIT(h, r) != 0) {
  ------------------
  |  |  141|    112|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|    112|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|    112|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|    112|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|    112|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  |  Branch (878:13): [True: 112, False: 835]
  |  Branch (878:40): [True: 112, False: 0]
  ------------------
  879|    112|            foundFirstNonZeroDigit = 1;
  880|       |
  881|       |            // adjust for deleted k-axes sequence
  882|    112|            if (_h3LeadingNonZeroDigit(h) == K_AXES_DIGIT)
  ------------------
  |  Branch (882:17): [True: 39, False: 73]
  ------------------
  883|     39|                h = _h3Rotate60ccw(h);
  884|    112|        }
  885|    947|    }
  886|    133|    return h;
  887|    133|}
_h3Rotate60ccw:
  918|    292|H3Index _h3Rotate60ccw(H3Index h) {
  919|  1.98k|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    292|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    292|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    292|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    292|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (919:49): [True: 1.69k, False: 292]
  ------------------
  920|  1.69k|        Direction oldDigit = H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  1.69k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  1.69k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  1.69k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  1.69k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  1.69k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  921|  1.69k|        H3_SET_INDEX_DIGIT(h, r, _rotate60ccw(oldDigit));
  ------------------
  |  |  162|  1.69k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.69k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.69k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.69k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.69k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.69k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.69k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.69k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.69k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  922|  1.69k|    }
  923|       |
  924|    292|    return h;
  925|    292|}
_h3Rotate60cw:
  931|    187|H3Index _h3Rotate60cw(H3Index h) {
  932|  2.02k|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    187|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    187|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    187|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    187|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (932:49): [True: 1.83k, False: 187]
  ------------------
  933|  1.83k|        H3_SET_INDEX_DIGIT(h, r, _rotate60cw(H3_GET_INDEX_DIGIT(h, r)));
  ------------------
  |  |  162|  1.83k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.83k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.83k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.83k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.83k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.83k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.83k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.83k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.83k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  934|  1.83k|    }
  935|       |
  936|    187|    return h;
  937|    187|}
_h3ToFaceIjkWithInitializedFijk:
 1090|  1.38k|int _h3ToFaceIjkWithInitializedFijk(H3Index h, FaceIJK *fijk) {
 1091|  1.38k|    CoordIJK *ijk = &fijk->coord;
 1092|  1.38k|    int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|  1.38k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  1.38k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  1.38k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  1.38k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1093|       |
 1094|       |    // center base cell hierarchy is entirely on this face
 1095|  1.38k|    int possibleOverage = 1;
 1096|  1.38k|    if (!_isBaseCellPentagon(H3_GET_BASE_CELL(h)) &&
  ------------------
  |  |  118|  1.38k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.38k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.38k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.38k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  |  Branch (1096:9): [True: 713, False: 672]
  ------------------
 1097|    713|        (res == 0 ||
  ------------------
  |  Branch (1097:10): [True: 64, False: 649]
  ------------------
 1098|    649|         (fijk->coord.i == 0 && fijk->coord.j == 0 && fijk->coord.k == 0)))
  ------------------
  |  Branch (1098:11): [True: 384, False: 265]
  |  Branch (1098:33): [True: 137, False: 247]
  |  Branch (1098:55): [True: 44, False: 93]
  ------------------
 1099|    108|        possibleOverage = 0;
 1100|       |
 1101|  16.1k|    for (int r = 1; r <= res; r++) {
  ------------------
  |  Branch (1101:21): [True: 14.7k, False: 1.38k]
  ------------------
 1102|  14.7k|        if (isResolutionClassIII(r)) {
  ------------------
  |  Branch (1102:13): [True: 7.93k, False: 6.80k]
  ------------------
 1103|       |            // Class III == rotate ccw
 1104|  7.93k|            _downAp7(ijk);
 1105|  7.93k|        } else {
 1106|       |            // Class II == rotate cw
 1107|  6.80k|            _downAp7r(ijk);
 1108|  6.80k|        }
 1109|       |
 1110|  14.7k|        _neighbor(ijk, H3_GET_INDEX_DIGIT(h, r));
  ------------------
  |  |  141|  14.7k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  14.7k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  14.7k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  14.7k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  14.7k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
 1111|  14.7k|    }
 1112|       |
 1113|  1.38k|    return possibleOverage;
 1114|  1.38k|}
_h3ToFaceIjk:
 1121|  1.38k|H3Error _h3ToFaceIjk(H3Index h, FaceIJK *fijk) {
 1122|  1.38k|    int baseCell = H3_GET_BASE_CELL(h);
  ------------------
  |  |  118|  1.38k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.38k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.38k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.38k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
 1123|  1.38k|    if (NEVER(baseCell < 0) || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |  119|  2.77k|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 1.38k]
  |  |  |  Branch (119:19): [True: 0, False: 1.38k]
  |  |  ------------------
  ------------------
                  if (NEVER(baseCell < 0) || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |   81|  1.38k|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (1123:9): [Folded, False: 0]
  |  Branch (1123:9): [Folded, False: 0]
  |  Branch (1123:32): [True: 4, False: 1.38k]
  ------------------
 1124|       |        // Base cells less than zero can not be represented in an index
 1125|       |        // To prevent reading uninitialized memory, we zero the output.
 1126|      4|        fijk->face = 0;
 1127|      4|        fijk->coord.i = fijk->coord.j = fijk->coord.k = 0;
 1128|      4|        return E_CELL_INVALID;
 1129|      4|    }
 1130|       |    // adjust for the pentagonal missing sequence; all of sub-sequence 5 needs
 1131|       |    // to be adjusted (and some of sub-sequence 4 below)
 1132|  1.38k|    if (_isBaseCellPentagon(baseCell) && _h3LeadingNonZeroDigit(h) == 5)
  ------------------
  |  Branch (1132:9): [True: 672, False: 713]
  |  Branch (1132:42): [True: 141, False: 531]
  ------------------
 1133|    141|        h = _h3Rotate60cw(h);
 1134|       |
 1135|       |    // start with the "home" face and ijk+ coordinates for the base cell of c
 1136|  1.38k|    *fijk = baseCellData[baseCell].homeFijk;
 1137|  1.38k|    if (!_h3ToFaceIjkWithInitializedFijk(h, fijk))
  ------------------
  |  Branch (1137:9): [True: 108, False: 1.27k]
  ------------------
 1138|    108|        return E_SUCCESS;  // no overage is possible; h lies on this face
 1139|       |
 1140|       |    // if we're here we have the potential for an "overage"; i.e., it is
 1141|       |    // possible that c lies on an adjacent face
 1142|       |
 1143|  1.27k|    CoordIJK origIJK = fijk->coord;
 1144|       |
 1145|       |    // if we're in Class III, drop into the next finer Class II grid
 1146|  1.27k|    int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|  1.27k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  1.27k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  1.27k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  1.27k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1147|  1.27k|    if (isResolutionClassIII(res)) {
  ------------------
  |  Branch (1147:9): [True: 1.10k, False: 173]
  ------------------
 1148|       |        // Class III
 1149|  1.10k|        _downAp7r(&fijk->coord);
 1150|  1.10k|        res++;
 1151|  1.10k|    }
 1152|       |
 1153|       |    // adjust for overage if needed
 1154|       |    // a pentagon base cell with a leading 4 digit requires special handling
 1155|  1.27k|    int pentLeading4 =
 1156|  1.27k|        (_isBaseCellPentagon(baseCell) && _h3LeadingNonZeroDigit(h) == 4);
  ------------------
  |  Branch (1156:10): [True: 672, False: 605]
  |  Branch (1156:43): [True: 194, False: 478]
  ------------------
 1157|  1.27k|    if (_adjustOverageClassII(fijk, res, pentLeading4, 0) != NO_OVERAGE) {
  ------------------
  |  Branch (1157:9): [True: 682, False: 595]
  ------------------
 1158|       |        // if the base cell is a pentagon we have the potential for secondary
 1159|       |        // overages
 1160|    682|        if (_isBaseCellPentagon(baseCell)) {
  ------------------
  |  Branch (1160:13): [True: 546, False: 136]
  ------------------
 1161|    938|            while (_adjustOverageClassII(fijk, res, 0, 0) != NO_OVERAGE)
  ------------------
  |  Branch (1161:20): [True: 392, False: 546]
  ------------------
 1162|    392|                continue;
 1163|    546|        }
 1164|       |
 1165|    682|        if (res != H3_GET_RESOLUTION(h)) _upAp7r(&fijk->coord);
  ------------------
  |  |  129|    682|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    682|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    682|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    682|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (1165:13): [True: 598, False: 84]
  ------------------
 1166|    682|    } else if (res != H3_GET_RESOLUTION(h)) {
  ------------------
  |  |  129|    595|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    595|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    595|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    595|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (1166:16): [True: 506, False: 89]
  ------------------
 1167|    506|        fijk->coord = origIJK;
 1168|    506|    }
 1169|  1.27k|    return E_SUCCESS;
 1170|  1.38k|}
maxFaceCount:
 1233|  1.22k|H3Error H3_EXPORT(maxFaceCount)(H3Index h3, int *out) {
 1234|       |    // a pentagon always intersects 5 faces, a hexagon never intersects more
 1235|       |    // than 2 (but may only intersect 1)
 1236|  1.22k|    *out = H3_EXPORT(isPentagon)(h3) ? 5 : 2;
  ------------------
  |  |   36|  1.22k|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|  1.22k|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|  1.22k|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1236:12): [True: 38, False: 1.18k]
  ------------------
 1237|  1.22k|    return E_SUCCESS;
 1238|  1.22k|}
getIcosahedronFaces:
 1249|    626|H3Error H3_EXPORT(getIcosahedronFaces)(H3Index h3, int *out) {
 1250|    626|    int res = H3_GET_RESOLUTION(h3);
  ------------------
  |  |  129|    626|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    626|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    626|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    626|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1251|    626|    int isPent = H3_EXPORT(isPentagon)(h3);
  ------------------
  |  |   36|    626|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    626|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    626|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1252|       |
 1253|       |    // We can't use the vertex-based approach here for class II pentagons,
 1254|       |    // because all their vertices are on the icosahedron edges. Their
 1255|       |    // direct child pentagons cross the same faces, so use those instead.
 1256|    626|    if (isPent && !isResolutionClassIII(res)) {
  ------------------
  |  Branch (1256:9): [True: 32, False: 594]
  |  Branch (1256:19): [True: 13, False: 19]
  ------------------
 1257|       |        // Note that this would not work for res 15, but this is only run on
 1258|       |        // Class II pentagons, it should never be invoked for a res 15 index.
 1259|     13|        H3Index childPentagon = makeDirectChild(h3, 0);
 1260|     13|        return H3_EXPORT(getIcosahedronFaces)(childPentagon, out);
  ------------------
  |  |   36|     13|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|     13|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|     13|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1261|     13|    }
 1262|       |
 1263|       |    // convert to FaceIJK
 1264|    613|    FaceIJK fijk;
 1265|    613|    H3Error err = _h3ToFaceIjk(h3, &fijk);
 1266|    613|    if (err) {
  ------------------
  |  Branch (1266:9): [True: 4, False: 609]
  ------------------
 1267|      4|        return err;
 1268|      4|    }
 1269|       |
 1270|       |    // Get all vertices as FaceIJK addresses. For simplicity, always
 1271|       |    // initialize the array with 6 verts, ignoring the last one for pentagons
 1272|    609|    FaceIJK fijkVerts[NUM_HEX_VERTS];
 1273|    609|    int vertexCount;
 1274|       |
 1275|    609|    if (isPent) {
  ------------------
  |  Branch (1275:9): [True: 19, False: 590]
  ------------------
 1276|     19|        vertexCount = NUM_PENT_VERTS;
  ------------------
  |  |   85|     19|#define NUM_PENT_VERTS 5
  ------------------
 1277|     19|        _faceIjkPentToVerts(&fijk, &res, fijkVerts);
 1278|    590|    } else {
 1279|    590|        vertexCount = NUM_HEX_VERTS;
  ------------------
  |  |   83|    590|#define NUM_HEX_VERTS 6
  ------------------
 1280|    590|        _faceIjkToVerts(&fijk, &res, fijkVerts);
 1281|    590|    }
 1282|       |
 1283|       |    // We may not use all of the slots in the output array,
 1284|       |    // so fill with invalid values to indicate unused slots
 1285|    609|    int faceCount;
 1286|    609|    H3Error maxFaceCountError = H3_EXPORT(maxFaceCount)(h3, &faceCount);
  ------------------
  |  |   36|    609|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    609|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    609|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1287|    609|    if (NEVER(maxFaceCountError != E_SUCCESS)) {
  ------------------
  |  |  119|    609|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 609]
  |  |  |  Branch (119:19): [True: 0, False: 609]
  |  |  ------------------
  ------------------
  |  Branch (1287:9): [Folded, False: 0]
  |  Branch (1287:9): [Folded, False: 0]
  ------------------
 1288|      0|        return maxFaceCountError;
 1289|      0|    }
 1290|  1.88k|    for (int i = 0; i < faceCount; i++) {
  ------------------
  |  Branch (1290:21): [True: 1.27k, False: 609]
  ------------------
 1291|  1.27k|        out[i] = INVALID_FACE;
  ------------------
  |  |   60|  1.27k|#define INVALID_FACE -1
  ------------------
 1292|  1.27k|    }
 1293|       |
 1294|       |    // add each vertex face, using the output array as a hash set
 1295|  4.23k|    for (int i = 0; i < vertexCount; i++) {
  ------------------
  |  Branch (1295:21): [True: 3.62k, False: 605]
  ------------------
 1296|  3.62k|        FaceIJK *vert = &fijkVerts[i];
 1297|       |
 1298|       |        // Adjust overage, determining whether this vertex is
 1299|       |        // on another face
 1300|  3.62k|        if (isPent) {
  ------------------
  |  Branch (1300:13): [True: 95, False: 3.53k]
  ------------------
 1301|     95|            _adjustPentVertOverage(vert, res);
 1302|  3.53k|        } else {
 1303|  3.53k|            _adjustOverageClassII(vert, res, 0, 1);
 1304|  3.53k|        }
 1305|       |
 1306|       |        // Save the face to the output array
 1307|  3.62k|        int face = vert->face;
 1308|  3.62k|        int pos = 0;
 1309|       |        // Find the first empty output position, or the first position
 1310|       |        // matching the current face
 1311|  3.94k|        while (out[pos] != INVALID_FACE && out[pos] != face) {
  ------------------
  |  |   60|  7.89k|#define INVALID_FACE -1
  ------------------
  |  Branch (1311:16): [True: 3.20k, False: 743]
  |  Branch (1311:44): [True: 322, False: 2.88k]
  ------------------
 1312|    322|            pos++;
 1313|    322|            if (pos >= faceCount) {
  ------------------
  |  Branch (1313:17): [True: 4, False: 318]
  ------------------
 1314|       |                // Mismatch between the heuristic used in maxFaceCount and
 1315|       |                // calculation here - indicates an invalid index.
 1316|      4|                return E_FAILED;
 1317|      4|            }
 1318|    322|        }
 1319|  3.62k|        out[pos] = face;
 1320|  3.62k|    }
 1321|    605|    return E_SUCCESS;
 1322|    609|}
isResolutionClassIII:
 1359|  20.0k|int isResolutionClassIII(int res) { return res % 2; }
h3Index.c:_hasGoodTopBits:
  216|  1.59k|static inline bool _hasGoodTopBits(H3Index h) {
  217|  1.59k|    h >>= (64 - 8);
  218|  1.59k|    return h == 0b00001000;
  219|  1.59k|}
h3Index.c:_hasAny7UptoRes:
  264|    607|static inline bool _hasAny7UptoRes(H3Index h, int res) {
  265|    607|    const uint64_t MHI = 0b100100100100100100100100100100100100100100100;
  266|    607|    const uint64_t MLO = MHI >> 2;
  267|       |
  268|    607|    int shift = 3 * (15 - res);
  269|    607|    h >>= shift;
  270|    607|    h <<= shift;
  271|    607|    h = (h & MHI & (~h - MLO));
  272|       |
  273|    607|    return h != 0;
  274|    607|}
h3Index.c:_hasAll7AfterRes:
  280|    538|static inline bool _hasAll7AfterRes(H3Index h, int res) {
  281|       |    // NOTE: res check is needed because we can't shift by 64
  282|    538|    if (res < 15) {
  ------------------
  |  Branch (282:9): [True: 281, False: 257]
  ------------------
  283|    281|        int shift = 19 + 3 * res;
  284|       |
  285|    281|        h = ~h;
  286|    281|        h <<= shift;
  287|    281|        h >>= shift;
  288|       |
  289|    281|        return h == 0;
  290|    281|    }
  291|    257|    return true;
  292|    538|}
h3Index.c:_hasDeletedSubsequence:
  327|    420|static inline bool _hasDeletedSubsequence(H3Index h, int base_cell) {
  328|    420|    if (isBaseCellPentagonArr[base_cell]) {
  ------------------
  |  Branch (328:9): [True: 246, False: 174]
  ------------------
  329|    246|        h <<= 19;
  330|    246|        h >>= 19;
  331|       |
  332|    246|        if (h == 0) return false;  // all zeros: res 15 pentagon
  ------------------
  |  Branch (332:13): [True: 4, False: 242]
  ------------------
  333|    242|        return _firstOneIndex(h) % 3 == 0;
  334|    246|    }
  335|    174|    return false;
  336|    420|}
h3Index.c:_firstOneIndex:
  300|    242|static inline int _firstOneIndex(H3Index h) {
  301|    242|#if defined(__GNUC__) || defined(__clang__)
  302|    242|    return 63 - __builtin_clzll(h);
  303|       |#elif defined(_MSC_VER) && defined(_M_X64)  // doesn't work on win32
  304|       |    unsigned long index;
  305|       |    _BitScanReverse64(&index, h);
  306|       |    return (int)index;
  307|       |#else
  308|       |    // Portable fallback
  309|       |    int pos = 63 - 19;
  310|       |    H3Index m = 1;
  311|       |    while ((h & (m << pos)) == 0) pos--;
  312|       |    return pos;
  313|       |#endif
  314|    242|}

vertexNumForDirection:
  130|    217|int vertexNumForDirection(const H3Index origin, const Direction direction) {
  131|    217|    int isPent = H3_EXPORT(isPentagon)(origin);
  ------------------
  |  |   36|    217|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    217|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    217|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |    // Check for invalid directions
  133|    217|    if (direction == CENTER_DIGIT || direction >= INVALID_DIGIT ||
  ------------------
  |  Branch (133:9): [True: 0, False: 217]
  |  Branch (133:38): [True: 0, False: 217]
  ------------------
  134|    217|        (isPent && direction == K_AXES_DIGIT))
  ------------------
  |  Branch (134:10): [True: 30, False: 187]
  |  Branch (134:20): [True: 0, False: 30]
  ------------------
  135|      0|        return INVALID_VERTEX_NUM;
  ------------------
  |  |   36|      0|#define INVALID_VERTEX_NUM -1
  ------------------
  136|       |
  137|       |    // Determine the vertex rotations for this cell
  138|    217|    int rotations;
  139|    217|    H3Error err = vertexRotations(origin, &rotations);
  140|    217|    if (err) {
  ------------------
  |  Branch (140:9): [True: 0, False: 217]
  ------------------
  141|      0|        return INVALID_VERTEX_NUM;
  ------------------
  |  |   36|      0|#define INVALID_VERTEX_NUM -1
  ------------------
  142|      0|    }
  143|       |
  144|       |    // Find the appropriate vertex, rotating CCW if necessary
  145|    217|    if (isPent) {
  ------------------
  |  Branch (145:9): [True: 30, False: 187]
  ------------------
  146|     30|        return (directionToVertexNumPent[direction] + NUM_PENT_VERTS -
  ------------------
  |  |   85|     30|#define NUM_PENT_VERTS 5
  ------------------
  147|     30|                rotations) %
  148|     30|               NUM_PENT_VERTS;
  ------------------
  |  |   85|     30|#define NUM_PENT_VERTS 5
  ------------------
  149|    187|    } else {
  150|    187|        return (directionToVertexNumHex[direction] + NUM_HEX_VERTS -
  ------------------
  |  |   83|    187|#define NUM_HEX_VERTS 6
  ------------------
  151|    187|                rotations) %
  152|    187|               NUM_HEX_VERTS;
  ------------------
  |  |   83|    187|#define NUM_HEX_VERTS 6
  ------------------
  153|    187|    }
  154|    217|}
directionForVertexNum:
  173|    559|Direction directionForVertexNum(const H3Index origin, const int vertexNum) {
  174|    559|    int isPent = H3_EXPORT(isPentagon)(origin);
  ------------------
  |  |   36|    559|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    559|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    559|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  175|       |    // Check for invalid vertexes
  176|    559|    if (vertexNum < 0 ||
  ------------------
  |  Branch (176:9): [True: 0, False: 559]
  ------------------
  177|    559|        vertexNum > (isPent ? NUM_PENT_VERTS : NUM_HEX_VERTS) - 1)
  ------------------
  |  |   85|      4|#define NUM_PENT_VERTS 5
  ------------------
                      vertexNum > (isPent ? NUM_PENT_VERTS : NUM_HEX_VERTS) - 1)
  ------------------
  |  |   83|    555|#define NUM_HEX_VERTS 6
  ------------------
  |  Branch (177:9): [True: 0, False: 559]
  |  Branch (177:22): [True: 4, False: 555]
  ------------------
  178|      0|        return INVALID_DIGIT;
  179|       |
  180|       |    // Determine the vertex rotations for this cell
  181|    559|    int rotations;
  182|    559|    H3Error err = vertexRotations(origin, &rotations);
  183|    559|    if (err) {
  ------------------
  |  Branch (183:9): [True: 0, False: 559]
  ------------------
  184|      0|        return INVALID_DIGIT;
  185|      0|    }
  186|       |
  187|       |    // Find the appropriate direction, rotating CW if necessary
  188|    559|    return isPent ? vertexNumToDirectionPent[(vertexNum + rotations) %
  ------------------
  |  Branch (188:12): [True: 4, False: 555]
  ------------------
  189|      4|                                             NUM_PENT_VERTS]
  ------------------
  |  |   85|      4|#define NUM_PENT_VERTS 5
  ------------------
  190|    559|                  : vertexNumToDirectionHex[(vertexNum + rotations) %
  191|    555|                                            NUM_HEX_VERTS];
  ------------------
  |  |   83|    555|#define NUM_HEX_VERTS 6
  ------------------
  192|    559|}
cellToVertex:
  212|    295|H3Error H3_EXPORT(cellToVertex)(H3Index cell, int vertexNum, H3Index *out) {
  213|    295|    int cellIsPentagon = H3_EXPORT(isPentagon)(cell);
  ------------------
  |  |   36|    295|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    295|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    295|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  214|    295|    int cellNumVerts = cellIsPentagon ? NUM_PENT_VERTS : NUM_HEX_VERTS;
  ------------------
  |  |   85|      4|#define NUM_PENT_VERTS 5
  ------------------
                  int cellNumVerts = cellIsPentagon ? NUM_PENT_VERTS : NUM_HEX_VERTS;
  ------------------
  |  |   83|    291|#define NUM_HEX_VERTS 6
  ------------------
  |  Branch (214:24): [True: 4, False: 291]
  ------------------
  215|    295|    int res = H3_GET_RESOLUTION(cell);
  ------------------
  |  |  129|    295|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    295|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    295|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    295|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  216|       |
  217|       |    // Check for invalid vertexes
  218|    295|    if (vertexNum < 0 || vertexNum > cellNumVerts - 1) return E_DOMAIN;
  ------------------
  |  Branch (218:9): [True: 0, False: 295]
  |  Branch (218:26): [True: 3, False: 292]
  ------------------
  219|       |
  220|       |    // Default the owner and vertex number to the input cell
  221|    292|    H3Index owner = cell;
  222|    292|    int ownerVertexNum = vertexNum;
  223|       |
  224|       |    // Determine the owner, looking at the three cells that share the vertex.
  225|       |    // By convention, the owner is the cell with the lowest numerical index.
  226|       |
  227|       |    // If the cell is the center child of its parent, it will always have
  228|       |    // the lowest index of any neighbor, so we can skip determining the owner
  229|    292|    if (res == 0 || H3_GET_INDEX_DIGIT(cell, res) != CENTER_DIGIT) {
  ------------------
  |  |  141|    277|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|    277|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|    277|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|    277|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|    277|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  |  Branch (229:9): [True: 15, False: 277]
  |  Branch (229:21): [True: 274, False: 3]
  ------------------
  230|       |        // Get the left neighbor of the vertex, with its rotations
  231|    289|        Direction left = directionForVertexNum(cell, vertexNum);
  232|    289|        if (left == INVALID_DIGIT) return E_FAILED;
  ------------------
  |  Branch (232:13): [True: 0, False: 289]
  ------------------
  233|    289|        int lRotations = 0;
  234|    289|        H3Index leftNeighbor;
  235|    289|        H3Error leftNeighborError =
  236|    289|            h3NeighborRotations(cell, left, &lRotations, &leftNeighbor);
  237|    289|        if (leftNeighborError) return leftNeighborError;
  ------------------
  |  Branch (237:13): [True: 0, False: 289]
  ------------------
  238|       |        // Set to owner if lowest index
  239|    289|        if (leftNeighbor < owner) owner = leftNeighbor;
  ------------------
  |  Branch (239:13): [True: 167, False: 122]
  ------------------
  240|       |
  241|       |        // As above, skip the right neighbor if the left is known lowest
  242|    289|        if (res == 0 || H3_GET_INDEX_DIGIT(leftNeighbor, res) != CENTER_DIGIT) {
  ------------------
  |  |  141|    274|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|    274|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|    274|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|    274|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|    274|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  |  Branch (242:13): [True: 15, False: 274]
  |  Branch (242:25): [True: 255, False: 19]
  ------------------
  243|       |            // Get the right neighbor of the vertex, with its rotations
  244|       |            // Note that vertex - 1 is the right side, as vertex numbers are CCW
  245|    270|            Direction right = directionForVertexNum(
  246|    270|                cell, (vertexNum - 1 + cellNumVerts) % cellNumVerts);
  247|       |            // This case should be unreachable; invalid verts fail earlier
  248|    270|            if (NEVER(right == INVALID_DIGIT)) return E_FAILED;
  ------------------
  |  |  119|    270|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 270]
  |  |  |  Branch (119:19): [True: 0, False: 270]
  |  |  ------------------
  ------------------
  |  Branch (248:17): [Folded, False: 0]
  |  Branch (248:17): [Folded, False: 0]
  ------------------
  249|    270|            int rRotations = 0;
  250|    270|            H3Index rightNeighbor;
  251|    270|            H3Error rightNeighborError =
  252|    270|                h3NeighborRotations(cell, right, &rRotations, &rightNeighbor);
  253|    270|            if (rightNeighborError) return rightNeighborError;
  ------------------
  |  Branch (253:17): [True: 0, False: 270]
  ------------------
  254|       |            // Set to owner if lowest index
  255|    270|            if (rightNeighbor < owner) {
  ------------------
  |  Branch (255:17): [True: 115, False: 155]
  ------------------
  256|    115|                owner = rightNeighbor;
  257|    115|                Direction dir =
  258|    115|                    H3_EXPORT(isPentagon)(owner)
  ------------------
  |  |   36|    115|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    115|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    115|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (258:21): [True: 22, False: 93]
  ------------------
  259|    115|                        ? directionForNeighbor(owner, cell)
  260|    115|                        : DIRECTIONS[(revNeighborDirectionsHex[right] +
  261|     93|                                      rRotations) %
  262|     93|                                     NUM_HEX_VERTS];
  ------------------
  |  |   83|     93|#define NUM_HEX_VERTS 6
  ------------------
  263|    115|                ownerVertexNum = vertexNumForDirection(owner, dir);
  264|    115|            }
  265|    270|        }
  266|       |
  267|       |        // Determine the vertex number for the left neighbor
  268|    289|        if (owner == leftNeighbor) {
  ------------------
  |  Branch (268:13): [True: 102, False: 187]
  ------------------
  269|    102|            int ownerIsPentagon = H3_EXPORT(isPentagon)(owner);
  ------------------
  |  |   36|    102|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    102|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    102|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  270|    102|            Direction dir =
  271|    102|                ownerIsPentagon
  ------------------
  |  Branch (271:17): [True: 8, False: 94]
  ------------------
  272|    102|                    ? directionForNeighbor(owner, cell)
  273|    102|                    : DIRECTIONS[(revNeighborDirectionsHex[left] + lRotations) %
  274|     94|                                 NUM_HEX_VERTS];
  ------------------
  |  |   83|     94|#define NUM_HEX_VERTS 6
  ------------------
  275|       |
  276|       |            // For the left neighbor, we need the second vertex of the
  277|       |            // edge, which may involve looping around the vertex nums
  278|    102|            ownerVertexNum = vertexNumForDirection(owner, dir) + 1;
  279|    102|            if (ownerVertexNum == NUM_HEX_VERTS ||
  ------------------
  |  |   83|    204|#define NUM_HEX_VERTS 6
  ------------------
  |  Branch (279:17): [True: 7, False: 95]
  ------------------
  280|     95|                (ownerIsPentagon && ownerVertexNum == NUM_PENT_VERTS)) {
  ------------------
  |  |   85|      8|#define NUM_PENT_VERTS 5
  ------------------
  |  Branch (280:18): [True: 8, False: 87]
  |  Branch (280:37): [True: 2, False: 6]
  ------------------
  281|      9|                ownerVertexNum = 0;
  282|      9|            }
  283|    102|        }
  284|    289|    }
  285|       |
  286|       |    // Create the vertex index
  287|    292|    H3Index vertex = owner;
  288|    292|    H3_SET_MODE(vertex, H3_VERTEX_MODE);
  ------------------
  |  |  113|    292|    (h3) = (((h3)&H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET))
  |  |  ------------------
  |  |  |  |   59|    292|#define H3_MODE_MASK_NEGATIVE (~H3_MODE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|    292|#define H3_MODE_MASK ((uint64_t)(15) << H3_MODE_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   35|    292|#define H3_MODE_OFFSET 59
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (h3) = (((h3)&H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET))
  |  |  ------------------
  |  |  |  |   35|    292|#define H3_MODE_OFFSET 59
  |  |  ------------------
  ------------------
  289|    292|    H3_SET_RESERVED_BITS(vertex, ownerVertexNum);
  ------------------
  |  |  149|    292|    (h3) = (((h3)&H3_RESERVED_MASK_NEGATIVE) | \
  |  |  ------------------
  |  |  |  |   77|    292|#define H3_RESERVED_MASK_NEGATIVE (~H3_RESERVED_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   74|    292|#define H3_RESERVED_MASK ((uint64_t)(7) << H3_RESERVED_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|    292|#define H3_RESERVED_OFFSET 56
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|    292|            (((uint64_t)(v)) << H3_RESERVED_OFFSET))
  |  |  ------------------
  |  |  |  |   44|    292|#define H3_RESERVED_OFFSET 56
  |  |  ------------------
  ------------------
  290|    292|    *out = vertex;
  291|       |
  292|    292|    return E_SUCCESS;
  293|    292|}
isValidVertex:
  354|    562|int H3_EXPORT(isValidVertex)(H3Index vertex) {
  355|    562|    if (H3_GET_MODE(vertex) != H3_VERTEX_MODE) {
  ------------------
  |  |  107|    562|#define H3_GET_MODE(h3) ((int)((((h3)&H3_MODE_MASK) >> H3_MODE_OFFSET)))
  |  |  ------------------
  |  |  |  |   56|    562|#define H3_MODE_MASK ((uint64_t)(15) << H3_MODE_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|    562|#define H3_MODE_OFFSET 59
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_MODE(h3) ((int)((((h3)&H3_MODE_MASK) >> H3_MODE_OFFSET)))
  |  |  ------------------
  |  |  |  |   35|    562|#define H3_MODE_OFFSET 59
  |  |  ------------------
  ------------------
                  if (H3_GET_MODE(vertex) != H3_VERTEX_MODE) {
  ------------------
  |  |   93|    562|#define H3_VERTEX_MODE 4
  ------------------
  |  Branch (355:9): [True: 216, False: 346]
  ------------------
  356|    216|        return 0;
  357|    216|    }
  358|       |
  359|    346|    int vertexNum = H3_GET_RESERVED_BITS(vertex);
  ------------------
  |  |  156|    346|    ((int)((((h3)&H3_RESERVED_MASK) >> H3_RESERVED_OFFSET)))
  |  |  ------------------
  |  |  |  |   74|    346|#define H3_RESERVED_MASK ((uint64_t)(7) << H3_RESERVED_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    346|#define H3_RESERVED_OFFSET 56
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   ((int)((((h3)&H3_RESERVED_MASK) >> H3_RESERVED_OFFSET)))
  |  |  ------------------
  |  |  |  |   44|    346|#define H3_RESERVED_OFFSET 56
  |  |  ------------------
  ------------------
  360|    346|    H3Index owner = vertex;
  361|    346|    H3_SET_MODE(owner, H3_CELL_MODE);
  ------------------
  |  |  113|    346|    (h3) = (((h3)&H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET))
  |  |  ------------------
  |  |  |  |   59|    346|#define H3_MODE_MASK_NEGATIVE (~H3_MODE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|    346|#define H3_MODE_MASK ((uint64_t)(15) << H3_MODE_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   35|    346|#define H3_MODE_OFFSET 59
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (h3) = (((h3)&H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET))
  |  |  ------------------
  |  |  |  |   35|    346|#define H3_MODE_OFFSET 59
  |  |  ------------------
  ------------------
  362|    346|    H3_SET_RESERVED_BITS(owner, 0);
  ------------------
  |  |  149|    346|    (h3) = (((h3)&H3_RESERVED_MASK_NEGATIVE) | \
  |  |  ------------------
  |  |  |  |   77|    346|#define H3_RESERVED_MASK_NEGATIVE (~H3_RESERVED_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   74|    346|#define H3_RESERVED_MASK ((uint64_t)(7) << H3_RESERVED_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|    346|#define H3_RESERVED_OFFSET 56
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|    346|            (((uint64_t)(v)) << H3_RESERVED_OFFSET))
  |  |  ------------------
  |  |  |  |   44|    346|#define H3_RESERVED_OFFSET 56
  |  |  ------------------
  ------------------
  363|       |
  364|    346|    if (!H3_EXPORT(isValidCell)(owner)) {
  ------------------
  |  |   36|    346|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    346|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    346|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (364:9): [True: 51, False: 295]
  ------------------
  365|     51|        return 0;
  366|     51|    }
  367|       |
  368|       |    // The easiest way to ensure that the owner + vertex number is valid,
  369|       |    // and that the vertex is canonical, is to recreate and compare.
  370|    295|    H3Index canonical;
  371|    295|    if (H3_EXPORT(cellToVertex)(owner, vertexNum, &canonical)) {
  ------------------
  |  |   36|    295|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    295|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    295|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (371:9): [True: 3, False: 292]
  ------------------
  372|      3|        return 0;
  373|      3|    }
  374|       |
  375|    292|    return vertex == canonical ? 1 : 0;
  ------------------
  |  Branch (375:12): [True: 75, False: 217]
  ------------------
  376|    295|}
vertex.c:vertexRotations:
   53|    776|static H3Error vertexRotations(H3Index cell, int *out) {
   54|       |    // Get the face and other info for the origin
   55|    776|    FaceIJK fijk;
   56|    776|    H3Error err = _h3ToFaceIjk(cell, &fijk);
   57|    776|    if (err) {
  ------------------
  |  Branch (57:9): [True: 0, False: 776]
  ------------------
   58|      0|        return err;
   59|      0|    }
   60|    776|    int baseCell = H3_EXPORT(getBaseCellNumber)(cell);
  ------------------
  |  |   36|    776|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    776|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    776|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   61|    776|    int cellLeadingDigit = _h3LeadingNonZeroDigit(cell);
   62|       |
   63|       |    // get the base cell face
   64|    776|    FaceIJK baseFijk;
   65|    776|    _baseCellToFaceIjk(baseCell, &baseFijk);
   66|       |
   67|    776|    int ccwRot60 = _baseCellToCCWrot60(baseCell, fijk.face);
   68|       |
   69|    776|    if (_isBaseCellPentagon(baseCell)) {
  ------------------
  |  Branch (69:9): [True: 378, False: 398]
  ------------------
   70|       |        // Find the appropriate direction-to-face mapping
   71|    378|        PentagonDirectionFaces dirFaces;
   72|       |        // We never hit the end condition
   73|    378|        int p = 0;
   74|       |        // Don't use a for loop here, for coverage reasons.
   75|  2.67k|        while (ALWAYS(p < NUM_PENTAGONS)) {
  ------------------
  |  |  118|  2.67k|#define ALWAYS(X) ((X) ? 1 : (assert(0), 0))
  |  |  ------------------
  |  |  |  Branch (118:19): [True: 2.67k, False: 0]
  |  |  |  Branch (118:20): [True: 2.67k, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (75:16): [Folded, False: 0]
  |  Branch (75:16): [Folded, False: 0]
  ------------------
   76|  2.67k|            if (pentagonDirectionFaces[p].baseCell == baseCell) {
  ------------------
  |  Branch (76:17): [True: 378, False: 2.30k]
  ------------------
   77|    378|                dirFaces = pentagonDirectionFaces[p];
   78|    378|                break;
   79|    378|            }
   80|  2.30k|            p++;
   81|  2.30k|        }
   82|    378|        if (NEVER(p == NUM_PENTAGONS)) {
  ------------------
  |  |  119|    378|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 378]
  |  |  |  Branch (119:19): [True: 0, False: 378]
  |  |  ------------------
  ------------------
  |  Branch (82:13): [Folded, False: 0]
  |  Branch (82:13): [Folded, False: 0]
  ------------------
   83|      0|            return E_FAILED;
   84|      0|        }
   85|       |
   86|       |        // additional CCW rotation for polar neighbors or IK neighbors
   87|    378|        if (fijk.face != baseFijk.face &&
  ------------------
  |  Branch (87:13): [True: 295, False: 83]
  ------------------
   88|    295|            (_isBaseCellPolarPentagon(baseCell) ||
  ------------------
  |  Branch (88:14): [True: 96, False: 199]
  ------------------
   89|    199|             fijk.face ==
  ------------------
  |  Branch (89:14): [True: 89, False: 110]
  ------------------
   90|    199|                 dirFaces.faces[IK_AXES_DIGIT - DIRECTION_INDEX_OFFSET])) {
  ------------------
  |  |   32|    199|#define DIRECTION_INDEX_OFFSET 2
  ------------------
   91|    185|            ccwRot60 = (ccwRot60 + 1) % 6;
   92|    185|        }
   93|       |
   94|       |        // Check whether the cell crosses a deleted pentagon subsequence
   95|    378|        if (cellLeadingDigit == JK_AXES_DIGIT &&
  ------------------
  |  Branch (95:13): [True: 80, False: 298]
  ------------------
   96|     80|            fijk.face ==
  ------------------
  |  Branch (96:13): [True: 48, False: 32]
  ------------------
   97|     80|                dirFaces.faces[IK_AXES_DIGIT - DIRECTION_INDEX_OFFSET]) {
  ------------------
  |  |   32|     80|#define DIRECTION_INDEX_OFFSET 2
  ------------------
   98|       |            // Crosses from JK to IK: Rotate CW
   99|     48|            ccwRot60 = (ccwRot60 + 5) % 6;
  100|    330|        } else if (cellLeadingDigit == IK_AXES_DIGIT &&
  ------------------
  |  Branch (100:20): [True: 86, False: 244]
  ------------------
  101|     86|                   fijk.face ==
  ------------------
  |  Branch (101:20): [True: 14, False: 72]
  ------------------
  102|     86|                       dirFaces.faces[JK_AXES_DIGIT - DIRECTION_INDEX_OFFSET]) {
  ------------------
  |  |   32|     86|#define DIRECTION_INDEX_OFFSET 2
  ------------------
  103|       |            // Crosses from IK to JK: Rotate CCW
  104|     14|            ccwRot60 = (ccwRot60 + 1) % 6;
  105|     14|        }
  106|    378|    }
  107|    776|    *out = ccwRot60;
  108|    776|    return E_SUCCESS;
  109|    776|}

