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

h3Index.c:_rotate60ccw:
  656|  2.33k|static inline Direction _rotate60ccw(Direction digit) {
  657|  2.33k|    switch (digit) {
  658|    476|        case K_AXES_DIGIT:
  ------------------
  |  Branch (658:9): [True: 476, False: 1.85k]
  ------------------
  659|    476|            return IK_AXES_DIGIT;
  660|    399|        case IK_AXES_DIGIT:
  ------------------
  |  Branch (660:9): [True: 399, False: 1.93k]
  ------------------
  661|    399|            return I_AXES_DIGIT;
  662|    315|        case I_AXES_DIGIT:
  ------------------
  |  Branch (662:9): [True: 315, False: 2.01k]
  ------------------
  663|    315|            return IJ_AXES_DIGIT;
  664|    266|        case IJ_AXES_DIGIT:
  ------------------
  |  Branch (664:9): [True: 266, False: 2.06k]
  ------------------
  665|    266|            return J_AXES_DIGIT;
  666|    340|        case J_AXES_DIGIT:
  ------------------
  |  Branch (666:9): [True: 340, False: 1.99k]
  ------------------
  667|    340|            return JK_AXES_DIGIT;
  668|    433|        case JK_AXES_DIGIT:
  ------------------
  |  Branch (668:9): [True: 433, False: 1.89k]
  ------------------
  669|    433|            return K_AXES_DIGIT;
  670|    102|        default:
  ------------------
  |  Branch (670:9): [True: 102, False: 2.22k]
  ------------------
  671|    102|            return digit;
  672|  2.33k|    }
  673|  2.33k|}
h3Index.c:_rotate60cw:
  680|  1.87k|static inline Direction _rotate60cw(Direction digit) {
  681|  1.87k|    switch (digit) {
  682|    325|        case K_AXES_DIGIT:
  ------------------
  |  Branch (682:9): [True: 325, False: 1.55k]
  ------------------
  683|    325|            return JK_AXES_DIGIT;
  684|    180|        case JK_AXES_DIGIT:
  ------------------
  |  Branch (684:9): [True: 180, False: 1.69k]
  ------------------
  685|    180|            return J_AXES_DIGIT;
  686|    118|        case J_AXES_DIGIT:
  ------------------
  |  Branch (686:9): [True: 118, False: 1.75k]
  ------------------
  687|    118|            return IJ_AXES_DIGIT;
  688|    113|        case IJ_AXES_DIGIT:
  ------------------
  |  Branch (688:9): [True: 113, False: 1.76k]
  ------------------
  689|    113|            return I_AXES_DIGIT;
  690|    221|        case I_AXES_DIGIT:
  ------------------
  |  Branch (690:9): [True: 221, False: 1.65k]
  ------------------
  691|    221|            return IK_AXES_DIGIT;
  692|    349|        case IK_AXES_DIGIT:
  ------------------
  |  Branch (692:9): [True: 349, False: 1.52k]
  ------------------
  693|    349|            return K_AXES_DIGIT;
  694|    569|        default:
  ------------------
  |  Branch (694:9): [True: 569, False: 1.30k]
  ------------------
  695|    569|            return digit;
  696|  1.87k|    }
  697|  1.87k|}
h3Index.c:_downAp7:
  512|  8.64k|static inline void _downAp7(CoordIJK *ijk) {
  513|       |    // res r unit vectors in res r+1
  514|  8.64k|    CoordIJK iVec = {3, 0, 1};
  515|  8.64k|    CoordIJK jVec = {1, 3, 0};
  516|  8.64k|    CoordIJK kVec = {0, 1, 3};
  517|       |
  518|  8.64k|    _ijkScale(&iVec, ijk->i);
  519|  8.64k|    _ijkScale(&jVec, ijk->j);
  520|  8.64k|    _ijkScale(&kVec, ijk->k);
  521|       |
  522|  8.64k|    _ijkAdd(&iVec, &jVec, ijk);
  523|  8.64k|    _ijkAdd(ijk, &kVec, ijk);
  524|       |
  525|  8.64k|    _ijkNormalize(ijk);
  526|  8.64k|}
h3Index.c:_ijkScale:
  155|  51.7k|static inline void _ijkScale(CoordIJK *c, int factor) {
  156|  51.7k|    c->i *= factor;
  157|  51.7k|    c->j *= factor;
  158|  51.7k|    c->k *= factor;
  159|  51.7k|}
h3Index.c:_ijkAdd:
  129|  46.4k|                           CoordIJK *sum) {
  130|  46.4k|    sum->i = h1->i + h2->i;
  131|  46.4k|    sum->j = h1->j + h2->j;
  132|  46.4k|    sum->k = h1->k + h2->k;
  133|  46.4k|}
h3Index.c:_upAp7r:
  494|    630|static inline void _upAp7r(CoordIJK *ijk) {
  495|       |    // convert to CoordIJ
  496|    630|    int i = ijk->i - ijk->k;
  497|    630|    int j = ijk->j - ijk->k;
  498|       |
  499|    630|    ijk->i = (int)lround((2 * i + j) * M_ONESEVENTH);
  ------------------
  |  |   54|    630|#define M_ONESEVENTH 0.14285714285714285714285714285714285
  ------------------
  500|    630|    ijk->j = (int)lround((3 * j - i) * M_ONESEVENTH);
  ------------------
  |  |   54|    630|#define M_ONESEVENTH 0.14285714285714285714285714285714285
  ------------------
  501|    630|    ijk->k = 0;
  502|    630|    _ijkNormalize(ijk);
  503|    630|}
h3Index.c:_downAp7r:
  534|  8.59k|static inline void _downAp7r(CoordIJK *ijk) {
  535|       |    // res r unit vectors in res r+1
  536|  8.59k|    CoordIJK iVec = {3, 1, 0};
  537|  8.59k|    CoordIJK jVec = {0, 3, 1};
  538|  8.59k|    CoordIJK kVec = {1, 0, 3};
  539|       |
  540|  8.59k|    _ijkScale(&iVec, ijk->i);
  541|  8.59k|    _ijkScale(&jVec, ijk->j);
  542|  8.59k|    _ijkScale(&kVec, ijk->k);
  543|       |
  544|  8.59k|    _ijkAdd(&iVec, &jVec, ijk);
  545|  8.59k|    _ijkAdd(ijk, &kVec, ijk);
  546|       |
  547|  8.59k|    _ijkNormalize(ijk);
  548|  8.59k|}
h3Index.c:_ijkNormalize:
  207|  29.8k|static inline void _ijkNormalize(CoordIJK *c) {
  208|       |    // remove any negative values
  209|  29.8k|    if (c->i < 0) {
  ------------------
  |  Branch (209:9): [True: 208, False: 29.5k]
  ------------------
  210|    208|        c->j -= c->i;
  211|    208|        c->k -= c->i;
  212|    208|        c->i = 0;
  213|    208|    }
  214|       |
  215|  29.8k|    if (c->j < 0) {
  ------------------
  |  Branch (215:9): [True: 210, False: 29.5k]
  ------------------
  216|    210|        c->i -= c->j;
  217|    210|        c->k -= c->j;
  218|    210|        c->j = 0;
  219|    210|    }
  220|       |
  221|  29.8k|    if (c->k < 0) {
  ------------------
  |  Branch (221:9): [True: 0, False: 29.8k]
  ------------------
  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|  29.8k|    int min = c->i;
  229|  29.8k|    if (c->j < min) min = c->j;
  ------------------
  |  Branch (229:9): [True: 21.2k, False: 8.57k]
  ------------------
  230|  29.8k|    if (c->k < min) min = c->k;
  ------------------
  |  Branch (230:9): [True: 8.60k, False: 21.1k]
  ------------------
  231|  29.8k|    if (min > 0) {
  ------------------
  |  Branch (231:9): [True: 19.7k, False: 10.0k]
  ------------------
  232|  19.7k|        c->i -= min;
  233|  19.7k|        c->j -= min;
  234|  19.7k|        c->k -= min;
  235|  19.7k|    }
  236|  29.8k|}
h3Index.c:_neighbor:
  602|  16.0k|static inline void _neighbor(CoordIJK *ijk, Direction digit) {
  603|  16.0k|    if (digit > CENTER_DIGIT && digit < NUM_DIGITS) {
  ------------------
  |  Branch (603:9): [True: 12.3k, False: 3.76k]
  |  Branch (603:33): [True: 11.9k, False: 401]
  ------------------
  604|  11.9k|        _ijkAdd(ijk, &UNIT_VECS[digit], ijk);
  605|  11.9k|        _ijkNormalize(ijk);
  606|  11.9k|    }
  607|  16.0k|}
faceijk.c:_ijkRotate60ccw:
  614|  4.12k|static inline void _ijkRotate60ccw(CoordIJK *ijk) {
  615|       |    // unit vector rotations
  616|  4.12k|    CoordIJK iVec = {1, 1, 0};
  617|  4.12k|    CoordIJK jVec = {0, 1, 1};
  618|  4.12k|    CoordIJK kVec = {1, 0, 1};
  619|       |
  620|  4.12k|    _ijkScale(&iVec, ijk->i);
  621|  4.12k|    _ijkScale(&jVec, ijk->j);
  622|  4.12k|    _ijkScale(&kVec, ijk->k);
  623|       |
  624|  4.12k|    _ijkAdd(&iVec, &jVec, ijk);
  625|  4.12k|    _ijkAdd(ijk, &kVec, ijk);
  626|       |
  627|  4.12k|    _ijkNormalize(ijk);
  628|  4.12k|}
faceijk.c:_ijkScale:
  155|  19.6k|static inline void _ijkScale(CoordIJK *c, int factor) {
  156|  19.6k|    c->i *= factor;
  157|  19.6k|    c->j *= factor;
  158|  19.6k|    c->k *= factor;
  159|  19.6k|}
faceijk.c:_ijkAdd:
  129|  17.6k|                           CoordIJK *sum) {
  130|  17.6k|    sum->i = h1->i + h2->i;
  131|  17.6k|    sum->j = h1->j + h2->j;
  132|  17.6k|    sum->k = h1->k + h2->k;
  133|  17.6k|}
faceijk.c:_ijkNormalize:
  207|  11.3k|static inline void _ijkNormalize(CoordIJK *c) {
  208|       |    // remove any negative values
  209|  11.3k|    if (c->i < 0) {
  ------------------
  |  Branch (209:9): [True: 0, False: 11.3k]
  ------------------
  210|      0|        c->j -= c->i;
  211|      0|        c->k -= c->i;
  212|      0|        c->i = 0;
  213|      0|    }
  214|       |
  215|  11.3k|    if (c->j < 0) {
  ------------------
  |  Branch (215:9): [True: 0, False: 11.3k]
  ------------------
  216|      0|        c->i -= c->j;
  217|      0|        c->k -= c->j;
  218|      0|        c->j = 0;
  219|      0|    }
  220|       |
  221|  11.3k|    if (c->k < 0) {
  ------------------
  |  Branch (221:9): [True: 0, False: 11.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|  11.3k|    int min = c->i;
  229|  11.3k|    if (c->j < min) min = c->j;
  ------------------
  |  Branch (229:9): [True: 5.46k, False: 5.92k]
  ------------------
  230|  11.3k|    if (c->k < min) min = c->k;
  ------------------
  |  Branch (230:9): [True: 4.11k, False: 7.27k]
  ------------------
  231|  11.3k|    if (min > 0) {
  ------------------
  |  Branch (231:9): [True: 9.74k, False: 1.64k]
  ------------------
  232|  9.74k|        c->i -= min;
  233|  9.74k|        c->j -= min;
  234|  9.74k|        c->k -= min;
  235|  9.74k|    }
  236|  11.3k|}
faceijk.c:_downAp3:
  557|    657|static inline void _downAp3(CoordIJK *ijk) {
  558|       |    // res r unit vectors in res r+1
  559|    657|    CoordIJK iVec = {2, 0, 1};
  560|    657|    CoordIJK jVec = {1, 2, 0};
  561|    657|    CoordIJK kVec = {0, 1, 2};
  562|       |
  563|    657|    _ijkScale(&iVec, ijk->i);
  564|    657|    _ijkScale(&jVec, ijk->j);
  565|    657|    _ijkScale(&kVec, ijk->k);
  566|       |
  567|    657|    _ijkAdd(&iVec, &jVec, ijk);
  568|    657|    _ijkAdd(ijk, &kVec, ijk);
  569|       |
  570|    657|    _ijkNormalize(ijk);
  571|    657|}
faceijk.c:_downAp3r:
  579|    657|static inline void _downAp3r(CoordIJK *ijk) {
  580|       |    // res r unit vectors in res r+1
  581|    657|    CoordIJK iVec = {2, 1, 0};
  582|    657|    CoordIJK jVec = {0, 2, 1};
  583|    657|    CoordIJK kVec = {1, 0, 2};
  584|       |
  585|    657|    _ijkScale(&iVec, ijk->i);
  586|    657|    _ijkScale(&jVec, ijk->j);
  587|    657|    _ijkScale(&kVec, ijk->k);
  588|       |
  589|    657|    _ijkAdd(&iVec, &jVec, ijk);
  590|    657|    _ijkAdd(ijk, &kVec, ijk);
  591|       |
  592|    657|    _ijkNormalize(ijk);
  593|    657|}
faceijk.c:_downAp7r:
  534|    539|static inline void _downAp7r(CoordIJK *ijk) {
  535|       |    // res r unit vectors in res r+1
  536|    539|    CoordIJK iVec = {3, 1, 0};
  537|    539|    CoordIJK jVec = {0, 3, 1};
  538|    539|    CoordIJK kVec = {1, 0, 3};
  539|       |
  540|    539|    _ijkScale(&iVec, ijk->i);
  541|    539|    _ijkScale(&jVec, ijk->j);
  542|    539|    _ijkScale(&kVec, ijk->k);
  543|       |
  544|    539|    _ijkAdd(&iVec, &jVec, ijk);
  545|    539|    _ijkAdd(ijk, &kVec, ijk);
  546|       |
  547|    539|    _ijkNormalize(ijk);
  548|    539|}
faceijk.c:_setIJK:
  103|    121|static inline void _setIJK(CoordIJK *ijk, int i, int j, int k) {
  104|    121|    ijk->i = i;
  105|    121|    ijk->j = j;
  106|    121|    ijk->k = k;
  107|    121|}
faceijk.c:_ijkSub:
  143|    121|                           CoordIJK *diff) {
  144|    121|    diff->i = h1->i - h2->i;
  145|    121|    diff->j = h1->j - h2->j;
  146|    121|    diff->k = h1->k - h2->k;
  147|    121|}
faceijk.c:_ijkRotate60cw:
  635|    121|static inline void _ijkRotate60cw(CoordIJK *ijk) {
  636|       |    // unit vector rotations
  637|    121|    CoordIJK iVec = {1, 0, 1};
  638|    121|    CoordIJK jVec = {1, 1, 0};
  639|    121|    CoordIJK kVec = {0, 1, 1};
  640|       |
  641|    121|    _ijkScale(&iVec, ijk->i);
  642|    121|    _ijkScale(&jVec, ijk->j);
  643|    121|    _ijkScale(&kVec, ijk->k);
  644|       |
  645|    121|    _ijkAdd(&iVec, &jVec, ijk);
  646|    121|    _ijkAdd(ijk, &kVec, ijk);
  647|       |
  648|    121|    _ijkNormalize(ijk);
  649|    121|}

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

_isBaseCellPentagon:
  824|  10.6k|int _isBaseCellPentagon(int baseCell) {
  825|  10.6k|    if (baseCell < 0 || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |   81|  10.6k|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (825:9): [True: 0, False: 10.6k]
  |  Branch (825:25): [True: 10, False: 10.6k]
  ------------------
  826|       |        // Base cells less than zero can not be represented in an index
  827|     10|        return false;
  828|     10|    }
  829|  10.6k|    return baseCellData[baseCell].isPentagon;
  830|  10.6k|}
_isBaseCellPolarPentagon:
  834|    394|bool _isBaseCellPolarPentagon(int baseCell) {
  835|    394|    return baseCell == 4 || baseCell == 117;
  ------------------
  |  Branch (835:12): [True: 84, False: 310]
  |  Branch (835:29): [True: 71, False: 239]
  ------------------
  836|    394|}
_baseCellToFaceIjk:
  866|    829|void _baseCellToFaceIjk(int baseCell, FaceIJK *h) {
  867|    829|    *h = baseCellData[baseCell].homeFijk;
  868|    829|}
_baseCellToCCWrot60:
  877|    829|int _baseCellToCCWrot60(int baseCell, int face) {
  878|    829|    if (face < 0 || face >= NUM_ICOSA_FACES) return INVALID_ROTATIONS;
  ------------------
  |  |   79|    829|#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: 829]
  |  Branch (878:21): [True: 0, False: 829]
  ------------------
  879|  1.45k|    for (int i = 0; i < 3; i++) {
  ------------------
  |  Branch (879:21): [True: 1.45k, False: 0]
  ------------------
  880|  3.74k|        for (int j = 0; j < 3; j++) {
  ------------------
  |  Branch (880:25): [True: 3.11k, False: 626]
  ------------------
  881|  10.2k|            for (int k = 0; k < 3; k++) {
  ------------------
  |  Branch (881:29): [True: 7.98k, False: 2.28k]
  ------------------
  882|  7.98k|                if (faceIjkBaseCells[face][i][j][k].baseCell == baseCell) {
  ------------------
  |  Branch (882:21): [True: 829, False: 7.15k]
  ------------------
  883|    829|                    return faceIjkBaseCells[face][i][j][k].ccwRot60;
  884|    829|                }
  885|  7.98k|            }
  886|  3.11k|        }
  887|  1.45k|    }
  888|      0|    return INVALID_ROTATIONS;
  ------------------
  |  |   49|      0|#define INVALID_ROTATIONS -1
  ------------------
  889|    829|}
_baseCellIsCwOffset:
  893|     19|bool _baseCellIsCwOffset(int baseCell, int testFace) {
  894|     19|    return baseCellData[baseCell].cwOffsetPent[0] == testFace ||
  ------------------
  |  Branch (894:12): [True: 6, False: 13]
  ------------------
  895|     13|           baseCellData[baseCell].cwOffsetPent[1] == testFace;
  ------------------
  |  Branch (895:12): [True: 13, False: 0]
  ------------------
  896|     19|}

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

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

getResolution:
   87|    660|int H3_EXPORT(getResolution)(H3Index h) { return H3_GET_RESOLUTION(h); }
  ------------------
  |  |  129|    660|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    660|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    660|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    660|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
getBaseCellNumber:
   98|  1.48k|int H3_EXPORT(getBaseCellNumber)(H3Index h) { return H3_GET_BASE_CELL(h); }
  ------------------
  |  |  118|  1.48k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.48k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.48k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.48k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
getIndexDigit:
  116|    660|H3Error H3_EXPORT(getIndexDigit)(H3Index h, int res, int *out) {
  117|    660|    if (res < 1 || res > MAX_H3_RES) {
  ------------------
  |  |   76|    384|#define MAX_H3_RES 15
  ------------------
  |  Branch (117:9): [True: 276, False: 384]
  |  Branch (117:20): [True: 372, False: 12]
  ------------------
  118|    648|        return E_RES_DOMAIN;
  119|    648|    }
  120|     12|    *out = H3_GET_INDEX_DIGIT(h, res);
  ------------------
  |  |  141|     12|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|     12|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|     12|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|     12|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|     12|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  121|     12|    return E_SUCCESS;
  122|    660|}
isValidCell:
  343|  1.72k|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.72k|    if (!_hasGoodTopBits(h)) return false;
  ------------------
  |  Branch (365:9): [True: 1.08k, False: 643]
  ------------------
  366|       |
  367|       |    // No need to check resolution; any 4 bits give a valid resolution.
  368|    643|    const int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|    643|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    643|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    643|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    643|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  369|       |
  370|       |    // Get base cell number and check that it is valid.
  371|    643|    const int bc = H3_GET_BASE_CELL(h);
  ------------------
  |  |  118|    643|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|    643|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|    643|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|    643|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  372|    643|    if (bc >= NUM_BASE_CELLS) return false;
  ------------------
  |  |   81|    643|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (372:9): [True: 3, False: 640]
  ------------------
  373|       |
  374|    640|    if (_hasAny7UptoRes(h, res)) return false;
  ------------------
  |  Branch (374:9): [True: 76, False: 564]
  ------------------
  375|    564|    if (!_hasAll7AfterRes(h, res)) return false;
  ------------------
  |  Branch (375:9): [True: 125, False: 439]
  ------------------
  376|    439|    if (_hasDeletedSubsequence(h, bc)) return false;
  ------------------
  |  Branch (376:9): [True: 23, False: 416]
  ------------------
  377|       |
  378|       |    // If no disqualifications were identified, the index is a valid H3 cell.
  379|    416|    return true;
  380|    439|}
isValidIndex:
  388|    660|int H3_EXPORT(isValidIndex)(H3Index h) {
  389|    660|    return H3_EXPORT(isValidCell)(h) || H3_EXPORT(isValidDirectedEdge)(h) ||
  ------------------
  |  |   36|    660|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    660|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    660|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  return H3_EXPORT(isValidCell)(h) || H3_EXPORT(isValidDirectedEdge)(h) ||
  ------------------
  |  |   36|    614|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    660|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    660|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (389:12): [True: 46, False: 614]
  |  Branch (389:41): [True: 2, False: 612]
  ------------------
  390|    612|           H3_EXPORT(isValidVertex)(h);
  ------------------
  |  |   36|    612|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    660|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    660|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (390:12): [True: 80, False: 532]
  ------------------
  391|    660|}
makeDirectChild:
  483|     16|H3Index makeDirectChild(H3Index h, int cellNumber) {
  484|     16|    int childRes = H3_GET_RESOLUTION(h) + 1;
  ------------------
  |  |  129|     16|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|     16|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|     16|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|     16|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  485|     16|    H3Index childH = H3_SET_RESOLUTION(h, childRes);
  ------------------
  |  |  135|     16|    (h3) = (((h3)&H3_RES_MASK_NEGATIVE) | (((uint64_t)(res)) << H3_RES_OFFSET))
  |  |  ------------------
  |  |  |  |   71|     16|#define H3_RES_MASK_NEGATIVE (~H3_RES_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   68|     16|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|     16|#define H3_RES_OFFSET 52
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (h3) = (((h3)&H3_RES_MASK_NEGATIVE) | (((uint64_t)(res)) << H3_RES_OFFSET))
  |  |  ------------------
  |  |  |  |   41|     16|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  486|     16|    H3_SET_INDEX_DIGIT(childH, childRes, cellNumber);
  ------------------
  |  |  162|     16|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|     16|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|     16|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|     16|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|     16|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|     16|            (((uint64_t)(digit))                                            \
  |  |  165|     16|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|     16|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|     16|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  487|     16|    return childH;
  488|     16|}
isResClassIII:
  834|    660|int H3_EXPORT(isResClassIII)(H3Index h) { return H3_GET_RESOLUTION(h) % 2; }
  ------------------
  |  |  129|    660|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    660|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    660|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    660|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
isPentagon:
  841|  4.10k|int H3_EXPORT(isPentagon)(H3Index h) {
  842|  4.10k|    return _isBaseCellPentagon(H3_GET_BASE_CELL(h)) &&
  ------------------
  |  |  118|  4.10k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  4.10k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  4.10k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  4.10k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  |  Branch (842:12): [True: 2.00k, False: 2.10k]
  ------------------
  843|  2.00k|           !_h3LeadingNonZeroDigit(h);
  ------------------
  |  Branch (843:12): [True: 258, False: 1.74k]
  ------------------
  844|  4.10k|}
_h3LeadingNonZeroDigit:
  851|  5.64k|Direction _h3LeadingNonZeroDigit(H3Index h) {
  852|  18.7k|    for (int r = 1; r <= H3_GET_RESOLUTION(h); r++)
  ------------------
  |  |  129|  18.7k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  18.7k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  18.7k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  18.7k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (852:21): [True: 18.0k, False: 774]
  ------------------
  853|  18.0k|        if (H3_GET_INDEX_DIGIT(h, r)) return H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  18.0k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  18.0k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  18.0k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  |  Branch (141:5): [True: 4.87k, False: 13.1k]
  |  |  ------------------
  |  |  142|  18.0k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  18.0k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
                      if (H3_GET_INDEX_DIGIT(h, r)) return H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  4.87k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  4.87k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  4.87k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  4.87k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  4.87k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  854|       |
  855|       |    // if we're here it's all 0's
  856|    774|    return CENTER_DIGIT;
  857|  5.64k|}
_h3RotatePent60ccw:
  863|    139|H3Index _h3RotatePent60ccw(H3Index h) {
  864|       |    // rotate in place; skips any leading 1 digits (k-axis)
  865|       |
  866|    139|    int foundFirstNonZeroDigit = 0;
  867|  1.04k|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    139|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    139|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    139|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    139|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (867:49): [True: 909, False: 139]
  ------------------
  868|       |        // rotate this digit
  869|    909|        H3_SET_INDEX_DIGIT(h, r, _rotate60ccw(H3_GET_INDEX_DIGIT(h, r)));
  ------------------
  |  |  162|    909|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|    909|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|    909|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|    909|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|    909|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|    909|            (((uint64_t)(digit))                                            \
  |  |  165|    909|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|    909|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|    909|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  870|       |
  871|       |        // look for the first non-zero digit so we
  872|       |        // can adjust for deleted k-axes sequence
  873|       |        // if necessary
  874|    909|        if (!foundFirstNonZeroDigit && H3_GET_INDEX_DIGIT(h, r) != 0) {
  ------------------
  |  |  141|    112|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|    112|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|    112|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|    112|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|    112|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  |  Branch (874:13): [True: 112, False: 797]
  |  Branch (874:40): [True: 112, False: 0]
  ------------------
  875|    112|            foundFirstNonZeroDigit = 1;
  876|       |
  877|       |            // adjust for deleted k-axes sequence
  878|    112|            if (_h3LeadingNonZeroDigit(h) == K_AXES_DIGIT)
  ------------------
  |  Branch (878:17): [True: 40, False: 72]
  ------------------
  879|     40|                h = _h3Rotate60ccw(h);
  880|    112|        }
  881|    909|    }
  882|    139|    return h;
  883|    139|}
_h3Rotate60ccw:
  914|    314|H3Index _h3Rotate60ccw(H3Index h) {
  915|  1.73k|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    314|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    314|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    314|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    314|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (915:49): [True: 1.42k, False: 314]
  ------------------
  916|  1.42k|        Direction oldDigit = H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  1.42k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  1.42k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  1.42k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  1.42k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  1.42k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  917|  1.42k|        H3_SET_INDEX_DIGIT(h, r, _rotate60ccw(oldDigit));
  ------------------
  |  |  162|  1.42k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.42k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.42k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.42k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.42k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.42k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.42k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.42k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.42k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  918|  1.42k|    }
  919|       |
  920|    314|    return h;
  921|    314|}
_h3Rotate60cw:
  927|    169|H3Index _h3Rotate60cw(H3Index h) {
  928|  2.04k|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    169|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    169|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    169|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    169|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (928:49): [True: 1.87k, False: 169]
  ------------------
  929|  1.87k|        H3_SET_INDEX_DIGIT(h, r, _rotate60cw(H3_GET_INDEX_DIGIT(h, r)));
  ------------------
  |  |  162|  1.87k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.87k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.87k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.87k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.87k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.87k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.87k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.87k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.87k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  930|  1.87k|    }
  931|       |
  932|    169|    return h;
  933|    169|}
_h3ToFaceIjkWithInitializedFijk:
 1086|  1.48k|int _h3ToFaceIjkWithInitializedFijk(H3Index h, FaceIJK *fijk) {
 1087|  1.48k|    CoordIJK *ijk = &fijk->coord;
 1088|  1.48k|    int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|  1.48k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  1.48k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  1.48k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  1.48k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1089|       |
 1090|       |    // center base cell hierarchy is entirely on this face
 1091|  1.48k|    int possibleOverage = 1;
 1092|  1.48k|    if (!_isBaseCellPentagon(H3_GET_BASE_CELL(h)) &&
  ------------------
  |  |  118|  1.48k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.48k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.48k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.48k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  |  Branch (1092:9): [True: 771, False: 715]
  ------------------
 1093|    771|        (res == 0 ||
  ------------------
  |  Branch (1093:10): [True: 97, False: 674]
  ------------------
 1094|    674|         (fijk->coord.i == 0 && fijk->coord.j == 0 && fijk->coord.k == 0)))
  ------------------
  |  Branch (1094:11): [True: 393, False: 281]
  |  Branch (1094:33): [True: 164, False: 229]
  |  Branch (1094:55): [True: 61, False: 103]
  ------------------
 1095|    158|        possibleOverage = 0;
 1096|       |
 1097|  17.5k|    for (int r = 1; r <= res; r++) {
  ------------------
  |  Branch (1097:21): [True: 16.0k, False: 1.48k]
  ------------------
 1098|  16.0k|        if (isResolutionClassIII(r)) {
  ------------------
  |  Branch (1098:13): [True: 8.64k, False: 7.44k]
  ------------------
 1099|       |            // Class III == rotate ccw
 1100|  8.64k|            _downAp7(ijk);
 1101|  8.64k|        } else {
 1102|       |            // Class II == rotate cw
 1103|  7.44k|            _downAp7r(ijk);
 1104|  7.44k|        }
 1105|       |
 1106|  16.0k|        _neighbor(ijk, H3_GET_INDEX_DIGIT(h, r));
  ------------------
  |  |  141|  16.0k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  16.0k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  16.0k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  16.0k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  16.0k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
 1107|  16.0k|    }
 1108|       |
 1109|  1.48k|    return possibleOverage;
 1110|  1.48k|}
_h3ToFaceIjk:
 1117|  1.48k|H3Error _h3ToFaceIjk(H3Index h, FaceIJK *fijk) {
 1118|  1.48k|    int baseCell = H3_GET_BASE_CELL(h);
  ------------------
  |  |  118|  1.48k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.48k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.48k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.48k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
 1119|  1.48k|    if (NEVER(baseCell < 0) || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |  119|  2.97k|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 1.48k]
  |  |  |  Branch (119:19): [True: 0, False: 1.48k]
  |  |  ------------------
  ------------------
                  if (NEVER(baseCell < 0) || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |   81|  1.48k|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (1119:9): [Folded, False: 0]
  |  Branch (1119:9): [Folded, False: 0]
  |  Branch (1119:32): [True: 3, False: 1.48k]
  ------------------
 1120|       |        // Base cells less than zero can not be represented in an index
 1121|       |        // To prevent reading uninitialized memory, we zero the output.
 1122|      3|        fijk->face = 0;
 1123|      3|        fijk->coord.i = fijk->coord.j = fijk->coord.k = 0;
 1124|      3|        return E_CELL_INVALID;
 1125|      3|    }
 1126|       |    // adjust for the pentagonal missing sequence; all of sub-sequence 5 needs
 1127|       |    // to be adjusted (and some of sub-sequence 4 below)
 1128|  1.48k|    if (_isBaseCellPentagon(baseCell) && _h3LeadingNonZeroDigit(h) == 5)
  ------------------
  |  Branch (1128:9): [True: 715, False: 771]
  |  Branch (1128:42): [True: 133, False: 582]
  ------------------
 1129|    133|        h = _h3Rotate60cw(h);
 1130|       |
 1131|       |    // start with the "home" face and ijk+ coordinates for the base cell of c
 1132|  1.48k|    *fijk = baseCellData[baseCell].homeFijk;
 1133|  1.48k|    if (!_h3ToFaceIjkWithInitializedFijk(h, fijk))
  ------------------
  |  Branch (1133:9): [True: 158, False: 1.32k]
  ------------------
 1134|    158|        return E_SUCCESS;  // no overage is possible; h lies on this face
 1135|       |
 1136|       |    // if we're here we have the potential for an "overage"; i.e., it is
 1137|       |    // possible that c lies on an adjacent face
 1138|       |
 1139|  1.32k|    CoordIJK origIJK = fijk->coord;
 1140|       |
 1141|       |    // if we're in Class III, drop into the next finer Class II grid
 1142|  1.32k|    int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|  1.32k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  1.32k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  1.32k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  1.32k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1143|  1.32k|    if (isResolutionClassIII(res)) {
  ------------------
  |  Branch (1143:9): [True: 1.14k, False: 185]
  ------------------
 1144|       |        // Class III
 1145|  1.14k|        _downAp7r(&fijk->coord);
 1146|  1.14k|        res++;
 1147|  1.14k|    }
 1148|       |
 1149|       |    // adjust for overage if needed
 1150|       |    // a pentagon base cell with a leading 4 digit requires special handling
 1151|  1.32k|    int pentLeading4 =
 1152|  1.32k|        (_isBaseCellPentagon(baseCell) && _h3LeadingNonZeroDigit(h) == 4);
  ------------------
  |  Branch (1152:10): [True: 715, False: 613]
  |  Branch (1152:43): [True: 201, False: 514]
  ------------------
 1153|  1.32k|    if (_adjustOverageClassII(fijk, res, pentLeading4, 0) != NO_OVERAGE) {
  ------------------
  |  Branch (1153:9): [True: 710, False: 618]
  ------------------
 1154|       |        // if the base cell is a pentagon we have the potential for secondary
 1155|       |        // overages
 1156|    710|        if (_isBaseCellPentagon(baseCell)) {
  ------------------
  |  Branch (1156:13): [True: 563, False: 147]
  ------------------
 1157|    958|            while (_adjustOverageClassII(fijk, res, 0, 0) != NO_OVERAGE)
  ------------------
  |  Branch (1157:20): [True: 395, False: 563]
  ------------------
 1158|    395|                continue;
 1159|    563|        }
 1160|       |
 1161|    710|        if (res != H3_GET_RESOLUTION(h)) _upAp7r(&fijk->coord);
  ------------------
  |  |  129|    710|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    710|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    710|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    710|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (1161:13): [True: 630, False: 80]
  ------------------
 1162|    710|    } else if (res != H3_GET_RESOLUTION(h)) {
  ------------------
  |  |  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 (1162:16): [True: 513, False: 105]
  ------------------
 1163|    513|        fijk->coord = origIJK;
 1164|    513|    }
 1165|  1.32k|    return E_SUCCESS;
 1166|  1.48k|}
maxFaceCount:
 1229|  1.31k|H3Error H3_EXPORT(maxFaceCount)(H3Index h3, int *out) {
 1230|       |    // a pentagon always intersects 5 faces, a hexagon never intersects more
 1231|       |    // than 2 (but may only intersect 1)
 1232|  1.31k|    *out = H3_EXPORT(isPentagon)(h3) ? 5 : 2;
  ------------------
  |  |   36|  1.31k|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|  1.31k|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|  1.31k|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1232:12): [True: 48, False: 1.26k]
  ------------------
 1233|  1.31k|    return E_SUCCESS;
 1234|  1.31k|}
getIcosahedronFaces:
 1245|    676|H3Error H3_EXPORT(getIcosahedronFaces)(H3Index h3, int *out) {
 1246|    676|    int res = H3_GET_RESOLUTION(h3);
  ------------------
  |  |  129|    676|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    676|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    676|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    676|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1247|    676|    int isPent = H3_EXPORT(isPentagon)(h3);
  ------------------
  |  |   36|    676|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    676|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    676|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1248|       |
 1249|       |    // We can't use the vertex-based approach here for class II pentagons,
 1250|       |    // because all their vertices are on the icosahedron edges. Their
 1251|       |    // direct child pentagons cross the same faces, so use those instead.
 1252|    676|    if (isPent && !isResolutionClassIII(res)) {
  ------------------
  |  Branch (1252:9): [True: 40, False: 636]
  |  Branch (1252:19): [True: 16, False: 24]
  ------------------
 1253|       |        // Note that this would not work for res 15, but this is only run on
 1254|       |        // Class II pentagons, it should never be invoked for a res 15 index.
 1255|     16|        H3Index childPentagon = makeDirectChild(h3, 0);
 1256|     16|        return H3_EXPORT(getIcosahedronFaces)(childPentagon, out);
  ------------------
  |  |   36|     16|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|     16|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|     16|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1257|     16|    }
 1258|       |
 1259|       |    // convert to FaceIJK
 1260|    660|    FaceIJK fijk;
 1261|    660|    H3Error err = _h3ToFaceIjk(h3, &fijk);
 1262|    660|    if (err) {
  ------------------
  |  Branch (1262:9): [True: 3, False: 657]
  ------------------
 1263|      3|        return err;
 1264|      3|    }
 1265|       |
 1266|       |    // Get all vertices as FaceIJK addresses. For simplicity, always
 1267|       |    // initialize the array with 6 verts, ignoring the last one for pentagons
 1268|    657|    FaceIJK fijkVerts[NUM_HEX_VERTS];
 1269|    657|    int vertexCount;
 1270|       |
 1271|    657|    if (isPent) {
  ------------------
  |  Branch (1271:9): [True: 24, False: 633]
  ------------------
 1272|     24|        vertexCount = NUM_PENT_VERTS;
  ------------------
  |  |   85|     24|#define NUM_PENT_VERTS 5
  ------------------
 1273|     24|        _faceIjkPentToVerts(&fijk, &res, fijkVerts);
 1274|    633|    } else {
 1275|    633|        vertexCount = NUM_HEX_VERTS;
  ------------------
  |  |   83|    633|#define NUM_HEX_VERTS 6
  ------------------
 1276|    633|        _faceIjkToVerts(&fijk, &res, fijkVerts);
 1277|    633|    }
 1278|       |
 1279|       |    // We may not use all of the slots in the output array,
 1280|       |    // so fill with invalid values to indicate unused slots
 1281|    657|    int faceCount;
 1282|    657|    H3Error maxFaceCountError = H3_EXPORT(maxFaceCount)(h3, &faceCount);
  ------------------
  |  |   36|    657|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    657|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    657|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1283|    657|    if (NEVER(maxFaceCountError != E_SUCCESS)) {
  ------------------
  |  |  119|    657|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 657]
  |  |  |  Branch (119:19): [True: 0, False: 657]
  |  |  ------------------
  ------------------
  |  Branch (1283:9): [Folded, False: 0]
  |  Branch (1283:9): [Folded, False: 0]
  ------------------
 1284|      0|        return maxFaceCountError;
 1285|      0|    }
 1286|  2.04k|    for (int i = 0; i < faceCount; i++) {
  ------------------
  |  Branch (1286:21): [True: 1.38k, False: 657]
  ------------------
 1287|  1.38k|        out[i] = INVALID_FACE;
  ------------------
  |  |   60|  1.38k|#define INVALID_FACE -1
  ------------------
 1288|  1.38k|    }
 1289|       |
 1290|       |    // add each vertex face, using the output array as a hash set
 1291|  4.57k|    for (int i = 0; i < vertexCount; i++) {
  ------------------
  |  Branch (1291:21): [True: 3.91k, False: 655]
  ------------------
 1292|  3.91k|        FaceIJK *vert = &fijkVerts[i];
 1293|       |
 1294|       |        // Adjust overage, determining whether this vertex is
 1295|       |        // on another face
 1296|  3.91k|        if (isPent) {
  ------------------
  |  Branch (1296:13): [True: 120, False: 3.79k]
  ------------------
 1297|    120|            _adjustPentVertOverage(vert, res);
 1298|  3.79k|        } else {
 1299|  3.79k|            _adjustOverageClassII(vert, res, 0, 1);
 1300|  3.79k|        }
 1301|       |
 1302|       |        // Save the face to the output array
 1303|  3.91k|        int face = vert->face;
 1304|  3.91k|        int pos = 0;
 1305|       |        // Find the first empty output position, or the first position
 1306|       |        // matching the current face
 1307|  4.30k|        while (out[pos] != INVALID_FACE && out[pos] != face) {
  ------------------
  |  |   60|  8.61k|#define INVALID_FACE -1
  ------------------
  |  Branch (1307:16): [True: 3.49k, False: 817]
  |  Branch (1307:44): [True: 396, False: 3.09k]
  ------------------
 1308|    396|            pos++;
 1309|    396|            if (pos >= faceCount) {
  ------------------
  |  Branch (1309:17): [True: 2, False: 394]
  ------------------
 1310|       |                // Mismatch between the heuristic used in maxFaceCount and
 1311|       |                // calculation here - indicates an invalid index.
 1312|      2|                return E_FAILED;
 1313|      2|            }
 1314|    396|        }
 1315|  3.91k|        out[pos] = face;
 1316|  3.91k|    }
 1317|    655|    return E_SUCCESS;
 1318|    657|}
isResolutionClassIII:
 1355|  21.8k|int isResolutionClassIII(int res) { return res % 2; }
h3Index.c:_hasGoodTopBits:
  216|  1.72k|static inline bool _hasGoodTopBits(H3Index h) {
  217|  1.72k|    h >>= (64 - 8);
  218|  1.72k|    return h == 0b00001000;
  219|  1.72k|}
h3Index.c:_hasAny7UptoRes:
  264|    640|static inline bool _hasAny7UptoRes(H3Index h, int res) {
  265|    640|    const uint64_t MHI = 0b100100100100100100100100100100100100100100100;
  266|    640|    const uint64_t MLO = MHI >> 2;
  267|       |
  268|    640|    int shift = 3 * (15 - res);
  269|    640|    h >>= shift;
  270|    640|    h <<= shift;
  271|    640|    h = (h & MHI & (~h - MLO));
  272|       |
  273|    640|    return h != 0;
  274|    640|}
h3Index.c:_hasAll7AfterRes:
  280|    564|static inline bool _hasAll7AfterRes(H3Index h, int res) {
  281|       |    // NOTE: res check is needed because we can't shift by 64
  282|    564|    if (res < 15) {
  ------------------
  |  Branch (282:9): [True: 284, False: 280]
  ------------------
  283|    284|        int shift = 19 + 3 * res;
  284|       |
  285|    284|        h = ~h;
  286|    284|        h <<= shift;
  287|    284|        h >>= shift;
  288|       |
  289|    284|        return h == 0;
  290|    284|    }
  291|    280|    return true;
  292|    564|}
h3Index.c:_hasDeletedSubsequence:
  327|    439|static inline bool _hasDeletedSubsequence(H3Index h, int base_cell) {
  328|    439|    if (isBaseCellPentagonArr[base_cell]) {
  ------------------
  |  Branch (328:9): [True: 257, False: 182]
  ------------------
  329|    257|        h <<= 19;
  330|    257|        h >>= 19;
  331|       |
  332|    257|        if (h == 0) return false;  // all zeros: res 15 pentagon
  ------------------
  |  Branch (332:13): [True: 6, False: 251]
  ------------------
  333|    251|        return _firstOneIndex(h) % 3 == 0;
  334|    257|    }
  335|    182|    return false;
  336|    439|}
h3Index.c:_firstOneIndex:
  300|    251|static inline int _firstOneIndex(H3Index h) {
  301|    251|#if defined(__GNUC__) || defined(__clang__)
  302|    251|    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|    251|}

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

