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

h3Index.c:_rotate60ccw:
  656|  2.39k|static inline Direction _rotate60ccw(Direction digit) {
  657|  2.39k|    switch (digit) {
  658|    440|        case K_AXES_DIGIT:
  ------------------
  |  Branch (658:9): [True: 440, False: 1.95k]
  ------------------
  659|    440|            return IK_AXES_DIGIT;
  660|    407|        case IK_AXES_DIGIT:
  ------------------
  |  Branch (660:9): [True: 407, False: 1.99k]
  ------------------
  661|    407|            return I_AXES_DIGIT;
  662|    373|        case I_AXES_DIGIT:
  ------------------
  |  Branch (662:9): [True: 373, False: 2.02k]
  ------------------
  663|    373|            return IJ_AXES_DIGIT;
  664|    328|        case IJ_AXES_DIGIT:
  ------------------
  |  Branch (664:9): [True: 328, False: 2.07k]
  ------------------
  665|    328|            return J_AXES_DIGIT;
  666|    343|        case J_AXES_DIGIT:
  ------------------
  |  Branch (666:9): [True: 343, False: 2.05k]
  ------------------
  667|    343|            return JK_AXES_DIGIT;
  668|    461|        case JK_AXES_DIGIT:
  ------------------
  |  Branch (668:9): [True: 461, False: 1.93k]
  ------------------
  669|    461|            return K_AXES_DIGIT;
  670|     46|        default:
  ------------------
  |  Branch (670:9): [True: 46, False: 2.35k]
  ------------------
  671|     46|            return digit;
  672|  2.39k|    }
  673|  2.39k|}
h3Index.c:_rotate60cw:
  680|  1.27k|static inline Direction _rotate60cw(Direction digit) {
  681|  1.27k|    switch (digit) {
  682|    175|        case K_AXES_DIGIT:
  ------------------
  |  Branch (682:9): [True: 175, False: 1.09k]
  ------------------
  683|    175|            return JK_AXES_DIGIT;
  684|    156|        case JK_AXES_DIGIT:
  ------------------
  |  Branch (684:9): [True: 156, False: 1.11k]
  ------------------
  685|    156|            return J_AXES_DIGIT;
  686|    128|        case J_AXES_DIGIT:
  ------------------
  |  Branch (686:9): [True: 128, False: 1.14k]
  ------------------
  687|    128|            return IJ_AXES_DIGIT;
  688|    131|        case IJ_AXES_DIGIT:
  ------------------
  |  Branch (688:9): [True: 131, False: 1.14k]
  ------------------
  689|    131|            return I_AXES_DIGIT;
  690|    131|        case I_AXES_DIGIT:
  ------------------
  |  Branch (690:9): [True: 131, False: 1.14k]
  ------------------
  691|    131|            return IK_AXES_DIGIT;
  692|    227|        case IK_AXES_DIGIT:
  ------------------
  |  Branch (692:9): [True: 227, False: 1.04k]
  ------------------
  693|    227|            return K_AXES_DIGIT;
  694|    324|        default:
  ------------------
  |  Branch (694:9): [True: 324, False: 948]
  ------------------
  695|    324|            return digit;
  696|  1.27k|    }
  697|  1.27k|}
h3Index.c:_downAp7:
  512|  7.94k|static inline void _downAp7(CoordIJK *ijk) {
  513|       |    // res r unit vectors in res r+1
  514|  7.94k|    CoordIJK iVec = {3, 0, 1};
  515|  7.94k|    CoordIJK jVec = {1, 3, 0};
  516|  7.94k|    CoordIJK kVec = {0, 1, 3};
  517|       |
  518|  7.94k|    _ijkScale(&iVec, ijk->i);
  519|  7.94k|    _ijkScale(&jVec, ijk->j);
  520|  7.94k|    _ijkScale(&kVec, ijk->k);
  521|       |
  522|  7.94k|    _ijkAdd(&iVec, &jVec, ijk);
  523|  7.94k|    _ijkAdd(ijk, &kVec, ijk);
  524|       |
  525|  7.94k|    _ijkNormalize(ijk);
  526|  7.94k|}
h3Index.c:_ijkScale:
  155|  47.5k|static inline void _ijkScale(CoordIJK *c, int factor) {
  156|  47.5k|    c->i *= factor;
  157|  47.5k|    c->j *= factor;
  158|  47.5k|    c->k *= factor;
  159|  47.5k|}
h3Index.c:_ijkAdd:
  129|  43.4k|                           CoordIJK *sum) {
  130|  43.4k|    sum->i = h1->i + h2->i;
  131|  43.4k|    sum->j = h1->j + h2->j;
  132|  43.4k|    sum->k = h1->k + h2->k;
  133|  43.4k|}
h3Index.c:_upAp7r:
  494|    498|static inline void _upAp7r(CoordIJK *ijk) {
  495|       |    // convert to CoordIJ
  496|    498|    int i = ijk->i - ijk->k;
  497|    498|    int j = ijk->j - ijk->k;
  498|       |
  499|    498|    ijk->i = (int)lround((2 * i + j) * M_ONESEVENTH);
  ------------------
  |  |   54|    498|#define M_ONESEVENTH 0.14285714285714285714285714285714285
  ------------------
  500|    498|    ijk->j = (int)lround((3 * j - i) * M_ONESEVENTH);
  ------------------
  |  |   54|    498|#define M_ONESEVENTH 0.14285714285714285714285714285714285
  ------------------
  501|    498|    ijk->k = 0;
  502|    498|    _ijkNormalize(ijk);
  503|    498|}
h3Index.c:_downAp7r:
  534|  7.89k|static inline void _downAp7r(CoordIJK *ijk) {
  535|       |    // res r unit vectors in res r+1
  536|  7.89k|    CoordIJK iVec = {3, 1, 0};
  537|  7.89k|    CoordIJK jVec = {0, 3, 1};
  538|  7.89k|    CoordIJK kVec = {1, 0, 3};
  539|       |
  540|  7.89k|    _ijkScale(&iVec, ijk->i);
  541|  7.89k|    _ijkScale(&jVec, ijk->j);
  542|  7.89k|    _ijkScale(&kVec, ijk->k);
  543|       |
  544|  7.89k|    _ijkAdd(&iVec, &jVec, ijk);
  545|  7.89k|    _ijkAdd(ijk, &kVec, ijk);
  546|       |
  547|  7.89k|    _ijkNormalize(ijk);
  548|  7.89k|}
h3Index.c:_ijkNormalize:
  207|  28.0k|static inline void _ijkNormalize(CoordIJK *c) {
  208|       |    // remove any negative values
  209|  28.0k|    if (c->i < 0) {
  ------------------
  |  Branch (209:9): [True: 163, False: 27.8k]
  ------------------
  210|    163|        c->j -= c->i;
  211|    163|        c->k -= c->i;
  212|    163|        c->i = 0;
  213|    163|    }
  214|       |
  215|  28.0k|    if (c->j < 0) {
  ------------------
  |  Branch (215:9): [True: 167, False: 27.8k]
  ------------------
  216|    167|        c->i -= c->j;
  217|    167|        c->k -= c->j;
  218|    167|        c->j = 0;
  219|    167|    }
  220|       |
  221|  28.0k|    if (c->k < 0) {
  ------------------
  |  Branch (221:9): [True: 0, False: 28.0k]
  ------------------
  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|  28.0k|    int min = c->i;
  229|  28.0k|    if (c->j < min) min = c->j;
  ------------------
  |  Branch (229:9): [True: 18.0k, False: 9.97k]
  ------------------
  230|  28.0k|    if (c->k < min) min = c->k;
  ------------------
  |  Branch (230:9): [True: 9.43k, False: 18.6k]
  ------------------
  231|  28.0k|    if (min > 0) {
  ------------------
  |  Branch (231:9): [True: 18.8k, False: 9.24k]
  ------------------
  232|  18.8k|        c->i -= min;
  233|  18.8k|        c->j -= min;
  234|  18.8k|        c->k -= min;
  235|  18.8k|    }
  236|  28.0k|}
h3Index.c:_neighbor:
  602|  14.8k|static inline void _neighbor(CoordIJK *ijk, Direction digit) {
  603|  14.8k|    if (digit > CENTER_DIGIT && digit < NUM_DIGITS) {
  ------------------
  |  Branch (603:9): [True: 12.0k, False: 2.77k]
  |  Branch (603:33): [True: 11.7k, False: 358]
  ------------------
  604|  11.7k|        _ijkAdd(ijk, &UNIT_VECS[digit], ijk);
  605|  11.7k|        _ijkNormalize(ijk);
  606|  11.7k|    }
  607|  14.8k|}
faceijk.c:_ijkRotate60ccw:
  614|  3.52k|static inline void _ijkRotate60ccw(CoordIJK *ijk) {
  615|       |    // unit vector rotations
  616|  3.52k|    CoordIJK iVec = {1, 1, 0};
  617|  3.52k|    CoordIJK jVec = {0, 1, 1};
  618|  3.52k|    CoordIJK kVec = {1, 0, 1};
  619|       |
  620|  3.52k|    _ijkScale(&iVec, ijk->i);
  621|  3.52k|    _ijkScale(&jVec, ijk->j);
  622|  3.52k|    _ijkScale(&kVec, ijk->k);
  623|       |
  624|  3.52k|    _ijkAdd(&iVec, &jVec, ijk);
  625|  3.52k|    _ijkAdd(ijk, &kVec, ijk);
  626|       |
  627|  3.52k|    _ijkNormalize(ijk);
  628|  3.52k|}
faceijk.c:_ijkScale:
  155|  16.8k|static inline void _ijkScale(CoordIJK *c, int factor) {
  156|  16.8k|    c->i *= factor;
  157|  16.8k|    c->j *= factor;
  158|  16.8k|    c->k *= factor;
  159|  16.8k|}
faceijk.c:_ijkAdd:
  129|  15.2k|                           CoordIJK *sum) {
  130|  15.2k|    sum->i = h1->i + h2->i;
  131|  15.2k|    sum->j = h1->j + h2->j;
  132|  15.2k|    sum->k = h1->k + h2->k;
  133|  15.2k|}
faceijk.c:_ijkNormalize:
  207|  9.88k|static inline void _ijkNormalize(CoordIJK *c) {
  208|       |    // remove any negative values
  209|  9.88k|    if (c->i < 0) {
  ------------------
  |  Branch (209:9): [True: 0, False: 9.88k]
  ------------------
  210|      0|        c->j -= c->i;
  211|      0|        c->k -= c->i;
  212|      0|        c->i = 0;
  213|      0|    }
  214|       |
  215|  9.88k|    if (c->j < 0) {
  ------------------
  |  Branch (215:9): [True: 0, False: 9.88k]
  ------------------
  216|      0|        c->i -= c->j;
  217|      0|        c->k -= c->j;
  218|      0|        c->j = 0;
  219|      0|    }
  220|       |
  221|  9.88k|    if (c->k < 0) {
  ------------------
  |  Branch (221:9): [True: 0, False: 9.88k]
  ------------------
  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.88k|    int min = c->i;
  229|  9.88k|    if (c->j < min) min = c->j;
  ------------------
  |  Branch (229:9): [True: 4.75k, False: 5.13k]
  ------------------
  230|  9.88k|    if (c->k < min) min = c->k;
  ------------------
  |  Branch (230:9): [True: 3.62k, False: 6.26k]
  ------------------
  231|  9.88k|    if (min > 0) {
  ------------------
  |  Branch (231:9): [True: 8.43k, False: 1.45k]
  ------------------
  232|  8.43k|        c->i -= min;
  233|  8.43k|        c->j -= min;
  234|  8.43k|        c->k -= min;
  235|  8.43k|    }
  236|  9.88k|}
faceijk.c:_downAp3:
  557|    586|static inline void _downAp3(CoordIJK *ijk) {
  558|       |    // res r unit vectors in res r+1
  559|    586|    CoordIJK iVec = {2, 0, 1};
  560|    586|    CoordIJK jVec = {1, 2, 0};
  561|    586|    CoordIJK kVec = {0, 1, 2};
  562|       |
  563|    586|    _ijkScale(&iVec, ijk->i);
  564|    586|    _ijkScale(&jVec, ijk->j);
  565|    586|    _ijkScale(&kVec, ijk->k);
  566|       |
  567|    586|    _ijkAdd(&iVec, &jVec, ijk);
  568|    586|    _ijkAdd(ijk, &kVec, ijk);
  569|       |
  570|    586|    _ijkNormalize(ijk);
  571|    586|}
faceijk.c:_downAp3r:
  579|    586|static inline void _downAp3r(CoordIJK *ijk) {
  580|       |    // res r unit vectors in res r+1
  581|    586|    CoordIJK iVec = {2, 1, 0};
  582|    586|    CoordIJK jVec = {0, 2, 1};
  583|    586|    CoordIJK kVec = {1, 0, 2};
  584|       |
  585|    586|    _ijkScale(&iVec, ijk->i);
  586|    586|    _ijkScale(&jVec, ijk->j);
  587|    586|    _ijkScale(&kVec, ijk->k);
  588|       |
  589|    586|    _ijkAdd(&iVec, &jVec, ijk);
  590|    586|    _ijkAdd(ijk, &kVec, ijk);
  591|       |
  592|    586|    _ijkNormalize(ijk);
  593|    586|}
faceijk.c:_downAp7r:
  534|    450|static inline void _downAp7r(CoordIJK *ijk) {
  535|       |    // res r unit vectors in res r+1
  536|    450|    CoordIJK iVec = {3, 1, 0};
  537|    450|    CoordIJK jVec = {0, 3, 1};
  538|    450|    CoordIJK kVec = {1, 0, 3};
  539|       |
  540|    450|    _ijkScale(&iVec, ijk->i);
  541|    450|    _ijkScale(&jVec, ijk->j);
  542|    450|    _ijkScale(&kVec, ijk->k);
  543|       |
  544|    450|    _ijkAdd(&iVec, &jVec, ijk);
  545|    450|    _ijkAdd(ijk, &kVec, ijk);
  546|       |
  547|    450|    _ijkNormalize(ijk);
  548|    450|}
faceijk.c:_setIJK:
  103|     90|static inline void _setIJK(CoordIJK *ijk, int i, int j, int k) {
  104|     90|    ijk->i = i;
  105|     90|    ijk->j = j;
  106|     90|    ijk->k = k;
  107|     90|}
faceijk.c:_ijkSub:
  143|     90|                           CoordIJK *diff) {
  144|     90|    diff->i = h1->i - h2->i;
  145|     90|    diff->j = h1->j - h2->j;
  146|     90|    diff->k = h1->k - h2->k;
  147|     90|}
faceijk.c:_ijkRotate60cw:
  635|     90|static inline void _ijkRotate60cw(CoordIJK *ijk) {
  636|       |    // unit vector rotations
  637|     90|    CoordIJK iVec = {1, 0, 1};
  638|     90|    CoordIJK jVec = {1, 1, 0};
  639|     90|    CoordIJK kVec = {0, 1, 1};
  640|       |
  641|     90|    _ijkScale(&iVec, ijk->i);
  642|     90|    _ijkScale(&jVec, ijk->j);
  643|     90|    _ijkScale(&kVec, ijk->k);
  644|       |
  645|     90|    _ijkAdd(&iVec, &jVec, ijk);
  646|     90|    _ijkAdd(ijk, &kVec, ijk);
  647|       |
  648|     90|    _ijkNormalize(ijk);
  649|     90|}

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

_isBaseCellPentagon:
  824|  9.62k|int _isBaseCellPentagon(int baseCell) {
  825|  9.62k|    if (baseCell < 0 || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |   81|  9.62k|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (825:9): [True: 0, False: 9.62k]
  |  Branch (825:25): [True: 11, False: 9.61k]
  ------------------
  826|       |        // Base cells less than zero can not be represented in an index
  827|     11|        return false;
  828|     11|    }
  829|  9.61k|    return baseCellData[baseCell].isPentagon;
  830|  9.62k|}
_isBaseCellPolarPentagon:
  834|    291|bool _isBaseCellPolarPentagon(int baseCell) {
  835|    291|    return baseCell == 4 || baseCell == 117;
  ------------------
  |  Branch (835:12): [True: 66, False: 225]
  |  Branch (835:29): [True: 49, False: 176]
  ------------------
  836|    291|}
_baseCellToFaceIjk:
  866|    758|void _baseCellToFaceIjk(int baseCell, FaceIJK *h) {
  867|    758|    *h = baseCellData[baseCell].homeFijk;
  868|    758|}
_baseCellToCCWrot60:
  877|    758|int _baseCellToCCWrot60(int baseCell, int face) {
  878|    758|    if (face < 0 || face > NUM_ICOSA_FACES) return INVALID_ROTATIONS;
  ------------------
  |  |   79|    758|#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: 758]
  |  Branch (878:21): [True: 0, False: 758]
  ------------------
  879|  1.30k|    for (int i = 0; i < 3; i++) {
  ------------------
  |  Branch (879:21): [True: 1.30k, False: 0]
  ------------------
  880|  3.36k|        for (int j = 0; j < 3; j++) {
  ------------------
  |  Branch (880:25): [True: 2.81k, False: 549]
  ------------------
  881|  9.21k|            for (int k = 0; k < 3; k++) {
  ------------------
  |  Branch (881:29): [True: 7.15k, False: 2.05k]
  ------------------
  882|  7.15k|                if (faceIjkBaseCells[face][i][j][k].baseCell == baseCell) {
  ------------------
  |  Branch (882:21): [True: 758, False: 6.39k]
  ------------------
  883|    758|                    return faceIjkBaseCells[face][i][j][k].ccwRot60;
  884|    758|                }
  885|  7.15k|            }
  886|  2.81k|        }
  887|  1.30k|    }
  888|      0|    return INVALID_ROTATIONS;
  ------------------
  |  |   49|      0|#define INVALID_ROTATIONS -1
  ------------------
  889|    758|}
_baseCellIsCwOffset:
  893|     16|bool _baseCellIsCwOffset(int baseCell, int testFace) {
  894|     16|    return baseCellData[baseCell].cwOffsetPent[0] == testFace ||
  ------------------
  |  Branch (894:12): [True: 9, False: 7]
  ------------------
  895|      7|           baseCellData[baseCell].cwOffsetPent[1] == testFace;
  ------------------
  |  Branch (895:12): [True: 7, False: 0]
  ------------------
  896|     16|}

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

_faceIjkPentToVerts:
  637|     15|void _faceIjkPentToVerts(FaceIJK *fijk, int *res, FaceIJK *fijkVerts) {
  638|       |    // the vertexes of an origin-centered pentagon in a Class II resolution on a
  639|       |    // substrate grid with aperture sequence 33r. The aperture 3 gets us the
  640|       |    // vertices, and the 3r gets us back to Class II.
  641|       |    // vertices listed ccw from the i-axes
  642|     15|    CoordIJK vertsCII[NUM_PENT_VERTS] = {
  643|     15|        {2, 1, 0},  // 0
  644|     15|        {1, 2, 0},  // 1
  645|     15|        {0, 2, 1},  // 2
  646|     15|        {0, 1, 2},  // 3
  647|     15|        {1, 0, 2},  // 4
  648|     15|    };
  649|       |
  650|       |    // the vertexes of an origin-centered pentagon in a Class III resolution on
  651|       |    // a substrate grid with aperture sequence 33r7r. The aperture 3 gets us the
  652|       |    // vertices, and the 3r7r gets us to Class II. vertices listed ccw from the
  653|       |    // i-axes
  654|     15|    CoordIJK vertsCIII[NUM_PENT_VERTS] = {
  655|     15|        {5, 4, 0},  // 0
  656|     15|        {1, 5, 0},  // 1
  657|     15|        {0, 5, 4},  // 2
  658|     15|        {0, 1, 5},  // 3
  659|     15|        {4, 0, 5},  // 4
  660|     15|    };
  661|       |
  662|       |    // get the correct set of substrate vertices for this resolution
  663|     15|    CoordIJK *verts;
  664|     15|    if (isResolutionClassIII(*res))
  ------------------
  |  Branch (664:9): [True: 15, False: 0]
  ------------------
  665|     15|        verts = vertsCIII;
  666|      0|    else
  667|      0|        verts = vertsCII;
  668|       |
  669|       |    // adjust the center point to be in an aperture 33r substrate grid
  670|       |    // these should be composed for speed
  671|     15|    _downAp3(&fijk->coord);
  672|     15|    _downAp3r(&fijk->coord);
  673|       |
  674|       |    // if res is Class III we need to add a cw aperture 7 to get to
  675|       |    // icosahedral Class II
  676|     15|    if (isResolutionClassIII(*res)) {
  ------------------
  |  Branch (676:9): [True: 15, False: 0]
  ------------------
  677|     15|        _downAp7r(&fijk->coord);
  678|     15|        *res += 1;
  679|     15|    }
  680|       |
  681|       |    // The center point is now in the same substrate grid as the origin
  682|       |    // cell vertices. Add the center point substate coordinates
  683|       |    // to each vertex to translate the vertices to that cell.
  684|     90|    for (int v = 0; v < NUM_PENT_VERTS; v++) {
  ------------------
  |  |   85|     90|#define NUM_PENT_VERTS 5
  ------------------
  |  Branch (684:21): [True: 75, False: 15]
  ------------------
  685|     75|        fijkVerts[v].face = fijk->face;
  686|     75|        _ijkAdd(&fijk->coord, &verts[v], &fijkVerts[v].coord);
  687|     75|        _ijkNormalize(&fijkVerts[v].coord);
  688|     75|    }
  689|     15|}
_faceIjkToVerts:
  814|    571|void _faceIjkToVerts(FaceIJK *fijk, int *res, FaceIJK *fijkVerts) {
  815|       |    // the vertexes of an origin-centered cell in a Class II resolution on a
  816|       |    // substrate grid with aperture sequence 33r. The aperture 3 gets us the
  817|       |    // vertices, and the 3r gets us back to Class II.
  818|       |    // vertices listed ccw from the i-axes
  819|    571|    CoordIJK vertsCII[NUM_HEX_VERTS] = {
  820|    571|        {2, 1, 0},  // 0
  821|    571|        {1, 2, 0},  // 1
  822|    571|        {0, 2, 1},  // 2
  823|    571|        {0, 1, 2},  // 3
  824|    571|        {1, 0, 2},  // 4
  825|    571|        {2, 0, 1}   // 5
  826|    571|    };
  827|       |
  828|       |    // the vertexes of an origin-centered cell in a Class III resolution on a
  829|       |    // substrate grid with aperture sequence 33r7r. The aperture 3 gets us the
  830|       |    // vertices, and the 3r7r gets us to Class II.
  831|       |    // vertices listed ccw from the i-axes
  832|    571|    CoordIJK vertsCIII[NUM_HEX_VERTS] = {
  833|    571|        {5, 4, 0},  // 0
  834|    571|        {1, 5, 0},  // 1
  835|    571|        {0, 5, 4},  // 2
  836|    571|        {0, 1, 5},  // 3
  837|    571|        {4, 0, 5},  // 4
  838|    571|        {5, 0, 1}   // 5
  839|    571|    };
  840|       |
  841|       |    // get the correct set of substrate vertices for this resolution
  842|    571|    CoordIJK *verts;
  843|    571|    if (isResolutionClassIII(*res))
  ------------------
  |  Branch (843:9): [True: 435, False: 136]
  ------------------
  844|    435|        verts = vertsCIII;
  845|    136|    else
  846|    136|        verts = vertsCII;
  847|       |
  848|       |    // adjust the center point to be in an aperture 33r substrate grid
  849|       |    // these should be composed for speed
  850|    571|    _downAp3(&fijk->coord);
  851|    571|    _downAp3r(&fijk->coord);
  852|       |
  853|       |    // if res is Class III we need to add a cw aperture 7 to get to
  854|       |    // icosahedral Class II
  855|    571|    if (isResolutionClassIII(*res)) {
  ------------------
  |  Branch (855:9): [True: 435, False: 136]
  ------------------
  856|    435|        _downAp7r(&fijk->coord);
  857|    435|        *res += 1;
  858|    435|    }
  859|       |
  860|       |    // The center point is now in the same substrate grid as the origin
  861|       |    // cell vertices. Add the center point substate coordinates
  862|       |    // to each vertex to translate the vertices to that cell.
  863|  3.99k|    for (int v = 0; v < NUM_HEX_VERTS; v++) {
  ------------------
  |  |   83|  3.99k|#define NUM_HEX_VERTS 6
  ------------------
  |  Branch (863:21): [True: 3.42k, False: 571]
  ------------------
  864|  3.42k|        fijkVerts[v].face = fijk->face;
  865|  3.42k|        _ijkAdd(&fijk->coord, &verts[v], &fijkVerts[v].coord);
  866|  3.42k|        _ijkNormalize(&fijkVerts[v].coord);
  867|  3.42k|    }
  868|    571|}
_adjustOverageClassII:
  883|  5.59k|                              int substrate) {
  884|  5.59k|    Overage overage = NO_OVERAGE;
  885|       |
  886|  5.59k|    CoordIJK *ijk = &fijk->coord;
  887|       |
  888|       |    // get the maximum dimension value; scale if a substrate grid
  889|  5.59k|    int maxDim = maxDimByCIIres[res];
  890|  5.59k|    if (substrate) maxDim *= 3;
  ------------------
  |  Branch (890:9): [True: 3.58k, False: 2.00k]
  ------------------
  891|       |
  892|       |    // check for overage
  893|  5.59k|    if (substrate && ijk->i + ijk->j + ijk->k == maxDim)  // on edge
  ------------------
  |  Branch (893:9): [True: 3.58k, False: 2.00k]
  |  Branch (893:22): [True: 242, False: 3.34k]
  ------------------
  894|    242|        overage = FACE_EDGE;
  895|  5.35k|    else if (ijk->i + ijk->j + ijk->k > maxDim)  // overage
  ------------------
  |  Branch (895:14): [True: 1.14k, False: 4.20k]
  ------------------
  896|  1.14k|    {
  897|  1.14k|        overage = NEW_FACE;
  898|       |
  899|  1.14k|        const FaceOrientIJK *fijkOrient;
  900|  1.14k|        if (ijk->k > 0) {
  ------------------
  |  Branch (900:13): [True: 748, False: 400]
  ------------------
  901|    748|            if (ijk->j > 0)  // jk "quadrant"
  ------------------
  |  Branch (901:17): [True: 270, False: 478]
  ------------------
  902|    270|                fijkOrient = &faceNeighbors[fijk->face][JK];
  ------------------
  |  |   57|    270|#define JK 3
  ------------------
  903|    478|            else  // ik "quadrant"
  904|    478|            {
  905|    478|                fijkOrient = &faceNeighbors[fijk->face][KI];
  ------------------
  |  |   55|    478|#define KI 2
  ------------------
  906|       |
  907|       |                // adjust for the pentagonal missing sequence
  908|    478|                if (pentLeading4) {
  ------------------
  |  Branch (908:21): [True: 90, False: 388]
  ------------------
  909|       |                    // translate origin to center of pentagon
  910|     90|                    CoordIJK origin;
  911|     90|                    _setIJK(&origin, maxDim, 0, 0);
  912|     90|                    CoordIJK tmp;
  913|     90|                    _ijkSub(ijk, &origin, &tmp);
  914|       |                    // rotate to adjust for the missing sequence
  915|     90|                    _ijkRotate60cw(&tmp);
  916|       |                    // translate the origin back to the center of the triangle
  917|     90|                    _ijkAdd(&tmp, &origin, ijk);
  918|     90|                }
  919|    478|            }
  920|    748|        } else  // ij "quadrant"
  921|    400|            fijkOrient = &faceNeighbors[fijk->face][IJ];
  ------------------
  |  |   53|    400|#define IJ 1
  ------------------
  922|       |
  923|  1.14k|        fijk->face = fijkOrient->face;
  924|       |
  925|       |        // rotate and translate for adjacent face
  926|  4.67k|        for (int i = 0; i < fijkOrient->ccwRot60; i++) _ijkRotate60ccw(ijk);
  ------------------
  |  Branch (926:25): [True: 3.52k, False: 1.14k]
  ------------------
  927|       |
  928|  1.14k|        CoordIJK transVec = fijkOrient->translate;
  929|  1.14k|        int unitScale = unitScaleByCIIres[res];
  930|  1.14k|        if (substrate) unitScale *= 3;
  ------------------
  |  Branch (930:13): [True: 191, False: 957]
  ------------------
  931|  1.14k|        _ijkScale(&transVec, unitScale);
  932|  1.14k|        _ijkAdd(ijk, &transVec, ijk);
  933|  1.14k|        _ijkNormalize(ijk);
  934|       |
  935|       |        // overage points on pentagon boundaries can end up on edges
  936|  1.14k|        if (substrate && ijk->i + ijk->j + ijk->k == maxDim)  // on edge
  ------------------
  |  Branch (936:13): [True: 191, False: 957]
  |  Branch (936:26): [True: 2, False: 189]
  ------------------
  937|      2|            overage = FACE_EDGE;
  938|  1.14k|    }
  939|       |
  940|  5.59k|    return overage;
  941|  5.59k|}
_adjustPentVertOverage:
  951|     75|Overage _adjustPentVertOverage(FaceIJK *fijk, int res) {
  952|     75|    int pentLeading4 = 0;
  953|     75|    Overage overage;
  954|    165|    do {
  955|    165|        overage = _adjustOverageClassII(fijk, res, pentLeading4, 1);
  956|    165|    } while (overage == NEW_FACE);
  ------------------
  |  Branch (956:14): [True: 90, False: 75]
  ------------------
  957|     75|    return overage;
  958|     75|}

getResolution:
   87|    589|int H3_EXPORT(getResolution)(H3Index h) { return H3_GET_RESOLUTION(h); }
  ------------------
  |  |  129|    589|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    589|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    589|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    589|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
getBaseCellNumber:
   98|  1.34k|int H3_EXPORT(getBaseCellNumber)(H3Index h) { return H3_GET_BASE_CELL(h); }
  ------------------
  |  |  118|  1.34k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.34k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.34k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.34k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
getIndexDigit:
  116|    589|H3Error H3_EXPORT(getIndexDigit)(H3Index h, int res, int *out) {
  117|    589|    if (res < 1 || res > MAX_H3_RES) {
  ------------------
  |  |   76|    340|#define MAX_H3_RES 15
  ------------------
  |  Branch (117:9): [True: 249, False: 340]
  |  Branch (117:20): [True: 332, False: 8]
  ------------------
  118|    581|        return E_RES_DOMAIN;
  119|    581|    }
  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|    589|}
isValidCell:
  343|  1.54k|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.54k|    if (!_hasGoodTopBits(h)) return false;
  ------------------
  |  Branch (365:9): [True: 974, False: 571]
  ------------------
  366|       |
  367|       |    // No need to check resolution; any 4 bits give a valid resolution.
  368|    571|    const int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|    571|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    571|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    571|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    571|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  369|       |
  370|       |    // Get base cell number and check that it is valid.
  371|    571|    const int bc = H3_GET_BASE_CELL(h);
  ------------------
  |  |  118|    571|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|    571|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|    571|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|    571|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  372|    571|    if (bc >= NUM_BASE_CELLS) return false;
  ------------------
  |  |   81|    571|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (372:9): [True: 3, False: 568]
  ------------------
  373|       |
  374|    568|    if (_hasAny7UptoRes(h, res)) return false;
  ------------------
  |  Branch (374:9): [True: 66, False: 502]
  ------------------
  375|    502|    if (!_hasAll7AfterRes(h, res)) return false;
  ------------------
  |  Branch (375:9): [True: 90, False: 412]
  ------------------
  376|    412|    if (_hasDeletedSubsequence(h, bc)) return false;
  ------------------
  |  Branch (376:9): [True: 20, False: 392]
  ------------------
  377|       |
  378|       |    // If no disqualifications were identified, the index is a valid H3 cell.
  379|    392|    return true;
  380|    412|}
isValidIndex:
  388|    589|int H3_EXPORT(isValidIndex)(H3Index h) {
  389|    589|    return H3_EXPORT(isValidCell)(h) || H3_EXPORT(isValidDirectedEdge)(h) ||
  ------------------
  |  |   36|    589|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    589|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    589|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  return H3_EXPORT(isValidCell)(h) || H3_EXPORT(isValidDirectedEdge)(h) ||
  ------------------
  |  |   36|    542|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    589|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    589|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (389:12): [True: 47, False: 542]
  |  Branch (389:41): [True: 2, False: 540]
  ------------------
  390|    540|           H3_EXPORT(isValidVertex)(h);
  ------------------
  |  |   36|    540|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    589|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    589|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (390:12): [True: 83, False: 457]
  ------------------
  391|    589|}
makeDirectChild:
  483|     13|H3Index makeDirectChild(H3Index h, int cellNumber) {
  484|     13|    int childRes = H3_GET_RESOLUTION(h) + 1;
  ------------------
  |  |  129|     13|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|     13|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|     13|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|     13|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  485|     13|    H3Index childH = H3_SET_RESOLUTION(h, childRes);
  ------------------
  |  |  135|     13|    (h3) = (((h3)&H3_RES_MASK_NEGATIVE) | (((uint64_t)(res)) << H3_RES_OFFSET))
  |  |  ------------------
  |  |  |  |   71|     13|#define H3_RES_MASK_NEGATIVE (~H3_RES_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |   68|     13|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|     13|#define H3_RES_OFFSET 52
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (h3) = (((h3)&H3_RES_MASK_NEGATIVE) | (((uint64_t)(res)) << H3_RES_OFFSET))
  |  |  ------------------
  |  |  |  |   41|     13|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  486|     13|    H3_SET_INDEX_DIGIT(childH, childRes, cellNumber);
  ------------------
  |  |  162|     13|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|     13|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|     13|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|     13|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|     13|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|     13|            (((uint64_t)(digit))                                            \
  |  |  165|     13|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|     13|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|     13|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  487|     13|    return childH;
  488|     13|}
isResClassIII:
  835|    589|int H3_EXPORT(isResClassIII)(H3Index h) { return H3_GET_RESOLUTION(h) % 2; }
  ------------------
  |  |  129|    589|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    589|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    589|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    589|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
isPentagon:
  842|  3.67k|int H3_EXPORT(isPentagon)(H3Index h) {
  843|  3.67k|    return _isBaseCellPentagon(H3_GET_BASE_CELL(h)) &&
  ------------------
  |  |  118|  3.67k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  3.67k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  3.67k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  3.67k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  |  Branch (843:12): [True: 1.60k, False: 2.07k]
  ------------------
  844|  1.60k|           !_h3LeadingNonZeroDigit(h);
  ------------------
  |  Branch (844:12): [True: 175, False: 1.42k]
  ------------------
  845|  3.67k|}
_h3LeadingNonZeroDigit:
  852|  4.67k|Direction _h3LeadingNonZeroDigit(H3Index h) {
  853|  13.7k|    for (int r = 1; r <= H3_GET_RESOLUTION(h); r++)
  ------------------
  |  |  129|  13.7k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  13.7k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  13.7k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  13.7k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (853:21): [True: 13.1k, False: 520]
  ------------------
  854|  13.1k|        if (H3_GET_INDEX_DIGIT(h, r)) return H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  13.1k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  13.1k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  13.1k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  |  Branch (141:5): [True: 4.15k, False: 9.03k]
  |  |  ------------------
  |  |  142|  13.1k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  13.1k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
                      if (H3_GET_INDEX_DIGIT(h, r)) return H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  4.15k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  4.15k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  4.15k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  4.15k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  4.15k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  855|       |
  856|       |    // if we're here it's all 0's
  857|    520|    return CENTER_DIGIT;
  858|  4.67k|}
_h3RotatePent60ccw:
  864|    128|H3Index _h3RotatePent60ccw(H3Index h) {
  865|       |    // rotate in place; skips any leading 1 digits (k-axis)
  866|       |
  867|    128|    int foundFirstNonZeroDigit = 0;
  868|    972|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    128|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    128|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    128|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    128|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (868:49): [True: 844, False: 128]
  ------------------
  869|       |        // rotate this digit
  870|    844|        H3_SET_INDEX_DIGIT(h, r, _rotate60ccw(H3_GET_INDEX_DIGIT(h, r)));
  ------------------
  |  |  162|    844|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|    844|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|    844|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|    844|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|    844|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|    844|            (((uint64_t)(digit))                                            \
  |  |  165|    844|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|    844|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|    844|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  871|       |
  872|       |        // look for the first non-zero digit so we
  873|       |        // can adjust for deleted k-axes sequence
  874|       |        // if necessary
  875|    844|        if (!foundFirstNonZeroDigit && H3_GET_INDEX_DIGIT(h, r) != 0) {
  ------------------
  |  |  141|    112|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|    112|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|    112|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|    112|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|    112|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  |  Branch (875:13): [True: 112, False: 732]
  |  Branch (875:40): [True: 112, False: 0]
  ------------------
  876|    112|            foundFirstNonZeroDigit = 1;
  877|       |
  878|       |            // adjust for deleted k-axes sequence
  879|    112|            if (_h3LeadingNonZeroDigit(h) == K_AXES_DIGIT)
  ------------------
  |  Branch (879:17): [True: 36, False: 76]
  ------------------
  880|     36|                h = _h3Rotate60ccw(h);
  881|    112|        }
  882|    844|    }
  883|    128|    return h;
  884|    128|}
_h3Rotate60ccw:
  915|    257|H3Index _h3Rotate60ccw(H3Index h) {
  916|  1.81k|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    257|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    257|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    257|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    257|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (916:49): [True: 1.55k, False: 257]
  ------------------
  917|  1.55k|        Direction oldDigit = H3_GET_INDEX_DIGIT(h, r);
  ------------------
  |  |  141|  1.55k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  1.55k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  1.55k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  1.55k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  1.55k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
  918|  1.55k|        H3_SET_INDEX_DIGIT(h, r, _rotate60ccw(oldDigit));
  ------------------
  |  |  162|  1.55k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.55k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.55k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.55k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.55k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.55k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.55k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.55k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.55k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  919|  1.55k|    }
  920|       |
  921|    257|    return h;
  922|    257|}
_h3Rotate60cw:
  928|    122|H3Index _h3Rotate60cw(H3Index h) {
  929|  1.39k|    for (int r = 1, res = H3_GET_RESOLUTION(h); r <= res; r++) {
  ------------------
  |  |  129|    122|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    122|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    122|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    122|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (929:49): [True: 1.27k, False: 122]
  ------------------
  930|  1.27k|        H3_SET_INDEX_DIGIT(h, r, _rotate60cw(H3_GET_INDEX_DIGIT(h, r)));
  ------------------
  |  |  162|  1.27k|    (h3) = (((h3) & ~((H3_DIGIT_MASK                                        \
  |  |  ------------------
  |  |  |  |   80|  1.27k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  |  |  163|  1.27k|                       << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   76|  1.27k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                                      << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))) | \
  |  |  ------------------
  |  |  |  |   47|  1.27k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  164|  1.27k|            (((uint64_t)(digit))                                            \
  |  |  165|  1.27k|             << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   76|  1.27k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                            << ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)))
  |  |  ------------------
  |  |  |  |   47|  1.27k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  ------------------
  931|  1.27k|    }
  932|       |
  933|    122|    return h;
  934|    122|}
_h3ToFaceIjkWithInitializedFijk:
 1087|  1.34k|int _h3ToFaceIjkWithInitializedFijk(H3Index h, FaceIJK *fijk) {
 1088|  1.34k|    CoordIJK *ijk = &fijk->coord;
 1089|  1.34k|    int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|  1.34k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  1.34k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  1.34k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  1.34k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1090|       |
 1091|       |    // center base cell hierarchy is entirely on this face
 1092|  1.34k|    int possibleOverage = 1;
 1093|  1.34k|    if (!_isBaseCellPentagon(H3_GET_BASE_CELL(h)) &&
  ------------------
  |  |  118|  1.34k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.34k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.34k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.34k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
  |  Branch (1093:9): [True: 778, False: 566]
  ------------------
 1094|    778|        (res == 0 ||
  ------------------
  |  Branch (1094:10): [True: 62, False: 716]
  ------------------
 1095|    716|         (fijk->coord.i == 0 && fijk->coord.j == 0 && fijk->coord.k == 0)))
  ------------------
  |  Branch (1095:11): [True: 420, False: 296]
  |  Branch (1095:33): [True: 164, False: 256]
  |  Branch (1095:55): [True: 53, False: 111]
  ------------------
 1096|    115|        possibleOverage = 0;
 1097|       |
 1098|  16.1k|    for (int r = 1; r <= res; r++) {
  ------------------
  |  Branch (1098:21): [True: 14.8k, False: 1.34k]
  ------------------
 1099|  14.8k|        if (isResolutionClassIII(r)) {
  ------------------
  |  Branch (1099:13): [True: 7.94k, False: 6.91k]
  ------------------
 1100|       |            // Class III == rotate ccw
 1101|  7.94k|            _downAp7(ijk);
 1102|  7.94k|        } else {
 1103|       |            // Class II == rotate cw
 1104|  6.91k|            _downAp7r(ijk);
 1105|  6.91k|        }
 1106|       |
 1107|  14.8k|        _neighbor(ijk, H3_GET_INDEX_DIGIT(h, r));
  ------------------
  |  |  141|  14.8k|    ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   76|  14.8k|#define MAX_H3_RES 15
  |  |  ------------------
  |  |                   ((Direction)((((h3) >> ((MAX_H3_RES - (res)) * H3_PER_DIGIT_OFFSET)) & \
  |  |  ------------------
  |  |  |  |   47|  14.8k|#define H3_PER_DIGIT_OFFSET 3
  |  |  ------------------
  |  |  142|  14.8k|                  H3_DIGIT_MASK)))
  |  |  ------------------
  |  |  |  |   80|  14.8k|#define H3_DIGIT_MASK ((uint64_t)(7))
  |  |  ------------------
  ------------------
 1108|  14.8k|    }
 1109|       |
 1110|  1.34k|    return possibleOverage;
 1111|  1.34k|}
_h3ToFaceIjk:
 1118|  1.34k|H3Error _h3ToFaceIjk(H3Index h, FaceIJK *fijk) {
 1119|  1.34k|    int baseCell = H3_GET_BASE_CELL(h);
  ------------------
  |  |  118|  1.34k|#define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   62|  1.34k|#define H3_BC_MASK ((uint64_t)(127) << H3_BC_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   38|  1.34k|#define H3_BC_OFFSET 45
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_BASE_CELL(h3) ((int)((((h3)&H3_BC_MASK) >> H3_BC_OFFSET)))
  |  |  ------------------
  |  |  |  |   38|  1.34k|#define H3_BC_OFFSET 45
  |  |  ------------------
  ------------------
 1120|  1.34k|    if (NEVER(baseCell < 0) || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |  119|  2.69k|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 1.34k]
  |  |  |  Branch (119:19): [True: 0, False: 1.34k]
  |  |  ------------------
  ------------------
                  if (NEVER(baseCell < 0) || baseCell >= NUM_BASE_CELLS) {
  ------------------
  |  |   81|  1.34k|#define NUM_BASE_CELLS 122
  ------------------
  |  Branch (1120:9): [Folded, False: 0]
  |  Branch (1120:9): [Folded, False: 0]
  |  Branch (1120:32): [True: 3, False: 1.34k]
  ------------------
 1121|       |        // Base cells less than zero can not be represented in an index
 1122|       |        // To prevent reading uninitialized memory, we zero the output.
 1123|      3|        fijk->face = 0;
 1124|      3|        fijk->coord.i = fijk->coord.j = fijk->coord.k = 0;
 1125|      3|        return E_CELL_INVALID;
 1126|      3|    }
 1127|       |    // adjust for the pentagonal missing sequence; all of sub-sequence 5 needs
 1128|       |    // to be adjusted (and some of sub-sequence 4 below)
 1129|  1.34k|    if (_isBaseCellPentagon(baseCell) && _h3LeadingNonZeroDigit(h) == 5)
  ------------------
  |  Branch (1129:9): [True: 566, False: 778]
  |  Branch (1129:42): [True: 99, False: 467]
  ------------------
 1130|     99|        h = _h3Rotate60cw(h);
 1131|       |
 1132|       |    // start with the "home" face and ijk+ coordinates for the base cell of c
 1133|  1.34k|    *fijk = baseCellData[baseCell].homeFijk;
 1134|  1.34k|    if (!_h3ToFaceIjkWithInitializedFijk(h, fijk))
  ------------------
  |  Branch (1134:9): [True: 115, False: 1.22k]
  ------------------
 1135|    115|        return E_SUCCESS;  // no overage is possible; h lies on this face
 1136|       |
 1137|       |    // if we're here we have the potential for an "overage"; i.e., it is
 1138|       |    // possible that c lies on an adjacent face
 1139|       |
 1140|  1.22k|    CoordIJK origIJK = fijk->coord;
 1141|       |
 1142|       |    // if we're in Class III, drop into the next finer Class II grid
 1143|  1.22k|    int res = H3_GET_RESOLUTION(h);
  ------------------
  |  |  129|  1.22k|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|  1.22k|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|  1.22k|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|  1.22k|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1144|  1.22k|    if (isResolutionClassIII(res)) {
  ------------------
  |  Branch (1144:9): [True: 983, False: 246]
  ------------------
 1145|       |        // Class III
 1146|    983|        _downAp7r(&fijk->coord);
 1147|    983|        res++;
 1148|    983|    }
 1149|       |
 1150|       |    // adjust for overage if needed
 1151|       |    // a pentagon base cell with a leading 4 digit requires special handling
 1152|  1.22k|    int pentLeading4 =
 1153|  1.22k|        (_isBaseCellPentagon(baseCell) && _h3LeadingNonZeroDigit(h) == 4);
  ------------------
  |  Branch (1153:10): [True: 566, False: 663]
  |  Branch (1153:43): [True: 175, False: 391]
  ------------------
 1154|  1.22k|    if (_adjustOverageClassII(fijk, res, pentLeading4, 0) != NO_OVERAGE) {
  ------------------
  |  Branch (1154:9): [True: 601, False: 628]
  ------------------
 1155|       |        // if the base cell is a pentagon we have the potential for secondary
 1156|       |        // overages
 1157|    601|        if (_isBaseCellPentagon(baseCell)) {
  ------------------
  |  Branch (1157:13): [True: 424, False: 177]
  ------------------
 1158|    780|            while (_adjustOverageClassII(fijk, res, 0, 0) != NO_OVERAGE)
  ------------------
  |  Branch (1158:20): [True: 356, False: 424]
  ------------------
 1159|    356|                continue;
 1160|    424|        }
 1161|       |
 1162|    601|        if (res != H3_GET_RESOLUTION(h)) _upAp7r(&fijk->coord);
  ------------------
  |  |  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
  |  |  ------------------
  ------------------
  |  Branch (1162:13): [True: 498, False: 103]
  ------------------
 1163|    628|    } else if (res != H3_GET_RESOLUTION(h)) {
  ------------------
  |  |  129|    628|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    628|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    628|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    628|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
  |  Branch (1163:16): [True: 485, False: 143]
  ------------------
 1164|    485|        fijk->coord = origIJK;
 1165|    485|    }
 1166|  1.22k|    return E_SUCCESS;
 1167|  1.34k|}
maxFaceCount:
 1230|  1.17k|H3Error H3_EXPORT(maxFaceCount)(H3Index h3, int *out) {
 1231|       |    // a pentagon always intersects 5 faces, a hexagon never intersects more
 1232|       |    // than 2 (but may only intersect 1)
 1233|  1.17k|    *out = H3_EXPORT(isPentagon)(h3) ? 5 : 2;
  ------------------
  |  |   36|  1.17k|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|  1.17k|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|  1.17k|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1233:12): [True: 30, False: 1.14k]
  ------------------
 1234|  1.17k|    return E_SUCCESS;
 1235|  1.17k|}
getIcosahedronFaces:
 1246|    602|H3Error H3_EXPORT(getIcosahedronFaces)(H3Index h3, int *out) {
 1247|    602|    int res = H3_GET_RESOLUTION(h3);
  ------------------
  |  |  129|    602|#define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   68|    602|#define H3_RES_MASK (UINT64_C(15) << H3_RES_OFFSET)
  |  |  |  |  ------------------
  |  |  |  |  |  |   41|    602|#define H3_RES_OFFSET 52
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define H3_GET_RESOLUTION(h3) ((int)((((h3)&H3_RES_MASK) >> H3_RES_OFFSET)))
  |  |  ------------------
  |  |  |  |   41|    602|#define H3_RES_OFFSET 52
  |  |  ------------------
  ------------------
 1248|    602|    int isPent = H3_EXPORT(isPentagon)(h3);
  ------------------
  |  |   36|    602|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    602|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    602|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1249|       |
 1250|       |    // We can't use the vertex-based approach here for class II pentagons,
 1251|       |    // because all their vertices are on the icosahedron edges. Their
 1252|       |    // direct child pentagons cross the same faces, so use those instead.
 1253|    602|    if (isPent && !isResolutionClassIII(res)) {
  ------------------
  |  Branch (1253:9): [True: 28, False: 574]
  |  Branch (1253:19): [True: 13, False: 15]
  ------------------
 1254|       |        // Note that this would not work for res 15, but this is only run on
 1255|       |        // Class II pentagons, it should never be invoked for a res 15 index.
 1256|     13|        H3Index childPentagon = makeDirectChild(h3, 0);
 1257|     13|        return H3_EXPORT(getIcosahedronFaces)(childPentagon, out);
  ------------------
  |  |   36|     13|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|     13|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|     13|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1258|     13|    }
 1259|       |
 1260|       |    // convert to FaceIJK
 1261|    589|    FaceIJK fijk;
 1262|    589|    H3Error err = _h3ToFaceIjk(h3, &fijk);
 1263|    589|    if (err) {
  ------------------
  |  Branch (1263:9): [True: 3, False: 586]
  ------------------
 1264|      3|        return err;
 1265|      3|    }
 1266|       |
 1267|       |    // Get all vertices as FaceIJK addresses. For simplicity, always
 1268|       |    // initialize the array with 6 verts, ignoring the last one for pentagons
 1269|    586|    FaceIJK fijkVerts[NUM_HEX_VERTS];
 1270|    586|    int vertexCount;
 1271|       |
 1272|    586|    if (isPent) {
  ------------------
  |  Branch (1272:9): [True: 15, False: 571]
  ------------------
 1273|     15|        vertexCount = NUM_PENT_VERTS;
  ------------------
  |  |   85|     15|#define NUM_PENT_VERTS 5
  ------------------
 1274|     15|        _faceIjkPentToVerts(&fijk, &res, fijkVerts);
 1275|    571|    } else {
 1276|    571|        vertexCount = NUM_HEX_VERTS;
  ------------------
  |  |   83|    571|#define NUM_HEX_VERTS 6
  ------------------
 1277|    571|        _faceIjkToVerts(&fijk, &res, fijkVerts);
 1278|    571|    }
 1279|       |
 1280|       |    // We may not use all of the slots in the output array,
 1281|       |    // so fill with invalid values to indicate unused slots
 1282|    586|    int faceCount;
 1283|    586|    H3Error maxFaceCountError = H3_EXPORT(maxFaceCount)(h3, &faceCount);
  ------------------
  |  |   36|    586|#define H3_EXPORT(name) TJOIN(H3_PREFIX, name)
  |  |  ------------------
  |  |  |  |   33|    586|#define TJOIN(a, b) XTJOIN(a, b)
  |  |  |  |  ------------------
  |  |  |  |  |  |   32|    586|#define XTJOIN(a, b) a##b
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1284|    586|    if (NEVER(maxFaceCountError != E_SUCCESS)) {
  ------------------
  |  |  119|    586|#define NEVER(X) ((X) ? (assert(0), 1) : 0)
  |  |  ------------------
  |  |  |  Branch (119:18): [True: 0, False: 586]
  |  |  |  Branch (119:19): [True: 0, False: 586]
  |  |  ------------------
  ------------------
  |  Branch (1284:9): [Folded, False: 0]
  |  Branch (1284:9): [Folded, False: 0]
  ------------------
 1285|      0|        return maxFaceCountError;
 1286|      0|    }
 1287|  1.80k|    for (int i = 0; i < faceCount; i++) {
  ------------------
  |  Branch (1287:21): [True: 1.21k, False: 586]
  ------------------
 1288|  1.21k|        out[i] = INVALID_FACE;
  ------------------
  |  |   60|  1.21k|#define INVALID_FACE -1
  ------------------
 1289|  1.21k|    }
 1290|       |
 1291|       |    // add each vertex face, using the output array as a hash set
 1292|  4.07k|    for (int i = 0; i < vertexCount; i++) {
  ------------------
  |  Branch (1292:21): [True: 3.49k, False: 583]
  ------------------
 1293|  3.49k|        FaceIJK *vert = &fijkVerts[i];
 1294|       |
 1295|       |        // Adjust overage, determining whether this vertex is
 1296|       |        // on another face
 1297|  3.49k|        if (isPent) {
  ------------------
  |  Branch (1297:13): [True: 75, False: 3.42k]
  ------------------
 1298|     75|            _adjustPentVertOverage(vert, res);
 1299|  3.42k|        } else {
 1300|  3.42k|            _adjustOverageClassII(vert, res, 0, 1);
 1301|  3.42k|        }
 1302|       |
 1303|       |        // Save the face to the output array
 1304|  3.49k|        int face = vert->face;
 1305|  3.49k|        int pos = 0;
 1306|       |        // Find the first empty output position, or the first position
 1307|       |        // matching the current face
 1308|  3.76k|        while (out[pos] != INVALID_FACE && out[pos] != face) {
  ------------------
  |  |   60|  7.53k|#define INVALID_FACE -1
  ------------------
  |  Branch (1308:16): [True: 3.07k, False: 694]
  |  Branch (1308:44): [True: 274, False: 2.79k]
  ------------------
 1309|    274|            pos++;
 1310|    274|            if (pos >= faceCount) {
  ------------------
  |  Branch (1310:17): [True: 3, False: 271]
  ------------------
 1311|       |                // Mismatch between the heuristic used in maxFaceCount and
 1312|       |                // calculation here - indicates an invalid index.
 1313|      3|                return E_FAILED;
 1314|      3|            }
 1315|    274|        }
 1316|  3.49k|        out[pos] = face;
 1317|  3.49k|    }
 1318|    583|    return E_SUCCESS;
 1319|    586|}
isResolutionClassIII:
 1356|  20.3k|int isResolutionClassIII(int res) { return res % 2; }
h3Index.c:_hasGoodTopBits:
  216|  1.54k|static inline bool _hasGoodTopBits(H3Index h) {
  217|  1.54k|    h >>= (64 - 8);
  218|  1.54k|    return h == 0b00001000;
  219|  1.54k|}
h3Index.c:_hasAny7UptoRes:
  264|    568|static inline bool _hasAny7UptoRes(H3Index h, int res) {
  265|    568|    const uint64_t MHI = 0b100100100100100100100100100100100100100100100;
  266|    568|    const uint64_t MLO = MHI >> 2;
  267|       |
  268|    568|    int shift = 3 * (15 - res);
  269|    568|    h >>= shift;
  270|    568|    h <<= shift;
  271|    568|    h = (h & MHI & (~h - MLO));
  272|       |
  273|    568|    return h != 0;
  274|    568|}
h3Index.c:_hasAll7AfterRes:
  280|    502|static inline bool _hasAll7AfterRes(H3Index h, int res) {
  281|       |    // NOTE: res check is needed because we can't shift by 64
  282|    502|    if (res < 15) {
  ------------------
  |  Branch (282:9): [True: 235, False: 267]
  ------------------
  283|    235|        int shift = 19 + 3 * res;
  284|       |
  285|    235|        h = ~h;
  286|    235|        h <<= shift;
  287|    235|        h >>= shift;
  288|       |
  289|    235|        return h == 0;
  290|    235|    }
  291|    267|    return true;
  292|    502|}
h3Index.c:_hasDeletedSubsequence:
  327|    412|static inline bool _hasDeletedSubsequence(H3Index h, int base_cell) {
  328|    412|    if (isBaseCellPentagonArr[base_cell]) {
  ------------------
  |  Branch (328:9): [True: 224, False: 188]
  ------------------
  329|    224|        h <<= 19;
  330|    224|        h >>= 19;
  331|       |
  332|    224|        if (h == 0) return false;  // all zeros: res 15 pentagon
  ------------------
  |  Branch (332:13): [True: 3, False: 221]
  ------------------
  333|    221|        return _firstOneIndex(h) % 3 == 0;
  334|    224|    }
  335|    188|    return false;
  336|    412|}
h3Index.c:_firstOneIndex:
  300|    221|static inline int _firstOneIndex(H3Index h) {
  301|    221|#if defined(__GNUC__) || defined(__clang__)
  302|    221|    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|    221|}

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

