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

h3Index.c:_rotate60ccw:
  656|  2.03k|static inline Direction _rotate60ccw(Direction digit) {
  657|  2.03k|    switch (digit) {
  658|    432|        case K_AXES_DIGIT:
  ------------------
  |  Branch (658:9): [True: 432, False: 1.60k]
  ------------------
  659|    432|            return IK_AXES_DIGIT;
  660|    317|        case IK_AXES_DIGIT:
  ------------------
  |  Branch (660:9): [True: 317, False: 1.71k]
  ------------------
  661|    317|            return I_AXES_DIGIT;
  662|    262|        case I_AXES_DIGIT:
  ------------------
  |  Branch (662:9): [True: 262, False: 1.77k]
  ------------------
  663|    262|            return IJ_AXES_DIGIT;
  664|    237|        case IJ_AXES_DIGIT:
  ------------------
  |  Branch (664:9): [True: 237, False: 1.79k]
  ------------------
  665|    237|            return J_AXES_DIGIT;
  666|    303|        case J_AXES_DIGIT:
  ------------------
  |  Branch (666:9): [True: 303, False: 1.72k]
  ------------------
  667|    303|            return JK_AXES_DIGIT;
  668|    421|        case JK_AXES_DIGIT:
  ------------------
  |  Branch (668:9): [True: 421, False: 1.61k]
  ------------------
  669|    421|            return K_AXES_DIGIT;
  670|     60|        default:
  ------------------
  |  Branch (670:9): [True: 60, False: 1.97k]
  ------------------
  671|     60|            return digit;
  672|  2.03k|    }
  673|  2.03k|}
h3Index.c:_rotate60cw:
  680|  1.54k|static inline Direction _rotate60cw(Direction digit) {
  681|  1.54k|    switch (digit) {
  682|    201|        case K_AXES_DIGIT:
  ------------------
  |  Branch (682:9): [True: 201, False: 1.34k]
  ------------------
  683|    201|            return JK_AXES_DIGIT;
  684|    159|        case JK_AXES_DIGIT:
  ------------------
  |  Branch (684:9): [True: 159, False: 1.38k]
  ------------------
  685|    159|            return J_AXES_DIGIT;
  686|    109|        case J_AXES_DIGIT:
  ------------------
  |  Branch (686:9): [True: 109, False: 1.43k]
  ------------------
  687|    109|            return IJ_AXES_DIGIT;
  688|    132|        case IJ_AXES_DIGIT:
  ------------------
  |  Branch (688:9): [True: 132, False: 1.41k]
  ------------------
  689|    132|            return I_AXES_DIGIT;
  690|    165|        case I_AXES_DIGIT:
  ------------------
  |  Branch (690:9): [True: 165, False: 1.37k]
  ------------------
  691|    165|            return IK_AXES_DIGIT;
  692|    287|        case IK_AXES_DIGIT:
  ------------------
  |  Branch (692:9): [True: 287, False: 1.25k]
  ------------------
  693|    287|            return K_AXES_DIGIT;
  694|    491|        default:
  ------------------
  |  Branch (694:9): [True: 491, False: 1.05k]
  ------------------
  695|    491|            return digit;
  696|  1.54k|    }
  697|  1.54k|}
h3Index.c:_downAp7:
  512|  7.75k|static inline void _downAp7(CoordIJK *ijk) {
  513|       |    // res r unit vectors in res r+1
  514|  7.75k|    CoordIJK iVec = {3, 0, 1};
  515|  7.75k|    CoordIJK jVec = {1, 3, 0};
  516|  7.75k|    CoordIJK kVec = {0, 1, 3};
  517|       |
  518|  7.75k|    _ijkScale(&iVec, ijk->i);
  519|  7.75k|    _ijkScale(&jVec, ijk->j);
  520|  7.75k|    _ijkScale(&kVec, ijk->k);
  521|       |
  522|  7.75k|    _ijkAdd(&iVec, &jVec, ijk);
  523|  7.75k|    _ijkAdd(ijk, &kVec, ijk);
  524|       |
  525|  7.75k|    _ijkNormalize(ijk);
  526|  7.75k|}
h3Index.c:_ijkScale:
  155|  46.4k|static inline void _ijkScale(CoordIJK *c, int factor) {
  156|  46.4k|    c->i *= factor;
  157|  46.4k|    c->j *= factor;
  158|  46.4k|    c->k *= factor;
  159|  46.4k|}
h3Index.c:_ijkAdd:
  129|  41.4k|                           CoordIJK *sum) {
  130|  41.4k|    sum->i = h1->i + h2->i;
  131|  41.4k|    sum->j = h1->j + h2->j;
  132|  41.4k|    sum->k = h1->k + h2->k;
  133|  41.4k|}
h3Index.c:_upAp7r:
  494|    515|static inline void _upAp7r(CoordIJK *ijk) {
  495|       |    // convert to CoordIJ
  496|    515|    int i = ijk->i - ijk->k;
  497|    515|    int j = ijk->j - ijk->k;
  498|       |
  499|    515|    ijk->i = (int)lround((2 * i + j) * M_ONESEVENTH);
  ------------------
  |  |   54|    515|#define M_ONESEVENTH 0.14285714285714285714285714285714285
  ------------------
  500|    515|    ijk->j = (int)lround((3 * j - i) * M_ONESEVENTH);
  ------------------
  |  |   54|    515|#define M_ONESEVENTH 0.14285714285714285714285714285714285
  ------------------
  501|    515|    ijk->k = 0;
  502|    515|    _ijkNormalize(ijk);
  503|    515|}
h3Index.c:_downAp7r:
  534|  7.71k|static inline void _downAp7r(CoordIJK *ijk) {
  535|       |    // res r unit vectors in res r+1
  536|  7.71k|    CoordIJK iVec = {3, 1, 0};
  537|  7.71k|    CoordIJK jVec = {0, 3, 1};
  538|  7.71k|    CoordIJK kVec = {1, 0, 3};
  539|       |
  540|  7.71k|    _ijkScale(&iVec, ijk->i);
  541|  7.71k|    _ijkScale(&jVec, ijk->j);
  542|  7.71k|    _ijkScale(&kVec, ijk->k);
  543|       |
  544|  7.71k|    _ijkAdd(&iVec, &jVec, ijk);
  545|  7.71k|    _ijkAdd(ijk, &kVec, ijk);
  546|       |
  547|  7.71k|    _ijkNormalize(ijk);
  548|  7.71k|}
h3Index.c:_ijkNormalize:
  207|  26.5k|static inline void _ijkNormalize(CoordIJK *c) {
  208|       |    // remove any negative values
  209|  26.5k|    if (c->i < 0) {
  ------------------
  |  Branch (209:9): [True: 172, False: 26.3k]
  ------------------
  210|    172|        c->j -= c->i;
  211|    172|        c->k -= c->i;
  212|    172|        c->i = 0;
  213|    172|    }
  214|       |
  215|  26.5k|    if (c->j < 0) {
  ------------------
  |  Branch (215:9): [True: 189, False: 26.3k]
  ------------------
  216|    189|        c->i -= c->j;
  217|    189|        c->k -= c->j;
  218|    189|        c->j = 0;
  219|    189|    }
  220|       |
  221|  26.5k|    if (c->k < 0) {
  ------------------
  |  Branch (221:9): [True: 0, False: 26.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|  26.5k|    int min = c->i;
  229|  26.5k|    if (c->j < min) min = c->j;
  ------------------
  |  Branch (229:9): [True: 19.8k, False: 6.72k]
  ------------------
  230|  26.5k|    if (c->k < min) min = c->k;
  ------------------
  |  Branch (230:9): [True: 7.38k, False: 19.1k]
  ------------------
  231|  26.5k|    if (min > 0) {
  ------------------
  |  Branch (231:9): [True: 17.2k, False: 9.26k]
  ------------------
  232|  17.2k|        c->i -= min;
  233|  17.2k|        c->j -= min;
  234|  17.2k|        c->k -= min;
  235|  17.2k|    }
  236|  26.5k|}
h3Index.c:_neighbor:
  602|  14.4k|static inline void _neighbor(CoordIJK *ijk, Direction digit) {
  603|  14.4k|    if (digit > CENTER_DIGIT && digit < NUM_DIGITS) {
  ------------------
  |  Branch (603:9): [True: 10.9k, False: 3.46k]
  |  Branch (603:33): [True: 10.5k, False: 411]
  ------------------
  604|  10.5k|        _ijkAdd(ijk, &UNIT_VECS[digit], ijk);
  605|  10.5k|        _ijkNormalize(ijk);
  606|  10.5k|    }
  607|  14.4k|}
faceijk.c:_ijkRotate60ccw:
  614|  3.76k|static inline void _ijkRotate60ccw(CoordIJK *ijk) {
  615|       |    // unit vector rotations
  616|  3.76k|    CoordIJK iVec = {1, 1, 0};
  617|  3.76k|    CoordIJK jVec = {0, 1, 1};
  618|  3.76k|    CoordIJK kVec = {1, 0, 1};
  619|       |
  620|  3.76k|    _ijkScale(&iVec, ijk->i);
  621|  3.76k|    _ijkScale(&jVec, ijk->j);
  622|  3.76k|    _ijkScale(&kVec, ijk->k);
  623|       |
  624|  3.76k|    _ijkAdd(&iVec, &jVec, ijk);
  625|  3.76k|    _ijkAdd(ijk, &kVec, ijk);
  626|       |
  627|  3.76k|    _ijkNormalize(ijk);
  628|  3.76k|}
faceijk.c:_ijkScale:
  155|  17.9k|static inline void _ijkScale(CoordIJK *c, int factor) {
  156|  17.9k|    c->i *= factor;
  157|  17.9k|    c->j *= factor;
  158|  17.9k|    c->k *= factor;
  159|  17.9k|}
faceijk.c:_ijkAdd:
  129|  16.0k|                           CoordIJK *sum) {
  130|  16.0k|    sum->i = h1->i + h2->i;
  131|  16.0k|    sum->j = h1->j + h2->j;
  132|  16.0k|    sum->k = h1->k + h2->k;
  133|  16.0k|}
faceijk.c:_ijkNormalize:
  207|  10.3k|static inline void _ijkNormalize(CoordIJK *c) {
  208|       |    // remove any negative values
  209|  10.3k|    if (c->i < 0) {
  ------------------
  |  Branch (209:9): [True: 0, False: 10.3k]
  ------------------
  210|      0|        c->j -= c->i;
  211|      0|        c->k -= c->i;
  212|      0|        c->i = 0;
  213|      0|    }
  214|       |
  215|  10.3k|    if (c->j < 0) {
  ------------------
  |  Branch (215:9): [True: 0, False: 10.3k]
  ------------------
  216|      0|        c->i -= c->j;
  217|      0|        c->k -= c->j;
  218|      0|        c->j = 0;
  219|      0|    }
  220|       |
  221|  10.3k|    if (c->k < 0) {
  ------------------
  |  Branch (221:9): [True: 0, False: 10.3k]
  ------------------
  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.3k|    int min = c->i;
  229|  10.3k|    if (c->j < min) min = c->j;
  ------------------
  |  Branch (229:9): [True: 5.13k, False: 5.25k]
  ------------------
  230|  10.3k|    if (c->k < min) min = c->k;
  ------------------
  |  Branch (230:9): [True: 3.81k, False: 6.57k]
  ------------------
  231|  10.3k|    if (min > 0) {
  ------------------
  |  Branch (231:9): [True: 8.92k, False: 1.46k]
  ------------------
  232|  8.92k|        c->i -= min;
  233|  8.92k|        c->j -= min;
  234|  8.92k|        c->k -= min;
  235|  8.92k|    }
  236|  10.3k|}
faceijk.c:_downAp3:
  557|    598|static inline void _downAp3(CoordIJK *ijk) {
  558|       |    // res r unit vectors in res r+1
  559|    598|    CoordIJK iVec = {2, 0, 1};
  560|    598|    CoordIJK jVec = {1, 2, 0};
  561|    598|    CoordIJK kVec = {0, 1, 2};
  562|       |
  563|    598|    _ijkScale(&iVec, ijk->i);
  564|    598|    _ijkScale(&jVec, ijk->j);
  565|    598|    _ijkScale(&kVec, ijk->k);
  566|       |
  567|    598|    _ijkAdd(&iVec, &jVec, ijk);
  568|    598|    _ijkAdd(ijk, &kVec, ijk);
  569|       |
  570|    598|    _ijkNormalize(ijk);
  571|    598|}
faceijk.c:_downAp3r:
  579|    598|static inline void _downAp3r(CoordIJK *ijk) {
  580|       |    // res r unit vectors in res r+1
  581|    598|    CoordIJK iVec = {2, 1, 0};
  582|    598|    CoordIJK jVec = {0, 2, 1};
  583|    598|    CoordIJK kVec = {1, 0, 2};
  584|       |
  585|    598|    _ijkScale(&iVec, ijk->i);
  586|    598|    _ijkScale(&jVec, ijk->j);
  587|    598|    _ijkScale(&kVec, ijk->k);
  588|       |
  589|    598|    _ijkAdd(&iVec, &jVec, ijk);
  590|    598|    _ijkAdd(ijk, &kVec, ijk);
  591|       |
  592|    598|    _ijkNormalize(ijk);
  593|    598|}
faceijk.c:_downAp7r:
  534|    482|static inline void _downAp7r(CoordIJK *ijk) {
  535|       |    // res r unit vectors in res r+1
  536|    482|    CoordIJK iVec = {3, 1, 0};
  537|    482|    CoordIJK jVec = {0, 3, 1};
  538|    482|    CoordIJK kVec = {1, 0, 3};
  539|       |
  540|    482|    _ijkScale(&iVec, ijk->i);
  541|    482|    _ijkScale(&jVec, ijk->j);
  542|    482|    _ijkScale(&kVec, ijk->k);
  543|       |
  544|    482|    _ijkAdd(&iVec, &jVec, ijk);
  545|    482|    _ijkAdd(ijk, &kVec, ijk);
  546|       |
  547|    482|    _ijkNormalize(ijk);
  548|    482|}
faceijk.c:_setIJK:
  103|    118|static inline void _setIJK(CoordIJK *ijk, int i, int j, int k) {
  104|    118|    ijk->i = i;
  105|    118|    ijk->j = j;
  106|    118|    ijk->k = k;
  107|    118|}
faceijk.c:_ijkSub:
  143|    118|                           CoordIJK *diff) {
  144|    118|    diff->i = h1->i - h2->i;
  145|    118|    diff->j = h1->j - h2->j;
  146|    118|    diff->k = h1->k - h2->k;
  147|    118|}
faceijk.c:_ijkRotate60cw:
  635|    118|static inline void _ijkRotate60cw(CoordIJK *ijk) {
  636|       |    // unit vector rotations
  637|    118|    CoordIJK iVec = {1, 0, 1};
  638|    118|    CoordIJK jVec = {1, 1, 0};
  639|    118|    CoordIJK kVec = {0, 1, 1};
  640|       |
  641|    118|    _ijkScale(&iVec, ijk->i);
  642|    118|    _ijkScale(&jVec, ijk->j);
  643|    118|    _ijkScale(&kVec, ijk->k);
  644|       |
  645|    118|    _ijkAdd(&iVec, &jVec, ijk);
  646|    118|    _ijkAdd(ijk, &kVec, ijk);
  647|       |
  648|    118|    _ijkNormalize(ijk);
  649|    118|}

h3NeighborRotations:
  458|    662|                            H3Index *out) {
  459|    662|    H3Index current = origin;
  460|       |
  461|    662|    if (dir < CENTER_DIGIT || dir >= INVALID_DIGIT) {
  ------------------
  |  Branch (461:9): [True: 0, False: 662]
  |  Branch (461:31): [True: 0, False: 662]
  ------------------
  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|    662|    *rotations = *rotations % 6;
  467|    662|    for (int i = 0; i < *rotations; i++) {
  ------------------
  |  Branch (467:21): [True: 0, False: 662]
  ------------------
  468|      0|        dir = _rotate60ccw(dir);
  469|      0|    }
  470|       |
  471|    662|    int newRotations = 0;
  472|    662|    int oldBaseCell = H3_GET_BASE_CELL(current);
  ------------------
  |  |  118|    662|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|    662|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|    662|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|    662|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  473|    662|    if (NEVER(oldBaseCell < 0) || oldBaseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |  119|  1.32k|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 662]
  |  |  |  Branch (119:19): [True: 0, False: 662]
  |  |  ------------------
  ------------------
                  if (NEVER(oldBaseCell < 0) || oldBaseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |   81|    662|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (473:9): [Folded, False: 0]
  |  Branch (473:9): [Folded, False: 0]
  |  Branch (473:35): [True: 0, False: 662]
  ------------------
  474|       |        // Base cells less than zero can not be represented in an index
  475|      0|        return E_CELL_INVALID;
  476|      0|    }
  477|    662|    Direction oldLeadingDigit = _h3LeadingNonZeroDigit(current);
  478|       |
  479|       |    // Adjust the indexing digits and, if needed, the base cell.
  480|    662|    int r = H3_GET_RESOLUTION(current) - 1;
  ------------------
  |  |  129|    662|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    662|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    662|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    662|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  481|  3.11k|    while (true) {
  ------------------
  |  Branch (481:12): [True: 3.11k, Folded]
  ------------------
  482|  3.11k|        if (r == -1) {
  ------------------
  |  Branch (482:13): [True: 173, False: 2.93k]
  ------------------
  483|    173|            H3_SET_BASE_CELL(current, baseCellNeighbors[oldBaseCell][dir]);
  ------------------
  |  |  124|    173|    (h3) = (((h3)&H3_BC_MASK_NEGATIVE) | (((uint64_t)(bc)) << H3_BC_OFFSET))
  |  |  ------------------
  |  |  |  |   65|    173|#define H3_BC_MASK_NEGATIVE (~H3_BC_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   62|    173|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|    173|#define H3_BC_OFFSET 45
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (h3) = (((h3)&H3_BC_MASK_NEGATIVE) | (((uint64_t)(bc)) << H3_BC_OFFSET))
  |  |  ------------------
  |  |  |  |   38|    173|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  484|    173|            newRotations = baseCellNeighbor60CCWRots[oldBaseCell][dir];
  485|       |
  486|    173|            if (H3_GET_BASE_CELL(current) == INVALID_BASE_CELL) {
  ------------------
  |  |  118|    173|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|    173|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|    173|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|    173|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
                          if (H3_GET_BASE_CELL(current) == INVALID_BASE_CELL) {
  ------------------
  |  |   38|    173|#define INVALID_BASE_CELL 127
  ------------------
  |  Branch (486:17): [True: 8, False: 165]
  ------------------
  487|       |                // Adjust for the deleted k vertex at the base cell level.
  488|       |                // This edge actually borders a different neighbor.
  489|      8|                H3_SET_BASE_CELL(current,
  ------------------
  |  |  124|      8|    (h3) = (((h3)&H3_BC_MASK_NEGATIVE) | (((uint64_t)(bc)) << H3_BC_OFFSET))
  |  |  ------------------
  |  |  |  |   65|      8|#define H3_BC_MASK_NEGATIVE (~H3_BC_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   62|      8|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   38|      8|#define H3_BC_OFFSET 45
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (h3) = (((h3)&H3_BC_MASK_NEGATIVE) | (((uint64_t)(bc)) << H3_BC_OFFSET))
  |  |  ------------------
  |  |  |  |   38|      8|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  490|      8|                                 baseCellNeighbors[oldBaseCell][IK_AXES_DIGIT]);
  491|      8|                newRotations =
  492|      8|                    baseCellNeighbor60CCWRots[oldBaseCell][IK_AXES_DIGIT];
  493|       |
  494|       |                // perform the adjustment for the k-subsequence we're skipping
  495|       |                // over.
  496|      8|                current = _h3Rotate60ccw(current);
  497|      8|                *rotations = *rotations + 1;
  498|      8|            }
  499|       |
  500|    173|            break;
  501|  2.93k|        } else {
  502|  2.93k|            Direction oldDigit = H3_GET_INDEX_DIGIT(current, r + 1);
  ------------------
  |  |  141|  2.93k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  2.93k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  2.93k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  2.93k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  2.93k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  503|  2.93k|            Direction nextDir;
  504|  2.93k|            if (oldDigit == INVALID_DIGIT) {
  ------------------
  |  Branch (504:17): [True: 0, False: 2.93k]
  ------------------
  505|       |                // Only possible on invalid input
  506|      0|                return E_CELL_INVALID;
  507|  2.93k|            } else if (isResolutionClassIII(r + 1)) {
  ------------------
  |  Branch (507:24): [True: 1.61k, False: 1.32k]
  ------------------
  508|  1.61k|                H3_SET_INDEX_DIGIT(current, r + 1, NEW_DIGIT_II[oldDigit][dir]);
  ------------------
  |  |  162|  1.61k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.61k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.61k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.61k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.61k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.61k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.61k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.61k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.61k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  509|  1.61k|                nextDir = NEW_ADJUSTMENT_II[oldDigit][dir];
  510|  1.61k|            } else {
  511|  1.32k|                H3_SET_INDEX_DIGIT(current, r + 1,
  ------------------
  |  |  162|  1.32k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.32k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.32k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.32k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.32k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.32k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.32k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.32k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.32k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  512|  1.32k|                                   NEW_DIGIT_III[oldDigit][dir]);
  513|  1.32k|                nextDir = NEW_ADJUSTMENT_III[oldDigit][dir];
  514|  1.32k|            }
  515|       |
  516|  2.93k|            if (nextDir != CENTER_DIGIT) {
  ------------------
  |  Branch (516:17): [True: 2.45k, False: 489]
  ------------------
  517|  2.45k|                dir = nextDir;
  518|  2.45k|                r--;
  519|  2.45k|            } else {
  520|       |                // No more adjustment to perform
  521|    489|                break;
  522|    489|            }
  523|  2.93k|        }
  524|  3.11k|    }
  525|       |
  526|    662|    int newBaseCell = H3_GET_BASE_CELL(current);
  ------------------
  |  |  118|    662|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|    662|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|    662|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|    662|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  527|    662|    if (_isBaseCellPentagon(newBaseCell)) {
  ------------------
  |  Branch (527:9): [True: 389, False: 273]
  ------------------
  528|    389|        int alreadyAdjustedKSubsequence = 0;
  529|       |
  530|       |        // force rotation out of missing k-axes sub-sequence
  531|    389|        if (_h3LeadingNonZeroDigit(current) == K_AXES_DIGIT) {
  ------------------
  |  Branch (531:13): [True: 53, False: 336]
  ------------------
  532|     53|            if (oldBaseCell != newBaseCell) {
  ------------------
  |  Branch (532:17): [True: 21, False: 32]
  ------------------
  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|     21|                if (ALWAYS(_baseCellIsCwOffset(
  ------------------
  |  |  118|     21|#define ALWAYS(X) ((X) ? 1 : (assert(0), 0))
  |  |  ------------------
  |  |  |  Branch (118:19): [True: 21, False: 0]
  |  |  |  Branch (118:20): [True: 21, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (539:21): [Folded, False: 0]
  |  Branch (539:21): [Folded, False: 0]
  ------------------
  540|     21|                        newBaseCell,
  541|     21|                        baseCellData[oldBaseCell].homeFijk.face))) {
  542|     21|                    current = _h3Rotate60cw(current);
  543|     21|                } else {
  544|       |                    // See cwOffsetPent in testGridDisk.c for why this is
  545|       |                    // unreachable.
  546|      0|                    current = _h3Rotate60ccw(current);
  547|      0|                }
  548|     21|                alreadyAdjustedKSubsequence = 1;
  549|     32|            } else {
  550|       |                // In this case, we traversed into the deleted
  551|       |                // k subsequence from within the same pentagon
  552|       |                // base cell.
  553|     32|                if (oldLeadingDigit == CENTER_DIGIT) {
  ------------------
  |  Branch (553:21): [True: 0, False: 32]
  ------------------
  554|       |                    // Undefined: the k direction is deleted from here
  555|      0|                    return E_PENTAGON;
  556|     32|                } else if (oldLeadingDigit == JK_AXES_DIGIT) {
  ------------------
  |  Branch (556:28): [True: 16, False: 16]
  ------------------
  557|       |                    // Rotate out of the deleted k subsequence
  558|       |                    // We also need an additional change to the direction we're
  559|       |                    // moving in
  560|     16|                    current = _h3Rotate60ccw(current);
  561|     16|                    *rotations = *rotations + 1;
  562|     16|                } else if (oldLeadingDigit == IK_AXES_DIGIT) {
  ------------------
  |  Branch (562:28): [True: 16, 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|     16|                    current = _h3Rotate60cw(current);
  567|     16|                    *rotations = *rotations + 5;
  568|     16|                } else {
  569|       |                    // Could occur on invalid inputs that were already within
  570|       |                    // the deleted k subsequence
  571|      0|                    return E_FAILED;
  572|      0|                }
  573|     32|            }
  574|     53|        }
  575|       |
  576|    520|        for (int i = 0; i < newRotations; i++)
  ------------------
  |  Branch (576:25): [True: 131, False: 389]
  ------------------
  577|    131|            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|    389|        if (oldBaseCell != newBaseCell) {
  ------------------
  |  Branch (581:13): [True: 82, False: 307]
  ------------------
  582|     82|            if (_isBaseCellPolarPentagon(newBaseCell)) {
  ------------------
  |  Branch (582:17): [True: 36, False: 46]
  ------------------
  583|       |                // 'polar' base cells behave differently because they have all
  584|       |                // i neighbors.
  585|     36|                if (oldBaseCell != 118 && oldBaseCell != 8 &&
  ------------------
  |  Branch (585:21): [True: 32, False: 4]
  |  Branch (585:43): [True: 24, False: 8]
  ------------------
  586|     24|                    _h3LeadingNonZeroDigit(current) != JK_AXES_DIGIT) {
  ------------------
  |  Branch (586:21): [True: 21, False: 3]
  ------------------
  587|     21|                    *rotations = *rotations + 1;
  588|     21|                }
  589|     46|            } else if (_h3LeadingNonZeroDigit(current) == IK_AXES_DIGIT &&
  ------------------
  |  Branch (589:24): [True: 20, False: 26]
  ------------------
  590|     20|                       !alreadyAdjustedKSubsequence) {
  ------------------
  |  Branch (590:24): [True: 8, False: 12]
  ------------------
  591|       |                // account for distortion introduced to the 5 neighbor by the
  592|       |                // deleted k subsequence.
  593|      8|                *rotations = *rotations + 1;
  594|      8|            }
  595|     82|        }
  596|    389|    } else {
  597|    426|        for (int i = 0; i < newRotations; i++)
  ------------------
  |  Branch (597:25): [True: 153, False: 273]
  ------------------
  598|    153|            current = _h3Rotate60ccw(current);
  599|    273|    }
  600|       |
  601|    662|    *rotations = (*rotations + newRotations) % 6;
  602|    662|    *out = current;
  603|       |
  604|    662|    return E_SUCCESS;
  605|    662|}
directionForNeighbor:
  615|     28|Direction directionForNeighbor(H3Index origin, H3Index destination) {
  616|     28|    bool isPent = H3_EXPORT(isPentagon)(origin);
  ------------------
  |  |   36|     28|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|     28|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|     28|#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|     28|    for (Direction direction = isPent ? J_AXES_DIGIT : K_AXES_DIGIT;
  ------------------
  |  Branch (620:32): [True: 28, False: 0]
  ------------------
  621|    115|         direction < NUM_DIGITS; direction++) {
  ------------------
  |  Branch (621:10): [True: 115, False: 0]
  ------------------
  622|    115|        H3Index neighbor;
  623|    115|        int rotations = 0;
  624|    115|        H3Error neighborError =
  625|    115|            h3NeighborRotations(origin, direction, &rotations, &neighbor);
  626|    115|        if (!neighborError && neighbor == destination) {
  ------------------
  |  Branch (626:13): [True: 115, False: 0]
  |  Branch (626:31): [True: 28, False: 87]
  ------------------
  627|     28|            return direction;
  628|     28|        }
  629|    115|    }
  630|      0|    return INVALID_DIGIT;
  631|     28|}

_isBaseCellPentagon:
  824|  9.67k|int _isBaseCellPentagon(int baseCell) {
  825|  9.67k|    if (baseCell < 0 || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |   81|  9.67k|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (825:9): [True: 0, False: 9.67k]
  |  Branch (825:25): [True: 10, False: 9.66k]
  ------------------
  826|       |        // Base cells less than zero can not be represented in an index
  827|     10|        return false;
  828|     10|    }
  829|  9.66k|    return baseCellData[baseCell].isPentagon;
  830|  9.67k|}
_isBaseCellPolarPentagon:
  834|    359|bool _isBaseCellPolarPentagon(int baseCell) {
  835|    359|    return baseCell == 4 || baseCell == 117;
  ------------------
  |  Branch (835:12): [True: 82, False: 277]
  |  Branch (835:29): [True: 76, False: 201]
  ------------------
  836|    359|}
_baseCellToFaceIjk:
  866|    749|void _baseCellToFaceIjk(int baseCell, FaceIJK *h) {
  867|    749|    *h = baseCellData[baseCell].homeFijk;
  868|    749|}
_baseCellToCCWrot60:
  877|    749|int _baseCellToCCWrot60(int baseCell, int face) {
  878|    749|    if (face < 0 || face >= NUM_ICOSA_FACES) return INVALID_ROTATIONS;
  ------------------
  |  |   79|    749|#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: 749]
  |  Branch (878:21): [True: 0, False: 749]
  ------------------
  879|  1.32k|    for (int i = 0; i < 3; i++) {
  ------------------
  |  Branch (879:21): [True: 1.32k, False: 0]
  ------------------
  880|  3.35k|        for (int j = 0; j < 3; j++) {
  ------------------
  |  Branch (880:25): [True: 2.78k, False: 577]
  ------------------
  881|  9.15k|            for (int k = 0; k < 3; k++) {
  ------------------
  |  Branch (881:29): [True: 7.12k, False: 2.03k]
  ------------------
  882|  7.12k|                if (faceIjkBaseCells[face][i][j][k].baseCell == baseCell) {
  ------------------
  |  Branch (882:21): [True: 749, False: 6.37k]
  ------------------
  883|    749|                    return faceIjkBaseCells[face][i][j][k].ccwRot60;
  884|    749|                }
  885|  7.12k|            }
  886|  2.78k|        }
  887|  1.32k|    }
  888|      0|    return INVALID_ROTATIONS;
  ------------------
  |  |   49|      0|#define INVALID_ROTATIONS -1
  ------------------
  889|    749|}
_baseCellIsCwOffset:
  893|     21|bool _baseCellIsCwOffset(int baseCell, int testFace) {
  894|     21|    return baseCellData[baseCell].cwOffsetPent[0] == testFace ||
  ------------------
  |  Branch (894:12): [True: 7, False: 14]
  ------------------
  895|     14|           baseCellData[baseCell].cwOffsetPent[1] == testFace;
  ------------------
  |  Branch (895:12): [True: 14, False: 0]
  ------------------
  896|     21|}

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

_faceIjkPentToVerts:
  642|     21|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|     21|    CoordIJK vertsCII[NUM_PENT_VERTS] = {
  648|     21|        {2, 1, 0},  // 0
  649|     21|        {1, 2, 0},  // 1
  650|     21|        {0, 2, 1},  // 2
  651|     21|        {0, 1, 2},  // 3
  652|     21|        {1, 0, 2},  // 4
  653|     21|    };
  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|     21|    CoordIJK vertsCIII[NUM_PENT_VERTS] = {
  660|     21|        {5, 4, 0},  // 0
  661|     21|        {1, 5, 0},  // 1
  662|     21|        {0, 5, 4},  // 2
  663|     21|        {0, 1, 5},  // 3
  664|     21|        {4, 0, 5},  // 4
  665|     21|    };
  666|       |
  667|       |    // get the correct set of substrate vertices for this resolution
  668|     21|    CoordIJK *verts;
  669|     21|    if (isResolutionClassIII(*res))
  ------------------
  |  Branch (669:9): [True: 21, False: 0]
  ------------------
  670|     21|        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|     21|    _downAp3(&fijk->coord);
  677|     21|    _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|     21|    if (isResolutionClassIII(*res)) {
  ------------------
  |  Branch (681:9): [True: 21, False: 0]
  ------------------
  682|     21|        _downAp7r(&fijk->coord);
  683|     21|        *res += 1;
  684|     21|    }
  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|    126|    for (int v = 0; v < NUM_PENT_VERTS; v++) {
  ------------------
  |  |   85|    126|#define NUM_PENT_VERTS 5
  ------------------
  |  Branch (689:21): [True: 105, False: 21]
  ------------------
  690|    105|        fijkVerts[v].face = fijk->face;
  691|    105|        _ijkAdd(&fijk->coord, &verts[v], &fijkVerts[v].coord);
  692|    105|        _ijkNormalize(&fijkVerts[v].coord);
  693|    105|    }
  694|     21|}
_faceIjkToVerts:
  819|    577|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|    577|    CoordIJK vertsCII[NUM_HEX_VERTS] = {
  825|    577|        {2, 1, 0},  // 0
  826|    577|        {1, 2, 0},  // 1
  827|    577|        {0, 2, 1},  // 2
  828|    577|        {0, 1, 2},  // 3
  829|    577|        {1, 0, 2},  // 4
  830|    577|        {2, 0, 1}   // 5
  831|    577|    };
  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|    577|    CoordIJK vertsCIII[NUM_HEX_VERTS] = {
  838|    577|        {5, 4, 0},  // 0
  839|    577|        {1, 5, 0},  // 1
  840|    577|        {0, 5, 4},  // 2
  841|    577|        {0, 1, 5},  // 3
  842|    577|        {4, 0, 5},  // 4
  843|    577|        {5, 0, 1}   // 5
  844|    577|    };
  845|       |
  846|       |    // get the correct set of substrate vertices for this resolution
  847|    577|    CoordIJK *verts;
  848|    577|    if (isResolutionClassIII(*res))
  ------------------
  |  Branch (848:9): [True: 461, False: 116]
  ------------------
  849|    461|        verts = vertsCIII;
  850|    116|    else
  851|    116|        verts = vertsCII;
  852|       |
  853|       |    // adjust the center point to be in an aperture 33r substrate grid
  854|       |    // these should be composed for speed
  855|    577|    _downAp3(&fijk->coord);
  856|    577|    _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|    577|    if (isResolutionClassIII(*res)) {
  ------------------
  |  Branch (860:9): [True: 461, False: 116]
  ------------------
  861|    461|        _downAp7r(&fijk->coord);
  862|    461|        *res += 1;
  863|    461|    }
  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.03k|    for (int v = 0; v < NUM_HEX_VERTS; v++) {
  ------------------
  |  |   83|  4.03k|#define NUM_HEX_VERTS 6
  ------------------
  |  Branch (868:21): [True: 3.46k, False: 577]
  ------------------
  869|  3.46k|        fijkVerts[v].face = fijk->face;
  870|  3.46k|        _ijkAdd(&fijk->coord, &verts[v], &fijkVerts[v].coord);
  871|  3.46k|        _ijkNormalize(&fijkVerts[v].coord);
  872|  3.46k|    }
  873|    577|}
_adjustOverageClassII:
  888|  5.83k|                              int substrate) {
  889|  5.83k|    Overage overage = NO_OVERAGE;
  890|       |
  891|  5.83k|    CoordIJK *ijk = &fijk->coord;
  892|       |
  893|       |    // get the maximum dimension value; scale if a substrate grid
  894|  5.83k|    int maxDim = maxDimByCIIres[res];
  895|  5.83k|    if (substrate) maxDim *= 3;
  ------------------
  |  Branch (895:9): [True: 3.68k, False: 2.14k]
  ------------------
  896|       |
  897|       |    // check for overage
  898|  5.83k|    if (substrate && ijk->i + ijk->j + ijk->k == maxDim)  // on edge
  ------------------
  |  Branch (898:9): [True: 3.68k, False: 2.14k]
  |  Branch (898:22): [True: 241, False: 3.44k]
  ------------------
  899|    241|        overage = FACE_EDGE;
  900|  5.59k|    else if (ijk->i + ijk->j + ijk->k > maxDim)  // overage
  ------------------
  |  Branch (900:14): [True: 1.25k, False: 4.33k]
  ------------------
  901|  1.25k|    {
  902|  1.25k|        overage = NEW_FACE;
  903|       |
  904|  1.25k|        const FaceOrientIJK *fijkOrient;
  905|  1.25k|        if (ijk->k > 0) {
  ------------------
  |  Branch (905:13): [True: 800, False: 453]
  ------------------
  906|    800|            if (ijk->j > 0)  // jk "quadrant"
  ------------------
  |  Branch (906:17): [True: 251, False: 549]
  ------------------
  907|    251|                fijkOrient = &faceNeighbors[fijk->face][JK];
  ------------------
  |  |   57|    251|#define JK 3
  ------------------
  908|    549|            else  // ik "quadrant"
  909|    549|            {
  910|    549|                fijkOrient = &faceNeighbors[fijk->face][KI];
  ------------------
  |  |   55|    549|#define KI 2
  ------------------
  911|       |
  912|       |                // adjust for the pentagonal missing sequence
  913|    549|                if (pentLeading4) {
  ------------------
  |  Branch (913:21): [True: 118, False: 431]
  ------------------
  914|       |                    // translate origin to center of pentagon
  915|    118|                    CoordIJK origin;
  916|    118|                    _setIJK(&origin, maxDim, 0, 0);
  917|    118|                    CoordIJK tmp;
  918|    118|                    _ijkSub(ijk, &origin, &tmp);
  919|       |                    // rotate to adjust for the missing sequence
  920|    118|                    _ijkRotate60cw(&tmp);
  921|       |                    // translate the origin back to the center of the triangle
  922|    118|                    _ijkAdd(&tmp, &origin, ijk);
  923|    118|                }
  924|    549|            }
  925|    800|        } else  // ij "quadrant"
  926|    453|            fijkOrient = &faceNeighbors[fijk->face][IJ];
  ------------------
  |  |   53|    453|#define IJ 1
  ------------------
  927|       |
  928|  1.25k|        fijk->face = fijkOrient->face;
  929|       |
  930|       |        // rotate and translate for adjacent face
  931|  5.01k|        for (int i = 0; i < fijkOrient->ccwRot60; i++) _ijkRotate60ccw(ijk);
  ------------------
  |  Branch (931:25): [True: 3.76k, False: 1.25k]
  ------------------
  932|       |
  933|  1.25k|        CoordIJK transVec = fijkOrient->translate;
  934|  1.25k|        int unitScale = unitScaleByCIIres[res];
  935|  1.25k|        if (substrate) unitScale *= 3;
  ------------------
  |  Branch (935:13): [True: 245, False: 1.00k]
  ------------------
  936|  1.25k|        _ijkScale(&transVec, unitScale);
  937|  1.25k|        _ijkAdd(ijk, &transVec, ijk);
  938|  1.25k|        _ijkNormalize(ijk);
  939|       |
  940|       |        // overage points on pentagon boundaries can end up on edges
  941|  1.25k|        if (substrate && ijk->i + ijk->j + ijk->k == maxDim)  // on edge
  ------------------
  |  Branch (941:13): [True: 245, False: 1.00k]
  |  Branch (941:26): [True: 2, False: 243]
  ------------------
  942|      2|            overage = FACE_EDGE;
  943|  1.25k|    }
  944|       |
  945|  5.83k|    return overage;
  946|  5.83k|}
_adjustPentVertOverage:
  956|    105|Overage _adjustPentVertOverage(FaceIJK *fijk, int res) {
  957|    105|    int pentLeading4 = 0;
  958|    105|    Overage overage;
  959|    231|    do {
  960|    231|        overage = _adjustOverageClassII(fijk, res, pentLeading4, 1);
  961|    231|    } while (overage == NEW_FACE);
  ------------------
  |  Branch (961:14): [True: 126, False: 105]
  ------------------
  962|    105|    return overage;
  963|    105|}

getResolution:
   87|    601|int H3_EXPORT(getResolution)(H3Index h) { return H3_GET_RESOLUTION(h); }
  ------------------
  |  |  129|    601|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    601|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    601|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    601|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
getBaseCellNumber:
   98|  1.35k|int H3_EXPORT(getBaseCellNumber)(H3Index h) { return H3_GET_BASE_CELL(h); }
  ------------------
  |  |  118|  1.35k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.35k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.35k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.35k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
getIndexDigit:
  116|    601|H3Error H3_EXPORT(getIndexDigit)(H3Index h, int res, int *out) {
  117|    601|    if (res < 1 || res > MAX_H3_RES) {
  ------------------
  |  |   76|    328|#define MAX_H3_RES 15
  ------------------
  |  Branch (117:9): [True: 273, False: 328]
  |  Branch (117:20): [True: 318, False: 10]
  ------------------
  118|    591|        return E_RES_DOMAIN;
  119|    591|    }
  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|    601|}
isValidCell:
  343|  1.55k|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.55k|    if (!_hasGoodTopBits(h)) return false;
  ------------------
  |  Branch (365:9): [True: 988, False: 570]
  ------------------
  366|       |
  367|       |    // No need to check resolution; any 4 bits give a valid resolution.
  368|    570|    const int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|    570|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    570|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    570|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    570|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  369|       |
  370|       |    // Get base cell number and check that it is valid.
  371|    570|    const int bc = H3_GET_BASE_CELL(h);
  ------------------
  |  |  118|    570|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|    570|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|    570|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|    570|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  372|    570|    if (bc >= NUM_BASE_CELLS) return false;
  ------------------
  |  |   81|    570|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (372:9): [True: 4, False: 566]
  ------------------
  373|       |
  374|    566|    if (_hasAny7UptoRes(h, res)) return false;
  ------------------
  |  Branch (374:9): [True: 75, False: 491]
  ------------------
  375|    491|    if (!_hasAll7AfterRes(h, res)) return false;
  ------------------
  |  Branch (375:9): [True: 111, False: 380]
  ------------------
  376|    380|    if (_hasDeletedSubsequence(h, bc)) return false;
  ------------------
  |  Branch (376:9): [True: 25, False: 355]
  ------------------
  377|       |
  378|       |    // If no disqualifications were identified, the index is a valid H3 cell.
  379|    355|    return true;
  380|    380|}
isValidIndex:
  388|    601|int H3_EXPORT(isValidIndex)(H3Index h) {
  389|    601|    return H3_EXPORT(isValidCell)(h) || H3_EXPORT(isValidDirectedEdge)(h) ||
  ------------------
  |  |   36|    601|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    601|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    601|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  return H3_EXPORT(isValidCell)(h) || H3_EXPORT(isValidDirectedEdge)(h) ||
  ------------------
  |  |   36|    571|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    601|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    601|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (389:12): [True: 30, False: 571]
  |  Branch (389:41): [True: 3, False: 568]
  ------------------
  390|    568|           H3_EXPORT(isValidVertex)(h);
  ------------------
  |  |   36|    568|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    601|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    601|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (390:12): [True: 85, False: 483]
  ------------------
  391|    601|}
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|    601|int H3_EXPORT(isResClassIII)(H3Index h) { return H3_GET_RESOLUTION(h) % 2; }
  ------------------
  |  |  129|    601|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    601|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    601|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    601|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
isPentagon:
  845|  3.70k|int H3_EXPORT(isPentagon)(H3Index h) {
  846|  3.70k|    return _isBaseCellPentagon(H3_GET_BASE_CELL(h)) &&
  ------------------
  |  |  118|  3.70k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  3.70k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  3.70k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  3.70k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  |  Branch (846:12): [True: 1.74k, False: 1.95k]
  ------------------
  847|  1.74k|           !_h3LeadingNonZeroDigit(h);
  ------------------
  |  Branch (847:12): [True: 196, False: 1.55k]
  ------------------
  848|  3.70k|}
_h3LeadingNonZeroDigit:
  855|  4.99k|Direction _h3LeadingNonZeroDigit(H3Index h) {
  856|  17.3k|    for (int r = 1; r <= H3_GET_RESOLUTION(h); r++)
  ------------------
  |  |  129|  17.3k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  17.3k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  17.3k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  17.3k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (856:21): [True: 16.8k, False: 522]
  ------------------
  857|  16.8k|        if (H3_GET_INDEX_DIGIT(h, r)) return H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  16.8k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  16.8k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  16.8k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  |  Branch (141:5): [True: 4.47k, False: 12.3k]
  |  |  ------------------
  |  |  142|  16.8k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  16.8k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
                      if (H3_GET_INDEX_DIGIT(h, r)) return H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  4.47k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  4.47k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  4.47k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  4.47k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  4.47k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  858|       |
  859|       |    // if we're here it's all 0's
  860|    522|    return CENTER_DIGIT;
  861|  4.99k|}
_h3RotatePent60ccw:
  867|    131|H3Index _h3RotatePent60ccw(H3Index h) {
  868|       |    // rotate in place; skips any leading 1 digits (k-axis)
  869|       |
  870|    131|    int foundFirstNonZeroDigit = 0;
  871|    959|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    131|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    131|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    131|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    131|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (871:49): [True: 828, False: 131]
  ------------------
  872|       |        // rotate this digit
  873|    828|        H3_SET_INDEX_DIGIT(h, r, _rotate60ccw(H3_GET_INDEX_DIGIT(h, r)));
  ------------------
  |  |  162|    828|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|    828|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|    828|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|    828|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|    828|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|    828|            (((uint64_t)(digit))                                            \
  |  |  165|    828|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|    828|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|    828|#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|    828|        if (!foundFirstNonZeroDigit && H3_GET_INDEX_DIGIT(h, r) != 0) {
  ------------------
  |  |  141|    115|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|    115|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|    115|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|    115|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|    115|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  |  Branch (878:13): [True: 115, False: 713]
  |  Branch (878:40): [True: 115, False: 0]
  ------------------
  879|    115|            foundFirstNonZeroDigit = 1;
  880|       |
  881|       |            // adjust for deleted k-axes sequence
  882|    115|            if (_h3LeadingNonZeroDigit(h) == K_AXES_DIGIT)
  ------------------
  |  Branch (882:17): [True: 47, False: 68]
  ------------------
  883|     47|                h = _h3Rotate60ccw(h);
  884|    115|        }
  885|    828|    }
  886|    131|    return h;
  887|    131|}
_h3Rotate60ccw:
  918|    224|H3Index _h3Rotate60ccw(H3Index h) {
  919|  1.42k|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    224|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    224|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    224|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    224|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (919:49): [True: 1.20k, False: 224]
  ------------------
  920|  1.20k|        Direction oldDigit = H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  1.20k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  1.20k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  1.20k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  1.20k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  1.20k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  921|  1.20k|        H3_SET_INDEX_DIGIT(h, r, _rotate60ccw(oldDigit));
  ------------------
  |  |  162|  1.20k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.20k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.20k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.20k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.20k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.20k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.20k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.20k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.20k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  922|  1.20k|    }
  923|       |
  924|    224|    return h;
  925|    224|}
_h3Rotate60cw:
  931|    158|H3Index _h3Rotate60cw(H3Index h) {
  932|  1.70k|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    158|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    158|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    158|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    158|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (932:49): [True: 1.54k, False: 158]
  ------------------
  933|  1.54k|        H3_SET_INDEX_DIGIT(h, r, _rotate60cw(H3_GET_INDEX_DIGIT(h, r)));
  ------------------
  |  |  162|  1.54k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.54k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.54k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.54k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.54k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.54k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.54k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.54k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.54k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  934|  1.54k|    }
  935|       |
  936|    158|    return h;
  937|    158|}
_h3ToFaceIjkWithInitializedFijk:
 1090|  1.34k|int _h3ToFaceIjkWithInitializedFijk(H3Index h, FaceIJK *fijk) {
 1091|  1.34k|    CoordIJK *ijk = &fijk->coord;
 1092|  1.34k|    int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|  1.34k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  1.34k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  1.34k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  1.34k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1093|       |
 1094|       |    // center base cell hierarchy is entirely on this face
 1095|  1.34k|    int possibleOverage = 1;
 1096|  1.34k|    if (!_isBaseCellPentagon(H3_GET_BASE_CELL(h)) &&
  ------------------
  |  |  118|  1.34k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.34k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.34k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.34k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  |  Branch (1096:9): [True: 718, False: 629]
  ------------------
 1097|    718|        (res == 0 ||
  ------------------
  |  Branch (1097:10): [True: 52, False: 666]
  ------------------
 1098|    666|         (fijk->coord.i == 0 && fijk->coord.j == 0 && fijk->coord.k == 0)))
  ------------------
  |  Branch (1098:11): [True: 365, False: 301]
  |  Branch (1098:33): [True: 190, False: 175]
  |  Branch (1098:55): [True: 43, False: 147]
  ------------------
 1099|     95|        possibleOverage = 0;
 1100|       |
 1101|  15.7k|    for (int r = 1; r <= res; r++) {
  ------------------
  |  Branch (1101:21): [True: 14.4k, False: 1.34k]
  ------------------
 1102|  14.4k|        if (isResolutionClassIII(r)) {
  ------------------
  |  Branch (1102:13): [True: 7.75k, False: 6.67k]
  ------------------
 1103|       |            // Class III == rotate ccw
 1104|  7.75k|            _downAp7(ijk);
 1105|  7.75k|        } else {
 1106|       |            // Class II == rotate cw
 1107|  6.67k|            _downAp7r(ijk);
 1108|  6.67k|        }
 1109|       |
 1110|  14.4k|        _neighbor(ijk, H3_GET_INDEX_DIGIT(h, r));
  ------------------
  |  |  141|  14.4k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  14.4k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  14.4k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  14.4k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  14.4k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
 1111|  14.4k|    }
 1112|       |
 1113|  1.34k|    return possibleOverage;
 1114|  1.34k|}
_h3ToFaceIjk:
 1121|  1.35k|H3Error _h3ToFaceIjk(H3Index h, FaceIJK *fijk) {
 1122|  1.35k|    int baseCell = H3_GET_BASE_CELL(h);
  ------------------
  |  |  118|  1.35k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.35k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.35k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.35k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
 1123|  1.35k|    if (NEVER(baseCell < 0) || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |  119|  2.70k|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 1.35k]
  |  |  |  Branch (119:19): [True: 0, False: 1.35k]
  |  |  ------------------
  ------------------
                  if (NEVER(baseCell < 0) || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |   81|  1.35k|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (1123:9): [Folded, False: 0]
  |  Branch (1123:9): [Folded, False: 0]
  |  Branch (1123:32): [True: 3, False: 1.34k]
  ------------------
 1124|       |        // Base cells less than zero can not be represented in an index
 1125|       |        // To prevent reading uninitialized memory, we zero the output.
 1126|      3|        fijk->face = 0;
 1127|      3|        fijk->coord.i = fijk->coord.j = fijk->coord.k = 0;
 1128|      3|        return E_CELL_INVALID;
 1129|      3|    }
 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.34k|    if (_isBaseCellPentagon(baseCell) && _h3LeadingNonZeroDigit(h) == 5)
  ------------------
  |  Branch (1132:9): [True: 629, False: 718]
  |  Branch (1132:42): [True: 121, False: 508]
  ------------------
 1133|    121|        h = _h3Rotate60cw(h);
 1134|       |
 1135|       |    // start with the "home" face and ijk+ coordinates for the base cell of c
 1136|  1.34k|    *fijk = baseCellData[baseCell].homeFijk;
 1137|  1.34k|    if (!_h3ToFaceIjkWithInitializedFijk(h, fijk))
  ------------------
  |  Branch (1137:9): [True: 95, False: 1.25k]
  ------------------
 1138|     95|        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.25k|    CoordIJK origIJK = fijk->coord;
 1144|       |
 1145|       |    // if we're in Class III, drop into the next finer Class II grid
 1146|  1.25k|    int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|  1.25k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  1.25k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  1.25k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  1.25k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1147|  1.25k|    if (isResolutionClassIII(res)) {
  ------------------
  |  Branch (1147:9): [True: 1.04k, False: 212]
  ------------------
 1148|       |        // Class III
 1149|  1.04k|        _downAp7r(&fijk->coord);
 1150|  1.04k|        res++;
 1151|  1.04k|    }
 1152|       |
 1153|       |    // adjust for overage if needed
 1154|       |    // a pentagon base cell with a leading 4 digit requires special handling
 1155|  1.25k|    int pentLeading4 =
 1156|  1.25k|        (_isBaseCellPentagon(baseCell) && _h3LeadingNonZeroDigit(h) == 4);
  ------------------
  |  Branch (1156:10): [True: 629, False: 623]
  |  Branch (1156:43): [True: 198, False: 431]
  ------------------
 1157|  1.25k|    if (_adjustOverageClassII(fijk, res, pentLeading4, 0) != NO_OVERAGE) {
  ------------------
  |  Branch (1157:9): [True: 618, False: 634]
  ------------------
 1158|       |        // if the base cell is a pentagon we have the potential for secondary
 1159|       |        // overages
 1160|    618|        if (_isBaseCellPentagon(baseCell)) {
  ------------------
  |  Branch (1160:13): [True: 501, False: 117]
  ------------------
 1161|    891|            while (_adjustOverageClassII(fijk, res, 0, 0) != NO_OVERAGE)
  ------------------
  |  Branch (1161:20): [True: 390, False: 501]
  ------------------
 1162|    390|                continue;
 1163|    501|        }
 1164|       |
 1165|    618|        if (res != H3_GET_RESOLUTION(h)) _upAp7r(&fijk->coord);
  ------------------
  |  |  129|    618|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    618|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    618|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    618|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (1165:13): [True: 515, False: 103]
  ------------------
 1166|    634|    } else if (res != H3_GET_RESOLUTION(h)) {
  ------------------
  |  |  129|    634|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    634|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    634|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    634|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (1166:16): [True: 525, False: 109]
  ------------------
 1167|    525|        fijk->coord = origIJK;
 1168|    525|    }
 1169|  1.25k|    return E_SUCCESS;
 1170|  1.34k|}
maxFaceCount:
 1233|  1.19k|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.19k|    *out = H3_EXPORT(isPentagon)(h3) ? 5 : 2;
  ------------------
  |  |   36|  1.19k|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|  1.19k|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|  1.19k|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1236:12): [True: 42, False: 1.15k]
  ------------------
 1237|  1.19k|    return E_SUCCESS;
 1238|  1.19k|}
getIcosahedronFaces:
 1249|    614|H3Error H3_EXPORT(getIcosahedronFaces)(H3Index h3, int *out) {
 1250|    614|    int res = H3_GET_RESOLUTION(h3);
  ------------------
  |  |  129|    614|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    614|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    614|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    614|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1251|    614|    int isPent = H3_EXPORT(isPentagon)(h3);
  ------------------
  |  |   36|    614|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    614|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    614|#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|    614|    if (isPent && !isResolutionClassIII(res)) {
  ------------------
  |  Branch (1256:9): [True: 34, False: 580]
  |  Branch (1256:19): [True: 13, False: 21]
  ------------------
 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|    601|    FaceIJK fijk;
 1265|    601|    H3Error err = _h3ToFaceIjk(h3, &fijk);
 1266|    601|    if (err) {
  ------------------
  |  Branch (1266:9): [True: 3, False: 598]
  ------------------
 1267|      3|        return err;
 1268|      3|    }
 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|    598|    FaceIJK fijkVerts[NUM_HEX_VERTS];
 1273|    598|    int vertexCount;
 1274|       |
 1275|    598|    if (isPent) {
  ------------------
  |  Branch (1275:9): [True: 21, False: 577]
  ------------------
 1276|     21|        vertexCount = NUM_PENT_VERTS;
  ------------------
  |  |   85|     21|#define NUM_PENT_VERTS 5
  ------------------
 1277|     21|        _faceIjkPentToVerts(&fijk, &res, fijkVerts);
 1278|    577|    } else {
 1279|    577|        vertexCount = NUM_HEX_VERTS;
  ------------------
  |  |   83|    577|#define NUM_HEX_VERTS 6
  ------------------
 1280|    577|        _faceIjkToVerts(&fijk, &res, fijkVerts);
 1281|    577|    }
 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|    598|    int faceCount;
 1286|    598|    H3Error maxFaceCountError = H3_EXPORT(maxFaceCount)(h3, &faceCount);
  ------------------
  |  |   36|    598|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    598|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    598|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1287|    598|    if (NEVER(maxFaceCountError != E_SUCCESS)) {
  ------------------
  |  |  119|    598|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 598]
  |  |  |  Branch (119:19): [True: 0, False: 598]
  |  |  ------------------
  ------------------
  |  Branch (1287:9): [Folded, False: 0]
  |  Branch (1287:9): [Folded, False: 0]
  ------------------
 1288|      0|        return maxFaceCountError;
 1289|      0|    }
 1290|  1.85k|    for (int i = 0; i < faceCount; i++) {
  ------------------
  |  Branch (1290:21): [True: 1.25k, False: 598]
  ------------------
 1291|  1.25k|        out[i] = INVALID_FACE;
  ------------------
  |  |   60|  1.25k|#define INVALID_FACE -1
  ------------------
 1292|  1.25k|    }
 1293|       |
 1294|       |    // add each vertex face, using the output array as a hash set
 1295|  4.15k|    for (int i = 0; i < vertexCount; i++) {
  ------------------
  |  Branch (1295:21): [True: 3.56k, False: 595]
  ------------------
 1296|  3.56k|        FaceIJK *vert = &fijkVerts[i];
 1297|       |
 1298|       |        // Adjust overage, determining whether this vertex is
 1299|       |        // on another face
 1300|  3.56k|        if (isPent) {
  ------------------
  |  Branch (1300:13): [True: 105, False: 3.45k]
  ------------------
 1301|    105|            _adjustPentVertOverage(vert, res);
 1302|  3.45k|        } else {
 1303|  3.45k|            _adjustOverageClassII(vert, res, 0, 1);
 1304|  3.45k|        }
 1305|       |
 1306|       |        // Save the face to the output array
 1307|  3.56k|        int face = vert->face;
 1308|  3.56k|        int pos = 0;
 1309|       |        // Find the first empty output position, or the first position
 1310|       |        // matching the current face
 1311|  3.91k|        while (out[pos] != INVALID_FACE && out[pos] != face) {
  ------------------
  |  |   60|  7.82k|#define INVALID_FACE -1
  ------------------
  |  Branch (1311:16): [True: 3.17k, False: 743]
  |  Branch (1311:44): [True: 354, False: 2.81k]
  ------------------
 1312|    354|            pos++;
 1313|    354|            if (pos >= faceCount) {
  ------------------
  |  Branch (1313:17): [True: 3, False: 351]
  ------------------
 1314|       |                // Mismatch between the heuristic used in maxFaceCount and
 1315|       |                // calculation here - indicates an invalid index.
 1316|      3|                return E_FAILED;
 1317|      3|            }
 1318|    354|        }
 1319|  3.55k|        out[pos] = face;
 1320|  3.55k|    }
 1321|    595|    return E_SUCCESS;
 1322|    598|}
isResolutionClassIII:
 1359|  19.8k|int isResolutionClassIII(int res) { return res % 2; }
h3Index.c:_hasGoodTopBits:
  216|  1.55k|static inline bool _hasGoodTopBits(H3Index h) {
  217|  1.55k|    h >>= (64 - 8);
  218|  1.55k|    return h == 0b00001000;
  219|  1.55k|}
h3Index.c:_hasAny7UptoRes:
  264|    566|static inline bool _hasAny7UptoRes(H3Index h, int res) {
  265|    566|    const uint64_t MHI = 0b100100100100100100100100100100100100100100100;
  266|    566|    const uint64_t MLO = MHI >> 2;
  267|       |
  268|    566|    int shift = 3 * (15 - res);
  269|    566|    h >>= shift;
  270|    566|    h <<= shift;
  271|    566|    h = (h & MHI & (~h - MLO));
  272|       |
  273|    566|    return h != 0;
  274|    566|}
h3Index.c:_hasAll7AfterRes:
  280|    491|static inline bool _hasAll7AfterRes(H3Index h, int res) {
  281|       |    // NOTE: res check is needed because we can't shift by 64
  282|    491|    if (res < 15) {
  ------------------
  |  Branch (282:9): [True: 272, False: 219]
  ------------------
  283|    272|        int shift = 19 + 3 * res;
  284|       |
  285|    272|        h = ~h;
  286|    272|        h <<= shift;
  287|    272|        h >>= shift;
  288|       |
  289|    272|        return h == 0;
  290|    272|    }
  291|    219|    return true;
  292|    491|}
h3Index.c:_hasDeletedSubsequence:
  327|    380|static inline bool _hasDeletedSubsequence(H3Index h, int base_cell) {
  328|    380|    if (isBaseCellPentagonArr[base_cell]) {
  ------------------
  |  Branch (328:9): [True: 208, False: 172]
  ------------------
  329|    208|        h <<= 19;
  330|    208|        h >>= 19;
  331|       |
  332|    208|        if (h == 0) return false;  // all zeros: res 15 pentagon
  ------------------
  |  Branch (332:13): [True: 6, False: 202]
  ------------------
  333|    202|        return _firstOneIndex(h) % 3 == 0;
  334|    208|    }
  335|    172|    return false;
  336|    380|}
h3Index.c:_firstOneIndex:
  300|    202|static inline int _firstOneIndex(H3Index h) {
  301|    202|#if defined(__GNUC__) || defined(__clang__)
  302|    202|    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|    202|}

vertexNumForDirection:
  130|    202|int vertexNumForDirection(const H3Index origin, const Direction direction) {
  131|    202|    int isPent = H3_EXPORT(isPentagon)(origin);
  ------------------
  |  |   36|    202|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    202|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    202|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |    // Check for invalid directions
  133|    202|    if (direction == CENTER_DIGIT || direction >= INVALID_DIGIT ||
  ------------------
  |  Branch (133:9): [True: 0, False: 202]
  |  Branch (133:38): [True: 0, False: 202]
  ------------------
  134|    202|        (isPent && direction == K_AXES_DIGIT))
  ------------------
  |  Branch (134:10): [True: 28, False: 174]
  |  Branch (134:20): [True: 0, False: 28]
  ------------------
  135|      0|        return INVALID_VERTEX_NUM;
  ------------------
  |  |   36|      0|#define INVALID_VERTEX_NUM -1
  ------------------
  136|       |
  137|       |    // Determine the vertex rotations for this cell
  138|    202|    int rotations;
  139|    202|    H3Error err = vertexRotations(origin, &rotations);
  140|    202|    if (err) {
  ------------------
  |  Branch (140:9): [True: 0, False: 202]
  ------------------
  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|    202|    if (isPent) {
  ------------------
  |  Branch (145:9): [True: 28, False: 174]
  ------------------
  146|     28|        return (directionToVertexNumPent[direction] + NUM_PENT_VERTS -
  ------------------
  |  |   85|     28|#define NUM_PENT_VERTS 5
  ------------------
  147|     28|                rotations) %
  148|     28|               NUM_PENT_VERTS;
  ------------------
  |  |   85|     28|#define NUM_PENT_VERTS 5
  ------------------
  149|    174|    } else {
  150|    174|        return (directionToVertexNumHex[direction] + NUM_HEX_VERTS -
  ------------------
  |  |   83|    174|#define NUM_HEX_VERTS 6
  ------------------
  151|    174|                rotations) %
  152|    174|               NUM_HEX_VERTS;
  ------------------
  |  |   83|    174|#define NUM_HEX_VERTS 6
  ------------------
  153|    174|    }
  154|    202|}
directionForVertexNum:
  173|    547|Direction directionForVertexNum(const H3Index origin, const int vertexNum) {
  174|    547|    int isPent = H3_EXPORT(isPentagon)(origin);
  ------------------
  |  |   36|    547|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    547|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    547|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  175|       |    // Check for invalid vertexes
  176|    547|    if (vertexNum < 0 ||
  ------------------
  |  Branch (176:9): [True: 0, False: 547]
  ------------------
  177|    547|        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|    543|#define NUM_HEX_VERTS 6
  ------------------
  |  Branch (177:9): [True: 0, False: 547]
  |  Branch (177:22): [True: 4, False: 543]
  ------------------
  178|      0|        return INVALID_DIGIT;
  179|       |
  180|       |    // Determine the vertex rotations for this cell
  181|    547|    int rotations;
  182|    547|    H3Error err = vertexRotations(origin, &rotations);
  183|    547|    if (err) {
  ------------------
  |  Branch (183:9): [True: 0, False: 547]
  ------------------
  184|      0|        return INVALID_DIGIT;
  185|      0|    }
  186|       |
  187|       |    // Find the appropriate direction, rotating CW if necessary
  188|    547|    return isPent ? vertexNumToDirectionPent[(vertexNum + rotations) %
  ------------------
  |  Branch (188:12): [True: 4, False: 543]
  ------------------
  189|      4|                                             NUM_PENT_VERTS]
  ------------------
  |  |   85|      4|#define NUM_PENT_VERTS 5
  ------------------
  190|    547|                  : vertexNumToDirectionHex[(vertexNum + rotations) %
  191|    543|                                            NUM_HEX_VERTS];
  ------------------
  |  |   83|    543|#define NUM_HEX_VERTS 6
  ------------------
  192|    547|}
cellToVertex:
  212|    292|H3Error H3_EXPORT(cellToVertex)(H3Index cell, int vertexNum, H3Index *out) {
  213|    292|    int cellIsPentagon = H3_EXPORT(isPentagon)(cell);
  ------------------
  |  |   36|    292|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    292|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    292|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  214|    292|    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|    288|#define NUM_HEX_VERTS 6
  ------------------
  |  Branch (214:24): [True: 4, False: 288]
  ------------------
  215|    292|    int res = H3_GET_RESOLUTION(cell);
  ------------------
  |  |  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
  |  |  ------------------
  ------------------
  216|       |
  217|       |    // Check for invalid vertexes
  218|    292|    if (vertexNum < 0 || vertexNum > cellNumVerts - 1) return E_DOMAIN;
  ------------------
  |  Branch (218:9): [True: 0, False: 292]
  |  Branch (218:26): [True: 5, False: 287]
  ------------------
  219|       |
  220|       |    // Default the owner and vertex number to the input cell
  221|    287|    H3Index owner = cell;
  222|    287|    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|    287|    if (res == 0 || H3_GET_INDEX_DIGIT(cell, res) != CENTER_DIGIT) {
  ------------------
  |  |  141|    278|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|    278|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|    278|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|    278|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|    278|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  |  Branch (229:9): [True: 9, False: 278]
  |  Branch (229:21): [True: 276, False: 2]
  ------------------
  230|       |        // Get the left neighbor of the vertex, with its rotations
  231|    285|        Direction left = directionForVertexNum(cell, vertexNum);
  232|    285|        if (left == INVALID_DIGIT) return E_FAILED;
  ------------------
  |  Branch (232:13): [True: 0, False: 285]
  ------------------
  233|    285|        int lRotations = 0;
  234|    285|        H3Index leftNeighbor;
  235|    285|        H3Error leftNeighborError =
  236|    285|            h3NeighborRotations(cell, left, &lRotations, &leftNeighbor);
  237|    285|        if (leftNeighborError) return leftNeighborError;
  ------------------
  |  Branch (237:13): [True: 0, False: 285]
  ------------------
  238|       |        // Set to owner if lowest index
  239|    285|        if (leftNeighbor < owner) owner = leftNeighbor;
  ------------------
  |  Branch (239:13): [True: 151, False: 134]
  ------------------
  240|       |
  241|       |        // As above, skip the right neighbor if the left is known lowest
  242|    285|        if (res == 0 || H3_GET_INDEX_DIGIT(leftNeighbor, res) != CENTER_DIGIT) {
  ------------------
  |  |  141|    276|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|    276|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|    276|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|    276|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|    276|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  |  Branch (242:13): [True: 9, False: 276]
  |  Branch (242:25): [True: 253, False: 23]
  ------------------
  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|    262|            Direction right = directionForVertexNum(
  246|    262|                cell, (vertexNum - 1 + cellNumVerts) % cellNumVerts);
  247|       |            // This case should be unreachable; invalid verts fail earlier
  248|    262|            if (NEVER(right == INVALID_DIGIT)) return E_FAILED;
  ------------------
  |  |  119|    262|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 262]
  |  |  |  Branch (119:19): [True: 0, False: 262]
  |  |  ------------------
  ------------------
  |  Branch (248:17): [Folded, False: 0]
  |  Branch (248:17): [Folded, False: 0]
  ------------------
  249|    262|            int rRotations = 0;
  250|    262|            H3Index rightNeighbor;
  251|    262|            H3Error rightNeighborError =
  252|    262|                h3NeighborRotations(cell, right, &rRotations, &rightNeighbor);
  253|    262|            if (rightNeighborError) return rightNeighborError;
  ------------------
  |  Branch (253:17): [True: 0, False: 262]
  ------------------
  254|       |            // Set to owner if lowest index
  255|    262|            if (rightNeighbor < owner) {
  ------------------
  |  Branch (255:17): [True: 105, False: 157]
  ------------------
  256|    105|                owner = rightNeighbor;
  257|    105|                Direction dir =
  258|    105|                    H3_EXPORT(isPentagon)(owner)
  ------------------
  |  |   36|    105|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    105|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    105|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (258:21): [True: 21, False: 84]
  ------------------
  259|    105|                        ? directionForNeighbor(owner, cell)
  260|    105|                        : DIRECTIONS[(revNeighborDirectionsHex[right] +
  261|     84|                                      rRotations) %
  262|     84|                                     NUM_HEX_VERTS];
  ------------------
  |  |   83|     84|#define NUM_HEX_VERTS 6
  ------------------
  263|    105|                ownerVertexNum = vertexNumForDirection(owner, dir);
  264|    105|            }
  265|    262|        }
  266|       |
  267|       |        // Determine the vertex number for the left neighbor
  268|    285|        if (owner == leftNeighbor) {
  ------------------
  |  Branch (268:13): [True: 97, False: 188]
  ------------------
  269|     97|            int ownerIsPentagon = H3_EXPORT(isPentagon)(owner);
  ------------------
  |  |   36|     97|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|     97|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|     97|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  270|     97|            Direction dir =
  271|     97|                ownerIsPentagon
  ------------------
  |  Branch (271:17): [True: 7, False: 90]
  ------------------
  272|     97|                    ? directionForNeighbor(owner, cell)
  273|     97|                    : DIRECTIONS[(revNeighborDirectionsHex[left] + lRotations) %
  274|     90|                                 NUM_HEX_VERTS];
  ------------------
  |  |   83|     90|#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|     97|            ownerVertexNum = vertexNumForDirection(owner, dir) + 1;
  279|     97|            if (ownerVertexNum == NUM_HEX_VERTS ||
  ------------------
  |  |   83|    194|#define NUM_HEX_VERTS 6
  ------------------
  |  Branch (279:17): [True: 10, False: 87]
  ------------------
  280|     87|                (ownerIsPentagon && ownerVertexNum == NUM_PENT_VERTS)) {
  ------------------
  |  |   85|      7|#define NUM_PENT_VERTS 5
  ------------------
  |  Branch (280:18): [True: 7, False: 80]
  |  Branch (280:37): [True: 2, False: 5]
  ------------------
  281|     12|                ownerVertexNum = 0;
  282|     12|            }
  283|     97|        }
  284|    285|    }
  285|       |
  286|       |    // Create the vertex index
  287|    287|    H3Index vertex = owner;
  288|    287|    H3_SET_MODE(vertex, H3_VERTEX_MODE);
  ------------------
  |  |  113|    287|    (h3) = (((h3)&H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET))
  |  |  ------------------
  |  |  |  |   59|    287|#define H3_MODE_MASK_NEGATIVE (~H3_MODE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|    287|#define H3_MODE_MASK ((uint64_t)(15) << H3_MODE_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   35|    287|#define H3_MODE_OFFSET 59
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (h3) = (((h3)&H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET))
  |  |  ------------------
  |  |  |  |   35|    287|#define H3_MODE_OFFSET 59
  |  |  ------------------
  ------------------
  289|    287|    H3_SET_RESERVED_BITS(vertex, ownerVertexNum);
  ------------------
  |  |  149|    287|    (h3) = (((h3)&H3_RESERVED_MASK_NEGATIVE) | \
  |  |  ------------------
  |  |  |  |   77|    287|#define H3_RESERVED_MASK_NEGATIVE (~H3_RESERVED_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   74|    287|#define H3_RESERVED_MASK ((uint64_t)(7) << H3_RESERVED_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|    287|#define H3_RESERVED_OFFSET 56
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|    287|            (((uint64_t)(v)) << H3_RESERVED_OFFSET))
  |  |  ------------------
  |  |  |  |   44|    287|#define H3_RESERVED_OFFSET 56
  |  |  ------------------
  ------------------
  290|    287|    *out = vertex;
  291|       |
  292|    287|    return E_SUCCESS;
  293|    287|}
isValidVertex:
  354|    568|int H3_EXPORT(isValidVertex)(H3Index vertex) {
  355|    568|    if (H3_GET_MODE(vertex) != H3_VERTEX_MODE) {
  ------------------
  |  |  107|    568|#define H3_GET_MODE(h3) ((int)((((h3)&H3_MODE_MASK) >> H3_MODE_OFFSET)))
  |  |  ------------------
  |  |  |  |   56|    568|#define H3_MODE_MASK ((uint64_t)(15) << H3_MODE_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   35|    568|#define H3_MODE_OFFSET 59
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_MODE(h3) ((int)((((h3)&H3_MODE_MASK) >> H3_MODE_OFFSET)))
  |  |  ------------------
  |  |  |  |   35|    568|#define H3_MODE_OFFSET 59
  |  |  ------------------
  ------------------
                  if (H3_GET_MODE(vertex) != H3_VERTEX_MODE) {
  ------------------
  |  |   93|    568|#define H3_VERTEX_MODE 4
  ------------------
  |  Branch (355:9): [True: 230, False: 338]
  ------------------
  356|    230|        return 0;
  357|    230|    }
  358|       |
  359|    338|    int vertexNum = H3_GET_RESERVED_BITS(vertex);
  ------------------
  |  |  156|    338|    ((int)((((h3)&H3_RESERVED_MASK) >> H3_RESERVED_OFFSET)))
  |  |  ------------------
  |  |  |  |   74|    338|#define H3_RESERVED_MASK ((uint64_t)(7) << H3_RESERVED_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    338|#define H3_RESERVED_OFFSET 56
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   ((int)((((h3)&H3_RESERVED_MASK) >> H3_RESERVED_OFFSET)))
  |  |  ------------------
  |  |  |  |   44|    338|#define H3_RESERVED_OFFSET 56
  |  |  ------------------
  ------------------
  360|    338|    H3Index owner = vertex;
  361|    338|    H3_SET_MODE(owner, H3_CELL_MODE);
  ------------------
  |  |  113|    338|    (h3) = (((h3)&H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET))
  |  |  ------------------
  |  |  |  |   59|    338|#define H3_MODE_MASK_NEGATIVE (~H3_MODE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   56|    338|#define H3_MODE_MASK ((uint64_t)(15) << H3_MODE_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   35|    338|#define H3_MODE_OFFSET 59
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (h3) = (((h3)&H3_MODE_MASK_NEGATIVE) | (((uint64_t)(v)) << H3_MODE_OFFSET))
  |  |  ------------------
  |  |  |  |   35|    338|#define H3_MODE_OFFSET 59
  |  |  ------------------
  ------------------
  362|    338|    H3_SET_RESERVED_BITS(owner, 0);
  ------------------
  |  |  149|    338|    (h3) = (((h3)&H3_RESERVED_MASK_NEGATIVE) | \
  |  |  ------------------
  |  |  |  |   77|    338|#define H3_RESERVED_MASK_NEGATIVE (~H3_RESERVED_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   74|    338|#define H3_RESERVED_MASK ((uint64_t)(7) << H3_RESERVED_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|    338|#define H3_RESERVED_OFFSET 56
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|    338|            (((uint64_t)(v)) << H3_RESERVED_OFFSET))
  |  |  ------------------
  |  |  |  |   44|    338|#define H3_RESERVED_OFFSET 56
  |  |  ------------------
  ------------------
  363|       |
  364|    338|    if (!H3_EXPORT(isValidCell)(owner)) {
  ------------------
  |  |   36|    338|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    338|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    338|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (364:9): [True: 46, False: 292]
  ------------------
  365|     46|        return 0;
  366|     46|    }
  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|    292|    H3Index canonical;
  371|    292|    if (H3_EXPORT(cellToVertex)(owner, vertexNum, &canonical)) {
  ------------------
  |  |   36|    292|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    292|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    292|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (371:9): [True: 5, False: 287]
  ------------------
  372|      5|        return 0;
  373|      5|    }
  374|       |
  375|    287|    return vertex == canonical ? 1 : 0;
  ------------------
  |  Branch (375:12): [True: 85, False: 202]
  ------------------
  376|    292|}
vertex.c:vertexRotations:
   53|    749|static H3Error vertexRotations(H3Index cell, int *out) {
   54|       |    // Get the face and other info for the origin
   55|    749|    FaceIJK fijk;
   56|    749|    H3Error err = _h3ToFaceIjk(cell, &fijk);
   57|    749|    if (err) {
  ------------------
  |  Branch (57:9): [True: 0, False: 749]
  ------------------
   58|      0|        return err;
   59|      0|    }
   60|    749|    int baseCell = H3_EXPORT(getBaseCellNumber)(cell);
  ------------------
  |  |   36|    749|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    749|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    749|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   61|    749|    int cellLeadingDigit = _h3LeadingNonZeroDigit(cell);
   62|       |
   63|       |    // get the base cell face
   64|    749|    FaceIJK baseFijk;
   65|    749|    _baseCellToFaceIjk(baseCell, &baseFijk);
   66|       |
   67|    749|    int ccwRot60 = _baseCellToCCWrot60(baseCell, fijk.face);
   68|       |
   69|    749|    if (_isBaseCellPentagon(baseCell)) {
  ------------------
  |  Branch (69:9): [True: 358, False: 391]
  ------------------
   70|       |        // Find the appropriate direction-to-face mapping
   71|    358|        PentagonDirectionFaces dirFaces;
   72|       |        // We never hit the end condition
   73|    358|        int p = 0;
   74|       |        // Don't use a for loop here, for coverage reasons.
   75|  2.39k|        while (ALWAYS(p < NUM_PENTAGONS)) {
  ------------------
  |  |  118|  2.39k|#define ALWAYS(X) ((X) ? 1 : (assert(0), 0))
  |  |  ------------------
  |  |  |  Branch (118:19): [True: 2.39k, False: 0]
  |  |  |  Branch (118:20): [True: 2.39k, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (75:16): [Folded, False: 0]
  |  Branch (75:16): [Folded, False: 0]
  ------------------
   76|  2.39k|            if (pentagonDirectionFaces[p].baseCell == baseCell) {
  ------------------
  |  Branch (76:17): [True: 358, False: 2.04k]
  ------------------
   77|    358|                dirFaces = pentagonDirectionFaces[p];
   78|    358|                break;
   79|    358|            }
   80|  2.04k|            p++;
   81|  2.04k|        }
   82|    358|        if (NEVER(p == NUM_PENTAGONS)) {
  ------------------
  |  |  119|    358|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 358]
  |  |  |  Branch (119:19): [True: 0, False: 358]
  |  |  ------------------
  ------------------
  |  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|    358|        if (fijk.face != baseFijk.face &&
  ------------------
  |  Branch (87:13): [True: 277, False: 81]
  ------------------
   88|    277|            (_isBaseCellPolarPentagon(baseCell) ||
  ------------------
  |  Branch (88:14): [True: 122, False: 155]
  ------------------
   89|    155|             fijk.face ==
  ------------------
  |  Branch (89:14): [True: 59, False: 96]
  ------------------
   90|    181|                 dirFaces.faces[IK_AXES_DIGIT - DIRECTION_INDEX_OFFSET])) {
  ------------------
  |  |   32|    155|#define DIRECTION_INDEX_OFFSET 2
  ------------------
   91|    181|            ccwRot60 = (ccwRot60 + 1) % 6;
   92|    181|        }
   93|       |
   94|       |        // Check whether the cell crosses a deleted pentagon subsequence
   95|    358|        if (cellLeadingDigit == JK_AXES_DIGIT &&
  ------------------
  |  Branch (95:13): [True: 72, False: 286]
  ------------------
   96|     72|            fijk.face ==
  ------------------
  |  Branch (96:13): [True: 29, False: 43]
  ------------------
   97|     72|                dirFaces.faces[IK_AXES_DIGIT - DIRECTION_INDEX_OFFSET]) {
  ------------------
  |  |   32|     72|#define DIRECTION_INDEX_OFFSET 2
  ------------------
   98|       |            // Crosses from JK to IK: Rotate CW
   99|     29|            ccwRot60 = (ccwRot60 + 5) % 6;
  100|    329|        } else if (cellLeadingDigit == IK_AXES_DIGIT &&
  ------------------
  |  Branch (100:20): [True: 76, False: 253]
  ------------------
  101|     76|                   fijk.face ==
  ------------------
  |  Branch (101:20): [True: 10, False: 66]
  ------------------
  102|     76|                       dirFaces.faces[JK_AXES_DIGIT - DIRECTION_INDEX_OFFSET]) {
  ------------------
  |  |   32|     76|#define DIRECTION_INDEX_OFFSET 2
  ------------------
  103|       |            // Crosses from IK to JK: Rotate CCW
  104|     10|            ccwRot60 = (ccwRot60 + 1) % 6;
  105|     10|        }
  106|    358|    }
  107|    749|    *out = ccwRot60;
  108|    749|    return E_SUCCESS;
  109|    749|}

