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

h3Index.c:_rotate60ccw:
  656|  1.90k|static inline Direction _rotate60ccw(Direction digit) {
  657|  1.90k|    switch (digit) {
  658|    356|        case K_AXES_DIGIT:
  ------------------
  |  Branch (658:9): [True: 356, False: 1.55k]
  ------------------
  659|    356|            return IK_AXES_DIGIT;
  660|    305|        case IK_AXES_DIGIT:
  ------------------
  |  Branch (660:9): [True: 305, False: 1.60k]
  ------------------
  661|    305|            return I_AXES_DIGIT;
  662|    260|        case I_AXES_DIGIT:
  ------------------
  |  Branch (662:9): [True: 260, False: 1.64k]
  ------------------
  663|    260|            return IJ_AXES_DIGIT;
  664|    267|        case IJ_AXES_DIGIT:
  ------------------
  |  Branch (664:9): [True: 267, False: 1.64k]
  ------------------
  665|    267|            return J_AXES_DIGIT;
  666|    312|        case J_AXES_DIGIT:
  ------------------
  |  Branch (666:9): [True: 312, False: 1.59k]
  ------------------
  667|    312|            return JK_AXES_DIGIT;
  668|    347|        case JK_AXES_DIGIT:
  ------------------
  |  Branch (668:9): [True: 347, False: 1.56k]
  ------------------
  669|    347|            return K_AXES_DIGIT;
  670|     60|        default:
  ------------------
  |  Branch (670:9): [True: 60, False: 1.84k]
  ------------------
  671|     60|            return digit;
  672|  1.90k|    }
  673|  1.90k|}
h3Index.c:_rotate60cw:
  680|  1.45k|static inline Direction _rotate60cw(Direction digit) {
  681|  1.45k|    switch (digit) {
  682|    175|        case K_AXES_DIGIT:
  ------------------
  |  Branch (682:9): [True: 175, False: 1.28k]
  ------------------
  683|    175|            return JK_AXES_DIGIT;
  684|    157|        case JK_AXES_DIGIT:
  ------------------
  |  Branch (684:9): [True: 157, False: 1.30k]
  ------------------
  685|    157|            return J_AXES_DIGIT;
  686|     98|        case J_AXES_DIGIT:
  ------------------
  |  Branch (686:9): [True: 98, False: 1.36k]
  ------------------
  687|     98|            return IJ_AXES_DIGIT;
  688|     94|        case IJ_AXES_DIGIT:
  ------------------
  |  Branch (688:9): [True: 94, False: 1.36k]
  ------------------
  689|     94|            return I_AXES_DIGIT;
  690|    150|        case I_AXES_DIGIT:
  ------------------
  |  Branch (690:9): [True: 150, False: 1.30k]
  ------------------
  691|    150|            return IK_AXES_DIGIT;
  692|    272|        case IK_AXES_DIGIT:
  ------------------
  |  Branch (692:9): [True: 272, False: 1.18k]
  ------------------
  693|    272|            return K_AXES_DIGIT;
  694|    512|        default:
  ------------------
  |  Branch (694:9): [True: 512, False: 946]
  ------------------
  695|    512|            return digit;
  696|  1.45k|    }
  697|  1.45k|}
h3Index.c:_downAp7:
  512|  7.51k|static inline void _downAp7(CoordIJK *ijk) {
  513|       |    // res r unit vectors in res r+1
  514|  7.51k|    CoordIJK iVec = {3, 0, 1};
  515|  7.51k|    CoordIJK jVec = {1, 3, 0};
  516|  7.51k|    CoordIJK kVec = {0, 1, 3};
  517|       |
  518|  7.51k|    _ijkScale(&iVec, ijk->i);
  519|  7.51k|    _ijkScale(&jVec, ijk->j);
  520|  7.51k|    _ijkScale(&kVec, ijk->k);
  521|       |
  522|  7.51k|    _ijkAdd(&iVec, &jVec, ijk);
  523|  7.51k|    _ijkAdd(ijk, &kVec, ijk);
  524|       |
  525|  7.51k|    _ijkNormalize(ijk);
  526|  7.51k|}
h3Index.c:_ijkScale:
  155|  44.9k|static inline void _ijkScale(CoordIJK *c, int factor) {
  156|  44.9k|    c->i *= factor;
  157|  44.9k|    c->j *= factor;
  158|  44.9k|    c->k *= factor;
  159|  44.9k|}
h3Index.c:_ijkAdd:
  129|  40.4k|                           CoordIJK *sum) {
  130|  40.4k|    sum->i = h1->i + h2->i;
  131|  40.4k|    sum->j = h1->j + h2->j;
  132|  40.4k|    sum->k = h1->k + h2->k;
  133|  40.4k|}
h3Index.c:_upAp7r:
  494|    487|static inline void _upAp7r(CoordIJK *ijk) {
  495|       |    // convert to CoordIJ
  496|    487|    int i = ijk->i - ijk->k;
  497|    487|    int j = ijk->j - ijk->k;
  498|       |
  499|    487|    ijk->i = (int)lround((2 * i + j) * M_ONESEVENTH);
  ------------------
  |  |   54|    487|#define M_ONESEVENTH 0.14285714285714285714285714285714285
  ------------------
  500|    487|    ijk->j = (int)lround((3 * j - i) * M_ONESEVENTH);
  ------------------
  |  |   54|    487|#define M_ONESEVENTH 0.14285714285714285714285714285714285
  ------------------
  501|    487|    ijk->k = 0;
  502|    487|    _ijkNormalize(ijk);
  503|    487|}
h3Index.c:_downAp7r:
  534|  7.48k|static inline void _downAp7r(CoordIJK *ijk) {
  535|       |    // res r unit vectors in res r+1
  536|  7.48k|    CoordIJK iVec = {3, 1, 0};
  537|  7.48k|    CoordIJK jVec = {0, 3, 1};
  538|  7.48k|    CoordIJK kVec = {1, 0, 3};
  539|       |
  540|  7.48k|    _ijkScale(&iVec, ijk->i);
  541|  7.48k|    _ijkScale(&jVec, ijk->j);
  542|  7.48k|    _ijkScale(&kVec, ijk->k);
  543|       |
  544|  7.48k|    _ijkAdd(&iVec, &jVec, ijk);
  545|  7.48k|    _ijkAdd(ijk, &kVec, ijk);
  546|       |
  547|  7.48k|    _ijkNormalize(ijk);
  548|  7.48k|}
h3Index.c:_ijkNormalize:
  207|  25.9k|static inline void _ijkNormalize(CoordIJK *c) {
  208|       |    // remove any negative values
  209|  25.9k|    if (c->i < 0) {
  ------------------
  |  Branch (209:9): [True: 186, False: 25.7k]
  ------------------
  210|    186|        c->j -= c->i;
  211|    186|        c->k -= c->i;
  212|    186|        c->i = 0;
  213|    186|    }
  214|       |
  215|  25.9k|    if (c->j < 0) {
  ------------------
  |  Branch (215:9): [True: 176, False: 25.7k]
  ------------------
  216|    176|        c->i -= c->j;
  217|    176|        c->k -= c->j;
  218|    176|        c->j = 0;
  219|    176|    }
  220|       |
  221|  25.9k|    if (c->k < 0) {
  ------------------
  |  Branch (221:9): [True: 0, False: 25.9k]
  ------------------
  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|  25.9k|    int min = c->i;
  229|  25.9k|    if (c->j < min) min = c->j;
  ------------------
  |  Branch (229:9): [True: 17.7k, False: 8.25k]
  ------------------
  230|  25.9k|    if (c->k < min) min = c->k;
  ------------------
  |  Branch (230:9): [True: 7.62k, False: 18.3k]
  ------------------
  231|  25.9k|    if (min > 0) {
  ------------------
  |  Branch (231:9): [True: 17.0k, False: 8.91k]
  ------------------
  232|  17.0k|        c->i -= min;
  233|  17.0k|        c->j -= min;
  234|  17.0k|        c->k -= min;
  235|  17.0k|    }
  236|  25.9k|}
h3Index.c:_neighbor:
  602|  14.0k|static inline void _neighbor(CoordIJK *ijk, Direction digit) {
  603|  14.0k|    if (digit > CENTER_DIGIT && digit < NUM_DIGITS) {
  ------------------
  |  Branch (603:9): [True: 10.9k, False: 3.09k]
  |  Branch (603:33): [True: 10.4k, False: 449]
  ------------------
  604|  10.4k|        _ijkAdd(ijk, &UNIT_VECS[digit], ijk);
  605|  10.4k|        _ijkNormalize(ijk);
  606|  10.4k|    }
  607|  14.0k|}
faceijk.c:_ijkRotate60ccw:
  614|  3.43k|static inline void _ijkRotate60ccw(CoordIJK *ijk) {
  615|       |    // unit vector rotations
  616|  3.43k|    CoordIJK iVec = {1, 1, 0};
  617|  3.43k|    CoordIJK jVec = {0, 1, 1};
  618|  3.43k|    CoordIJK kVec = {1, 0, 1};
  619|       |
  620|  3.43k|    _ijkScale(&iVec, ijk->i);
  621|  3.43k|    _ijkScale(&jVec, ijk->j);
  622|  3.43k|    _ijkScale(&kVec, ijk->k);
  623|       |
  624|  3.43k|    _ijkAdd(&iVec, &jVec, ijk);
  625|  3.43k|    _ijkAdd(ijk, &kVec, ijk);
  626|       |
  627|  3.43k|    _ijkNormalize(ijk);
  628|  3.43k|}
faceijk.c:_ijkScale:
  155|  16.5k|static inline void _ijkScale(CoordIJK *c, int factor) {
  156|  16.5k|    c->i *= factor;
  157|  16.5k|    c->j *= factor;
  158|  16.5k|    c->k *= factor;
  159|  16.5k|}
faceijk.c:_ijkAdd:
  129|  14.9k|                           CoordIJK *sum) {
  130|  14.9k|    sum->i = h1->i + h2->i;
  131|  14.9k|    sum->j = h1->j + h2->j;
  132|  14.9k|    sum->k = h1->k + h2->k;
  133|  14.9k|}
faceijk.c:_ijkNormalize:
  207|  9.75k|static inline void _ijkNormalize(CoordIJK *c) {
  208|       |    // remove any negative values
  209|  9.75k|    if (c->i < 0) {
  ------------------
  |  Branch (209:9): [True: 0, False: 9.75k]
  ------------------
  210|      0|        c->j -= c->i;
  211|      0|        c->k -= c->i;
  212|      0|        c->i = 0;
  213|      0|    }
  214|       |
  215|  9.75k|    if (c->j < 0) {
  ------------------
  |  Branch (215:9): [True: 0, False: 9.75k]
  ------------------
  216|      0|        c->i -= c->j;
  217|      0|        c->k -= c->j;
  218|      0|        c->j = 0;
  219|      0|    }
  220|       |
  221|  9.75k|    if (c->k < 0) {
  ------------------
  |  Branch (221:9): [True: 0, False: 9.75k]
  ------------------
  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|  9.75k|    int min = c->i;
  229|  9.75k|    if (c->j < min) min = c->j;
  ------------------
  |  Branch (229:9): [True: 4.65k, False: 5.09k]
  ------------------
  230|  9.75k|    if (c->k < min) min = c->k;
  ------------------
  |  Branch (230:9): [True: 3.38k, False: 6.37k]
  ------------------
  231|  9.75k|    if (min > 0) {
  ------------------
  |  Branch (231:9): [True: 8.29k, False: 1.46k]
  ------------------
  232|  8.29k|        c->i -= min;
  233|  8.29k|        c->j -= min;
  234|  8.29k|        c->k -= min;
  235|  8.29k|    }
  236|  9.75k|}
faceijk.c:_downAp3:
  557|    582|static inline void _downAp3(CoordIJK *ijk) {
  558|       |    // res r unit vectors in res r+1
  559|    582|    CoordIJK iVec = {2, 0, 1};
  560|    582|    CoordIJK jVec = {1, 2, 0};
  561|    582|    CoordIJK kVec = {0, 1, 2};
  562|       |
  563|    582|    _ijkScale(&iVec, ijk->i);
  564|    582|    _ijkScale(&jVec, ijk->j);
  565|    582|    _ijkScale(&kVec, ijk->k);
  566|       |
  567|    582|    _ijkAdd(&iVec, &jVec, ijk);
  568|    582|    _ijkAdd(ijk, &kVec, ijk);
  569|       |
  570|    582|    _ijkNormalize(ijk);
  571|    582|}
faceijk.c:_downAp3r:
  579|    582|static inline void _downAp3r(CoordIJK *ijk) {
  580|       |    // res r unit vectors in res r+1
  581|    582|    CoordIJK iVec = {2, 1, 0};
  582|    582|    CoordIJK jVec = {0, 2, 1};
  583|    582|    CoordIJK kVec = {1, 0, 2};
  584|       |
  585|    582|    _ijkScale(&iVec, ijk->i);
  586|    582|    _ijkScale(&jVec, ijk->j);
  587|    582|    _ijkScale(&kVec, ijk->k);
  588|       |
  589|    582|    _ijkAdd(&iVec, &jVec, ijk);
  590|    582|    _ijkAdd(ijk, &kVec, ijk);
  591|       |
  592|    582|    _ijkNormalize(ijk);
  593|    582|}
faceijk.c:_downAp7r:
  534|    452|static inline void _downAp7r(CoordIJK *ijk) {
  535|       |    // res r unit vectors in res r+1
  536|    452|    CoordIJK iVec = {3, 1, 0};
  537|    452|    CoordIJK jVec = {0, 3, 1};
  538|    452|    CoordIJK kVec = {1, 0, 3};
  539|       |
  540|    452|    _ijkScale(&iVec, ijk->i);
  541|    452|    _ijkScale(&jVec, ijk->j);
  542|    452|    _ijkScale(&kVec, ijk->k);
  543|       |
  544|    452|    _ijkAdd(&iVec, &jVec, ijk);
  545|    452|    _ijkAdd(ijk, &kVec, ijk);
  546|       |
  547|    452|    _ijkNormalize(ijk);
  548|    452|}
faceijk.c:_setIJK:
  103|     84|static inline void _setIJK(CoordIJK *ijk, int i, int j, int k) {
  104|     84|    ijk->i = i;
  105|     84|    ijk->j = j;
  106|     84|    ijk->k = k;
  107|     84|}
faceijk.c:_ijkSub:
  143|     84|                           CoordIJK *diff) {
  144|     84|    diff->i = h1->i - h2->i;
  145|     84|    diff->j = h1->j - h2->j;
  146|     84|    diff->k = h1->k - h2->k;
  147|     84|}
faceijk.c:_ijkRotate60cw:
  635|     84|static inline void _ijkRotate60cw(CoordIJK *ijk) {
  636|       |    // unit vector rotations
  637|     84|    CoordIJK iVec = {1, 0, 1};
  638|     84|    CoordIJK jVec = {1, 1, 0};
  639|     84|    CoordIJK kVec = {0, 1, 1};
  640|       |
  641|     84|    _ijkScale(&iVec, ijk->i);
  642|     84|    _ijkScale(&jVec, ijk->j);
  643|     84|    _ijkScale(&kVec, ijk->k);
  644|       |
  645|     84|    _ijkAdd(&iVec, &jVec, ijk);
  646|     84|    _ijkAdd(ijk, &kVec, ijk);
  647|       |
  648|     84|    _ijkNormalize(ijk);
  649|     84|}

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

_isBaseCellPentagon:
  824|  9.30k|int _isBaseCellPentagon(int baseCell) {
  825|  9.30k|    if (baseCell < 0 || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |   81|  9.30k|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (825:9): [True: 0, False: 9.30k]
  |  Branch (825:25): [True: 10, False: 9.29k]
  ------------------
  826|       |        // Base cells less than zero can not be represented in an index
  827|     10|        return false;
  828|     10|    }
  829|  9.29k|    return baseCellData[baseCell].isPentagon;
  830|  9.30k|}
_isBaseCellPolarPentagon:
  834|    325|bool _isBaseCellPolarPentagon(int baseCell) {
  835|    325|    return baseCell == 4 || baseCell == 117;
  ------------------
  |  Branch (835:12): [True: 67, False: 258]
  |  Branch (835:29): [True: 68, False: 190]
  ------------------
  836|    325|}
_baseCellToFaceIjk:
  866|    714|void _baseCellToFaceIjk(int baseCell, FaceIJK *h) {
  867|    714|    *h = baseCellData[baseCell].homeFijk;
  868|    714|}
_baseCellToCCWrot60:
  877|    714|int _baseCellToCCWrot60(int baseCell, int face) {
  878|    714|    if (face < 0 || face >= NUM_ICOSA_FACES) return INVALID_ROTATIONS;
  ------------------
  |  |   79|    714|#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: 714]
  |  Branch (878:21): [True: 0, False: 714]
  ------------------
  879|  1.24k|    for (int i = 0; i < 3; i++) {
  ------------------
  |  Branch (879:21): [True: 1.24k, False: 0]
  ------------------
  880|  3.15k|        for (int j = 0; j < 3; j++) {
  ------------------
  |  Branch (880:25): [True: 2.61k, False: 533]
  ------------------
  881|  8.60k|            for (int k = 0; k < 3; k++) {
  ------------------
  |  Branch (881:29): [True: 6.69k, False: 1.90k]
  ------------------
  882|  6.69k|                if (faceIjkBaseCells[face][i][j][k].baseCell == baseCell) {
  ------------------
  |  Branch (882:21): [True: 714, False: 5.98k]
  ------------------
  883|    714|                    return faceIjkBaseCells[face][i][j][k].ccwRot60;
  884|    714|                }
  885|  6.69k|            }
  886|  2.61k|        }
  887|  1.24k|    }
  888|      0|    return INVALID_ROTATIONS;
  ------------------
  |  |   49|      0|#define INVALID_ROTATIONS -1
  ------------------
  889|    714|}
_baseCellIsCwOffset:
  893|     19|bool _baseCellIsCwOffset(int baseCell, int testFace) {
  894|     19|    return baseCellData[baseCell].cwOffsetPent[0] == testFace ||
  ------------------
  |  Branch (894:12): [True: 11, False: 8]
  ------------------
  895|      8|           baseCellData[baseCell].cwOffsetPent[1] == testFace;
  ------------------
  |  Branch (895:12): [True: 8, False: 0]
  ------------------
  896|     19|}

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

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

getResolution:
   87|    585|int H3_EXPORT(getResolution)(H3Index h) { return H3_GET_RESOLUTION(h); }
  ------------------
  |  |  129|    585|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    585|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    585|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    585|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
getBaseCellNumber:
   98|  1.29k|int H3_EXPORT(getBaseCellNumber)(H3Index h) { return H3_GET_BASE_CELL(h); }
  ------------------
  |  |  118|  1.29k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.29k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.29k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.29k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
getIndexDigit:
  116|    585|H3Error H3_EXPORT(getIndexDigit)(H3Index h, int res, int *out) {
  117|    585|    if (res < 1 || res > MAX_H3_RES) {
  ------------------
  |  |   76|    325|#define MAX_H3_RES 15
  ------------------
  |  Branch (117:9): [True: 260, False: 325]
  |  Branch (117:20): [True: 317, False: 8]
  ------------------
  118|    577|        return E_RES_DOMAIN;
  119|    577|    }
  120|      8|    *out = H3_GET_INDEX_DIGIT(h, res);
  ------------------
  |  |  141|      8|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|      8|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|      8|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|      8|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|      8|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  121|      8|    return E_SUCCESS;
  122|    585|}
isValidCell:
  343|  1.50k|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.50k|    if (!_hasGoodTopBits(h)) return false;
  ------------------
  |  Branch (365:9): [True: 957, False: 547]
  ------------------
  366|       |
  367|       |    // No need to check resolution; any 4 bits give a valid resolution.
  368|    547|    const int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|    547|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    547|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    547|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    547|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  369|       |
  370|       |    // Get base cell number and check that it is valid.
  371|    547|    const int bc = H3_GET_BASE_CELL(h);
  ------------------
  |  |  118|    547|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|    547|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|    547|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|    547|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  372|    547|    if (bc >= NUM_BASE_CELLS) return false;
  ------------------
  |  |   81|    547|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (372:9): [True: 3, False: 544]
  ------------------
  373|       |
  374|    544|    if (_hasAny7UptoRes(h, res)) return false;
  ------------------
  |  Branch (374:9): [True: 79, False: 465]
  ------------------
  375|    465|    if (!_hasAll7AfterRes(h, res)) return false;
  ------------------
  |  Branch (375:9): [True: 113, False: 352]
  ------------------
  376|    352|    if (_hasDeletedSubsequence(h, bc)) return false;
  ------------------
  |  Branch (376:9): [True: 10, False: 342]
  ------------------
  377|       |
  378|       |    // If no disqualifications were identified, the index is a valid H3 cell.
  379|    342|    return true;
  380|    352|}
isValidIndex:
  388|    585|int H3_EXPORT(isValidIndex)(H3Index h) {
  389|    585|    return H3_EXPORT(isValidCell)(h) || H3_EXPORT(isValidDirectedEdge)(h) ||
  ------------------
  |  |   36|    585|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    585|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    585|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  return H3_EXPORT(isValidCell)(h) || H3_EXPORT(isValidDirectedEdge)(h) ||
  ------------------
  |  |   36|    555|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    585|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    585|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (389:12): [True: 30, False: 555]
  |  Branch (389:41): [True: 4, False: 551]
  ------------------
  390|    551|           H3_EXPORT(isValidVertex)(h);
  ------------------
  |  |   36|    551|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    585|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    585|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (390:12): [True: 84, False: 467]
  ------------------
  391|    585|}
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:
  838|    585|int H3_EXPORT(isResClassIII)(H3Index h) { return H3_GET_RESOLUTION(h) % 2; }
  ------------------
  |  |  129|    585|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    585|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    585|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    585|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
isPentagon:
  845|  3.58k|int H3_EXPORT(isPentagon)(H3Index h) {
  846|  3.58k|    return _isBaseCellPentagon(H3_GET_BASE_CELL(h)) &&
  ------------------
  |  |  118|  3.58k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  3.58k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  3.58k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  3.58k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  |  Branch (846:12): [True: 1.63k, False: 1.94k]
  ------------------
  847|  1.63k|           !_h3LeadingNonZeroDigit(h);
  ------------------
  |  Branch (847:12): [True: 194, False: 1.43k]
  ------------------
  848|  3.58k|}
_h3LeadingNonZeroDigit:
  855|  4.69k|Direction _h3LeadingNonZeroDigit(H3Index h) {
  856|  16.5k|    for (int r = 1; r <= H3_GET_RESOLUTION(h); r++)
  ------------------
  |  |  129|  16.5k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  16.5k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  16.5k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  16.5k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (856:21): [True: 15.9k, False: 563]
  ------------------
  857|  15.9k|        if (H3_GET_INDEX_DIGIT(h, r)) return H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  15.9k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  15.9k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  15.9k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  |  Branch (141:5): [True: 4.13k, False: 11.8k]
  |  |  ------------------
  |  |  142|  15.9k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  15.9k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
                      if (H3_GET_INDEX_DIGIT(h, r)) return H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  4.13k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  4.13k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  4.13k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  4.13k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  4.13k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  858|       |
  859|       |    // if we're here it's all 0's
  860|    563|    return CENTER_DIGIT;
  861|  4.69k|}
_h3RotatePent60ccw:
  867|    118|H3Index _h3RotatePent60ccw(H3Index h) {
  868|       |    // rotate in place; skips any leading 1 digits (k-axis)
  869|       |
  870|    118|    int foundFirstNonZeroDigit = 0;
  871|    984|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    118|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    118|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    118|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    118|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (871:49): [True: 866, False: 118]
  ------------------
  872|       |        // rotate this digit
  873|    866|        H3_SET_INDEX_DIGIT(h, r, _rotate60ccw(H3_GET_INDEX_DIGIT(h, r)));
  ------------------
  |  |  162|    866|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|    866|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|    866|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|    866|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|    866|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|    866|            (((uint64_t)(digit))                                            \
  |  |  165|    866|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|    866|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|    866|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  874|       |
  875|       |        // look for the first non-zero digit so we
  876|       |        // can adjust for deleted k-axes sequence
  877|       |        // if necessary
  878|    866|        if (!foundFirstNonZeroDigit && H3_GET_INDEX_DIGIT(h, r) != 0) {
  ------------------
  |  |  141|    101|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|    101|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|    101|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|    101|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|    101|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  |  Branch (878:13): [True: 101, False: 765]
  |  Branch (878:40): [True: 101, False: 0]
  ------------------
  879|    101|            foundFirstNonZeroDigit = 1;
  880|       |
  881|       |            // adjust for deleted k-axes sequence
  882|    101|            if (_h3LeadingNonZeroDigit(h) == K_AXES_DIGIT)
  ------------------
  |  Branch (882:17): [True: 36, False: 65]
  ------------------
  883|     36|                h = _h3Rotate60ccw(h);
  884|    101|        }
  885|    866|    }
  886|    118|    return h;
  887|    118|}
_h3Rotate60ccw:
  918|    247|H3Index _h3Rotate60ccw(H3Index h) {
  919|  1.28k|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    247|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    247|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    247|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    247|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (919:49): [True: 1.04k, False: 247]
  ------------------
  920|  1.04k|        Direction oldDigit = H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  1.04k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  1.04k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  1.04k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  1.04k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  1.04k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  921|  1.04k|        H3_SET_INDEX_DIGIT(h, r, _rotate60ccw(oldDigit));
  ------------------
  |  |  162|  1.04k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.04k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.04k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.04k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.04k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.04k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.04k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.04k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.04k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  922|  1.04k|    }
  923|       |
  924|    247|    return h;
  925|    247|}
_h3Rotate60cw:
  931|    135|H3Index _h3Rotate60cw(H3Index h) {
  932|  1.59k|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    135|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    135|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    135|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    135|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (932:49): [True: 1.45k, False: 135]
  ------------------
  933|  1.45k|        H3_SET_INDEX_DIGIT(h, r, _rotate60cw(H3_GET_INDEX_DIGIT(h, r)));
  ------------------
  |  |  162|  1.45k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.45k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.45k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.45k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.45k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.45k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.45k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.45k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.45k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  934|  1.45k|    }
  935|       |
  936|    135|    return h;
  937|    135|}
_h3ToFaceIjkWithInitializedFijk:
 1090|  1.29k|int _h3ToFaceIjkWithInitializedFijk(H3Index h, FaceIJK *fijk) {
 1091|  1.29k|    CoordIJK *ijk = &fijk->coord;
 1092|  1.29k|    int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|  1.29k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  1.29k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  1.29k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  1.29k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1093|       |
 1094|       |    // center base cell hierarchy is entirely on this face
 1095|  1.29k|    int possibleOverage = 1;
 1096|  1.29k|    if (!_isBaseCellPentagon(H3_GET_BASE_CELL(h)) &&
  ------------------
  |  |  118|  1.29k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.29k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.29k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.29k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  |  Branch (1096:9): [True: 713, False: 583]
  ------------------
 1097|    713|        (res == 0 ||
  ------------------
  |  Branch (1097:10): [True: 74, False: 639]
  ------------------
 1098|    639|         (fijk->coord.i == 0 && fijk->coord.j == 0 && fijk->coord.k == 0)))
  ------------------
  |  Branch (1098:11): [True: 369, False: 270]
  |  Branch (1098:33): [True: 155, False: 214]
  |  Branch (1098:55): [True: 46, False: 109]
  ------------------
 1099|    120|        possibleOverage = 0;
 1100|       |
 1101|  15.3k|    for (int r = 1; r <= res; r++) {
  ------------------
  |  Branch (1101:21): [True: 14.0k, False: 1.29k]
  ------------------
 1102|  14.0k|        if (isResolutionClassIII(r)) {
  ------------------
  |  Branch (1102:13): [True: 7.51k, False: 6.50k]
  ------------------
 1103|       |            // Class III == rotate ccw
 1104|  7.51k|            _downAp7(ijk);
 1105|  7.51k|        } else {
 1106|       |            // Class II == rotate cw
 1107|  6.50k|            _downAp7r(ijk);
 1108|  6.50k|        }
 1109|       |
 1110|  14.0k|        _neighbor(ijk, H3_GET_INDEX_DIGIT(h, r));
  ------------------
  |  |  141|  14.0k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  14.0k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  14.0k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  14.0k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  14.0k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
 1111|  14.0k|    }
 1112|       |
 1113|  1.29k|    return possibleOverage;
 1114|  1.29k|}
_h3ToFaceIjk:
 1121|  1.29k|H3Error _h3ToFaceIjk(H3Index h, FaceIJK *fijk) {
 1122|  1.29k|    int baseCell = H3_GET_BASE_CELL(h);
  ------------------
  |  |  118|  1.29k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.29k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.29k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.29k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
 1123|  1.29k|    if (NEVER(baseCell < 0) || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |  119|  2.59k|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 1.29k]
  |  |  |  Branch (119:19): [True: 0, False: 1.29k]
  |  |  ------------------
  ------------------
                  if (NEVER(baseCell < 0) || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |   81|  1.29k|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (1123:9): [Folded, False: 0]
  |  Branch (1123:9): [Folded, False: 0]
  |  Branch (1123:32): [True: 3, False: 1.29k]
  ------------------
 1124|       |        // Base cells less than zero can not be represented in an index
 1125|       |        // To prevent reading uninitialized memory, we zero the output.
 1126|      3|        fijk->face = 0;
 1127|      3|        fijk->coord.i = fijk->coord.j = fijk->coord.k = 0;
 1128|      3|        return E_CELL_INVALID;
 1129|      3|    }
 1130|       |    // adjust for the pentagonal missing sequence; all of sub-sequence 5 needs
 1131|       |    // to be adjusted (and some of sub-sequence 4 below)
 1132|  1.29k|    if (_isBaseCellPentagon(baseCell) && _h3LeadingNonZeroDigit(h) == 5)
  ------------------
  |  Branch (1132:9): [True: 583, False: 713]
  |  Branch (1132:42): [True: 101, False: 482]
  ------------------
 1133|    101|        h = _h3Rotate60cw(h);
 1134|       |
 1135|       |    // start with the "home" face and ijk+ coordinates for the base cell of c
 1136|  1.29k|    *fijk = baseCellData[baseCell].homeFijk;
 1137|  1.29k|    if (!_h3ToFaceIjkWithInitializedFijk(h, fijk))
  ------------------
  |  Branch (1137:9): [True: 120, False: 1.17k]
  ------------------
 1138|    120|        return E_SUCCESS;  // no overage is possible; h lies on this face
 1139|       |
 1140|       |    // if we're here we have the potential for an "overage"; i.e., it is
 1141|       |    // possible that c lies on an adjacent face
 1142|       |
 1143|  1.17k|    CoordIJK origIJK = fijk->coord;
 1144|       |
 1145|       |    // if we're in Class III, drop into the next finer Class II grid
 1146|  1.17k|    int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|  1.17k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  1.17k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  1.17k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  1.17k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1147|  1.17k|    if (isResolutionClassIII(res)) {
  ------------------
  |  Branch (1147:9): [True: 978, False: 198]
  ------------------
 1148|       |        // Class III
 1149|    978|        _downAp7r(&fijk->coord);
 1150|    978|        res++;
 1151|    978|    }
 1152|       |
 1153|       |    // adjust for overage if needed
 1154|       |    // a pentagon base cell with a leading 4 digit requires special handling
 1155|  1.17k|    int pentLeading4 =
 1156|  1.17k|        (_isBaseCellPentagon(baseCell) && _h3LeadingNonZeroDigit(h) == 4);
  ------------------
  |  Branch (1156:10): [True: 583, False: 593]
  |  Branch (1156:43): [True: 156, False: 427]
  ------------------
 1157|  1.17k|    if (_adjustOverageClassII(fijk, res, pentLeading4, 0) != NO_OVERAGE) {
  ------------------
  |  Branch (1157:9): [True: 595, False: 581]
  ------------------
 1158|       |        // if the base cell is a pentagon we have the potential for secondary
 1159|       |        // overages
 1160|    595|        if (_isBaseCellPentagon(baseCell)) {
  ------------------
  |  Branch (1160:13): [True: 456, False: 139]
  ------------------
 1161|    801|            while (_adjustOverageClassII(fijk, res, 0, 0) != NO_OVERAGE)
  ------------------
  |  Branch (1161:20): [True: 345, False: 456]
  ------------------
 1162|    345|                continue;
 1163|    456|        }
 1164|       |
 1165|    595|        if (res != H3_GET_RESOLUTION(h)) _upAp7r(&fijk->coord);
  ------------------
  |  |  129|    595|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    595|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    595|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    595|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (1165:13): [True: 487, False: 108]
  ------------------
 1166|    595|    } else if (res != H3_GET_RESOLUTION(h)) {
  ------------------
  |  |  129|    581|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    581|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    581|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    581|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (1166:16): [True: 491, False: 90]
  ------------------
 1167|    491|        fijk->coord = origIJK;
 1168|    491|    }
 1169|  1.17k|    return E_SUCCESS;
 1170|  1.29k|}
maxFaceCount:
 1233|  1.16k|H3Error H3_EXPORT(maxFaceCount)(H3Index h3, int *out) {
 1234|       |    // a pentagon always intersects 5 faces, a hexagon never intersects more
 1235|       |    // than 2 (but may only intersect 1)
 1236|  1.16k|    *out = H3_EXPORT(isPentagon)(h3) ? 5 : 2;
  ------------------
  |  |   36|  1.16k|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|  1.16k|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|  1.16k|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1236:12): [True: 38, False: 1.12k]
  ------------------
 1237|  1.16k|    return E_SUCCESS;
 1238|  1.16k|}
getIcosahedronFaces:
 1249|    601|H3Error H3_EXPORT(getIcosahedronFaces)(H3Index h3, int *out) {
 1250|    601|    int res = H3_GET_RESOLUTION(h3);
  ------------------
  |  |  129|    601|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    601|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    601|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    601|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1251|    601|    int isPent = H3_EXPORT(isPentagon)(h3);
  ------------------
  |  |   36|    601|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    601|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    601|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1252|       |
 1253|       |    // We can't use the vertex-based approach here for class II pentagons,
 1254|       |    // because all their vertices are on the icosahedron edges. Their
 1255|       |    // direct child pentagons cross the same faces, so use those instead.
 1256|    601|    if (isPent && !isResolutionClassIII(res)) {
  ------------------
  |  Branch (1256:9): [True: 35, False: 566]
  |  Branch (1256:19): [True: 16, False: 19]
  ------------------
 1257|       |        // Note that this would not work for res 15, but this is only run on
 1258|       |        // Class II pentagons, it should never be invoked for a res 15 index.
 1259|     16|        H3Index childPentagon = makeDirectChild(h3, 0);
 1260|     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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1261|     16|    }
 1262|       |
 1263|       |    // convert to FaceIJK
 1264|    585|    FaceIJK fijk;
 1265|    585|    H3Error err = _h3ToFaceIjk(h3, &fijk);
 1266|    585|    if (err) {
  ------------------
  |  Branch (1266:9): [True: 3, False: 582]
  ------------------
 1267|      3|        return err;
 1268|      3|    }
 1269|       |
 1270|       |    // Get all vertices as FaceIJK addresses. For simplicity, always
 1271|       |    // initialize the array with 6 verts, ignoring the last one for pentagons
 1272|    582|    FaceIJK fijkVerts[NUM_HEX_VERTS];
 1273|    582|    int vertexCount;
 1274|       |
 1275|    582|    if (isPent) {
  ------------------
  |  Branch (1275:9): [True: 19, False: 563]
  ------------------
 1276|     19|        vertexCount = NUM_PENT_VERTS;
  ------------------
  |  |   85|     19|#define NUM_PENT_VERTS 5
  ------------------
 1277|     19|        _faceIjkPentToVerts(&fijk, &res, fijkVerts);
 1278|    563|    } else {
 1279|    563|        vertexCount = NUM_HEX_VERTS;
  ------------------
  |  |   83|    563|#define NUM_HEX_VERTS 6
  ------------------
 1280|    563|        _faceIjkToVerts(&fijk, &res, fijkVerts);
 1281|    563|    }
 1282|       |
 1283|       |    // We may not use all of the slots in the output array,
 1284|       |    // so fill with invalid values to indicate unused slots
 1285|    582|    int faceCount;
 1286|    582|    H3Error maxFaceCountError = H3_EXPORT(maxFaceCount)(h3, &faceCount);
  ------------------
  |  |   36|    582|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    582|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    582|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1287|    582|    if (NEVER(maxFaceCountError != E_SUCCESS)) {
  ------------------
  |  |  119|    582|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 582]
  |  |  |  Branch (119:19): [True: 0, False: 582]
  |  |  ------------------
  ------------------
  |  Branch (1287:9): [Folded, False: 0]
  |  Branch (1287:9): [Folded, False: 0]
  ------------------
 1288|      0|        return maxFaceCountError;
 1289|      0|    }
 1290|  1.80k|    for (int i = 0; i < faceCount; i++) {
  ------------------
  |  Branch (1290:21): [True: 1.22k, False: 582]
  ------------------
 1291|  1.22k|        out[i] = INVALID_FACE;
  ------------------
  |  |   60|  1.22k|#define INVALID_FACE -1
  ------------------
 1292|  1.22k|    }
 1293|       |
 1294|       |    // add each vertex face, using the output array as a hash set
 1295|  4.04k|    for (int i = 0; i < vertexCount; i++) {
  ------------------
  |  Branch (1295:21): [True: 3.46k, False: 579]
  ------------------
 1296|  3.46k|        FaceIJK *vert = &fijkVerts[i];
 1297|       |
 1298|       |        // Adjust overage, determining whether this vertex is
 1299|       |        // on another face
 1300|  3.46k|        if (isPent) {
  ------------------
  |  Branch (1300:13): [True: 95, False: 3.37k]
  ------------------
 1301|     95|            _adjustPentVertOverage(vert, res);
 1302|  3.37k|        } else {
 1303|  3.37k|            _adjustOverageClassII(vert, res, 0, 1);
 1304|  3.37k|        }
 1305|       |
 1306|       |        // Save the face to the output array
 1307|  3.46k|        int face = vert->face;
 1308|  3.46k|        int pos = 0;
 1309|       |        // Find the first empty output position, or the first position
 1310|       |        // matching the current face
 1311|  3.76k|        while (out[pos] != INVALID_FACE && out[pos] != face) {
  ------------------
  |  |   60|  7.53k|#define INVALID_FACE -1
  ------------------
  |  Branch (1311:16): [True: 3.06k, False: 706]
  |  Branch (1311:44): [True: 303, False: 2.76k]
  ------------------
 1312|    303|            pos++;
 1313|    303|            if (pos >= faceCount) {
  ------------------
  |  Branch (1313:17): [True: 3, False: 300]
  ------------------
 1314|       |                // Mismatch between the heuristic used in maxFaceCount and
 1315|       |                // calculation here - indicates an invalid index.
 1316|      3|                return E_FAILED;
 1317|      3|            }
 1318|    303|        }
 1319|  3.46k|        out[pos] = face;
 1320|  3.46k|    }
 1321|    579|    return E_SUCCESS;
 1322|    582|}
isResolutionClassIII:
 1359|  19.2k|int isResolutionClassIII(int res) { return res % 2; }
h3Index.c:_hasGoodTopBits:
  216|  1.50k|static inline bool _hasGoodTopBits(H3Index h) {
  217|  1.50k|    h >>= (64 - 8);
  218|  1.50k|    return h == 0b00001000;
  219|  1.50k|}
h3Index.c:_hasAny7UptoRes:
  264|    544|static inline bool _hasAny7UptoRes(H3Index h, int res) {
  265|    544|    const uint64_t MHI = 0b100100100100100100100100100100100100100100100;
  266|    544|    const uint64_t MLO = MHI >> 2;
  267|       |
  268|    544|    int shift = 3 * (15 - res);
  269|    544|    h >>= shift;
  270|    544|    h <<= shift;
  271|    544|    h = (h & MHI & (~h - MLO));
  272|       |
  273|    544|    return h != 0;
  274|    544|}
h3Index.c:_hasAll7AfterRes:
  280|    465|static inline bool _hasAll7AfterRes(H3Index h, int res) {
  281|       |    // NOTE: res check is needed because we can't shift by 64
  282|    465|    if (res < 15) {
  ------------------
  |  Branch (282:9): [True: 259, False: 206]
  ------------------
  283|    259|        int shift = 19 + 3 * res;
  284|       |
  285|    259|        h = ~h;
  286|    259|        h <<= shift;
  287|    259|        h >>= shift;
  288|       |
  289|    259|        return h == 0;
  290|    259|    }
  291|    206|    return true;
  292|    465|}
h3Index.c:_hasDeletedSubsequence:
  327|    352|static inline bool _hasDeletedSubsequence(H3Index h, int base_cell) {
  328|    352|    if (isBaseCellPentagonArr[base_cell]) {
  ------------------
  |  Branch (328:9): [True: 187, False: 165]
  ------------------
  329|    187|        h <<= 19;
  330|    187|        h >>= 19;
  331|       |
  332|    187|        if (h == 0) return false;  // all zeros: res 15 pentagon
  ------------------
  |  Branch (332:13): [True: 3, False: 184]
  ------------------
  333|    184|        return _firstOneIndex(h) % 3 == 0;
  334|    187|    }
  335|    165|    return false;
  336|    352|}
h3Index.c:_firstOneIndex:
  300|    184|static inline int _firstOneIndex(H3Index h) {
  301|    184|#if defined(__GNUC__) || defined(__clang__)
  302|    184|    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|    184|}

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

