LZ4_decompress_safe:
 2570|     94|{
 2571|     94|    return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize,
 2572|     94|                                  decode_full_block, noDict,
 2573|       |                                  (BYTE*)dest, NULL, 0);
 2574|     94|}
LZ4_decompress_safe_forceExtDict:
 2644|    109|{
 2645|    109|    DEBUGLOG(5, "LZ4_decompress_safe_forceExtDict");
  ------------------
  |  |  289|    109|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2646|    109|    return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize,
 2647|    109|                                  decode_full_block, usingExtDict,
 2648|    109|                                  (BYTE*)dest, (const BYTE*)dictStart, dictSize);
 2649|    109|}
LZ4_decompress_safe_usingDict:
 2843|    109|{
 2844|    109|    if (dictSize < 0) return -1;
  ------------------
  |  Branch (2844:9): [True: 0, False: 109]
  ------------------
 2845|    109|    if (dictSize==0)
  ------------------
  |  Branch (2845:9): [True: 0, False: 109]
  ------------------
 2846|      0|        return LZ4_decompress_safe(source, dest, compressedSize, maxOutputSize);
 2847|    109|    if (dictStart+dictSize == dest) {
  ------------------
  |  Branch (2847:9): [True: 0, False: 109]
  ------------------
 2848|      0|        if (dictSize >= 64 KB - 1) {
  ------------------
  |  |  251|      0|#define KB *(1 <<10)
  ------------------
  |  Branch (2848:13): [True: 0, False: 0]
  ------------------
 2849|      0|            return LZ4_decompress_safe_withPrefix64k(source, dest, compressedSize, maxOutputSize);
 2850|      0|        }
 2851|      0|        assert(dictSize >= 0);
  ------------------
  |  |  273|      0|#    define assert(condition) ((void)0)
  ------------------
 2852|      0|        return LZ4_decompress_safe_withSmallPrefix(source, dest, compressedSize, maxOutputSize, (size_t)dictSize);
 2853|      0|    }
 2854|    109|    assert(dictSize >= 0);
  ------------------
  |  |  273|    109|#    define assert(condition) ((void)0)
  ------------------
 2855|    109|    return LZ4_decompress_safe_forceExtDict(source, dest, compressedSize, maxOutputSize, dictStart, (size_t)dictSize);
 2856|    109|}
lz4.c:LZ4_isLittleEndian:
  364|    855|{
  365|    855|    const union { U32 u; BYTE c[4]; } one = { 1 };   /* don't use static : performance detrimental */
  366|    855|    return one.c[0];
  367|    855|}
lz4.c:LZ4_wildCopy8:
  466|    469|{
  467|    469|    BYTE* d = (BYTE*)dstPtr;
  468|    469|    const BYTE* s = (const BYTE*)srcPtr;
  469|    469|    BYTE* const e = (BYTE*)dstEnd;
  470|       |
  471|  6.67k|    do { LZ4_memcpy(d,s,8); d+=8; s+=8; } while (d<e);
  ------------------
  |  |  349|  6.67k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (471:50): [True: 6.20k, False: 469]
  ------------------
  472|    469|}
lz4.c:LZ4_read16:
  393|    855|static U16 LZ4_read16(const void* ptr) { return ((const LZ4_unalign16*)ptr)->u16; }
lz4.c:LZ4_write32:
  398|    462|static void LZ4_write32(void* memPtr, U32 value) { ((LZ4_unalign32*)memPtr)->u32 = value; }
lz4.c:LZ4_decompress_generic:
 2225|    203|{
 2226|    203|    if ((src == NULL) || (outputSize < 0)) { return -1; }
  ------------------
  |  Branch (2226:9): [True: 0, False: 203]
  |  Branch (2226:26): [True: 0, False: 203]
  ------------------
 2227|       |
 2228|    203|    {   const BYTE* ip = (const BYTE*) src;
 2229|    203|        const BYTE* const iend = ip + srcSize;
 2230|       |
 2231|    203|        BYTE* op = (BYTE*) dst;
 2232|    203|        BYTE* const oend = op + outputSize;
 2233|       |
 2234|    203|        const BYTE* const dictEnd = (dictStart == NULL) ? NULL : dictStart + dictSize;
  ------------------
  |  Branch (2234:37): [True: 94, False: 109]
  ------------------
 2235|       |
 2236|       |        /* withPrefix64k : offset <= 65535 can't reach beyond the 64 KB prefix */
 2237|    203|        const int checkOffset = (dict != withPrefix64k) && (dictSize < (int)(64 KB));
  ------------------
  |  |  251|    203|#define KB *(1 <<10)
  ------------------
  |  Branch (2237:33): [True: 203, False: 0]
  |  Branch (2237:60): [True: 203, False: 0]
  ------------------
 2238|       |
 2239|       |
 2240|       |        /* Set up the "end" pointers for the shortcut. */
 2241|    203|        const BYTE* const shortiend = iend - 14 /*maxLL*/ - 2 /*offset*/;
 2242|    203|        const BYTE* const shortoend = oend - 14 /*maxLL*/ - 18 /*maxML*/;
 2243|       |
 2244|       |        /* shared by both loops : the fast loop can hand over a decoded match (safe_match_copy) */
 2245|    203|        const BYTE* match;
 2246|    203|        size_t offset;
 2247|    203|        size_t ml;   /* match length */
 2248|       |
 2249|       |
 2250|    203|        DEBUGLOG(5, "LZ4_decompress_generic (srcSize:%i, dstSize:%i)", srcSize, outputSize);
  ------------------
  |  |  289|    203|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2251|       |
 2252|       |        /* Special cases */
 2253|    203|        assert(lowPrefix <= op);
  ------------------
  |  |  273|    203|#    define assert(condition) ((void)0)
  ------------------
 2254|    203|        if (unlikely(outputSize==0)) {
  ------------------
  |  |  180|    203|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    203|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 203]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2255|       |            /* Empty output buffer */
 2256|      0|            if (partialDecoding) return 0;
  ------------------
  |  Branch (2256:17): [True: 0, False: 0]
  ------------------
 2257|      0|            if ((srcSize==1) && (*ip==0)) return 0;   /* empty block */
  ------------------
  |  Branch (2257:17): [True: 0, False: 0]
  |  Branch (2257:33): [True: 0, False: 0]
  ------------------
 2258|      0|            return (srcSize > 1) ? -2 : -1;   /* -2 : output buffer too small */
  ------------------
  |  Branch (2258:20): [True: 0, False: 0]
  ------------------
 2259|      0|        }
 2260|    203|        if (unlikely(srcSize<=0)) { return -1; }
  ------------------
  |  |  180|    203|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    203|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 203]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2261|       |
 2262|       |    /* LZ4_FAST_DEC_LOOP:
 2263|       |     * designed for modern OoO performance cpus,
 2264|       |     * where copying reliably 32-bytes is preferable to an unpredictable branch.
 2265|       |     * note : fast loop may show a regression for some client arm chips. */
 2266|    203|#if LZ4_FAST_DEC_LOOP
 2267|    203|        if ((oend - op) < FASTLOOP_SAFE_DISTANCE) {
  ------------------
  |  |  248|    203|#define FASTLOOP_SAFE_DISTANCE 64
  ------------------
  |  Branch (2267:13): [True: 9, False: 194]
  ------------------
 2268|      9|            DEBUGLOG(6, "move to safe decode loop");
  ------------------
  |  |  289|      9|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2269|      9|            goto safe_decode;
 2270|      9|        }
 2271|       |        /* Ring buffer restarting at its beginning : the oldest referenced history (max distance behind op)
 2272|       |         * lies in the external dictionary, ahead of op, always at the same distance.
 2273|       |         * Rings sized with the former LZ4_DECODER_RING_BUFFER_SIZE() (margin 14, up to v1.10.0)
 2274|       |         * still work, but leave as little as 16 bytes :
 2275|       |         * the fast loop's wide copies could overwrite it, the safe loop's can't. */
 2276|    194|        if ( (dict==usingExtDict)
  ------------------
  |  Branch (2276:14): [True: 106, False: 88]
  ------------------
 2277|    106|          && ((uptrval)dictEnd - (uptrval)lowPrefix - LZ4_DISTANCE_ABSOLUTE_MAX < FASTLOOP_SAFE_DISTANCE) ) {
  ------------------
  |  |  255|    106|#define LZ4_DISTANCE_ABSOLUTE_MAX 65535
  ------------------
                        && ((uptrval)dictEnd - (uptrval)lowPrefix - LZ4_DISTANCE_ABSOLUTE_MAX < FASTLOOP_SAFE_DISTANCE) ) {
  ------------------
  |  |  248|    106|#define FASTLOOP_SAFE_DISTANCE 64
  ------------------
  |  Branch (2277:14): [True: 0, False: 106]
  ------------------
 2278|      0|            DEBUGLOG(6, "history just ahead : move to safe decode loop");
  ------------------
  |  |  289|      0|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2279|      0|            goto safe_decode;
 2280|      0|        }
 2281|       |
 2282|       |        /* Fast loop : decode sequences as long as output < oend-FASTLOOP_SAFE_DISTANCE,
 2283|       |         * and input is not too close to iend.
 2284|       |         * It hands over to the safe loop either at a sequence start (break),
 2285|       |         * or once a match is fully decoded (goto safe_match_copy). */
 2286|    194|        DEBUGLOG(6, "using fast decode loop");
  ------------------
  |  |  289|    194|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2287|    673|        while (1) {
  ------------------
  |  Branch (2287:16): [True: 673, Folded]
  ------------------
 2288|    673|            unsigned token;
 2289|    673|            size_t ll;   /* literal length */
 2290|    673|            BYTE* cpy;
 2291|       |            /* Main fastloop assertion: We can always wildcopy FASTLOOP_SAFE_DISTANCE */
 2292|    673|            assert(oend - op >= FASTLOOP_SAFE_DISTANCE);
  ------------------
  |  |  273|    673|#    define assert(condition) ((void)0)
  ------------------
 2293|    673|            assert(ip < iend);
  ------------------
  |  |  273|    673|#    define assert(condition) ((void)0)
  ------------------
 2294|    673|            token = *ip++;
 2295|    673|            ll = token >> ML_BITS;
  ------------------
  |  |  260|    673|#define ML_BITS  4
  ------------------
 2296|    673|            DEBUGLOG(7, "blockPos%6u: litLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)ll);
  ------------------
  |  |  289|    673|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2297|       |
 2298|       |            /* too close to input end : the safe loop restarts this sequence */
 2299|    673|            if (ip > iend-(16 + 1/*max lit + offset + nextToken*/)) { ip--; break; }
  ------------------
  |  Branch (2299:17): [True: 50, False: 623]
  ------------------
 2300|       |
 2301|       |            /* decode literal length */
 2302|    623|            if (ll == RUN_MASK) {
  ------------------
  |  |  263|    623|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|    623|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|    623|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2302:17): [True: 117, False: 506]
  ------------------
 2303|       |                /* literal length >= RUN_MASK means >= RUN_MASK literal bytes follow the extension bytes,
 2304|       |                 * so extension bytes cannot reach the last RUN_MASK bytes of input */
 2305|    117|                const BYTE* const tokenPos = ip-1;
 2306|    117|                size_t const addl = read_variable_length(&ip, iend - RUN_MASK);
  ------------------
  |  |  263|    117|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|    117|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|    117|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2307|    117|                if (addl == rvl_error) {
  ------------------
  |  Branch (2307:21): [True: 5, False: 112]
  ------------------
 2308|      5|                    DEBUGLOG(6, "error reading long literal length");
  ------------------
  |  |  289|      5|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2309|      5|                    goto _output_error;
 2310|      5|                }
 2311|    112|                ll += addl;
 2312|    112|                if (unlikely((uptrval)(op)+ll<(uptrval)(op))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|    112|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    112|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 112]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2313|    112|                if (unlikely((uptrval)(ip)+ll<(uptrval)(ip))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|    112|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    112|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 112]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2314|       |
 2315|       |                /* copy literals, unless too close to the end for a wild copy :
 2316|       |                 * nothing is written yet, so the safe loop can restart this sequence */
 2317|    112|                cpy = op+ll;
 2318|    112|                LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
  ------------------
  |  |  277|    112|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
 2319|    112|              #if LZ4_WILDCOPY64
 2320|    112|                if ((cpy>oend-64) || (ip+ll>iend-64)) { ip = tokenPos; break; }
  ------------------
  |  Branch (2320:21): [True: 9, False: 103]
  |  Branch (2320:38): [True: 96, False: 7]
  ------------------
 2321|      7|                LZ4_wildCopy64(op, ip, cpy);
 2322|       |              #else
 2323|       |                if ((cpy>oend-32) || (ip+ll>iend-32)) { ip = tokenPos; break; }
 2324|       |                LZ4_wildCopy32(op, ip, cpy);
 2325|       |              #endif
 2326|      7|                ip += ll; op = cpy;
 2327|    506|            } else {
 2328|    506|                DEBUGLOG(7, "copy %u bytes in a 16-bytes stripe", (unsigned)ll);
  ------------------
  |  |  289|    506|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2329|       |                /* Literals can only be <= 14, but hope compilers optimize better when copy by a register size */
 2330|    506|                LZ4_memcpy(op, ip, 16);
  ------------------
  |  |  349|    506|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2331|    506|                ip += ll; op += ll;
 2332|    506|            }
 2333|       |
 2334|       |            /* get offset */
 2335|    513|            offset = LZ4_readLE16(ip); ip+=2;
 2336|    513|            DEBUGLOG(6, "blockPos%6u: offset = %u", (unsigned)(op-(BYTE*)dst), (unsigned)offset);
  ------------------
  |  |  289|    513|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2337|    513|            match = op - offset;
 2338|    513|            assert(match <= op);  /* overflow check */
  ------------------
  |  |  273|    513|#    define assert(condition) ((void)0)
  ------------------
 2339|       |
 2340|       |            /* get matchlength */
 2341|    513|            ml = token & ML_MASK;
  ------------------
  |  |  261|    513|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    513|#define ML_BITS  4
  |  |  ------------------
  ------------------
 2342|    513|            DEBUGLOG(7, "  match length token = %u (len==%u)", (unsigned)ml, (unsigned)ml+MINMATCH);
  ------------------
  |  |  289|    513|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2343|       |
 2344|    513|            if (ml == ML_MASK) {
  ------------------
  |  |  261|    513|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    513|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2344:17): [True: 210, False: 303]
  ------------------
 2345|       |                /* after match length extension bytes, at least 1 token + LASTLITERALS literals must remain */
 2346|    210|                size_t const addl = read_variable_length(&ip, iend - (1 + LASTLITERALS));
  ------------------
  |  |  245|    210|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 2347|    210|                if (addl == rvl_error) {
  ------------------
  |  Branch (2347:21): [True: 1, False: 209]
  ------------------
 2348|      1|                    DEBUGLOG(5, "error reading long match length");
  ------------------
  |  |  289|      1|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2349|      1|                    goto _output_error;
 2350|      1|                }
 2351|    209|                ml += addl;
 2352|    209|                DEBUGLOG(7, "  long match length == %u", (unsigned)ml + MINMATCH);
  ------------------
  |  |  289|    209|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2353|    209|                if (unlikely((uptrval)(op)+ml<(uptrval)op)) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|    209|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    209|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 209]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2354|    209|            }
 2355|    512|            ml += MINMATCH;
  ------------------
  |  |  242|    512|#define MINMATCH 4
  ------------------
 2356|       |
 2357|    512|            if (op + ml >= oend - FASTLOOP_SAFE_DISTANCE) {
  ------------------
  |  |  248|    512|#define FASTLOOP_SAFE_DISTANCE 64
  ------------------
  |  Branch (2357:17): [True: 6, False: 506]
  ------------------
 2358|      6|                DEBUGLOG(7, "moving to safe_match_copy (ml==%u)", (unsigned)ml);
  ------------------
  |  |  289|      6|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2359|      6|                goto safe_match_copy;
 2360|      6|            }
 2361|       |
 2362|       |            /* match length from token only (<= 18), no overlap, within prefix : copy 18 bytes */
 2363|    506|            if ( ((token & ML_MASK) != ML_MASK) && (offset >= 8)
  ------------------
  |  |  261|    506|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    506|#define ML_BITS  4
  |  |  ------------------
  ------------------
                          if ( ((token & ML_MASK) != ML_MASK) && (offset >= 8)
  ------------------
  |  |  261|    506|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    506|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2363:18): [True: 302, False: 204]
  |  Branch (2363:52): [True: 68, False: 234]
  ------------------
 2364|     68|              && ((dict == withPrefix64k) || (match >= lowPrefix)) ) {
  ------------------
  |  Branch (2364:19): [True: 0, False: 68]
  |  Branch (2364:46): [True: 38, False: 30]
  ------------------
 2365|     38|                assert(match >= lowPrefix);
  ------------------
  |  |  273|     38|#    define assert(condition) ((void)0)
  ------------------
 2366|     38|                assert(match <= op);
  ------------------
  |  |  273|     38|#    define assert(condition) ((void)0)
  ------------------
 2367|     38|                assert(op + 18 <= oend);
  ------------------
  |  |  273|     38|#    define assert(condition) ((void)0)
  ------------------
 2368|     38|                LZ4_memcpy(op, match, 8);
  ------------------
  |  |  349|     38|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2369|     38|                LZ4_memcpy(op+8, match+8, 8);
  ------------------
  |  |  349|     38|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2370|     38|                LZ4_memcpy(op+16, match+16, 2);
  ------------------
  |  |  349|     38|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2371|     38|                op += ml;
 2372|     38|                continue;
 2373|     38|            }
 2374|       |
 2375|       |            /* match ends far from oend : no end-of-block condition to check */
 2376|    468|            assert(op + ml < oend - FASTLOOP_SAFE_DISTANCE);
  ------------------
  |  |  273|    468|#    define assert(condition) ((void)0)
  ------------------
 2377|       |
 2378|    468|            if ( checkOffset && (unlikely(match + dictSize < lowPrefix)) ) {
  ------------------
  |  |  180|    468|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    468|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (2378:18): [True: 468, False: 0]
  |  Branch (2378:33): [True: 27, False: 441]
  ------------------
 2379|     27|                DEBUGLOG(5, "Error : pos=%zi, offset=%zi => outside buffers", op-lowPrefix, op-match);
  ------------------
  |  |  289|     27|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2380|     27|                goto _offset_error;
 2381|     27|            }
 2382|       |            /* match starting within external dictionary */
 2383|    441|            if ((dict==usingExtDict) && (match < lowPrefix)) {
  ------------------
  |  Branch (2383:17): [True: 221, False: 220]
  |  Branch (2383:41): [True: 29, False: 192]
  ------------------
 2384|     29|                assert(dictEnd != NULL);
  ------------------
  |  |  273|     29|#    define assert(condition) ((void)0)
  ------------------
 2385|     29|                op = LZ4_copyExtDictMatch(op, match, ml, lowPrefix, dictEnd);
 2386|     29|                continue;
 2387|     29|            }
 2388|       |
 2389|       |            /* copy match within block */
 2390|    412|            cpy = op + ml;
 2391|       |
 2392|    412|            assert((op <= oend) && (oend-op >= 64));
  ------------------
  |  |  273|    412|#    define assert(condition) ((void)0)
  ------------------
 2393|    412|            if (unlikely(offset<16)) {
  ------------------
  |  |  180|    412|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    412|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 362, False: 50]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2394|    362|                LZ4_memcpy_using_offset(op, match, cpy, offset);
 2395|    362|    #if LZ4_WILDCOPY64
 2396|    362|            } else if (offset >= 64) {
  ------------------
  |  Branch (2396:24): [True: 23, False: 27]
  ------------------
 2397|     23|                LZ4_wildCopy64(op, match, cpy);
 2398|     23|    #endif
 2399|     27|            } else {
 2400|     27|                LZ4_wildCopy32(op, match, cpy);
 2401|     27|            }
 2402|       |
 2403|    412|            op = cpy;   /* wildcopy correction */
 2404|    412|        }
 2405|    164|    safe_decode:
 2406|    164|#endif
 2407|       |
 2408|       |        /* Safe loop : decode remaining sequences, without writing beyond oend nor reading beyond iend.
 2409|       |         * With LZ4_FAST_DEC_LOOP, that's the end of the block (or a block too small for the fast loop),
 2410|       |         * entered at a sequence start, or at safe_match_copy with a decoded match.
 2411|       |         * Without it, that's the whole block. */
 2412|    164|        DEBUGLOG(6, "using safe decode loop");
  ------------------
  |  |  289|    164|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2413|    457|        while (1) {
  ------------------
  |  Branch (2413:16): [True: 457, Folded]
  ------------------
 2414|    457|            unsigned token;
 2415|    457|            size_t ll;   /* literal length */
 2416|    457|            BYTE* cpy;
 2417|    457|            assert(ip < iend);
  ------------------
  |  |  273|    457|#    define assert(condition) ((void)0)
  ------------------
 2418|    457|            token = *ip++;
 2419|    457|            ll = token >> ML_BITS;
  ------------------
  |  |  260|    457|#define ML_BITS  4
  ------------------
 2420|    457|            DEBUGLOG(7, "blockPos%6u: litLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)ll);
  ------------------
  |  |  289|    457|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2421|       |
 2422|       |            /* A two-stage shortcut for the most common case:
 2423|       |             * 1) If the literal length is 0..14, and there is enough space,
 2424|       |             * enter the shortcut and copy 16 bytes on behalf of the literals.
 2425|       |             * 2) Further if the match length is 4..18, copy 18 bytes in a similar
 2426|       |             * manner; but we ensure that there's enough space in the output for
 2427|       |             * those 18 bytes earlier, upon entering the shortcut (in other words,
 2428|       |             * there is a combined check for both stages).
 2429|       |             */
 2430|    457|            if ( (ll != RUN_MASK)
  ------------------
  |  |  263|    457|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|    457|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|    457|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2430:18): [True: 309, False: 148]
  ------------------
 2431|       |                /* strictly "less than" on input, to re-enter the loop with at least one byte */
 2432|    309|              && likely((ip < shortiend) & (op <= shortoend)) ) {
  ------------------
  |  |  177|    309|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  171|    309|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 137, False: 172]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2433|       |                /* Copy the literals */
 2434|    137|                LZ4_memcpy(op, ip, 16);
  ------------------
  |  |  349|    137|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2435|    137|                op += ll; ip += ll;
 2436|       |
 2437|       |                /* The second stage: prepare for match copying, decode full info.
 2438|       |                 * If it doesn't work out, the info won't be wasted. */
 2439|    137|                offset = LZ4_readLE16(ip); ip += 2;
 2440|    137|                match = op - offset;
 2441|    137|                assert(match <= op); /* check overflow */
  ------------------
  |  |  273|    137|#    define assert(condition) ((void)0)
  ------------------
 2442|    137|                ml = token & ML_MASK;
  ------------------
  |  |  261|    137|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    137|#define ML_BITS  4
  |  |  ------------------
  ------------------
 2443|    137|                DEBUGLOG(7, "blockPos%6u: matchLength token = %u (len=%u)", (unsigned)(op-(BYTE*)dst), (unsigned)ml, (unsigned)ml + 4);
  ------------------
  |  |  289|    137|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2444|       |
 2445|       |                /* Do not deal with overlapping matches. */
 2446|    137|                if ( (ml != ML_MASK)
  ------------------
  |  |  261|    137|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    137|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2446:22): [True: 76, False: 61]
  ------------------
 2447|     76|                  && (offset >= 8)
  ------------------
  |  Branch (2447:22): [True: 33, False: 43]
  ------------------
 2448|     33|                  && (dict==withPrefix64k || match >= lowPrefix) ) {
  ------------------
  |  Branch (2448:23): [True: 0, False: 33]
  |  Branch (2448:46): [True: 23, False: 10]
  ------------------
 2449|       |                    /* Copy the match. */
 2450|     23|                    LZ4_memcpy(op + 0, match + 0, 8);
  ------------------
  |  |  349|     23|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2451|     23|                    LZ4_memcpy(op + 8, match + 8, 8);
  ------------------
  |  |  349|     23|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2452|     23|                    LZ4_memcpy(op +16, match +16, 2);
  ------------------
  |  |  349|     23|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2453|     23|                    op += ml + MINMATCH;
  ------------------
  |  |  242|     23|#define MINMATCH 4
  ------------------
 2454|       |                    /* Both stages worked, load the next token. */
 2455|     23|                    continue;
 2456|     23|                }
 2457|       |                /* The second stage didn't work out, but the info is ready for the match copy below. */
 2458|    320|            } else {
 2459|       |                /* decode literal length */
 2460|    320|                if (ll == RUN_MASK) {
  ------------------
  |  |  263|    320|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|    320|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|    320|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2460:21): [True: 148, False: 172]
  ------------------
 2461|       |                    /* literal length >= RUN_MASK means >= RUN_MASK literal bytes follow the extension bytes,
 2462|       |                     * so extension bytes cannot reach the last RUN_MASK bytes of input */
 2463|    148|                    size_t const addl = read_variable_length(&ip, iend-RUN_MASK);
  ------------------
  |  |  263|    148|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|    148|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|    148|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2464|    148|                    if (addl == rvl_error) { goto _output_error; }
  ------------------
  |  Branch (2464:25): [True: 22, False: 126]
  ------------------
 2465|    126|                    ll += addl;
 2466|    126|                    if (unlikely((uptrval)(op)+ll<(uptrval)(op))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|    126|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    126|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 126]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2467|    126|                    if (unlikely((uptrval)(ip)+ll<(uptrval)(ip))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|    126|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    126|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 126]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2468|    126|                }
 2469|       |
 2470|       |                /* copy literals */
 2471|    298|                cpy = op+ll;
 2472|    298|                LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
  ------------------
  |  |  277|    298|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
 2473|    298|                if ((cpy>oend-MFLIMIT) || (ip+ll>iend-(2+1+LASTLITERALS))) {
  ------------------
  |  |  246|    298|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
                              if ((cpy>oend-MFLIMIT) || (ip+ll>iend-(2+1+LASTLITERALS))) {
  ------------------
  |  |  245|    282|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (2473:21): [True: 16, False: 282]
  |  Branch (2473:43): [True: 77, False: 205]
  ------------------
 2474|       |                    /* close to input or output end : these must be the last literals of the block,
 2475|       |                     * except with partialDecoding, which can also stop within them */
 2476|     93|                    if (partialDecoding) {
  ------------------
  |  Branch (2476:25): [True: 0, False: 93]
  ------------------
 2477|       |                        /* stop at input end, or when output is full */
 2478|      0|                        ll = MIN(ll, (size_t)(iend-ip));
  ------------------
  |  | 1997|      0|#define MIN(a,b)    ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (1997:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2479|      0|                        ll = MIN(ll, (size_t)(oend-op));
  ------------------
  |  | 1997|      0|#define MIN(a,b)    ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (1997:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2480|     93|                    } else if ((ip+ll != iend) || (cpy > oend)) {
  ------------------
  |  Branch (2480:32): [True: 88, False: 5]
  |  Branch (2480:51): [True: 1, False: 4]
  ------------------
 2481|       |                        /* last literals must end exactly at input end, within output */
 2482|     89|                        DEBUGLOG(5, "invalid last literals : they end at iend%+zi and oend%+zi", (ip+ll)-iend, cpy-oend);
  ------------------
  |  |  289|     89|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2483|     89|                        if ((ip+ll <= iend) && (cpy > oend-MFLIMIT)) goto _dst_too_small;   /* output full, input left */
  ------------------
  |  |  246|     48|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (2483:29): [True: 48, False: 41]
  |  Branch (2483:48): [True: 6, False: 42]
  ------------------
 2484|     83|                        goto _output_error;
 2485|     89|                    }
 2486|      4|                    LZ4_memmove(op, ip, ll);  /* supports overlapping memory regions, for in-place decompression scenarios */
  ------------------
  |  |  357|      4|#    define LZ4_memmove __builtin_memmove
  ------------------
 2487|      4|                    ip += ll;
 2488|      4|                    op += ll;
 2489|       |                    /* end of block, unless partialDecoding can go on : output not full, input left for a match */
 2490|      4|                    if (!partialDecoding || (op == oend) || (ip >= (iend-2))) {
  ------------------
  |  Branch (2490:25): [True: 4, False: 0]
  |  Branch (2490:45): [True: 0, False: 0]
  |  Branch (2490:61): [True: 0, False: 0]
  ------------------
 2491|      4|                        break;
 2492|      4|                    }
 2493|    205|                } else {
 2494|    205|                    LZ4_wildCopy8(op, ip, cpy);   /* can overwrite up to 8 bytes beyond cpy */
 2495|    205|                    ip += ll; op = cpy;
 2496|    205|                }
 2497|       |
 2498|       |                /* get offset */
 2499|    205|                offset = LZ4_readLE16(ip); ip+=2;
 2500|    205|                match = op - offset;
 2501|       |
 2502|       |                /* get matchlength */
 2503|    205|                ml = token & ML_MASK;
  ------------------
  |  |  261|    205|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    205|#define ML_BITS  4
  |  |  ------------------
  ------------------
 2504|    205|                DEBUGLOG(7, "blockPos%6u: matchLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)ml);
  ------------------
  |  |  289|    205|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2505|    205|            }
 2506|       |
 2507|       |            /* literals copied, offset decoded, ml == match length token */
 2508|    319|            if (ml == ML_MASK) {
  ------------------
  |  |  261|    319|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    319|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2508:17): [True: 177, False: 142]
  ------------------
 2509|       |                /* after match length extension bytes, at least 1 token + LASTLITERALS literals must remain */
 2510|    177|                size_t const addl = read_variable_length(&ip, iend - (1 + LASTLITERALS));
  ------------------
  |  |  245|    177|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 2511|    177|                if (addl == rvl_error) { goto _output_error; }
  ------------------
  |  Branch (2511:21): [True: 9, False: 168]
  ------------------
 2512|    168|                ml += addl;
 2513|    168|                if (unlikely((uptrval)(op)+ml<(uptrval)op)) goto _output_error;   /* overflow detection */
  ------------------
  |  |  180|    168|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    168|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 168]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2514|    168|            }
 2515|    310|            ml += MINMATCH;
  ------------------
  |  |  242|    310|#define MINMATCH 4
  ------------------
 2516|       |
 2517|    310|#if LZ4_FAST_DEC_LOOP
 2518|    316|        safe_match_copy:
 2519|    316|#endif
 2520|       |            /* literals copied, match fully decoded (ml includes MINMATCH), offset not validated yet */
 2521|    316|            if ((checkOffset) && (unlikely(match + dictSize < lowPrefix))) goto _offset_error;   /* Error : offset outside buffers */
  ------------------
  |  |  180|    316|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    316|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (2521:17): [True: 316, False: 0]
  |  Branch (2521:34): [True: 44, False: 272]
  ------------------
 2522|       |
 2523|       |            /* end of block : the last LASTLITERALS bytes must be literals */
 2524|    272|            assert(op <= oend);
  ------------------
  |  |  273|    272|#    define assert(condition) ((void)0)
  ------------------
 2525|    272|            if (unlikely(op+ml > oend-LASTLITERALS)) {
  ------------------
  |  |  180|    272|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    272|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 2, False: 270]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2526|      2|                if (partialDecoding) ml = MIN(ml, (size_t)(oend-op));   /* partialDecoding : may end anywhere */
  ------------------
  |  | 1997|      0|#define MIN(a,b)    ( (a) < (b) ? (a) : (b) )
  |  |  ------------------
  |  |  |  Branch (1997:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (2526:21): [True: 0, False: 2]
  ------------------
 2527|      2|                else goto _dst_too_small;
 2528|      2|            }
 2529|       |
 2530|       |            /* match starting within external dictionary */
 2531|    270|            if ((dict==usingExtDict) && (match < lowPrefix)) {
  ------------------
  |  Branch (2531:17): [True: 153, False: 117]
  |  Branch (2531:41): [True: 21, False: 132]
  ------------------
 2532|     21|                assert(dictEnd != NULL);
  ------------------
  |  |  273|     21|#    define assert(condition) ((void)0)
  ------------------
 2533|     21|                op = LZ4_copyExtDictMatch(op, match, ml, lowPrefix, dictEnd);
 2534|     21|                continue;
 2535|     21|            }
 2536|    249|            assert(match >= lowPrefix);
  ------------------
  |  |  273|    249|#    define assert(condition) ((void)0)
  ------------------
 2537|       |
 2538|       |            /* close to block end : no wild copy */
 2539|    249|            if (unlikely(op+ml > oend-MATCH_SAFEGUARD_DISTANCE)) {
  ------------------
  |  |  180|    249|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    249|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 4, False: 245]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2540|      4|                op = LZ4_copyMatchExact(op, match, ml);
 2541|      4|                if (op == oend) { break; }   /* partialDecoding : output buffer full */
  ------------------
  |  Branch (2541:21): [True: 0, False: 4]
  ------------------
 2542|      4|                continue;
 2543|      4|            }
 2544|       |
 2545|       |            /* copy match within block */
 2546|    245|            cpy = op + ml;
 2547|    245|            LZ4_memcpy_using_offset_base(op, match, cpy, offset);
 2548|    245|            op = cpy;   /* wildcopy correction */
 2549|    245|        }
 2550|       |
 2551|       |        /* end of decoding */
 2552|      4|        DEBUGLOG(5, "decoded %i bytes", (int) (((char*)op)-dst));
  ------------------
  |  |  289|      4|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2553|      4|        return (int) (((char*)op)-dst);     /* Nb of output bytes decoded */
 2554|       |
 2555|       |        /* errors : see LZ4_decompress_safe() in lz4.h */
 2556|    120|    _output_error:
 2557|    120|        return -1;
 2558|      8|    _dst_too_small:
 2559|      8|        return -2;
 2560|     71|    _offset_error:
 2561|     71|        return -3;
 2562|    164|    }
 2563|    164|}
lz4.c:read_variable_length:
 2132|    652|{
 2133|    652|    Rvl_t s, length = 0;
 2134|    652|    assert(ipPtr != NULL);
  ------------------
  |  |  273|    652|#    define assert(condition) ((void)0)
  ------------------
 2135|    652|    assert(*ipPtr !=  NULL);
  ------------------
  |  |  273|    652|#    define assert(condition) ((void)0)
  ------------------
 2136|    652|    assert(ilimit != NULL);
  ------------------
  |  |  273|    652|#    define assert(condition) ((void)0)
  ------------------
 2137|    652|    if (unlikely((*ipPtr) >= ilimit)) {    /* read limit reached */
  ------------------
  |  |  180|    652|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    652|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 27, False: 625]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2138|     27|        return rvl_error;
 2139|     27|    }
 2140|    625|    s = **ipPtr;
 2141|    625|    (*ipPtr)++;
 2142|    625|    length += s;
 2143|    625|    if (likely(s != 255)) return length;
  ------------------
  |  |  177|    625|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  171|    625|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 440, False: 185]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2144|  1.06k|    do {
 2145|  1.06k|        if (unlikely((*ipPtr) >= ilimit)) {    /* read limit reached */
  ------------------
  |  |  180|  1.06k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  1.06k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 10, False: 1.05k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2146|     10|            return rvl_error;
 2147|     10|        }
 2148|  1.05k|        s = **ipPtr;
 2149|  1.05k|        (*ipPtr)++;
 2150|  1.05k|        length += s;
 2151|       |        /* accumulator overflow detection (32-bit mode only) */
 2152|  1.05k|        if ((sizeof(length) < 8) && unlikely(length > ((Rvl_t)(-1)/2)) ) {
  ------------------
  |  |  180|      0|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|      0|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2152:13): [Folded, False: 1.05k]
  ------------------
 2153|      0|            return rvl_error;
 2154|      0|        }
 2155|  1.05k|    } while (s == 255);
  ------------------
  |  Branch (2155:14): [True: 881, False: 175]
  ------------------
 2156|       |
 2157|    175|    return length;
 2158|    185|}
lz4.c:LZ4_wildCopy64:
  537|     30|{
  538|     30|    BYTE* d = (BYTE*)dstPtr;
  539|     30|    const BYTE* s = (const BYTE*)srcPtr;
  540|     30|    BYTE* const e = (BYTE*)dstEnd;
  541|       |
  542|    207|    do { LZ4_memcpy(d,s,64); d+=64; s+=64; } while (d<e);
  ------------------
  |  |  349|    207|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (542:53): [True: 177, False: 30]
  ------------------
  543|     30|}
lz4.c:LZ4_readLE16:
  431|    855|{
  432|    855|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (432:9): [True: 855, False: 0]
  ------------------
  433|    855|        return LZ4_read16(memPtr);
  434|    855|    } else {
  435|      0|        const BYTE* p = (const BYTE*)memPtr;
  436|      0|        return (U16)((U16)p[0] | (p[1]<<8));
  437|      0|    }
  438|    855|}
lz4.c:LZ4_copyExtDictMatch:
 2193|     50|{
 2194|     50|    if (length <= (size_t)(lowPrefix-match)) {
  ------------------
  |  Branch (2194:9): [True: 12, False: 38]
  ------------------
 2195|       |        /* match fits entirely within external dictionary : just copy */
 2196|     12|        LZ4_memmove(op, dictEnd - (lowPrefix-match), length);
  ------------------
  |  |  357|     12|#    define LZ4_memmove __builtin_memmove
  ------------------
 2197|     12|        return op + length;
 2198|     38|    } else {
 2199|       |        /* match stretches into both external dictionary and current block */
 2200|     38|        size_t const copySize = (size_t)(lowPrefix - match);
 2201|     38|        LZ4_memcpy(op, dictEnd - copySize, copySize);
  ------------------
  |  |  349|     38|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2202|     38|        return LZ4_copyMatchExact(op + copySize, lowPrefix, length - copySize);
 2203|     38|    }
 2204|     50|}
lz4.c:LZ4_memcpy_using_offset:
  564|    362|{
  565|    362|    BYTE v[8];
  566|       |
  567|    362|    assert(dstEnd >= dstPtr + MINMATCH);
  ------------------
  |  |  273|    362|#    define assert(condition) ((void)0)
  ------------------
  568|       |
  569|    362|    switch(offset) {
  570|     41|    case 1:
  ------------------
  |  Branch (570:5): [True: 41, False: 321]
  ------------------
  571|     41|        MEM_INIT(v, *srcPtr, 8);
  ------------------
  |  |  236|     41|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  234|     41|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
  572|     41|        break;
  573|      8|    case 2:
  ------------------
  |  Branch (573:5): [True: 8, False: 354]
  ------------------
  574|      8|        LZ4_memcpy(v, srcPtr, 2);
  ------------------
  |  |  349|      8|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  575|      8|        LZ4_memcpy(&v[2], srcPtr, 2);
  ------------------
  |  |  349|      8|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  576|       |#if defined(_MSC_VER) && (_MSC_VER <= 1937) /* MSVC 2022 ver 17.7 or earlier */
  577|       |#  pragma warning(push)
  578|       |#  pragma warning(disable : 6385) /* warning C6385: Reading invalid data from 'v'. */
  579|       |#endif
  580|      8|        LZ4_memcpy(&v[4], v, 4);
  ------------------
  |  |  349|      8|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  581|       |#if defined(_MSC_VER) && (_MSC_VER <= 1937) /* MSVC 2022 ver 17.7 or earlier */
  582|       |#  pragma warning(pop)
  583|       |#endif
  584|      8|        break;
  585|     25|    case 4:
  ------------------
  |  Branch (585:5): [True: 25, False: 337]
  ------------------
  586|     25|        LZ4_memcpy(v, srcPtr, 4);
  ------------------
  |  |  349|     25|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  587|     25|        LZ4_memcpy(&v[4], srcPtr, 4);
  ------------------
  |  |  349|     25|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  588|     25|        break;
  589|    288|    default:
  ------------------
  |  Branch (589:5): [True: 288, False: 74]
  ------------------
  590|    288|        LZ4_memcpy_using_offset_base(dstPtr, srcPtr, dstEnd, offset);
  591|    288|        return;
  592|    362|    }
  593|       |
  594|     74|    LZ4_memcpy(dstPtr, v, 8);
  ------------------
  |  |  349|     74|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  595|     74|    dstPtr += 8;
  596|    623|    while (dstPtr < dstEnd) {
  ------------------
  |  Branch (596:12): [True: 549, False: 74]
  ------------------
  597|    549|        LZ4_memcpy(dstPtr, v, 8);
  ------------------
  |  |  349|    549|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  598|    549|        dstPtr += 8;
  599|    549|    }
  600|     74|}
lz4.c:LZ4_wildCopy32:
  551|     27|{
  552|     27|    BYTE* d = (BYTE*)dstPtr;
  553|     27|    const BYTE* s = (const BYTE*)srcPtr;
  554|     27|    BYTE* const e = (BYTE*)dstEnd;
  555|       |
  556|    926|    do { LZ4_memcpy(d,s,16); LZ4_memcpy(d+16,s+16,16); d+=32; s+=32; } while (d<e);
  ------------------
  |  |  349|    926|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
                  do { LZ4_memcpy(d,s,16); LZ4_memcpy(d+16,s+16,16); d+=32; s+=32; } while (d<e);
  ------------------
  |  |  349|    926|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (556:79): [True: 899, False: 27]
  ------------------
  557|     27|}
lz4.c:LZ4_copyMatchExact:
 2167|     42|{
 2168|     42|    if (unlikely(match == op)) {   /* invalid offset 0 : clear the match segment, see doc/lz4_Block_format.md */
  ------------------
  |  |  180|     42|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|     42|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 3, False: 39]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2169|      3|        MEM_INIT(op, 0, length);
  ------------------
  |  |  236|      3|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  234|      3|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
 2170|      3|        return op + length;
 2171|      3|    }
 2172|       |    /* bytes from match to op repeat with period (op-match) :
 2173|       |     * copy all of them, so the distance doubles at each round.
 2174|       |     * Beyond 2 KB, keep the distance : larger copies of just written data are slower */
 2175|    212|    while (length > (size_t)(op - match)) {
  ------------------
  |  Branch (2175:12): [True: 173, False: 39]
  ------------------
 2176|    173|        size_t const available = (size_t)(op - match);
 2177|    173|        LZ4_memcpy(op, match, available);
  ------------------
  |  |  349|    173|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2178|    173|        op += available;
 2179|    173|        length -= available;
 2180|    173|        if (available >= 2048) match += available;
  ------------------
  |  Branch (2180:13): [True: 0, False: 173]
  ------------------
 2181|    173|    }
 2182|     39|    LZ4_memcpy(op, match, length);
  ------------------
  |  |  349|     39|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2183|     39|    return op + length;
 2184|     42|}
lz4.c:LZ4_memcpy_using_offset_base:
  497|    533|{
  498|    533|    assert(srcPtr + offset == dstPtr);
  ------------------
  |  |  273|    533|#    define assert(condition) ((void)0)
  ------------------
  499|    533|    if (unlikely(offset < 8)) {
  ------------------
  |  |  180|    533|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    533|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 462, False: 71]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  500|    462|        LZ4_write32(dstPtr, 0);   /* silence an msan warning when offset==0 */
  501|    462|        dstPtr[0] = srcPtr[0];
  502|    462|        dstPtr[1] = srcPtr[1];
  503|    462|        dstPtr[2] = srcPtr[2];
  504|    462|        dstPtr[3] = srcPtr[3];
  505|    462|        srcPtr += inc32table[offset];
  506|    462|        LZ4_memcpy(dstPtr+4, srcPtr, 4);
  ------------------
  |  |  349|    462|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  507|    462|        srcPtr -= dec64table[offset];
  508|    462|    } else {
  509|     71|        LZ4_memcpy(dstPtr, srcPtr, 8);
  ------------------
  |  |  349|     71|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  510|     71|        srcPtr += 8;
  511|     71|    }
  512|    533|    dstPtr += 8;
  513|       |
  514|       |    /* srcPtr is now at least 8 bytes behind dstPtr */
  515|    533|    LZ4_memcpy(dstPtr, srcPtr, 8);
  ------------------
  |  |  349|    533|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  516|    533|    if (dstEnd > dstPtr + 8) { LZ4_wildCopy8(dstPtr + 8, srcPtr + 8, dstEnd); }
  ------------------
  |  Branch (516:9): [True: 264, False: 269]
  ------------------
  517|    533|}

x86_check_features:
   79|      1|void Z_INTERNAL x86_check_features(struct x86_cpu_features *features) {
   80|      1|    unsigned eax, ebx, ecx, edx;
   81|      1|    unsigned maxbasic;
   82|       |
   83|      1|    cpuid(0, &maxbasic, &ebx, &ecx, &edx);
   84|      1|    cpuid(1 /*CPU_PROCINFO_AND_FEATUREBITS*/, &eax, &ebx, &ecx, &edx);
   85|       |
   86|      1|    features->has_sse2 = edx & 0x4000000;
   87|      1|    features->has_ssse3 = ecx & 0x200;
   88|      1|    features->has_sse41 = ecx & 0x80000;
   89|      1|    features->has_sse42 = ecx & 0x100000;
   90|      1|    features->has_pclmulqdq = ecx & 0x2;
   91|       |
   92|      1|    if (ecx & 0x08000000) {
  ------------------
  |  Branch (92:9): [True: 1, False: 0]
  ------------------
   93|      1|        uint64_t xfeature = xgetbv(0);
   94|       |
   95|      1|        features->has_os_save_ymm = ((xfeature & 0x06) == 0x06);
   96|      1|        features->has_os_save_zmm = ((xfeature & 0xe6) == 0xe6);
   97|      1|    }
   98|       |
   99|      1|    if (maxbasic >= 7) {
  ------------------
  |  Branch (99:9): [True: 1, False: 0]
  ------------------
  100|       |        // Reference: https://software.intel.com/sites/default/files/article/405250/how-to-detect-new-instruction-support-in-the-4th-generation-intel-core-processor-family.pdf
  101|      1|        cpuidex(7, 0, &eax, &ebx, &ecx, &edx);
  102|       |
  103|       |        // check BMI2 bit
  104|      1|        features->has_bmi2 = ebx & 0x100;
  105|       |
  106|       |        // check AVX2 bit if the OS supports saving YMM registers
  107|      1|        if (features->has_os_save_ymm) {
  ------------------
  |  Branch (107:13): [True: 1, False: 0]
  ------------------
  108|      1|            features->has_avx2 = ebx & 0x20;
  109|      1|        }
  110|       |
  111|       |        // check AVX512 bits if the OS supports saving ZMM registers
  112|      1|        if (features->has_os_save_zmm) {
  ------------------
  |  Branch (112:13): [True: 0, False: 1]
  ------------------
  113|      0|            features->has_avx512f = ebx & 0x00010000;
  114|      0|            if (features->has_avx512f) {
  ------------------
  |  Branch (114:17): [True: 0, False: 0]
  ------------------
  115|       |                // According to the Intel Software Developer's Manual, AVX512F must be enabled too in order to enable
  116|       |                // AVX512(DQ,BW,VL).
  117|      0|                features->has_avx512dq = ebx & 0x00020000;
  118|      0|                features->has_avx512bw = ebx & 0x40000000;
  119|      0|                features->has_avx512vl = ebx & 0x80000000;
  120|      0|            }
  121|      0|            features->has_avx512_common = features->has_avx512f && features->has_avx512dq && features->has_avx512bw \
  ------------------
  |  Branch (121:43): [True: 0, False: 0]
  |  Branch (121:68): [True: 0, False: 0]
  |  Branch (121:94): [True: 0, False: 0]
  ------------------
  122|      0|              && features->has_avx512vl && features->has_bmi2;
  ------------------
  |  Branch (122:18): [True: 0, False: 0]
  |  Branch (122:44): [True: 0, False: 0]
  ------------------
  123|      0|            features->has_avx512vnni = ecx & 0x800;
  124|      0|            features->has_vpclmulqdq = ecx & 0x400;
  125|      0|        }
  126|      1|    }
  127|      1|}
x86_features.c:cpuid:
   30|      2|static inline void cpuid(int info, unsigned* eax, unsigned* ebx, unsigned* ecx, unsigned* edx) {
   31|       |#if defined(HAVE_CPUID_MS)
   32|       |    unsigned int registers[4];
   33|       |    __cpuid((int *)registers, info);
   34|       |
   35|       |    *eax = registers[0];
   36|       |    *ebx = registers[1];
   37|       |    *ecx = registers[2];
   38|       |    *edx = registers[3];
   39|       |#elif defined(HAVE_CPUID_GNU)
   40|       |    *eax = *ebx = *ecx = *edx = 0;
   41|      2|    __cpuid(info, *eax, *ebx, *ecx, *edx);
   42|       |#else
   43|       |    /* When using this fallback, the faster SSE/AVX code is disabled */
   44|       |    *eax = *ebx = *ecx = *edx = 0;
   45|       |#endif
   46|      2|}
x86_features.c:xgetbv:
   66|      1|static inline uint64_t xgetbv(unsigned int xcr) {
   67|      1|#if defined(_MSC_VER) || defined(X86_HAVE_XSAVE_INTRIN)
   68|      1|    return _xgetbv(xcr);
   69|       |#elif defined(__GNUC__)
   70|       |    uint32_t eax, edx;
   71|       |    __asm__ ( ".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c"(xcr));
   72|       |    return (uint64_t)(edx) << 32 | eax;
   73|       |#else
   74|       |    /* When using this fallback, some of the faster code is disabled */
   75|       |    return 0;
   76|       |#endif
   77|      1|}
x86_features.c:cpuidex:
   48|      1|static inline void cpuidex(int info, int subinfo, unsigned* eax, unsigned* ebx, unsigned* ecx, unsigned* edx) {
   49|       |#if defined(HAVE_CPUID_MS)
   50|       |    unsigned int registers[4];
   51|       |    __cpuidex((int *)registers, info, subinfo);
   52|       |
   53|       |    *eax = registers[0];
   54|       |    *ebx = registers[1];
   55|       |    *ecx = registers[2];
   56|       |    *edx = registers[3];
   57|       |#elif defined(HAVE_CPUID_GNU)
   58|       |    *eax = *ebx = *ecx = *edx = 0;
   59|      1|    __cpuid_count(info, subinfo, *eax, *ebx, *ecx, *edx);
   60|       |#else
   61|       |    /* When using this fallback, the faster SSE/AVX code is disabled */
   62|       |    *eax = *ebx = *ecx = *edx = 0;
   63|       |#endif
   64|      1|}

cpu_check_features:
   10|      1|Z_INTERNAL void cpu_check_features(struct cpu_features *features) {
   11|      1|    memset(features, 0, sizeof(struct cpu_features));
   12|      1|#if defined(X86_FEATURES)
   13|      1|    x86_check_features(&features->x86);
   14|       |#elif defined(ARM_FEATURES)
   15|       |    arm_check_features(&features->arm);
   16|       |#elif defined(PPC_FEATURES) || defined(POWER_FEATURES)
   17|       |    power_check_features(&features->power);
   18|       |#elif defined(S390_FEATURES)
   19|       |    s390_check_features(&features->s390);
   20|       |#elif defined(RISCV_FEATURES)
   21|       |    riscv_check_features(&features->riscv);
   22|       |#elif defined(LOONGARCH_FEATURES)
   23|       |    loongarch_check_features(&features->loongarch);
   24|       |#endif
   25|      1|}

functable.c:force_init_stub:
  377|      1|static int force_init_stub(void) {
  378|      1|    return init_functable();
  379|      1|}
functable.c:init_functable:
   70|      1|static int init_functable(void) {
   71|      1|    struct functable_s ft;
   72|      1|    struct cpu_features cf;
   73|       |
   74|      1|    memset(&ft, 0, sizeof(struct functable_s));
   75|      1|    cpu_check_features(&cf);
   76|      1|    ft.force_init = &force_init_empty;
   77|       |
   78|       |    // Set up generic C code fallbacks
   79|      1|#ifndef WITH_ALL_FALLBACKS
   80|      1|#  if (defined(__x86_64__) || defined(_M_X64)) && defined(X86_SSE2)
   81|       |    // x86_64 always has SSE2, so we can use SSE2 functions as fallbacks where available.
   82|      1|    ft.adler32 = &adler32_c;
   83|      1|    ft.adler32_fold_copy = &adler32_fold_copy_c;
   84|      1|    ft.crc32 = &crc32_braid;
   85|      1|    ft.crc32_fold = &crc32_fold_c;
   86|      1|    ft.crc32_fold_copy = &crc32_fold_copy_c;
   87|      1|    ft.crc32_fold_final = &crc32_fold_final_c;
   88|      1|    ft.crc32_fold_reset = &crc32_fold_reset_c;
   89|       |#    ifndef HAVE_BUILTIN_CTZ
   90|       |    ft.longest_match = &longest_match_c;
   91|       |    ft.longest_match_slow = &longest_match_slow_c;
   92|       |    ft.compare256 = &compare256_c;
   93|       |#    endif
   94|      1|#  endif
   95|       |#else // WITH_ALL_FALLBACKS
   96|       |    ft.adler32 = &adler32_c;
   97|       |    ft.adler32_fold_copy = &adler32_fold_copy_c;
   98|       |    ft.chunkmemset_safe = &chunkmemset_safe_c;
   99|       |    ft.crc32 = &crc32_braid;
  100|       |    ft.crc32_fold = &crc32_fold_c;
  101|       |    ft.crc32_fold_copy = &crc32_fold_copy_c;
  102|       |    ft.crc32_fold_final = &crc32_fold_final_c;
  103|       |    ft.crc32_fold_reset = &crc32_fold_reset_c;
  104|       |    ft.inflate_fast = &inflate_fast_c;
  105|       |    ft.slide_hash = &slide_hash_c;
  106|       |    ft.longest_match = &longest_match_c;
  107|       |    ft.longest_match_slow = &longest_match_slow_c;
  108|       |    ft.compare256 = &compare256_c;
  109|       |#endif
  110|       |
  111|       |    // Select arch-optimized functions
  112|      1|#ifdef WITH_OPTIM
  113|       |
  114|       |    // Chorba generic C fallback
  115|      1|#ifndef WITHOUT_CHORBA
  116|      1|    ft.crc32 = &crc32_chorba;
  117|      1|#endif
  118|       |
  119|       |    // X86 - SSE2
  120|      1|#ifdef X86_SSE2
  121|       |#  if !defined(__x86_64__) && !defined(_M_X64)
  122|       |    if (cf.x86.has_sse2)
  123|       |#  endif
  124|      1|    {
  125|      1|        ft.chunkmemset_safe = &chunkmemset_safe_sse2;
  126|      1|#  if !defined(WITHOUT_CHORBA_SSE)
  127|      1|        ft.crc32 = &crc32_chorba_sse2;
  128|      1|#  endif
  129|      1|        ft.inflate_fast = &inflate_fast_sse2;
  130|      1|        ft.slide_hash = &slide_hash_sse2;
  131|      1|#  ifdef HAVE_BUILTIN_CTZ
  132|      1|        ft.compare256 = &compare256_sse2;
  133|      1|        ft.longest_match = &longest_match_sse2;
  134|      1|        ft.longest_match_slow = &longest_match_slow_sse2;
  135|      1|#  endif
  136|      1|    }
  137|      1|#endif
  138|       |    // X86 - SSSE3
  139|      1|#ifdef X86_SSSE3
  140|      1|    if (cf.x86.has_ssse3) {
  ------------------
  |  Branch (140:9): [True: 1, False: 0]
  ------------------
  141|      1|        ft.adler32 = &adler32_ssse3;
  142|      1|        ft.chunkmemset_safe = &chunkmemset_safe_ssse3;
  143|      1|        ft.inflate_fast = &inflate_fast_ssse3;
  144|      1|    }
  145|      1|#endif
  146|       |
  147|       |    // X86 - SSE4.1
  148|      1|#if defined(X86_SSE41) && !defined(WITHOUT_CHORBA_SSE)
  149|      1|    if (cf.x86.has_sse41) {
  ------------------
  |  Branch (149:9): [True: 1, False: 0]
  ------------------
  150|      1|        ft.crc32 = &crc32_chorba_sse41;
  151|      1|    }
  152|      1|#endif
  153|       |
  154|       |    // X86 - SSE4.2
  155|      1|#ifdef X86_SSE42
  156|      1|    if (cf.x86.has_sse42) {
  ------------------
  |  Branch (156:9): [True: 1, False: 0]
  ------------------
  157|      1|        ft.adler32_fold_copy = &adler32_fold_copy_sse42;
  158|      1|    }
  159|      1|#endif
  160|       |    // X86 - PCLMUL
  161|      1|#ifdef X86_PCLMULQDQ_CRC
  162|      1|    if (cf.x86.has_pclmulqdq) {
  ------------------
  |  Branch (162:9): [True: 1, False: 0]
  ------------------
  163|      1|        ft.crc32 = &crc32_pclmulqdq;
  164|      1|        ft.crc32_fold = &crc32_fold_pclmulqdq;
  165|      1|        ft.crc32_fold_copy = &crc32_fold_pclmulqdq_copy;
  166|      1|        ft.crc32_fold_final = &crc32_fold_pclmulqdq_final;
  167|      1|        ft.crc32_fold_reset = &crc32_fold_pclmulqdq_reset;
  168|      1|    }
  169|      1|#endif
  170|       |    // X86 - AVX
  171|      1|#ifdef X86_AVX2
  172|       |    /* BMI2 support is all but implicit with AVX2 but let's sanity check this just in case. Enabling BMI2 allows for
  173|       |     * flagless shifts, resulting in fewer flag stalls for the pipeline, and allows us to set destination registers
  174|       |     * for the shift results as an operand, eliminating several register-register moves when the original value needs
  175|       |     * to remain intact. They also allow for a count operand that isn't the CL register, avoiding contention there */
  176|      1|    if (cf.x86.has_avx2 && cf.x86.has_bmi2) {
  ------------------
  |  Branch (176:9): [True: 1, False: 0]
  |  Branch (176:28): [True: 1, False: 0]
  ------------------
  177|      1|        ft.adler32 = &adler32_avx2;
  178|      1|        ft.adler32_fold_copy = &adler32_fold_copy_avx2;
  179|      1|        ft.chunkmemset_safe = &chunkmemset_safe_avx2;
  180|      1|        ft.inflate_fast = &inflate_fast_avx2;
  181|      1|        ft.slide_hash = &slide_hash_avx2;
  182|      1|#  ifdef HAVE_BUILTIN_CTZ
  183|      1|        ft.compare256 = &compare256_avx2;
  184|      1|        ft.longest_match = &longest_match_avx2;
  185|      1|        ft.longest_match_slow = &longest_match_slow_avx2;
  186|      1|#  endif
  187|      1|    }
  188|      1|#endif
  189|       |    // X86 - AVX512 (F,DQ,BW,Vl)
  190|      1|#ifdef X86_AVX512
  191|      1|    if (cf.x86.has_avx512_common) {
  ------------------
  |  Branch (191:9): [True: 0, False: 1]
  ------------------
  192|      0|        ft.adler32 = &adler32_avx512;
  193|      0|        ft.adler32_fold_copy = &adler32_fold_copy_avx512;
  194|      0|        ft.chunkmemset_safe = &chunkmemset_safe_avx512;
  195|      0|        ft.inflate_fast = &inflate_fast_avx512;
  196|      0|#  ifdef HAVE_BUILTIN_CTZLL
  197|      0|        ft.compare256 = &compare256_avx512;
  198|      0|        ft.longest_match = &longest_match_avx512;
  199|      0|        ft.longest_match_slow = &longest_match_slow_avx512;
  200|      0|#  endif
  201|      0|    }
  202|      1|#endif
  203|      1|#ifdef X86_AVX512VNNI
  204|      1|    if (cf.x86.has_avx512vnni) {
  ------------------
  |  Branch (204:9): [True: 0, False: 1]
  ------------------
  205|      0|        ft.adler32 = &adler32_avx512_vnni;
  206|      0|        ft.adler32_fold_copy = &adler32_fold_copy_avx512_vnni;
  207|      0|    }
  208|      1|#endif
  209|       |    // X86 - VPCLMULQDQ
  210|      1|#ifdef X86_VPCLMULQDQ_CRC
  211|      1|    if (cf.x86.has_pclmulqdq && cf.x86.has_avx512_common && cf.x86.has_vpclmulqdq) {
  ------------------
  |  Branch (211:9): [True: 1, False: 0]
  |  Branch (211:33): [True: 0, False: 1]
  |  Branch (211:61): [True: 0, False: 0]
  ------------------
  212|      0|        ft.crc32 = &crc32_vpclmulqdq;
  213|      0|        ft.crc32_fold = &crc32_fold_vpclmulqdq;
  214|      0|        ft.crc32_fold_copy = &crc32_fold_vpclmulqdq_copy;
  215|      0|        ft.crc32_fold_final = &crc32_fold_vpclmulqdq_final;
  216|      0|        ft.crc32_fold_reset = &crc32_fold_vpclmulqdq_reset;
  217|      0|    }
  218|      1|#endif
  219|       |
  220|       |
  221|       |    // ARM - SIMD
  222|       |#ifdef ARM_SIMD
  223|       |#  ifndef ARM_NOCHECK_SIMD
  224|       |    if (cf.arm.has_simd)
  225|       |#  endif
  226|       |    {
  227|       |        ft.slide_hash = &slide_hash_armv6;
  228|       |    }
  229|       |#endif
  230|       |    // ARM - NEON
  231|       |#ifdef ARM_NEON
  232|       |#  ifndef ARM_NOCHECK_NEON
  233|       |    if (cf.arm.has_neon)
  234|       |#  endif
  235|       |    {
  236|       |        ft.adler32 = &adler32_neon;
  237|       |        ft.adler32_fold_copy = &adler32_fold_copy_neon;
  238|       |        ft.chunkmemset_safe = &chunkmemset_safe_neon;
  239|       |        ft.inflate_fast = &inflate_fast_neon;
  240|       |        ft.slide_hash = &slide_hash_neon;
  241|       |#  ifdef HAVE_BUILTIN_CTZLL
  242|       |        ft.compare256 = &compare256_neon;
  243|       |        ft.longest_match = &longest_match_neon;
  244|       |        ft.longest_match_slow = &longest_match_slow_neon;
  245|       |#  endif
  246|       |    }
  247|       |#endif
  248|       |    // ARM - CRC32
  249|       |#ifdef ARM_CRC32
  250|       |    if (cf.arm.has_crc32) {
  251|       |        ft.crc32 = &crc32_armv8;
  252|       |        ft.crc32_fold = &crc32_fold_armv8;
  253|       |        ft.crc32_fold_copy = &crc32_fold_copy_armv8;
  254|       |    }
  255|       |#endif
  256|       |
  257|       |
  258|       |    // Power - VMX
  259|       |#ifdef PPC_VMX
  260|       |    if (cf.power.has_altivec) {
  261|       |        ft.adler32 = &adler32_vmx;
  262|       |        ft.slide_hash = &slide_hash_vmx;
  263|       |    }
  264|       |#endif
  265|       |    // Power8 - VSX
  266|       |#ifdef POWER8_VSX
  267|       |    if (cf.power.has_arch_2_07) {
  268|       |        ft.adler32 = &adler32_power8;
  269|       |        ft.chunkmemset_safe = &chunkmemset_safe_power8;
  270|       |        ft.inflate_fast = &inflate_fast_power8;
  271|       |        ft.slide_hash = &slide_hash_power8;
  272|       |    }
  273|       |#endif
  274|       |#ifdef POWER8_VSX_CRC32
  275|       |    if (cf.power.has_arch_2_07)
  276|       |        ft.crc32 = &crc32_power8;
  277|       |#endif
  278|       |    // Power9
  279|       |#ifdef POWER9
  280|       |    if (cf.power.has_arch_3_00) {
  281|       |        ft.compare256 = &compare256_power9;
  282|       |        ft.longest_match = &longest_match_power9;
  283|       |        ft.longest_match_slow = &longest_match_slow_power9;
  284|       |    }
  285|       |#endif
  286|       |
  287|       |
  288|       |    // RISCV - RVV
  289|       |#ifdef RISCV_RVV
  290|       |    if (cf.riscv.has_rvv) {
  291|       |        ft.adler32 = &adler32_rvv;
  292|       |        ft.adler32_fold_copy = &adler32_fold_copy_rvv;
  293|       |        ft.chunkmemset_safe = &chunkmemset_safe_rvv;
  294|       |        ft.compare256 = &compare256_rvv;
  295|       |        ft.inflate_fast = &inflate_fast_rvv;
  296|       |        ft.longest_match = &longest_match_rvv;
  297|       |        ft.longest_match_slow = &longest_match_slow_rvv;
  298|       |        ft.slide_hash = &slide_hash_rvv;
  299|       |    }
  300|       |#endif
  301|       |
  302|       |    // RISCV - ZBC
  303|       |#ifdef RISCV_CRC32_ZBC
  304|       |    if (cf.riscv.has_zbc) {
  305|       |        ft.crc32 = &crc32_riscv64_zbc;
  306|       |    }
  307|       |#endif
  308|       |
  309|       |    // S390
  310|       |#ifdef S390_CRC32_VX
  311|       |    if (cf.s390.has_vx)
  312|       |        ft.crc32 = crc32_s390_vx;
  313|       |#endif
  314|       |
  315|       |    // LOONGARCH
  316|       |#ifdef LOONGARCH_CRC
  317|       |    if (cf.loongarch.has_crc) {
  318|       |        ft.crc32 = crc32_loongarch64;
  319|       |        ft.crc32_fold = &crc32_fold_loongarch64;
  320|       |        ft.crc32_fold_copy = &crc32_fold_copy_loongarch64;
  321|       |    }
  322|       |#endif
  323|       |#ifdef LOONGARCH_LSX
  324|       |    if (cf.loongarch.has_lsx) {
  325|       |        ft.adler32 = &adler32_lsx;
  326|       |        ft.adler32_fold_copy = &adler32_fold_copy_lsx;
  327|       |        ft.slide_hash = slide_hash_lsx;
  328|       |#  ifdef HAVE_BUILTIN_CTZ
  329|       |        ft.compare256 = &compare256_lsx;
  330|       |        ft.longest_match = &longest_match_lsx;
  331|       |        ft.longest_match_slow = &longest_match_slow_lsx;
  332|       |#  endif
  333|       |        ft.chunkmemset_safe = &chunkmemset_safe_lsx;
  334|       |        ft.inflate_fast = &inflate_fast_lsx;
  335|       |    }
  336|       |#endif
  337|       |#ifdef LOONGARCH_LASX
  338|       |    if (cf.loongarch.has_lasx) {
  339|       |        ft.adler32 = &adler32_lasx;
  340|       |        ft.adler32_fold_copy = &adler32_fold_copy_lasx;
  341|       |        ft.slide_hash = slide_hash_lasx;
  342|       |#  ifdef HAVE_BUILTIN_CTZ
  343|       |        ft.compare256 = &compare256_lasx;
  344|       |        ft.longest_match = &longest_match_lasx;
  345|       |        ft.longest_match_slow = &longest_match_slow_lasx;
  346|       |#  endif
  347|       |        ft.chunkmemset_safe = &chunkmemset_safe_lasx;
  348|       |        ft.inflate_fast = &inflate_fast_lasx;
  349|       |    }
  350|       |#endif
  351|       |
  352|      1|#endif // WITH_OPTIM
  353|       |
  354|       |    // Assign function pointers individually for atomic operation
  355|      1|    FUNCTABLE_ASSIGN(ft, force_init);
  ------------------
  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  ------------------
  356|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, adler32);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  357|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, adler32_fold_copy);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  358|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, chunkmemset_safe);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  359|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, compare256);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  360|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, crc32);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  361|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, crc32_fold);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  362|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, crc32_fold_copy);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  363|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, crc32_fold_final);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  364|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, crc32_fold_reset);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  365|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, inflate_fast);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  366|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, longest_match);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  367|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, longest_match_slow);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  368|      1|    FUNCTABLE_VERIFY_ASSIGN(ft, slide_hash);
  ------------------
  |  |   46|      1|    if (!VAR.FUNC_NAME) { \
  |  |  ------------------
  |  |  |  Branch (46:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   47|      0|        fprintf(stderr, "Zlib-ng functable failed initialization!\n"); \
  |  |   48|      0|        return 1; \
  |  |   49|      0|    } \
  |  |   50|      1|    FUNCTABLE_ASSIGN(VAR, FUNC_NAME);
  |  |  ------------------
  |  |  |  |   20|      1|    __atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
  |  |  ------------------
  ------------------
  369|       |
  370|       |    // Memory barrier for weak memory order CPUs
  371|      1|    FUNCTABLE_BARRIER();
  ------------------
  |  |   21|      1|#  define FUNCTABLE_BARRIER() __atomic_thread_fence(__ATOMIC_SEQ_CST)
  ------------------
  372|       |
  373|      1|    return Z_OK;
  ------------------
  |  |  180|      1|#define Z_OK            0
  ------------------
  374|      1|}
functable.c:force_init_empty:
   63|      4|static int force_init_empty(void) {
   64|      4|    return 0;
   65|      4|}

zng_inflateResetKeep:
   61|      5|int32_t Z_EXPORT PREFIX(inflateResetKeep)(PREFIX3(stream) *strm) {
   62|      5|    struct inflate_state *state;
   63|       |
   64|      5|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (64:9): [True: 0, False: 5]
  ------------------
   65|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
   66|      5|    state = (struct inflate_state *)strm->state;
   67|      5|    strm->total_in = strm->total_out = state->total = 0;
   68|      5|    strm->msg = NULL;
   69|      5|    if (state->wrap)        /* to support ill-conceived Java test suite */
  ------------------
  |  Branch (69:9): [True: 5, False: 0]
  ------------------
   70|      5|        strm->adler = state->wrap & 1;
   71|      5|    state->mode = HEAD;
   72|      5|    state->check = ADLER32_INITIAL_VALUE;
  ------------------
  |  |   65|      5|#define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */
  ------------------
   73|      5|    state->last = 0;
   74|      5|    state->havedict = 0;
   75|      5|    state->flags = -1;
   76|      5|    state->head = NULL;
   77|      5|    state->hold = 0;
   78|      5|    state->bits = 0;
   79|      5|    state->lencode = state->distcode = state->next = state->codes;
   80|      5|    state->back = -1;
   81|       |#ifdef INFLATE_STRICT
   82|       |    state->dmax = 32768U;
   83|       |#endif
   84|       |#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
   85|       |    state->sane = 1;
   86|       |#endif
   87|      5|    INFLATE_RESET_KEEP_HOOK(strm);  /* hook for IBM Z DFLTCC */
  ------------------
  |  |   25|      5|#  define INFLATE_RESET_KEEP_HOOK(strm) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (25:54): [Folded, False: 5]
  |  |  ------------------
  ------------------
   88|      5|    Tracev((stderr, "inflate: reset\n"));
   89|      5|    return Z_OK;
  ------------------
  |  |  180|      5|#define Z_OK            0
  ------------------
   90|      5|}
zng_inflateReset:
   92|      5|int32_t Z_EXPORT PREFIX(inflateReset)(PREFIX3(stream) *strm) {
   93|      5|    struct inflate_state *state;
   94|       |
   95|      5|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (95:9): [True: 0, False: 5]
  ------------------
   96|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
   97|      5|    state = (struct inflate_state *)strm->state;
   98|      5|    state->wsize = 0;
   99|      5|    state->whave = 0;
  100|      5|    state->wnext = 0;
  101|      5|    return PREFIX(inflateResetKeep)(strm);
  ------------------
  |  |   97|      5|#  define PREFIX(x) zng_ ## x
  ------------------
  102|      5|}
zng_inflateReset2:
  104|      5|int32_t Z_EXPORT PREFIX(inflateReset2)(PREFIX3(stream) *strm, int32_t windowBits) {
  105|      5|    int wrap;
  106|      5|    struct inflate_state *state;
  107|       |
  108|       |    /* get the state */
  109|      5|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (109:9): [True: 0, False: 5]
  ------------------
  110|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  111|      5|    state = (struct inflate_state *)strm->state;
  112|       |
  113|       |    /* extract wrap request from windowBits parameter */
  114|      5|    if (windowBits < 0) {
  ------------------
  |  Branch (114:9): [True: 0, False: 5]
  ------------------
  115|      0|        wrap = 0;
  116|      0|        if (windowBits < -MAX_WBITS)
  ------------------
  |  |   39|      0|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  |  Branch (116:13): [True: 0, False: 0]
  ------------------
  117|      0|            return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  118|      0|        windowBits = -windowBits;
  119|      5|    } else {
  120|      5|        wrap = (windowBits >> 4) + 5;
  121|      5|#ifdef GUNZIP
  122|      5|        if (windowBits < 48)
  ------------------
  |  Branch (122:13): [True: 5, False: 0]
  ------------------
  123|      5|            windowBits &= MAX_WBITS;
  ------------------
  |  |   39|      5|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  124|      5|#endif
  125|      5|    }
  126|       |
  127|       |    /* set number of window bits */
  128|      5|    if (windowBits && (windowBits < MIN_WBITS || windowBits > MAX_WBITS))
  ------------------
  |  |   36|     10|#  define MIN_WBITS   8  /* 256 LZ77 window */
  ------------------
                  if (windowBits && (windowBits < MIN_WBITS || windowBits > MAX_WBITS))
  ------------------
  |  |   39|      5|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  |  Branch (128:9): [True: 5, False: 0]
  |  Branch (128:24): [True: 0, False: 5]
  |  Branch (128:50): [True: 0, False: 5]
  ------------------
  129|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  130|       |
  131|       |    /* update state and reset the rest of it */
  132|      5|    state->wrap = wrap;
  133|      5|    state->wbits = (unsigned)windowBits;
  134|      5|    return PREFIX(inflateReset)(strm);
  ------------------
  |  |   97|      5|#  define PREFIX(x) zng_ ## x
  ------------------
  135|      5|}
alloc_inflate:
  152|      5|Z_INTERNAL inflate_allocs* alloc_inflate(PREFIX3(stream) *strm) {
  153|      5|    int curr_size = 0;
  154|       |
  155|       |    /* Define sizes */
  156|      5|    int window_size = INFLATE_ADJUST_WINDOW_SIZE((1 << MAX_WBITS) + 64); /* 64B padding for chunksize */
  ------------------
  |  |   23|      5|#  define INFLATE_ADJUST_WINDOW_SIZE(n) (n)
  ------------------
  157|      5|    int state_size = sizeof(inflate_state);
  158|      5|    int alloc_size = sizeof(inflate_allocs);
  159|       |
  160|       |    /* Calculate relative buffer positions and paddings */
  161|      5|    LOGSZP("window", window_size, PAD_WINDOW(curr_size), PADSZ(curr_size,WINDOW_PAD_SIZE));
  162|      5|    int window_pos = PAD_WINDOW(curr_size);
  ------------------
  |  |  465|      5|#  define PAD_WINDOW            PAD_64
  |  |  ------------------
  |  |  |  |  245|      5|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  |  |  ------------------
  |  |  |  |  |  |  243|      5|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|      5|    curr_size = window_pos + window_size;
  164|       |
  165|      5|    LOGSZP("state", state_size, PAD_64(curr_size), PADSZ(curr_size,64));
  166|      5|    int state_pos = PAD_64(curr_size);
  ------------------
  |  |  245|      5|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  ------------------
  |  |  |  |  243|      5|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  167|      5|    curr_size = state_pos + state_size;
  168|       |
  169|      5|    LOGSZP("alloc", alloc_size, PAD_16(curr_size), PADSZ(curr_size,16));
  170|      5|    int alloc_pos = PAD_16(curr_size);
  ------------------
  |  |  244|      5|#define PAD_16(bpos) ((bpos) + PADSZ((bpos),16))
  |  |  ------------------
  |  |  |  |  243|      5|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  171|      5|    curr_size = alloc_pos + alloc_size;
  172|       |
  173|       |    /* Add 64-1 or 4096-1 to allow window alignment, and round size of buffer up to multiple of 64 */
  174|      5|    int total_size = PAD_64(curr_size + (WINDOW_PAD_SIZE - 1));
  ------------------
  |  |  245|      5|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  ------------------
  |  |  |  |  243|      5|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  175|       |
  176|       |    /* Allocate buffer, align to 64-byte cacheline, and zerofill the resulting buffer */
  177|      5|    char *original_buf = (char *)strm->zalloc(strm->opaque, 1, total_size);
  178|      5|    if (original_buf == NULL)
  ------------------
  |  Branch (178:9): [True: 0, False: 5]
  ------------------
  179|      0|        return NULL;
  180|       |
  181|      5|    char *buff = (char *)HINT_ALIGNED_WINDOW((char *)PAD_WINDOW(original_buf));
  ------------------
  |  |  467|      5|#  define HINT_ALIGNED_WINDOW   HINT_ALIGNED_64
  |  |  ------------------
  |  |  |  |  236|      5|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  |  |  ------------------
  |  |  |  |  |  |  231|      5|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|      5|    LOGSZPL("Buffer alloc", total_size, PADSZ((uintptr_t)original_buf,WINDOW_PAD_SIZE), PADSZ(curr_size,WINDOW_PAD_SIZE));
  183|       |
  184|       |    /* Initialize alloc_bufs */
  185|      5|    inflate_allocs *alloc_bufs  = (struct inflate_allocs_s *)(buff + alloc_pos);
  186|      5|    alloc_bufs->buf_start = original_buf;
  187|      5|    alloc_bufs->zfree = strm->zfree;
  188|       |
  189|      5|    alloc_bufs->window =  (unsigned char *)HINT_ALIGNED_WINDOW((buff + window_pos));
  ------------------
  |  |  467|      5|#  define HINT_ALIGNED_WINDOW   HINT_ALIGNED_64
  |  |  ------------------
  |  |  |  |  236|      5|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  |  |  ------------------
  |  |  |  |  |  |  231|      5|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  190|      5|    alloc_bufs->state = (inflate_state *)HINT_ALIGNED_64((buff + state_pos));
  ------------------
  |  |  236|      5|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  ------------------
  |  |  |  |  231|      5|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  ------------------
  ------------------
  191|       |
  192|       |#ifdef Z_MEMORY_SANITIZER
  193|       |    /* This is _not_ to subvert the memory sanitizer but to instead unposion some
  194|       |       data we willingly and purposefully load uninitialized into vector registers
  195|       |       in order to safely read the last < chunksize bytes of the window. */
  196|       |    __msan_unpoison(alloc_bufs->window + window_size, 64);
  197|       |#endif
  198|       |
  199|      5|    return alloc_bufs;
  200|      5|}
free_inflate:
  205|      5|Z_INTERNAL void free_inflate(PREFIX3(stream) *strm) {
  206|      5|    struct inflate_state *state = (struct inflate_state *)strm->state;
  207|       |
  208|      5|    if (state->alloc_bufs != NULL) {
  ------------------
  |  Branch (208:9): [True: 5, False: 0]
  ------------------
  209|      5|        inflate_allocs *alloc_bufs = state->alloc_bufs;
  210|      5|        alloc_bufs->zfree(strm->opaque, alloc_bufs->buf_start);
  211|       |        strm->state = NULL;
  212|      5|    }
  213|      5|}
zng_inflateInit2:
  219|      5|int32_t ZNG_CONDEXPORT PREFIX(inflateInit2)(PREFIX3(stream) *strm, int32_t windowBits) {
  220|      5|    struct inflate_state *state;
  221|      5|    int32_t ret;
  222|       |
  223|       |    /* Initialize functable */
  224|      5|    FUNCTABLE_INIT;
  ------------------
  |  |   48|      5|#  define FUNCTABLE_INIT if (functable.force_init()) {return Z_VERSION_ERROR;}
  |  |  ------------------
  |  |  |  |  188|      0|#define Z_VERSION_ERROR (-6)
  |  |  ------------------
  |  |  |  Branch (48:30): [True: 0, False: 5]
  |  |  ------------------
  ------------------
  225|       |
  226|      5|    if (strm == NULL)
  ------------------
  |  Branch (226:9): [True: 0, False: 5]
  ------------------
  227|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  228|      5|    strm->msg = NULL;                   /* in case we return an error */
  229|      5|    if (strm->zalloc == NULL) {
  ------------------
  |  Branch (229:9): [True: 5, False: 0]
  ------------------
  230|      5|        strm->zalloc = PREFIX(zcalloc);
  ------------------
  |  |   97|      5|#  define PREFIX(x) zng_ ## x
  ------------------
  231|      5|        strm->opaque = NULL;
  232|      5|    }
  233|      5|    if (strm->zfree == NULL)
  ------------------
  |  Branch (233:9): [True: 5, False: 0]
  ------------------
  234|      5|        strm->zfree = PREFIX(zcfree);
  ------------------
  |  |   97|      5|#  define PREFIX(x) zng_ ## x
  ------------------
  235|       |
  236|      5|    inflate_allocs *alloc_bufs = alloc_inflate(strm);
  237|      5|    if (alloc_bufs == NULL)
  ------------------
  |  Branch (237:9): [True: 0, False: 5]
  ------------------
  238|      0|        return Z_MEM_ERROR;
  ------------------
  |  |  186|      0|#define Z_MEM_ERROR    (-4)
  ------------------
  239|       |
  240|      5|    state = alloc_bufs->state;
  241|      5|    state->window = alloc_bufs->window;
  242|      5|    state->alloc_bufs = alloc_bufs;
  243|      5|    state->wbufsize = INFLATE_ADJUST_WINDOW_SIZE((1 << MAX_WBITS) + 64);
  ------------------
  |  |   23|      5|#  define INFLATE_ADJUST_WINDOW_SIZE(n) (n)
  ------------------
  244|      5|    Tracev((stderr, "inflate: allocated\n"));
  245|       |
  246|      5|    strm->state = (struct internal_state *)state;
  247|      5|    state->strm = strm;
  248|      5|    state->mode = HEAD;     /* to pass state test in inflateReset2() */
  249|      5|    ret = PREFIX(inflateReset2)(strm, windowBits);
  ------------------
  |  |   97|      5|#  define PREFIX(x) zng_ ## x
  ------------------
  250|      5|    if (ret != Z_OK) {
  ------------------
  |  |  180|      5|#define Z_OK            0
  ------------------
  |  Branch (250:9): [True: 0, False: 5]
  ------------------
  251|      0|        free_inflate(strm);
  252|      0|    }
  253|      5|    return ret;
  254|      5|}
zng_inflateInit:
  257|      5|int32_t Z_EXPORT PREFIX(inflateInit)(PREFIX3(stream) *strm) {
  258|      5|    return PREFIX(inflateInit2)(strm, DEF_WBITS);
  ------------------
  |  |   97|      5|#  define PREFIX(x) zng_ ## x
  ------------------
                  return PREFIX(inflateInit2)(strm, DEF_WBITS);
  ------------------
  |  |   35|      5|#  define DEF_WBITS MAX_WBITS
  |  |  ------------------
  |  |  |  |   39|      5|#  define MAX_WBITS   15 /* 32K LZ77 window */
  |  |  ------------------
  ------------------
  259|      5|}
zng_inflate:
  475|      8|int32_t Z_EXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int32_t flush) {
  476|      8|    struct inflate_state *state;
  477|      8|    const unsigned char *next;  /* next input */
  478|      8|    unsigned char *put;         /* next output */
  479|      8|    unsigned char *from;        /* where to copy match bytes from */
  480|      8|    unsigned have, left;        /* available input and output */
  481|      8|    uint64_t hold;              /* bit buffer */
  482|      8|    unsigned bits;              /* bits in bit buffer */
  483|      8|    uint32_t in, out;           /* save starting available input and output */
  484|      8|    unsigned copy;              /* number of stored or match bytes to copy */
  485|      8|    code here;                  /* current decoding table entry */
  486|      8|    code last;                  /* parent table entry */
  487|      8|    unsigned len;               /* length to copy for repeats, bits to drop */
  488|      8|    int32_t ret;                /* return code */
  489|      8|#ifdef GUNZIP
  490|      8|    unsigned char hbuf[4];      /* buffer for gzip header crc calculation */
  491|      8|#endif
  492|      8|    static const uint16_t order[19] = /* permutation of code lengths */
  493|      8|        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
  494|       |
  495|      8|    if (inflateStateCheck(strm) || strm->next_out == NULL ||
  ------------------
  |  Branch (495:9): [True: 0, False: 8]
  |  Branch (495:36): [True: 0, False: 8]
  ------------------
  496|      8|        (strm->next_in == NULL && strm->avail_in != 0))
  ------------------
  |  Branch (496:10): [True: 0, False: 8]
  |  Branch (496:35): [True: 0, False: 0]
  ------------------
  497|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  498|       |
  499|      8|    state = (struct inflate_state *)strm->state;
  500|      8|    if (state->mode == TYPE)      /* skip check */
  ------------------
  |  Branch (500:9): [True: 0, False: 8]
  ------------------
  501|      0|        state->mode = TYPEDO;
  502|      8|    LOAD();
  ------------------
  |  |   77|      8|    do { \
  |  |   78|      8|        put = strm->next_out; \
  |  |   79|      8|        left = strm->avail_out; \
  |  |   80|      8|        next = strm->next_in; \
  |  |   81|      8|        have = strm->avail_in; \
  |  |   82|      8|        hold = state->hold; \
  |  |   83|      8|        bits = state->bits; \
  |  |   84|      8|    } while (0)
  |  |  ------------------
  |  |  |  Branch (84:14): [Folded, False: 8]
  |  |  ------------------
  ------------------
  503|      8|    in = have;
  504|      8|    out = left;
  505|      8|    ret = Z_OK;
  ------------------
  |  |  180|      8|#define Z_OK            0
  ------------------
  506|      8|    for (;;)
  507|     10|        switch (state->mode) {
  508|      8|        case HEAD:
  ------------------
  |  Branch (508:9): [True: 8, False: 2]
  ------------------
  509|      8|            if (state->wrap == 0) {
  ------------------
  |  Branch (509:17): [True: 0, False: 8]
  ------------------
  510|      0|                state->mode = TYPEDO;
  511|      0|                break;
  512|      0|            }
  513|      8|            NEEDBITS(16);
  ------------------
  |  |  107|      8|    do { \
  |  |  108|     15|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 13, False: 2]
  |  |  ------------------
  |  |  109|     13|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|     13|    do { \
  |  |  |  |  387|     13|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 6, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  388|     13|        have--; \
  |  |  |  |  389|      7|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      7|        bits += 8; \
  |  |  |  |  391|      7|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      8|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
  514|      2|#ifdef GUNZIP
  515|      2|            if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */
  ------------------
  |  Branch (515:17): [True: 0, False: 2]
  |  Branch (515:38): [True: 0, False: 0]
  ------------------
  516|      0|                if (state->wbits == 0)
  ------------------
  |  Branch (516:21): [True: 0, False: 0]
  ------------------
  517|      0|                    state->wbits = MAX_WBITS;
  ------------------
  |  |   39|      0|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  518|      0|                state->check = CRC32_INITIAL_VALUE;
  ------------------
  |  |   66|      0|#define CRC32_INITIAL_VALUE   0 /* initial crc-32 hash value */
  ------------------
  519|      0|                CRC2(state->check, hold);
  ------------------
  |  |   59|      0|    do { \
  |  |   60|      0|        hbuf[0] = (unsigned char)(word); \
  |  |   61|      0|        hbuf[1] = (unsigned char)((word) >> 8); \
  |  |   62|      0|        check = PREFIX(crc32)(check, hbuf, 2); \
  |  |  ------------------
  |  |  |  |   97|      0|#  define PREFIX(x) zng_ ## x
  |  |  ------------------
  |  |   63|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (63:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  520|      0|                INITBITS();
  ------------------
  |  |   99|      0|    do { \
  |  |  100|      0|        hold = 0; \
  |  |  101|      0|        bits = 0; \
  |  |  102|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  521|      0|                state->mode = FLAGS;
  522|      0|                break;
  523|      0|            }
  524|      2|            if (state->head != NULL)
  ------------------
  |  Branch (524:17): [True: 0, False: 2]
  ------------------
  525|      0|                state->head->done = -1;
  526|      2|            if (!(state->wrap & 1) ||   /* check if zlib header allowed */
  ------------------
  |  Branch (526:17): [True: 0, False: 2]
  ------------------
  527|       |#else
  528|       |            if (
  529|       |#endif
  530|      2|                ((BITS(8) << 8) + (hold >> 8)) % 31) {
  ------------------
  |  |  114|      2|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  |  Branch (530:17): [True: 1, False: 1]
  ------------------
  531|      1|                SET_BAD("incorrect header check");
  ------------------
  |  |  132|      1|    do { \
  |  |  133|      1|        state->mode = BAD; \
  |  |  134|      1|        strm->msg = (char *)errmsg; \
  |  |  135|      1|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 1]
  |  |  ------------------
  ------------------
  532|      1|                break;
  533|      1|            }
  534|      1|            if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  114|      1|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
                          if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  212|      1|#define Z_DEFLATED   8
  ------------------
  |  Branch (534:17): [True: 0, False: 1]
  ------------------
  535|      0|                SET_BAD("unknown compression method");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  536|      0|                break;
  537|      0|            }
  538|      1|            DROPBITS(4);
  ------------------
  |  |  118|      1|    do { \
  |  |  119|      1|        hold >>= (n); \
  |  |  120|      1|        bits -= (unsigned)(n); \
  |  |  121|      1|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 1]
  |  |  ------------------
  ------------------
  539|      1|            len = BITS(4) + 8;
  ------------------
  |  |  114|      1|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  540|      1|            if (state->wbits == 0)
  ------------------
  |  Branch (540:17): [True: 0, False: 1]
  ------------------
  541|      0|                state->wbits = len;
  542|      1|            if (len > MAX_WBITS || len > state->wbits) {
  ------------------
  |  |   39|      2|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  |  Branch (542:17): [True: 1, False: 0]
  |  Branch (542:36): [True: 0, False: 0]
  ------------------
  543|      1|                SET_BAD("invalid window size");
  ------------------
  |  |  132|      1|    do { \
  |  |  133|      1|        state->mode = BAD; \
  |  |  134|      1|        strm->msg = (char *)errmsg; \
  |  |  135|      1|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 1]
  |  |  ------------------
  ------------------
  544|      1|                break;
  545|      1|            }
  546|       |#ifdef INFLATE_STRICT
  547|       |            state->dmax = 1U << len;
  548|       |#endif
  549|      0|            state->flags = 0;               /* indicate zlib header */
  550|      0|            Tracev((stderr, "inflate:   zlib header ok\n"));
  551|      0|            strm->adler = state->check = ADLER32_INITIAL_VALUE;
  ------------------
  |  |   65|      0|#define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */
  ------------------
  552|      0|            state->mode = hold & 0x200 ? DICTID : TYPE;
  ------------------
  |  Branch (552:27): [True: 0, False: 0]
  ------------------
  553|      0|            INITBITS();
  ------------------
  |  |   99|      0|    do { \
  |  |  100|      0|        hold = 0; \
  |  |  101|      0|        bits = 0; \
  |  |  102|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  554|      0|            break;
  555|      0|#ifdef GUNZIP
  556|       |
  557|      0|        case FLAGS:
  ------------------
  |  Branch (557:9): [True: 0, False: 10]
  ------------------
  558|      0|            NEEDBITS(16);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  559|      0|            state->flags = (int)(hold);
  560|      0|            if ((state->flags & 0xff) != Z_DEFLATED) {
  ------------------
  |  |  212|      0|#define Z_DEFLATED   8
  ------------------
  |  Branch (560:17): [True: 0, False: 0]
  ------------------
  561|      0|                SET_BAD("unknown compression method");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  562|      0|                break;
  563|      0|            }
  564|      0|            if (state->flags & 0xe000) {
  ------------------
  |  Branch (564:17): [True: 0, False: 0]
  ------------------
  565|      0|                SET_BAD("unknown header flags set");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  566|      0|                break;
  567|      0|            }
  568|      0|            if (state->head != NULL)
  ------------------
  |  Branch (568:17): [True: 0, False: 0]
  ------------------
  569|      0|                state->head->text = (int)((hold >> 8) & 1);
  570|      0|            if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (570:17): [True: 0, False: 0]
  |  Branch (570:44): [True: 0, False: 0]
  ------------------
  571|      0|                CRC2(state->check, hold);
  ------------------
  |  |   59|      0|    do { \
  |  |   60|      0|        hbuf[0] = (unsigned char)(word); \
  |  |   61|      0|        hbuf[1] = (unsigned char)((word) >> 8); \
  |  |   62|      0|        check = PREFIX(crc32)(check, hbuf, 2); \
  |  |  ------------------
  |  |  |  |   97|      0|#  define PREFIX(x) zng_ ## x
  |  |  ------------------
  |  |   63|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (63:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  572|      0|            INITBITS();
  ------------------
  |  |   99|      0|    do { \
  |  |  100|      0|        hold = 0; \
  |  |  101|      0|        bits = 0; \
  |  |  102|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  573|      0|            state->mode = TIME;
  574|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  575|       |
  576|      0|        case TIME:
  ------------------
  |  Branch (576:9): [True: 0, False: 10]
  ------------------
  577|      0|            NEEDBITS(32);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  578|      0|            if (state->head != NULL)
  ------------------
  |  Branch (578:17): [True: 0, False: 0]
  ------------------
  579|      0|                state->head->time = (unsigned)(hold);
  580|      0|            if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (580:17): [True: 0, False: 0]
  |  Branch (580:44): [True: 0, False: 0]
  ------------------
  581|      0|                CRC4(state->check, hold);
  ------------------
  |  |   66|      0|    do { \
  |  |   67|      0|        hbuf[0] = (unsigned char)(word); \
  |  |   68|      0|        hbuf[1] = (unsigned char)((word) >> 8); \
  |  |   69|      0|        hbuf[2] = (unsigned char)((word) >> 16); \
  |  |   70|      0|        hbuf[3] = (unsigned char)((word) >> 24); \
  |  |   71|      0|        check = PREFIX(crc32)(check, hbuf, 4); \
  |  |  ------------------
  |  |  |  |   97|      0|#  define PREFIX(x) zng_ ## x
  |  |  ------------------
  |  |   72|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (72:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  582|      0|            INITBITS();
  ------------------
  |  |   99|      0|    do { \
  |  |  100|      0|        hold = 0; \
  |  |  101|      0|        bits = 0; \
  |  |  102|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  583|      0|            state->mode = OS;
  584|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  585|       |
  586|      0|        case OS:
  ------------------
  |  Branch (586:9): [True: 0, False: 10]
  ------------------
  587|      0|            NEEDBITS(16);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  588|      0|            if (state->head != NULL) {
  ------------------
  |  Branch (588:17): [True: 0, False: 0]
  ------------------
  589|      0|                state->head->xflags = (int)(hold & 0xff);
  590|      0|                state->head->os = (int)(hold >> 8);
  591|      0|            }
  592|      0|            if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (592:17): [True: 0, False: 0]
  |  Branch (592:44): [True: 0, False: 0]
  ------------------
  593|      0|                CRC2(state->check, hold);
  ------------------
  |  |   59|      0|    do { \
  |  |   60|      0|        hbuf[0] = (unsigned char)(word); \
  |  |   61|      0|        hbuf[1] = (unsigned char)((word) >> 8); \
  |  |   62|      0|        check = PREFIX(crc32)(check, hbuf, 2); \
  |  |  ------------------
  |  |  |  |   97|      0|#  define PREFIX(x) zng_ ## x
  |  |  ------------------
  |  |   63|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (63:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  594|      0|            INITBITS();
  ------------------
  |  |   99|      0|    do { \
  |  |  100|      0|        hold = 0; \
  |  |  101|      0|        bits = 0; \
  |  |  102|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  595|      0|            state->mode = EXLEN;
  596|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  597|       |
  598|      0|        case EXLEN:
  ------------------
  |  Branch (598:9): [True: 0, False: 10]
  ------------------
  599|      0|            if (state->flags & 0x0400) {
  ------------------
  |  Branch (599:17): [True: 0, False: 0]
  ------------------
  600|      0|                NEEDBITS(16);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  601|      0|                state->length = (uint16_t)hold;
  602|      0|                if (state->head != NULL)
  ------------------
  |  Branch (602:21): [True: 0, False: 0]
  ------------------
  603|      0|                    state->head->extra_len = (uint16_t)hold;
  604|      0|                if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (604:21): [True: 0, False: 0]
  |  Branch (604:48): [True: 0, False: 0]
  ------------------
  605|      0|                    CRC2(state->check, hold);
  ------------------
  |  |   59|      0|    do { \
  |  |   60|      0|        hbuf[0] = (unsigned char)(word); \
  |  |   61|      0|        hbuf[1] = (unsigned char)((word) >> 8); \
  |  |   62|      0|        check = PREFIX(crc32)(check, hbuf, 2); \
  |  |  ------------------
  |  |  |  |   97|      0|#  define PREFIX(x) zng_ ## x
  |  |  ------------------
  |  |   63|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (63:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  606|      0|                INITBITS();
  ------------------
  |  |   99|      0|    do { \
  |  |  100|      0|        hold = 0; \
  |  |  101|      0|        bits = 0; \
  |  |  102|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  607|      0|            } else if (state->head != NULL) {
  ------------------
  |  Branch (607:24): [True: 0, False: 0]
  ------------------
  608|      0|                state->head->extra = NULL;
  609|      0|            }
  610|      0|            state->mode = EXTRA;
  611|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  612|       |
  613|      0|        case EXTRA:
  ------------------
  |  Branch (613:9): [True: 0, False: 10]
  ------------------
  614|      0|            if (state->flags & 0x0400) {
  ------------------
  |  Branch (614:17): [True: 0, False: 0]
  ------------------
  615|      0|                copy = state->length;
  616|      0|                if (copy > have)
  ------------------
  |  Branch (616:21): [True: 0, False: 0]
  ------------------
  617|      0|                    copy = have;
  618|      0|                if (copy) {
  ------------------
  |  Branch (618:21): [True: 0, False: 0]
  ------------------
  619|      0|                    if (state->head != NULL && state->head->extra != NULL) {
  ------------------
  |  Branch (619:25): [True: 0, False: 0]
  |  Branch (619:48): [True: 0, False: 0]
  ------------------
  620|      0|                        len = state->head->extra_len - state->length;
  621|      0|                        if (len < state->head->extra_max) {
  ------------------
  |  Branch (621:29): [True: 0, False: 0]
  ------------------
  622|      0|                            memcpy(state->head->extra + len, next,
  623|      0|                                    len + copy > state->head->extra_max ?
  ------------------
  |  Branch (623:37): [True: 0, False: 0]
  ------------------
  624|      0|                                    state->head->extra_max - len : copy);
  625|      0|                        }
  626|      0|                    }
  627|      0|                    if ((state->flags & 0x0200) && (state->wrap & 4)) {
  ------------------
  |  Branch (627:25): [True: 0, False: 0]
  |  Branch (627:52): [True: 0, False: 0]
  ------------------
  628|      0|                        state->check = PREFIX(crc32)(state->check, next, copy);
  ------------------
  |  |   97|      0|#  define PREFIX(x) zng_ ## x
  ------------------
  629|      0|                    }
  630|      0|                    have -= copy;
  631|      0|                    next += copy;
  632|      0|                    state->length -= copy;
  633|      0|                }
  634|      0|                if (state->length)
  ------------------
  |  Branch (634:21): [True: 0, False: 0]
  ------------------
  635|      0|                    goto inf_leave;
  636|      0|            }
  637|      0|            state->length = 0;
  638|      0|            state->mode = NAME;
  639|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  640|       |
  641|      0|        case NAME:
  ------------------
  |  Branch (641:9): [True: 0, False: 10]
  ------------------
  642|      0|            if (state->flags & 0x0800) {
  ------------------
  |  Branch (642:17): [True: 0, False: 0]
  ------------------
  643|      0|                if (have == 0) goto inf_leave;
  ------------------
  |  Branch (643:21): [True: 0, False: 0]
  ------------------
  644|      0|                copy = 0;
  645|      0|                do {
  646|      0|                    len = (unsigned)(next[copy++]);
  647|      0|                    if (state->head != NULL && state->head->name != NULL && state->length < state->head->name_max)
  ------------------
  |  Branch (647:25): [True: 0, False: 0]
  |  Branch (647:48): [True: 0, False: 0]
  |  Branch (647:77): [True: 0, False: 0]
  ------------------
  648|      0|                        state->head->name[state->length++] = (unsigned char)len;
  649|      0|                } while (len && copy < have);
  ------------------
  |  Branch (649:26): [True: 0, False: 0]
  |  Branch (649:33): [True: 0, False: 0]
  ------------------
  650|      0|                if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (650:21): [True: 0, False: 0]
  |  Branch (650:48): [True: 0, False: 0]
  ------------------
  651|      0|                    state->check = PREFIX(crc32)(state->check, next, copy);
  ------------------
  |  |   97|      0|#  define PREFIX(x) zng_ ## x
  ------------------
  652|      0|                have -= copy;
  653|      0|                next += copy;
  654|      0|                if (len)
  ------------------
  |  Branch (654:21): [True: 0, False: 0]
  ------------------
  655|      0|                    goto inf_leave;
  656|      0|            } else if (state->head != NULL) {
  ------------------
  |  Branch (656:24): [True: 0, False: 0]
  ------------------
  657|      0|                state->head->name = NULL;
  658|      0|            }
  659|      0|            state->length = 0;
  660|      0|            state->mode = COMMENT;
  661|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  662|       |
  663|      0|        case COMMENT:
  ------------------
  |  Branch (663:9): [True: 0, False: 10]
  ------------------
  664|      0|            if (state->flags & 0x1000) {
  ------------------
  |  Branch (664:17): [True: 0, False: 0]
  ------------------
  665|      0|                if (have == 0) goto inf_leave;
  ------------------
  |  Branch (665:21): [True: 0, False: 0]
  ------------------
  666|      0|                copy = 0;
  667|      0|                do {
  668|      0|                    len = (unsigned)(next[copy++]);
  669|      0|                    if (state->head != NULL && state->head->comment != NULL
  ------------------
  |  Branch (669:25): [True: 0, False: 0]
  |  Branch (669:48): [True: 0, False: 0]
  ------------------
  670|      0|                        && state->length < state->head->comm_max)
  ------------------
  |  Branch (670:28): [True: 0, False: 0]
  ------------------
  671|      0|                        state->head->comment[state->length++] = (unsigned char)len;
  672|      0|                } while (len && copy < have);
  ------------------
  |  Branch (672:26): [True: 0, False: 0]
  |  Branch (672:33): [True: 0, False: 0]
  ------------------
  673|      0|                if ((state->flags & 0x0200) && (state->wrap & 4))
  ------------------
  |  Branch (673:21): [True: 0, False: 0]
  |  Branch (673:48): [True: 0, False: 0]
  ------------------
  674|      0|                    state->check = PREFIX(crc32)(state->check, next, copy);
  ------------------
  |  |   97|      0|#  define PREFIX(x) zng_ ## x
  ------------------
  675|      0|                have -= copy;
  676|      0|                next += copy;
  677|      0|                if (len)
  ------------------
  |  Branch (677:21): [True: 0, False: 0]
  ------------------
  678|      0|                    goto inf_leave;
  679|      0|            } else if (state->head != NULL) {
  ------------------
  |  Branch (679:24): [True: 0, False: 0]
  ------------------
  680|      0|                state->head->comment = NULL;
  681|      0|            }
  682|      0|            state->mode = HCRC;
  683|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  684|       |
  685|      0|        case HCRC:
  ------------------
  |  Branch (685:9): [True: 0, False: 10]
  ------------------
  686|      0|            if (state->flags & 0x0200) {
  ------------------
  |  Branch (686:17): [True: 0, False: 0]
  ------------------
  687|      0|                NEEDBITS(16);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  688|      0|                if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
  ------------------
  |  Branch (688:21): [True: 0, False: 0]
  |  Branch (688:42): [True: 0, False: 0]
  ------------------
  689|      0|                    SET_BAD("header crc mismatch");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  690|      0|                    break;
  691|      0|                }
  692|      0|                INITBITS();
  ------------------
  |  |   99|      0|    do { \
  |  |  100|      0|        hold = 0; \
  |  |  101|      0|        bits = 0; \
  |  |  102|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  693|      0|            }
  694|      0|            if (state->head != NULL) {
  ------------------
  |  Branch (694:17): [True: 0, False: 0]
  ------------------
  695|      0|                state->head->hcrc = (int)((state->flags >> 9) & 1);
  696|      0|                state->head->done = 1;
  697|      0|            }
  698|       |            /* compute crc32 checksum if not in raw mode */
  699|      0|            if ((state->wrap & 4) && state->flags)
  ------------------
  |  Branch (699:17): [True: 0, False: 0]
  |  Branch (699:38): [True: 0, False: 0]
  ------------------
  700|      0|                strm->adler = state->check = FUNCTABLE_CALL(crc32_fold_reset)(&state->crc_fold);
  ------------------
  |  |   49|      0|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
  701|      0|            state->mode = TYPE;
  702|      0|            break;
  703|      0|#endif
  704|      0|        case DICTID:
  ------------------
  |  Branch (704:9): [True: 0, False: 10]
  ------------------
  705|      0|            NEEDBITS(32);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  706|      0|            strm->adler = state->check = ZSWAP32((unsigned)hold);
  ------------------
  |  |  170|      0|#  define ZSWAP32(q) __builtin_bswap32(q)
  ------------------
  707|      0|            INITBITS();
  ------------------
  |  |   99|      0|    do { \
  |  |  100|      0|        hold = 0; \
  |  |  101|      0|        bits = 0; \
  |  |  102|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  708|      0|            state->mode = DICT;
  709|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  710|       |
  711|      0|        case DICT:
  ------------------
  |  Branch (711:9): [True: 0, False: 10]
  ------------------
  712|      0|            if (state->havedict == 0) {
  ------------------
  |  Branch (712:17): [True: 0, False: 0]
  ------------------
  713|      0|                RESTORE();
  ------------------
  |  |   88|      0|    do { \
  |  |   89|      0|        strm->next_out = put; \
  |  |   90|      0|        strm->avail_out = left; \
  |  |   91|      0|        strm->next_in = (z_const unsigned char *)next; \
  |  |   92|      0|        strm->avail_in = have; \
  |  |   93|      0|        state->hold = hold; \
  |  |   94|      0|        state->bits = bits; \
  |  |   95|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (95:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  714|      0|                return Z_NEED_DICT;
  ------------------
  |  |  182|      0|#define Z_NEED_DICT     2
  ------------------
  715|      0|            }
  716|      0|            strm->adler = state->check = ADLER32_INITIAL_VALUE;
  ------------------
  |  |   65|      0|#define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */
  ------------------
  717|      0|            state->mode = TYPE;
  718|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  719|       |
  720|      0|        case TYPE:
  ------------------
  |  Branch (720:9): [True: 0, False: 10]
  ------------------
  721|      0|            if (flush == Z_BLOCK || flush == Z_TREES)
  ------------------
  |  |  176|      0|#define Z_BLOCK         5
  ------------------
                          if (flush == Z_BLOCK || flush == Z_TREES)
  ------------------
  |  |  177|      0|#define Z_TREES         6
  ------------------
  |  Branch (721:17): [True: 0, False: 0]
  |  Branch (721:37): [True: 0, False: 0]
  ------------------
  722|      0|                goto inf_leave;
  723|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  724|       |
  725|      0|        case TYPEDO:
  ------------------
  |  Branch (725:9): [True: 0, False: 10]
  ------------------
  726|       |            /* determine and dispatch block type */
  727|      0|            INFLATE_TYPEDO_HOOK(strm, flush);  /* hook for IBM Z DFLTCC */
  ------------------
  |  |   29|      0|#  define INFLATE_TYPEDO_HOOK(strm, flush) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (29:57): [Folded, False: 0]
  |  |  ------------------
  ------------------
  728|      0|            if (state->last) {
  ------------------
  |  Branch (728:17): [True: 0, False: 0]
  ------------------
  729|      0|                BYTEBITS();
  ------------------
  |  |  125|      0|    do { \
  |  |  126|      0|        hold >>= bits & 7; \
  |  |  127|      0|        bits -= bits & 7; \
  |  |  128|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (128:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  730|      0|                state->mode = CHECK;
  731|      0|                break;
  732|      0|            }
  733|      0|            NEEDBITS(3);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  734|      0|            state->last = BITS(1);
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  735|      0|            DROPBITS(1);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  736|      0|            switch (BITS(2)) {
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  |  |  ------------------
  |  |  |  Branch (114:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  737|      0|            case 0:                             /* stored block */
  ------------------
  |  Branch (737:13): [True: 0, False: 0]
  ------------------
  738|      0|                Tracev((stderr, "inflate:     stored block%s\n", state->last ? " (last)" : ""));
  739|      0|                state->mode = STORED;
  740|      0|                break;
  741|      0|            case 1:                             /* fixed block */
  ------------------
  |  Branch (741:13): [True: 0, False: 0]
  ------------------
  742|      0|                PREFIX(fixedtables)(state);
  ------------------
  |  |   97|      0|#  define PREFIX(x) zng_ ## x
  ------------------
  743|      0|                Tracev((stderr, "inflate:     fixed codes block%s\n", state->last ? " (last)" : ""));
  744|      0|                state->mode = LEN_;             /* decode codes */
  745|      0|                if (flush == Z_TREES) {
  ------------------
  |  |  177|      0|#define Z_TREES         6
  ------------------
  |  Branch (745:21): [True: 0, False: 0]
  ------------------
  746|      0|                    DROPBITS(2);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  747|      0|                    goto inf_leave;
  748|      0|                }
  749|      0|                break;
  750|      0|            case 2:                             /* dynamic block */
  ------------------
  |  Branch (750:13): [True: 0, False: 0]
  ------------------
  751|      0|                Tracev((stderr, "inflate:     dynamic codes block%s\n", state->last ? " (last)" : ""));
  752|      0|                state->mode = TABLE;
  753|      0|                break;
  754|      0|            case 3:
  ------------------
  |  Branch (754:13): [True: 0, False: 0]
  ------------------
  755|      0|                SET_BAD("invalid block type");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  756|      0|            }
  757|      0|            DROPBITS(2);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  758|      0|            break;
  759|       |
  760|      0|        case STORED:
  ------------------
  |  Branch (760:9): [True: 0, False: 10]
  ------------------
  761|       |            /* get and verify stored block length */
  762|      0|            BYTEBITS();                         /* go to byte boundary */
  ------------------
  |  |  125|      0|    do { \
  |  |  126|      0|        hold >>= bits & 7; \
  |  |  127|      0|        bits -= bits & 7; \
  |  |  128|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (128:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  763|      0|            NEEDBITS(32);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  764|      0|            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
  ------------------
  |  Branch (764:17): [True: 0, False: 0]
  ------------------
  765|      0|                SET_BAD("invalid stored block lengths");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  766|      0|                break;
  767|      0|            }
  768|      0|            state->length = (uint16_t)hold;
  769|      0|            Tracev((stderr, "inflate:       stored length %u\n", state->length));
  770|      0|            INITBITS();
  ------------------
  |  |   99|      0|    do { \
  |  |  100|      0|        hold = 0; \
  |  |  101|      0|        bits = 0; \
  |  |  102|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  771|      0|            state->mode = COPY_;
  772|      0|            if (flush == Z_TREES)
  ------------------
  |  |  177|      0|#define Z_TREES         6
  ------------------
  |  Branch (772:17): [True: 0, False: 0]
  ------------------
  773|      0|                goto inf_leave;
  774|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  775|       |
  776|      0|        case COPY_:
  ------------------
  |  Branch (776:9): [True: 0, False: 10]
  ------------------
  777|      0|            state->mode = COPY;
  778|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  779|       |
  780|      0|        case COPY:
  ------------------
  |  Branch (780:9): [True: 0, False: 10]
  ------------------
  781|       |            /* copy stored block from input to output */
  782|      0|            copy = state->length;
  783|      0|            if (copy) {
  ------------------
  |  Branch (783:17): [True: 0, False: 0]
  ------------------
  784|      0|                copy = MIN(copy, have);
  ------------------
  |  |  124|      0|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (124:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  785|      0|                copy = MIN(copy, left);
  ------------------
  |  |  124|      0|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (124:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  786|      0|                if (copy == 0)
  ------------------
  |  Branch (786:21): [True: 0, False: 0]
  ------------------
  787|      0|                    goto inf_leave;
  788|      0|                memcpy(put, next, copy);
  789|      0|                have -= copy;
  790|      0|                next += copy;
  791|      0|                left -= copy;
  792|      0|                put += copy;
  793|      0|                state->length -= copy;
  794|      0|                break;
  795|      0|            }
  796|      0|            Tracev((stderr, "inflate:       stored end\n"));
  797|      0|            state->mode = TYPE;
  798|      0|            break;
  799|       |
  800|      0|        case TABLE:
  ------------------
  |  Branch (800:9): [True: 0, False: 10]
  ------------------
  801|       |            /* get dynamic table entries descriptor */
  802|      0|            NEEDBITS(14);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  803|      0|            state->nlen = BITS(5) + 257;
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  804|      0|            DROPBITS(5);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  805|      0|            state->ndist = BITS(5) + 1;
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  806|      0|            DROPBITS(5);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  807|      0|            state->ncode = BITS(4) + 4;
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  808|      0|            DROPBITS(4);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  809|      0|#ifndef PKZIP_BUG_WORKAROUND
  810|      0|            if (state->nlen > 286 || state->ndist > 30) {
  ------------------
  |  Branch (810:17): [True: 0, False: 0]
  |  Branch (810:38): [True: 0, False: 0]
  ------------------
  811|      0|                SET_BAD("too many length or distance symbols");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  812|      0|                break;
  813|      0|            }
  814|      0|#endif
  815|      0|            Tracev((stderr, "inflate:       table sizes ok\n"));
  816|      0|            state->have = 0;
  817|      0|            state->mode = LENLENS;
  818|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  819|       |
  820|      0|        case LENLENS:
  ------------------
  |  Branch (820:9): [True: 0, False: 10]
  ------------------
  821|       |            /* get code length code lengths (not a typo) */
  822|      0|            while (state->have < state->ncode) {
  ------------------
  |  Branch (822:20): [True: 0, False: 0]
  ------------------
  823|      0|                NEEDBITS(3);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  824|      0|                state->lens[order[state->have++]] = (uint16_t)BITS(3);
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  825|      0|                DROPBITS(3);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  826|      0|            }
  827|      0|            while (state->have < 19)
  ------------------
  |  Branch (827:20): [True: 0, False: 0]
  ------------------
  828|      0|                state->lens[order[state->have++]] = 0;
  829|      0|            state->next = state->codes;
  830|      0|            state->lencode = (const code *)(state->next);
  831|      0|            state->lenbits = 7;
  832|      0|            ret = zng_inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work);
  833|      0|            if (ret) {
  ------------------
  |  Branch (833:17): [True: 0, False: 0]
  ------------------
  834|      0|                SET_BAD("invalid code lengths set");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  835|      0|                break;
  836|      0|            }
  837|      0|            Tracev((stderr, "inflate:       code lengths ok\n"));
  838|      0|            state->have = 0;
  839|      0|            state->mode = CODELENS;
  840|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  841|       |
  842|      0|        case CODELENS:
  ------------------
  |  Branch (842:9): [True: 0, False: 10]
  ------------------
  843|       |            /* get length and distance code code lengths */
  844|      0|            while (state->have < state->nlen + state->ndist) {
  ------------------
  |  Branch (844:20): [True: 0, False: 0]
  ------------------
  845|      0|                for (;;) {
  846|      0|                    here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  847|      0|                    if (here.bits <= bits) break;
  ------------------
  |  Branch (847:25): [True: 0, False: 0]
  ------------------
  848|      0|                    PULLBYTE();
  ------------------
  |  |  386|      0|    do { \
  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|        have--; \
  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  390|      0|        bits += 8; \
  |  |  391|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  849|      0|                }
  850|      0|                if (here.val < 16) {
  ------------------
  |  Branch (850:21): [True: 0, False: 0]
  ------------------
  851|      0|                    DROPBITS(here.bits);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  852|      0|                    state->lens[state->have++] = here.val;
  853|      0|                } else {
  854|      0|                    if (here.val == 16) {
  ------------------
  |  Branch (854:25): [True: 0, False: 0]
  ------------------
  855|      0|                        NEEDBITS(here.bits + 2);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  856|      0|                        DROPBITS(here.bits);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  857|      0|                        if (state->have == 0) {
  ------------------
  |  Branch (857:29): [True: 0, False: 0]
  ------------------
  858|      0|                            SET_BAD("invalid bit length repeat");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  859|      0|                            break;
  860|      0|                        }
  861|      0|                        len = state->lens[state->have - 1];
  862|      0|                        copy = 3 + BITS(2);
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  863|      0|                        DROPBITS(2);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  864|      0|                    } else if (here.val == 17) {
  ------------------
  |  Branch (864:32): [True: 0, False: 0]
  ------------------
  865|      0|                        NEEDBITS(here.bits + 3);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  866|      0|                        DROPBITS(here.bits);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  867|      0|                        len = 0;
  868|      0|                        copy = 3 + BITS(3);
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  869|      0|                        DROPBITS(3);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  870|      0|                    } else {
  871|      0|                        NEEDBITS(here.bits + 7);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  872|      0|                        DROPBITS(here.bits);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  873|      0|                        len = 0;
  874|      0|                        copy = 11 + BITS(7);
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  875|      0|                        DROPBITS(7);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  876|      0|                    }
  877|      0|                    if (state->have + copy > state->nlen + state->ndist) {
  ------------------
  |  Branch (877:25): [True: 0, False: 0]
  ------------------
  878|      0|                        SET_BAD("invalid bit length repeat");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  879|      0|                        break;
  880|      0|                    }
  881|      0|                    while (copy) {
  ------------------
  |  Branch (881:28): [True: 0, False: 0]
  ------------------
  882|      0|                        --copy;
  883|      0|                        state->lens[state->have++] = (uint16_t)len;
  884|      0|                    }
  885|      0|                }
  886|      0|            }
  887|       |
  888|       |            /* handle error breaks in while */
  889|      0|            if (state->mode == BAD)
  ------------------
  |  Branch (889:17): [True: 0, False: 0]
  ------------------
  890|      0|                break;
  891|       |
  892|       |            /* check for end-of-block code (better have one) */
  893|      0|            if (state->lens[256] == 0) {
  ------------------
  |  Branch (893:17): [True: 0, False: 0]
  ------------------
  894|      0|                SET_BAD("invalid code -- missing end-of-block");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  895|      0|                break;
  896|      0|            }
  897|       |
  898|       |            /* build code tables -- note: do not change the lenbits or distbits
  899|       |               values here (10 and 9) without reading the comments in inftrees.h
  900|       |               concerning the ENOUGH constants, which depend on those values */
  901|      0|            state->next = state->codes;
  902|      0|            state->lencode = (const code *)(state->next);
  903|      0|            state->lenbits = 10;
  904|      0|            ret = zng_inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work);
  905|      0|            if (ret) {
  ------------------
  |  Branch (905:17): [True: 0, False: 0]
  ------------------
  906|      0|                SET_BAD("invalid literal/lengths set");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  907|      0|                break;
  908|      0|            }
  909|      0|            state->distcode = (const code *)(state->next);
  910|      0|            state->distbits = 9;
  911|      0|            ret = zng_inflate_table(DISTS, state->lens + state->nlen, state->ndist,
  912|      0|                            &(state->next), &(state->distbits), state->work);
  913|      0|            if (ret) {
  ------------------
  |  Branch (913:17): [True: 0, False: 0]
  ------------------
  914|      0|                SET_BAD("invalid distances set");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  915|      0|                break;
  916|      0|            }
  917|      0|            Tracev((stderr, "inflate:       codes ok\n"));
  918|      0|            state->mode = LEN_;
  919|      0|            if (flush == Z_TREES)
  ------------------
  |  |  177|      0|#define Z_TREES         6
  ------------------
  |  Branch (919:17): [True: 0, False: 0]
  ------------------
  920|      0|                goto inf_leave;
  921|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  922|       |
  923|      0|        case LEN_:
  ------------------
  |  Branch (923:9): [True: 0, False: 10]
  ------------------
  924|      0|            state->mode = LEN;
  925|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  926|       |
  927|      0|        case LEN:
  ------------------
  |  Branch (927:9): [True: 0, False: 10]
  ------------------
  928|       |            /* use inflate_fast() if we have enough input and output */
  929|      0|            if (have >= INFLATE_FAST_MIN_HAVE && left >= INFLATE_FAST_MIN_LEFT) {
  ------------------
  |  |  137|      0|#define INFLATE_FAST_MIN_HAVE 15
  ------------------
                          if (have >= INFLATE_FAST_MIN_HAVE && left >= INFLATE_FAST_MIN_LEFT) {
  ------------------
  |  |  138|      0|#define INFLATE_FAST_MIN_LEFT 260
  ------------------
  |  Branch (929:17): [True: 0, False: 0]
  |  Branch (929:50): [True: 0, False: 0]
  ------------------
  930|      0|                RESTORE();
  ------------------
  |  |   88|      0|    do { \
  |  |   89|      0|        strm->next_out = put; \
  |  |   90|      0|        strm->avail_out = left; \
  |  |   91|      0|        strm->next_in = (z_const unsigned char *)next; \
  |  |   92|      0|        strm->avail_in = have; \
  |  |   93|      0|        state->hold = hold; \
  |  |   94|      0|        state->bits = bits; \
  |  |   95|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (95:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  931|      0|                FUNCTABLE_CALL(inflate_fast)(strm, out);
  ------------------
  |  |   49|      0|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
  932|      0|                LOAD();
  ------------------
  |  |   77|      0|    do { \
  |  |   78|      0|        put = strm->next_out; \
  |  |   79|      0|        left = strm->avail_out; \
  |  |   80|      0|        next = strm->next_in; \
  |  |   81|      0|        have = strm->avail_in; \
  |  |   82|      0|        hold = state->hold; \
  |  |   83|      0|        bits = state->bits; \
  |  |   84|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (84:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  933|      0|                if (state->mode == TYPE)
  ------------------
  |  Branch (933:21): [True: 0, False: 0]
  ------------------
  934|      0|                    state->back = -1;
  935|      0|                break;
  936|      0|            }
  937|      0|            state->back = 0;
  938|       |
  939|       |            /* get a literal, length, or end-of-block code */
  940|      0|            for (;;) {
  941|      0|                here = state->lencode[BITS(state->lenbits)];
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  942|      0|                if (here.bits <= bits)
  ------------------
  |  Branch (942:21): [True: 0, False: 0]
  ------------------
  943|      0|                    break;
  944|      0|                PULLBYTE();
  ------------------
  |  |  386|      0|    do { \
  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|        have--; \
  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  390|      0|        bits += 8; \
  |  |  391|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  945|      0|            }
  946|      0|            if (here.op && (here.op & 0xf0) == 0) {
  ------------------
  |  Branch (946:17): [True: 0, False: 0]
  |  Branch (946:28): [True: 0, False: 0]
  ------------------
  947|      0|                last = here;
  948|      0|                for (;;) {
  949|      0|                    here = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)];
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  950|      0|                    if ((unsigned)last.bits + (unsigned)here.bits <= bits)
  ------------------
  |  Branch (950:25): [True: 0, False: 0]
  ------------------
  951|      0|                        break;
  952|      0|                    PULLBYTE();
  ------------------
  |  |  386|      0|    do { \
  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|        have--; \
  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  390|      0|        bits += 8; \
  |  |  391|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  953|      0|                }
  954|      0|                DROPBITS(last.bits);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  955|      0|                state->back += last.bits;
  956|      0|            }
  957|      0|            DROPBITS(here.bits);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  958|      0|            state->back += here.bits;
  959|      0|            state->length = here.val;
  960|       |
  961|       |            /* process literal */
  962|      0|            if ((int)(here.op) == 0) {
  ------------------
  |  Branch (962:17): [True: 0, False: 0]
  ------------------
  963|      0|                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
  964|      0|                        "inflate:         literal '%c'\n" :
  965|      0|                        "inflate:         literal 0x%02x\n", here.val));
  966|      0|                state->mode = LIT;
  967|      0|                break;
  968|      0|            }
  969|       |
  970|       |            /* process end of block */
  971|      0|            if (here.op & 32) {
  ------------------
  |  Branch (971:17): [True: 0, False: 0]
  ------------------
  972|      0|                Tracevv((stderr, "inflate:         end of block\n"));
  973|      0|                state->back = -1;
  974|      0|                state->mode = TYPE;
  975|      0|                break;
  976|      0|            }
  977|       |
  978|       |            /* invalid code */
  979|      0|            if (here.op & 64) {
  ------------------
  |  Branch (979:17): [True: 0, False: 0]
  ------------------
  980|      0|                SET_BAD("invalid literal/length code");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  981|      0|                break;
  982|      0|            }
  983|       |
  984|       |            /* length code */
  985|      0|            state->extra = (here.op & MAX_BITS);
  ------------------
  |  |   39|      0|#define MAX_BITS 15
  ------------------
  986|      0|            state->mode = LENEXT;
  987|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  988|       |
  989|      0|        case LENEXT:
  ------------------
  |  Branch (989:9): [True: 0, False: 10]
  ------------------
  990|       |            /* get extra bits, if any */
  991|      0|            if (state->extra) {
  ------------------
  |  Branch (991:17): [True: 0, False: 0]
  ------------------
  992|      0|                NEEDBITS(state->extra);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  993|      0|                state->length += BITS(state->extra);
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  994|      0|                DROPBITS(state->extra);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  995|      0|                state->back += state->extra;
  996|      0|            }
  997|      0|            Tracevv((stderr, "inflate:         length %u\n", state->length));
  998|      0|            state->was = state->length;
  999|      0|            state->mode = DIST;
 1000|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 1001|       |
 1002|      0|        case DIST:
  ------------------
  |  Branch (1002:9): [True: 0, False: 10]
  ------------------
 1003|       |            /* get distance code */
 1004|      0|            for (;;) {
 1005|      0|                here = state->distcode[BITS(state->distbits)];
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
 1006|      0|                if (here.bits <= bits)
  ------------------
  |  Branch (1006:21): [True: 0, False: 0]
  ------------------
 1007|      0|                    break;
 1008|      0|                PULLBYTE();
  ------------------
  |  |  386|      0|    do { \
  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|        have--; \
  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  390|      0|        bits += 8; \
  |  |  391|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1009|      0|            }
 1010|      0|            if ((here.op & 0xf0) == 0) {
  ------------------
  |  Branch (1010:17): [True: 0, False: 0]
  ------------------
 1011|      0|                last = here;
 1012|      0|                for (;;) {
 1013|      0|                    here = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)];
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
 1014|      0|                    if ((unsigned)last.bits + (unsigned)here.bits <= bits)
  ------------------
  |  Branch (1014:25): [True: 0, False: 0]
  ------------------
 1015|      0|                        break;
 1016|      0|                    PULLBYTE();
  ------------------
  |  |  386|      0|    do { \
  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  ------------------
  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  388|      0|        have--; \
  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  390|      0|        bits += 8; \
  |  |  391|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1017|      0|                }
 1018|      0|                DROPBITS(last.bits);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1019|      0|                state->back += last.bits;
 1020|      0|            }
 1021|      0|            DROPBITS(here.bits);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1022|      0|            state->back += here.bits;
 1023|      0|            if (here.op & 64) {
  ------------------
  |  Branch (1023:17): [True: 0, False: 0]
  ------------------
 1024|      0|                SET_BAD("invalid distance code");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1025|      0|                break;
 1026|      0|            }
 1027|      0|            state->offset = here.val;
 1028|      0|            state->extra = (here.op & MAX_BITS);
  ------------------
  |  |   39|      0|#define MAX_BITS 15
  ------------------
 1029|      0|            state->mode = DISTEXT;
 1030|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 1031|       |
 1032|      0|        case DISTEXT:
  ------------------
  |  Branch (1032:9): [True: 0, False: 10]
  ------------------
 1033|       |            /* get distance extra bits, if any */
 1034|      0|            if (state->extra) {
  ------------------
  |  Branch (1034:17): [True: 0, False: 0]
  ------------------
 1035|      0|                NEEDBITS(state->extra);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1036|      0|                state->offset += BITS(state->extra);
  ------------------
  |  |  114|      0|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
 1037|      0|                DROPBITS(state->extra);
  ------------------
  |  |  118|      0|    do { \
  |  |  119|      0|        hold >>= (n); \
  |  |  120|      0|        bits -= (unsigned)(n); \
  |  |  121|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (121:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1038|      0|                state->back += state->extra;
 1039|      0|            }
 1040|       |#ifdef INFLATE_STRICT
 1041|       |            if (state->offset > state->dmax) {
 1042|       |                SET_BAD("invalid distance too far back");
 1043|       |                break;
 1044|       |            }
 1045|       |#endif
 1046|      0|            Tracevv((stderr, "inflate:         distance %u\n", state->offset));
 1047|      0|            state->mode = MATCH;
 1048|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 1049|       |
 1050|      0|        case MATCH:
  ------------------
  |  Branch (1050:9): [True: 0, False: 10]
  ------------------
 1051|       |            /* copy match from window to output */
 1052|      0|            if (left == 0)
  ------------------
  |  Branch (1052:17): [True: 0, False: 0]
  ------------------
 1053|      0|                goto inf_leave;
 1054|      0|            copy = out - left;
 1055|      0|            if (state->offset > copy) {         /* copy from window */
  ------------------
  |  Branch (1055:17): [True: 0, False: 0]
  ------------------
 1056|      0|                copy = state->offset - copy;
 1057|      0|                if (copy > state->whave) {
  ------------------
  |  Branch (1057:21): [True: 0, False: 0]
  ------------------
 1058|       |#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
 1059|       |                    if (state->sane) {
 1060|       |                        SET_BAD("invalid distance too far back");
 1061|       |                        break;
 1062|       |                    }
 1063|       |                    Trace((stderr, "inflate.c too far\n"));
 1064|       |                    copy -= state->whave;
 1065|       |                    copy = MIN(copy, state->length);
 1066|       |                    copy = MIN(copy, left);
 1067|       |                    left -= copy;
 1068|       |                    state->length -= copy;
 1069|       |                    do {
 1070|       |                        *put++ = 0;
 1071|       |                    } while (--copy);
 1072|       |                    if (state->length == 0)
 1073|       |                        state->mode = LEN;
 1074|       |#else
 1075|      0|                    SET_BAD("invalid distance too far back");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1076|      0|#endif
 1077|      0|                    break;
 1078|      0|                }
 1079|      0|                if (copy > state->wnext) {
  ------------------
  |  Branch (1079:21): [True: 0, False: 0]
  ------------------
 1080|      0|                    copy -= state->wnext;
 1081|      0|                    from = state->window + (state->wsize - copy);
 1082|      0|                } else {
 1083|      0|                    from = state->window + (state->wnext - copy);
 1084|      0|                }
 1085|      0|                copy = MIN(copy, state->length);
  ------------------
  |  |  124|      0|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (124:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1086|      0|                copy = MIN(copy, left);
  ------------------
  |  |  124|      0|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (124:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1087|       |
 1088|      0|                put = chunkcopy_safe(put, from, copy, put + left);
 1089|      0|            } else {
 1090|      0|                copy = MIN(state->length, left);
  ------------------
  |  |  124|      0|#define MIN(a, b) ((a) > (b) ? (b) : (a))
  |  |  ------------------
  |  |  |  Branch (124:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1091|       |
 1092|      0|                put = FUNCTABLE_CALL(chunkmemset_safe)(put, put - state->offset, copy, left);
  ------------------
  |  |   49|      0|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
 1093|      0|            }
 1094|      0|            left -= copy;
 1095|      0|            state->length -= copy;
 1096|      0|            if (state->length == 0)
  ------------------
  |  Branch (1096:17): [True: 0, False: 0]
  ------------------
 1097|      0|                state->mode = LEN;
 1098|      0|            break;
 1099|       |
 1100|      0|        case LIT:
  ------------------
  |  Branch (1100:9): [True: 0, False: 10]
  ------------------
 1101|      0|            if (left == 0)
  ------------------
  |  Branch (1101:17): [True: 0, False: 0]
  ------------------
 1102|      0|                goto inf_leave;
 1103|      0|            *put++ = (unsigned char)(state->length);
 1104|      0|            left--;
 1105|      0|            state->mode = LEN;
 1106|      0|            break;
 1107|       |
 1108|      0|        case CHECK:
  ------------------
  |  Branch (1108:9): [True: 0, False: 10]
  ------------------
 1109|      0|            if (state->wrap) {
  ------------------
  |  Branch (1109:17): [True: 0, False: 0]
  ------------------
 1110|      0|                NEEDBITS(32);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1111|      0|                out -= left;
 1112|      0|                strm->total_out += out;
 1113|      0|                state->total += out;
 1114|       |
 1115|       |                /* compute crc32 checksum if not in raw mode */
 1116|      0|                if (INFLATE_NEED_CHECKSUM(strm) && state->wrap & 4) {
  ------------------
  |  |   31|      0|#  define INFLATE_NEED_CHECKSUM(strm) 1
  |  |  ------------------
  |  |  |  Branch (31:39): [True: 0, Folded]
  |  |  ------------------
  ------------------
  |  Branch (1116:52): [True: 0, False: 0]
  ------------------
 1117|      0|                    if (out) {
  ------------------
  |  Branch (1117:25): [True: 0, False: 0]
  ------------------
 1118|      0|                        inf_chksum(strm, put - out, out);
 1119|      0|                    }
 1120|      0|#ifdef GUNZIP
 1121|      0|                    if (state->flags)
  ------------------
  |  Branch (1121:25): [True: 0, False: 0]
  ------------------
 1122|      0|                        strm->adler = state->check = FUNCTABLE_CALL(crc32_fold_final)(&state->crc_fold);
  ------------------
  |  |   49|      0|#  define FUNCTABLE_CALL(name) functable.name
  ------------------
 1123|      0|#endif
 1124|      0|                }
 1125|      0|                out = left;
 1126|      0|                if ((state->wrap & 4) && (
  ------------------
  |  Branch (1126:21): [True: 0, False: 0]
  |  Branch (1126:42): [True: 0, False: 0]
  ------------------
 1127|      0|#ifdef GUNZIP
 1128|      0|                     state->flags ? hold :
  ------------------
  |  Branch (1128:22): [True: 0, False: 0]
  ------------------
 1129|      0|#endif
 1130|      0|                     ZSWAP32((unsigned)hold)) != state->check) {
  ------------------
  |  |  170|      0|#  define ZSWAP32(q) __builtin_bswap32(q)
  ------------------
 1131|      0|                    SET_BAD("incorrect data check");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1132|      0|                    break;
 1133|      0|                }
 1134|      0|                INITBITS();
  ------------------
  |  |   99|      0|    do { \
  |  |  100|      0|        hold = 0; \
  |  |  101|      0|        bits = 0; \
  |  |  102|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1135|      0|                Tracev((stderr, "inflate:   check matches trailer\n"));
 1136|      0|            }
 1137|      0|#ifdef GUNZIP
 1138|      0|            state->mode = LENGTH;
 1139|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 1140|       |
 1141|      0|        case LENGTH:
  ------------------
  |  Branch (1141:9): [True: 0, False: 10]
  ------------------
 1142|      0|            if (state->wrap && state->flags) {
  ------------------
  |  Branch (1142:17): [True: 0, False: 0]
  |  Branch (1142:32): [True: 0, False: 0]
  ------------------
 1143|      0|                NEEDBITS(32);
  ------------------
  |  |  107|      0|    do { \
  |  |  108|      0|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  109|      0|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|      0|    do { \
  |  |  |  |  387|      0|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  388|      0|        have--; \
  |  |  |  |  389|      0|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|      0|        bits += 8; \
  |  |  |  |  391|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1144|      0|                if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
  ------------------
  |  Branch (1144:21): [True: 0, False: 0]
  |  Branch (1144:42): [True: 0, False: 0]
  ------------------
 1145|      0|                    SET_BAD("incorrect length check");
  ------------------
  |  |  132|      0|    do { \
  |  |  133|      0|        state->mode = BAD; \
  |  |  134|      0|        strm->msg = (char *)errmsg; \
  |  |  135|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1146|      0|                    break;
 1147|      0|                }
 1148|      0|                INITBITS();
  ------------------
  |  |   99|      0|    do { \
  |  |  100|      0|        hold = 0; \
  |  |  101|      0|        bits = 0; \
  |  |  102|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1149|      0|                Tracev((stderr, "inflate:   length matches trailer\n"));
 1150|      0|            }
 1151|      0|#endif
 1152|      0|            state->mode = DONE;
 1153|      0|            Z_FALLTHROUGH;
  ------------------
  |  |   45|      0|#    define Z_FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
 1154|       |
 1155|      0|        case DONE:
  ------------------
  |  Branch (1155:9): [True: 0, False: 10]
  ------------------
 1156|       |            /* inflate stream terminated properly */
 1157|      0|            ret = Z_STREAM_END;
  ------------------
  |  |  181|      0|#define Z_STREAM_END    1
  ------------------
 1158|      0|            goto inf_leave;
 1159|       |
 1160|      2|        case BAD:
  ------------------
  |  Branch (1160:9): [True: 2, False: 8]
  ------------------
 1161|      2|            ret = Z_DATA_ERROR;
  ------------------
  |  |  185|      2|#define Z_DATA_ERROR   (-3)
  ------------------
 1162|      2|            goto inf_leave;
 1163|       |
 1164|      0|        case SYNC:
  ------------------
  |  Branch (1164:9): [True: 0, False: 10]
  ------------------
 1165|       |
 1166|      0|        default:                 /* can't happen, but makes compilers happy */
  ------------------
  |  Branch (1166:9): [True: 0, False: 10]
  ------------------
 1167|      0|            return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1168|     10|        }
 1169|       |
 1170|       |    /*
 1171|       |       Return from inflate(), updating the total counts and the check value.
 1172|       |       If there was no progress during the inflate() call, return a buffer
 1173|       |       error.  Call updatewindow() to create and/or update the window state.
 1174|       |     */
 1175|      8|  inf_leave:
 1176|      8|    RESTORE();
  ------------------
  |  |   88|      8|    do { \
  |  |   89|      8|        strm->next_out = put; \
  |  |   90|      8|        strm->avail_out = left; \
  |  |   91|      8|        strm->next_in = (z_const unsigned char *)next; \
  |  |   92|      8|        strm->avail_in = have; \
  |  |   93|      8|        state->hold = hold; \
  |  |   94|      8|        state->bits = bits; \
  |  |   95|      8|    } while (0)
  |  |  ------------------
  |  |  |  Branch (95:14): [Folded, False: 8]
  |  |  ------------------
  ------------------
 1177|      8|    uint32_t check_bytes = out - strm->avail_out;
 1178|      8|    if (INFLATE_NEED_UPDATEWINDOW(strm) &&
  ------------------
  |  |   33|     16|#  define INFLATE_NEED_UPDATEWINDOW(strm) 1
  |  |  ------------------
  |  |  |  Branch (33:43): [True: 8, Folded]
  |  |  ------------------
  ------------------
 1179|      8|            (state->wsize || (out != strm->avail_out && state->mode < BAD &&
  ------------------
  |  Branch (1179:14): [True: 0, False: 8]
  |  Branch (1179:31): [True: 0, False: 8]
  |  Branch (1179:57): [True: 0, False: 0]
  ------------------
 1180|      0|                 (state->mode < CHECK || flush != Z_FINISH)))) {
  ------------------
  |  |  175|      0|#define Z_FINISH        4
  ------------------
  |  Branch (1180:19): [True: 0, False: 0]
  |  Branch (1180:42): [True: 0, False: 0]
  ------------------
 1181|       |        /* update sliding window with respective checksum if not in "raw" mode */
 1182|      0|        updatewindow(strm, strm->next_out, check_bytes, state->wrap & 4);
 1183|      0|    }
 1184|      8|    in -= strm->avail_in;
 1185|      8|    out -= strm->avail_out;
 1186|      8|    strm->total_in += in;
 1187|      8|    strm->total_out += out;
 1188|      8|    state->total += out;
 1189|       |
 1190|      8|    strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
  ------------------
  |  Branch (1190:43): [True: 0, False: 8]
  ------------------
 1191|      8|                      (state->mode == TYPE ? 128 : 0) + (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
  ------------------
  |  Branch (1191:24): [True: 0, False: 8]
  |  Branch (1191:58): [True: 0, False: 8]
  |  Branch (1191:81): [True: 0, False: 8]
  ------------------
 1192|      8|    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) {
  ------------------
  |  |  175|      5|#define Z_FINISH        4
  ------------------
                  if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) {
  ------------------
  |  |  180|      3|#define Z_OK            0
  ------------------
  |  Branch (1192:11): [True: 3, False: 5]
  |  Branch (1192:22): [True: 3, False: 0]
  |  Branch (1192:35): [True: 0, False: 5]
  |  Branch (1192:57): [True: 3, False: 0]
  ------------------
 1193|       |        /* when no sliding window is used, hash the output bytes if no CHECK state */
 1194|      3|        if (INFLATE_NEED_CHECKSUM(strm) && !state->wsize && flush == Z_FINISH) {
  ------------------
  |  |   31|      6|#  define INFLATE_NEED_CHECKSUM(strm) 1
  |  |  ------------------
  |  |  |  Branch (31:39): [True: 3, Folded]
  |  |  ------------------
  ------------------
                      if (INFLATE_NEED_CHECKSUM(strm) && !state->wsize && flush == Z_FINISH) {
  ------------------
  |  |  175|      3|#define Z_FINISH        4
  ------------------
  |  Branch (1194:44): [True: 3, False: 0]
  |  Branch (1194:61): [True: 0, False: 3]
  ------------------
 1195|      0|            inf_chksum(strm, put - check_bytes, check_bytes);
 1196|      0|        }
 1197|      3|        ret = Z_BUF_ERROR;
  ------------------
  |  |  187|      3|#define Z_BUF_ERROR    (-5)
  ------------------
 1198|      3|    }
 1199|      8|    return ret;
 1200|      8|}
zng_inflateEnd:
 1202|      5|int32_t Z_EXPORT PREFIX(inflateEnd)(PREFIX3(stream) *strm) {
 1203|      5|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (1203:9): [True: 0, False: 5]
  ------------------
 1204|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1205|       |
 1206|       |    /* Free allocated buffers */
 1207|      5|    free_inflate(strm);
 1208|       |
 1209|      5|    Tracev((stderr, "inflate: end\n"));
 1210|      5|    return Z_OK;
  ------------------
  |  |  180|      5|#define Z_OK            0
  ------------------
 1211|      5|}
inflate.c:inflateStateCheck:
   51|     28|static int inflateStateCheck(PREFIX3(stream) *strm) {
   52|     28|    struct inflate_state *state;
   53|     28|    if (strm == NULL || strm->zalloc == NULL || strm->zfree == NULL)
  ------------------
  |  Branch (53:9): [True: 0, False: 28]
  |  Branch (53:25): [True: 0, False: 28]
  |  Branch (53:49): [True: 0, False: 28]
  ------------------
   54|      0|        return 1;
   55|     28|    state = (struct inflate_state *)strm->state;
   56|     28|    if (state == NULL || state->alloc_bufs == NULL || state->strm != strm || state->mode < HEAD || state->mode > SYNC)
  ------------------
  |  Branch (56:9): [True: 0, False: 28]
  |  Branch (56:26): [True: 0, False: 28]
  |  Branch (56:55): [True: 0, False: 28]
  |  Branch (56:78): [True: 0, False: 28]
  |  Branch (56:100): [True: 0, False: 28]
  ------------------
   57|      0|        return 1;
   58|     28|    return 0;
   59|     28|}

zng_uncompress2:
   25|      5|z_int32_t Z_EXPORT PREFIX(uncompress2)(unsigned char *dest, z_uintmax_t *destLen, const unsigned char *source, z_uintmax_t *sourceLen) {
   26|      5|    PREFIX3(stream) stream;
  ------------------
  |  |   99|      5|#  define PREFIX3(x) zng_ ## x
  ------------------
   27|      5|    int err;
   28|      5|    const unsigned int max = (unsigned int)-1;
   29|      5|    z_uintmax_t len, left;
  ------------------
  |  |  109|      5|#  define z_uintmax_t size_t
  ------------------
   30|      5|    unsigned char buf[1];    /* for detection of incomplete stream when *destLen == 0 */
   31|       |
   32|      5|    len = *sourceLen;
   33|      5|    if (*destLen) {
  ------------------
  |  Branch (33:9): [True: 5, False: 0]
  ------------------
   34|      5|        left = *destLen;
   35|      5|        *destLen = 0;
   36|      5|    } else {
   37|      0|        left = 1;
   38|      0|        dest = buf;
   39|      0|    }
   40|       |
   41|      5|    stream.next_in = (z_const unsigned char *)source;
   42|      5|    stream.avail_in = 0;
   43|      5|    stream.zalloc = NULL;
   44|      5|    stream.zfree = NULL;
   45|      5|    stream.opaque = NULL;
   46|       |
   47|      5|    err = PREFIX(inflateInit)(&stream);
  ------------------
  |  |   97|      5|#  define PREFIX(x) zng_ ## x
  ------------------
   48|      5|    if (err != Z_OK) return err;
  ------------------
  |  |  180|      5|#define Z_OK            0
  ------------------
  |  Branch (48:9): [True: 0, False: 5]
  ------------------
   49|       |
   50|      5|    stream.next_out = dest;
   51|      5|    stream.avail_out = 0;
   52|       |
   53|      8|    do {
   54|      8|        if (stream.avail_out == 0) {
  ------------------
  |  Branch (54:13): [True: 5, False: 3]
  ------------------
   55|      5|            stream.avail_out = left > (unsigned long)max ? max : (unsigned int)left;
  ------------------
  |  Branch (55:32): [True: 0, False: 5]
  ------------------
   56|      5|            left -= stream.avail_out;
   57|      5|        }
   58|      8|        if (stream.avail_in == 0) {
  ------------------
  |  Branch (58:13): [True: 8, False: 0]
  ------------------
   59|      8|            stream.avail_in = len > (unsigned long)max ? max : (unsigned int)len;
  ------------------
  |  Branch (59:31): [True: 0, False: 8]
  ------------------
   60|      8|            len -= stream.avail_in;
   61|      8|        }
   62|      8|        err = PREFIX(inflate)(&stream, Z_NO_FLUSH);
  ------------------
  |  |   97|      8|#  define PREFIX(x) zng_ ## x
  ------------------
                      err = PREFIX(inflate)(&stream, Z_NO_FLUSH);
  ------------------
  |  |  171|      8|#define Z_NO_FLUSH      0
  ------------------
   63|      8|    } while (err == Z_OK);
  ------------------
  |  |  180|      8|#define Z_OK            0
  ------------------
  |  Branch (63:14): [True: 3, False: 5]
  ------------------
   64|       |
   65|      5|    *sourceLen -= len + stream.avail_in;
   66|      5|    if (dest != buf)
  ------------------
  |  Branch (66:9): [True: 5, False: 0]
  ------------------
   67|      5|        *destLen = (z_size_t)stream.total_out;
   68|      0|    else if (stream.total_out && err == Z_BUF_ERROR)
  ------------------
  |  |  187|      0|#define Z_BUF_ERROR    (-5)
  ------------------
  |  Branch (68:14): [True: 0, False: 0]
  |  Branch (68:34): [True: 0, False: 0]
  ------------------
   69|      0|        left = 1;
   70|       |
   71|      5|    PREFIX(inflateEnd)(&stream);
  ------------------
  |  |   97|      5|#  define PREFIX(x) zng_ ## x
  ------------------
   72|      5|    return err == Z_STREAM_END ? Z_OK :
  ------------------
  |  |  181|      5|#define Z_STREAM_END    1
  ------------------
                  return err == Z_STREAM_END ? Z_OK :
  ------------------
  |  |  180|      0|#define Z_OK            0
  ------------------
  |  Branch (72:12): [True: 0, False: 5]
  ------------------
   73|      5|           err == Z_NEED_DICT ? Z_DATA_ERROR  :
  ------------------
  |  |  182|      5|#define Z_NEED_DICT     2
  ------------------
                         err == Z_NEED_DICT ? Z_DATA_ERROR  :
  ------------------
  |  |  185|      0|#define Z_DATA_ERROR   (-3)
  ------------------
  |  Branch (73:12): [True: 0, False: 5]
  ------------------
   74|      5|           err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :
  ------------------
  |  |  187|     10|#define Z_BUF_ERROR    (-5)
  ------------------
                         err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :
  ------------------
  |  |  185|      3|#define Z_DATA_ERROR   (-3)
  ------------------
  |  Branch (74:12): [True: 3, False: 2]
  |  Branch (74:34): [True: 3, False: 0]
  ------------------
   75|      5|           err;
   76|      5|}
zng_uncompress:
   78|      5|z_int32_t Z_EXPORT PREFIX(uncompress)(unsigned char *dest, z_uintmax_t *destLen, const unsigned char *source, z_uintmax_t sourceLen) {
   79|      5|    return PREFIX(uncompress2)(dest, destLen, source, &sourceLen);
  ------------------
  |  |   97|      5|#  define PREFIX(x) zng_ ## x
  ------------------
   80|      5|}

zng_zcalloc:
  105|      5|void Z_INTERNAL *PREFIX(zcalloc)(void *opaque, unsigned items, unsigned size) {
  106|      5|    Z_UNUSED(opaque);
  ------------------
  |  |  128|      5|#define Z_UNUSED(var) (void)(var)
  ------------------
  107|      5|    return zng_alloc((size_t)items * (size_t)size);
  108|      5|}
zng_zcfree:
  110|      5|void Z_INTERNAL PREFIX(zcfree)(void *opaque, void *ptr) {
  111|      5|    Z_UNUSED(opaque);
  ------------------
  |  |  128|      5|#define Z_UNUSED(var) (void)(var)
  ------------------
  112|      5|    zng_free(ptr);
  113|      5|}

zutil.c:zng_alloc:
   12|      5|static inline void *zng_alloc(size_t size) {
   13|      5|    return (void *)malloc(size);
   14|      5|}
zutil.c:zng_free:
   16|      5|static inline void zng_free(void *ptr) {
   17|      5|    free(ptr);
   18|      5|}

zstd_ddict.c:ZSTD_customMalloc:
   27|     16|{
   28|     16|    if (customMem.customAlloc)
  ------------------
  |  Branch (28:9): [True: 0, False: 16]
  ------------------
   29|      0|        return customMem.customAlloc(customMem.opaque, size);
   30|     16|    return ZSTD_malloc(size);
  ------------------
  |  |   66|     16|#define ZSTD_malloc(s) malloc(s)
  ------------------
   31|     16|}
zstd_ddict.c:ZSTD_customFree:
   50|     16|{
   51|     16|    if (ptr!=NULL) {
  ------------------
  |  Branch (51:9): [True: 16, False: 0]
  ------------------
   52|     16|        if (customMem.customFree)
  ------------------
  |  Branch (52:13): [True: 0, False: 16]
  ------------------
   53|      0|            customMem.customFree(customMem.opaque, ptr);
   54|     16|        else
   55|     16|            ZSTD_free(ptr);
  ------------------
  |  |   68|     16|#define ZSTD_free(p) free((p))
  ------------------
   56|     16|    }
   57|     16|}
zstd_decompress.c:ZSTD_customFree:
   50|     22|{
   51|     22|    if (ptr!=NULL) {
  ------------------
  |  Branch (51:9): [True: 11, False: 11]
  ------------------
   52|     11|        if (customMem.customFree)
  ------------------
  |  Branch (52:13): [True: 0, False: 11]
  ------------------
   53|      0|            customMem.customFree(customMem.opaque, ptr);
   54|     11|        else
   55|     11|            ZSTD_free(ptr);
  ------------------
  |  |   68|     11|#define ZSTD_free(p) free((p))
  ------------------
   56|     11|    }
   57|     22|}
zstd_decompress.c:ZSTD_customMalloc:
   27|     11|{
   28|     11|    if (customMem.customAlloc)
  ------------------
  |  Branch (28:9): [True: 0, False: 11]
  ------------------
   29|      0|        return customMem.customAlloc(customMem.opaque, size);
   30|     11|    return ZSTD_malloc(size);
  ------------------
  |  |   66|     11|#define ZSTD_malloc(s) malloc(s)
  ------------------
   31|     11|}

zstd_decompress.c:ZSTD_cpuid:
   32|     11|MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
   33|     11|    U32 f1c = 0;
   34|     11|    U32 f1d = 0;
   35|     11|    U32 f7b = 0;
   36|     11|    U32 f7c = 0;
   37|       |#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
   38|       |#if !defined(_M_X64) || !defined(__clang__) || __clang_major__ >= 16
   39|       |    int reg[4];
   40|       |    __cpuid((int*)reg, 0);
   41|       |    {
   42|       |        int const n = reg[0];
   43|       |        if (n >= 1) {
   44|       |            __cpuid((int*)reg, 1);
   45|       |            f1c = (U32)reg[2];
   46|       |            f1d = (U32)reg[3];
   47|       |        }
   48|       |        if (n >= 7) {
   49|       |            __cpuidex((int*)reg, 7, 0);
   50|       |            f7b = (U32)reg[1];
   51|       |            f7c = (U32)reg[2];
   52|       |        }
   53|       |    }
   54|       |#else
   55|       |    /* Clang compiler has a bug (fixed in https://reviews.llvm.org/D101338) in
   56|       |     * which the `__cpuid` intrinsic does not save and restore `rbx` as it needs
   57|       |     * to due to being a reserved register. So in that case, do the `cpuid`
   58|       |     * ourselves. Clang supports inline assembly anyway.
   59|       |     */
   60|       |    U32 n;
   61|       |    __asm__(
   62|       |        "pushq %%rbx\n\t"
   63|       |        "cpuid\n\t"
   64|       |        "popq %%rbx\n\t"
   65|       |        : "=a"(n)
   66|       |        : "a"(0)
   67|       |        : "rcx", "rdx");
   68|       |    if (n >= 1) {
   69|       |      U32 f1a;
   70|       |      __asm__(
   71|       |          "pushq %%rbx\n\t"
   72|       |          "cpuid\n\t"
   73|       |          "popq %%rbx\n\t"
   74|       |          : "=a"(f1a), "=c"(f1c), "=d"(f1d)
   75|       |          : "a"(1)
   76|       |          :);
   77|       |    }
   78|       |    if (n >= 7) {
   79|       |      __asm__(
   80|       |          "pushq %%rbx\n\t"
   81|       |          "cpuid\n\t"
   82|       |          "movq %%rbx, %%rax\n\t"
   83|       |          "popq %%rbx"
   84|       |          : "=a"(f7b), "=c"(f7c)
   85|       |          : "a"(7), "c"(0)
   86|       |          : "rdx");
   87|       |    }
   88|       |#endif
   89|       |#elif defined(__i386__) && defined(__PIC__) && !defined(__clang__) && defined(__GNUC__)
   90|       |    /* The following block like the normal cpuid branch below, but gcc
   91|       |     * reserves ebx for use of its pic register so we must specially
   92|       |     * handle the save and restore to avoid clobbering the register
   93|       |     */
   94|       |    U32 n;
   95|       |    __asm__(
   96|       |        "pushl %%ebx\n\t"
   97|       |        "cpuid\n\t"
   98|       |        "popl %%ebx\n\t"
   99|       |        : "=a"(n)
  100|       |        : "a"(0)
  101|       |        : "ecx", "edx");
  102|       |    if (n >= 1) {
  103|       |      U32 f1a;
  104|       |      __asm__(
  105|       |          "pushl %%ebx\n\t"
  106|       |          "cpuid\n\t"
  107|       |          "popl %%ebx\n\t"
  108|       |          : "=a"(f1a), "=c"(f1c), "=d"(f1d)
  109|       |          : "a"(1));
  110|       |    }
  111|       |    if (n >= 7) {
  112|       |      __asm__(
  113|       |          "pushl %%ebx\n\t"
  114|       |          "cpuid\n\t"
  115|       |          "movl %%ebx, %%eax\n\t"
  116|       |          "popl %%ebx"
  117|       |          : "=a"(f7b), "=c"(f7c)
  118|       |          : "a"(7), "c"(0)
  119|       |          : "edx");
  120|       |    }
  121|       |#elif defined(__x86_64__) || defined(_M_X64) || defined(__i386__)
  122|       |    U32 n;
  123|     11|    __asm__("cpuid" : "=a"(n) : "a"(0) : "ebx", "ecx", "edx");
  124|     11|    if (n >= 1) {
  ------------------
  |  Branch (124:9): [True: 11, False: 0]
  ------------------
  125|     11|      U32 f1a;
  126|     11|      __asm__("cpuid" : "=a"(f1a), "=c"(f1c), "=d"(f1d) : "a"(1) : "ebx");
  127|     11|    }
  128|     11|    if (n >= 7) {
  ------------------
  |  Branch (128:9): [True: 11, False: 0]
  ------------------
  129|     11|      U32 f7a;
  130|     11|      __asm__("cpuid"
  131|     11|              : "=a"(f7a), "=b"(f7b), "=c"(f7c)
  132|     11|              : "a"(7), "c"(0)
  133|     11|              : "edx");
  134|     11|    }
  135|     11|#endif
  136|     11|    {
  137|     11|        ZSTD_cpuid_t cpuid;
  138|     11|        cpuid.f1c = f1c;
  139|     11|        cpuid.f1d = f1d;
  140|     11|        cpuid.f7b = f7b;
  141|     11|        cpuid.f7c = f7c;
  142|     11|        return cpuid;
  143|     11|    }
  144|     11|}
zstd_decompress.c:ZSTD_cpuid_bmi1:
  147|     11|  MEM_STATIC int ZSTD_cpuid_##name(ZSTD_cpuid_t const cpuid) {                 \
  148|     11|    return ((cpuid.r) & (1U << bit)) != 0;                                     \
  149|     11|  }
zstd_decompress.c:ZSTD_cpuid_bmi2:
  147|     11|  MEM_STATIC int ZSTD_cpuid_##name(ZSTD_cpuid_t const cpuid) {                 \
  148|     11|    return ((cpuid.r) & (1U << bit)) != 0;                                     \
  149|     11|  }

zstd_common.c:ERR_isError:
   52|     21|ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
  ------------------
  |  |   49|     21|#define ERROR(name) ZSTD_ERROR(name)
  |  |  ------------------
  |  |  |  |   50|     21|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|     21|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
zstd_common.c:ERR_getErrorCode:
   54|     10|ERR_STATIC ERR_enum ERR_getErrorCode(size_t code) { if (!ERR_isError(code)) return (ERR_enum)0; return (ERR_enum) (0-code); }
  ------------------
  |  Branch (54:57): [True: 0, False: 10]
  ------------------
zstd_ddict.c:ERR_isError:
   52|     24|ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
  ------------------
  |  |   49|     24|#define ERROR(name) ZSTD_ERROR(name)
  |  |  ------------------
  |  |  |  |   50|     24|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|     24|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
zstd_decompress.c:ERR_isError:
   52|     57|ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
  ------------------
  |  |   49|     57|#define ERROR(name) ZSTD_ERROR(name)
  |  |  ------------------
  |  |  |  |   50|     57|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|     57|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------

zstd_ddict.c:MEM_readLE32:
  322|      6|{
  323|      6|    if (MEM_isLittleEndian())
  ------------------
  |  Branch (323:9): [True: 6, False: 0]
  ------------------
  324|      6|        return MEM_read32(memPtr);
  325|      0|    else
  326|      0|        return MEM_swap32(MEM_read32(memPtr));
  327|      6|}
zstd_ddict.c:MEM_isLittleEndian:
  141|      6|{
  142|      6|#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  143|      6|    return 1;
  144|       |#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  145|       |    return 0;
  146|       |#elif defined(__clang__) && __LITTLE_ENDIAN__
  147|       |    return 1;
  148|       |#elif defined(__clang__) && __BIG_ENDIAN__
  149|       |    return 0;
  150|       |#elif defined(_MSC_VER) && (_M_X64 || _M_IX86)
  151|       |    return 1;
  152|       |#elif defined(__DMC__) && defined(_M_IX86)
  153|       |    return 1;
  154|       |#elif defined(__IAR_SYSTEMS_ICC__) && __LITTLE_ENDIAN__
  155|       |    return 1;
  156|       |#else
  157|       |    const union { U32 u; BYTE c[4]; } one = { 1 };   /* don't use static : performance detrimental  */
  158|       |    return one.c[0];
  159|       |#endif
  160|      6|}
zstd_ddict.c:MEM_read32:
  183|      6|MEM_STATIC U32 MEM_read32(const void* ptr) { return *(const unalign32*)ptr; }
zstd_decompress.c:MEM_readLE32:
  322|     28|{
  323|     28|    if (MEM_isLittleEndian())
  ------------------
  |  Branch (323:9): [True: 28, False: 0]
  ------------------
  324|     28|        return MEM_read32(memPtr);
  325|      0|    else
  326|      0|        return MEM_swap32(MEM_read32(memPtr));
  327|     28|}
zstd_decompress.c:MEM_isLittleEndian:
  141|     28|{
  142|     28|#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  143|     28|    return 1;
  144|       |#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  145|       |    return 0;
  146|       |#elif defined(__clang__) && __LITTLE_ENDIAN__
  147|       |    return 1;
  148|       |#elif defined(__clang__) && __BIG_ENDIAN__
  149|       |    return 0;
  150|       |#elif defined(_MSC_VER) && (_M_X64 || _M_IX86)
  151|       |    return 1;
  152|       |#elif defined(__DMC__) && defined(_M_IX86)
  153|       |    return 1;
  154|       |#elif defined(__IAR_SYSTEMS_ICC__) && __LITTLE_ENDIAN__
  155|       |    return 1;
  156|       |#else
  157|       |    const union { U32 u; BYTE c[4]; } one = { 1 };   /* don't use static : performance detrimental  */
  158|       |    return one.c[0];
  159|       |#endif
  160|     28|}
zstd_decompress.c:MEM_read32:
  183|     28|MEM_STATIC U32 MEM_read32(const void* ptr) { return *(const unalign32*)ptr; }

ZSTD_isError:
   36|     11|unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
ZSTD_getErrorCode:
   44|     10|ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }

zstd_decompress.c:ZSTD_cpuSupportsBmi2:
  321|     11|{
  322|     11|    ZSTD_cpuid_t cpuid = ZSTD_cpuid();
  323|     11|    return ZSTD_cpuid_bmi1(cpuid) && ZSTD_cpuid_bmi2(cpuid);
  ------------------
  |  Branch (323:12): [True: 11, False: 0]
  |  Branch (323:38): [True: 11, False: 0]
  ------------------
  324|     11|}

ZSTD_DDict_dictContent:
   48|      6|{
   49|      6|    assert(ddict != NULL);
  ------------------
  |  |   70|      6|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
   50|      6|    return ddict->dictContent;
   51|      6|}
ZSTD_DDict_dictSize:
   54|     12|{
   55|     12|    assert(ddict != NULL);
  ------------------
  |  |   70|     12|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
   56|     12|    return ddict->dictSize;
   57|     12|}
ZSTD_copyDDictParameters:
   60|      6|{
   61|      6|    const void* content;
   62|      6|    DEBUGLOG(4, "ZSTD_copyDDictParameters");
  ------------------
  |  |  104|      6|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 6]
  |  |  ------------------
  ------------------
   63|      6|    assert(dctx != NULL);
  ------------------
  |  |   70|      6|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
   64|      6|    assert(ddict != NULL);
  ------------------
  |  |   70|      6|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
   65|      6|    content = ddict->dictHeaderSize != 0
  ------------------
  |  Branch (65:15): [True: 0, False: 6]
  ------------------
   66|      6|            ? (const BYTE*)ddict->dictContent + ddict->dictHeaderSize
   67|      6|            : ddict->dictContent;
   68|      6|    dctx->dictID = ddict->dictID;
   69|      6|    dctx->prefixStart = content;
   70|      6|    dctx->virtualStart = content;
   71|       |    /* An empty DDict may have NULL content. */
   72|      6|    dctx->dictEnd = ddict->dictSize != 0
  ------------------
  |  Branch (72:21): [True: 6, False: 0]
  ------------------
   73|      6|            ? (const BYTE*)ddict->dictContent + ddict->dictSize
   74|      6|            : ddict->dictContent;
   75|      6|    dctx->previousDstEnd = dctx->dictEnd;
   76|      6|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
   77|      6|    dctx->dictContentBeginForFuzzing = dctx->prefixStart;
   78|      6|    dctx->dictContentEndForFuzzing = dctx->previousDstEnd;
   79|      6|#endif
   80|      6|    if (ddict->entropyPresent) {
  ------------------
  |  Branch (80:9): [True: 0, False: 6]
  ------------------
   81|      0|        dctx->litEntropy = 1;
   82|      0|        dctx->fseEntropy = 1;
   83|      0|        dctx->LLTptr = ddict->entropy.LLTable;
   84|      0|        dctx->MLTptr = ddict->entropy.MLTable;
   85|      0|        dctx->OFTptr = ddict->entropy.OFTable;
   86|      0|        dctx->HUFptr = ddict->entropy.hufTable;
   87|      0|        dctx->entropy.rep[0] = ddict->entropy.rep[0];
   88|      0|        dctx->entropy.rep[1] = ddict->entropy.rep[1];
   89|      0|        dctx->entropy.rep[2] = ddict->entropy.rep[2];
   90|      6|    } else {
   91|      6|        dctx->litEntropy = 0;
   92|      6|        dctx->fseEntropy = 0;
   93|      6|    }
   94|      6|}
ZSTD_createDDict_advanced_internal:
  164|      8|{
  165|      8|    ZSTD_DDict* ddict;
  166|      8|    *ddictPtr = NULL;
  167|      8|    RETURN_ERROR_IF((!customMem.customAlloc) ^ (!customMem.customFree),
  ------------------
  |  |  114|      8|    do {                                                                       \
  |  |  115|      8|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 8]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      8|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 8]
  |  |  ------------------
  ------------------
  168|      8|                    parameter_combination_unsupported, "Invalid custom allocator");
  169|       |
  170|      8|    ddict = (ZSTD_DDict*) ZSTD_customMalloc(sizeof(ZSTD_DDict), customMem);
  171|      8|    RETURN_ERROR_IF(ddict == NULL, memory_allocation, "");
  ------------------
  |  |  114|      8|    do {                                                                       \
  |  |  115|      8|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 8]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      8|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 8]
  |  |  ------------------
  ------------------
  172|      8|    ddict->cMem = customMem;
  173|      8|    {   size_t const initResult = ZSTD_initDDict_internal(ddict,
  174|      8|                                        dict, dictSize,
  175|      8|                                        dictLoadMethod, dictContentType);
  176|      8|        if (ZSTD_isError(initResult)) {
  ------------------
  |  |   44|      8|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (176:13): [True: 0, False: 8]
  ------------------
  177|      0|            ZSTD_freeDDict(ddict);
  178|      0|            return initResult;
  179|      0|    }   }
  180|      8|    *ddictPtr = ddict;
  181|      8|    return 0;
  182|      8|}
ZSTD_createDDict_advanced:
  188|      8|{
  189|      8|    ZSTD_DDict* ddict;
  190|      8|    size_t const err = ZSTD_createDDict_advanced_internal(&ddict,
  191|      8|                            dict, dictSize, dictLoadMethod, dictContentType, customMem);
  192|      8|    if (ZSTD_isError(err)) return NULL;
  ------------------
  |  |   44|      8|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (192:9): [True: 0, False: 8]
  ------------------
  193|      8|    return ddict;
  194|      8|}
ZSTD_createDDict:
  201|      8|{
  202|      8|    ZSTD_customMem const allocator = { NULL, NULL, NULL };
  203|      8|    return ZSTD_createDDict_advanced(dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto, allocator);
  204|      8|}
ZSTD_freeDDict:
  242|     23|{
  243|     23|    if (ddict==NULL) return 0;   /* support free on NULL */
  ------------------
  |  Branch (243:9): [True: 15, False: 8]
  ------------------
  244|      8|    {   ZSTD_customMem const cMem = ddict->cMem;
  245|      8|        ZSTD_customFree(ddict->dictBuffer, cMem);
  246|      8|        ZSTD_customFree(ddict, cMem);
  247|      8|        return 0;
  248|     23|    }
  249|     23|}
ZSTD_sizeof_DDict:
  263|     10|{
  264|     10|    if (ddict==NULL) return 0;   /* support sizeof on NULL */
  ------------------
  |  Branch (264:9): [True: 10, False: 0]
  ------------------
  265|      0|    return sizeof(*ddict) + (ddict->dictBuffer ? ddict->dictSize : 0) ;
  ------------------
  |  Branch (265:30): [True: 0, False: 0]
  ------------------
  266|     10|}
zstd_ddict.c:ZSTD_initDDict_internal:
  136|      8|{
  137|       |    /* An empty dictionary has no referenced storage, even in by-copy mode. */
  138|      8|    if (dictSize == 0) dict = NULL;
  ------------------
  |  Branch (138:9): [True: 0, False: 8]
  ------------------
  139|      8|    if ((dictLoadMethod == ZSTD_dlm_byRef) || (!dict) || (!dictSize)) {
  ------------------
  |  Branch (139:9): [True: 0, False: 8]
  |  Branch (139:47): [True: 0, False: 8]
  |  Branch (139:58): [True: 0, False: 8]
  ------------------
  140|      0|        ddict->dictBuffer = NULL;
  141|      0|        ddict->dictContent = dict;
  142|      0|        if (!dict) dictSize = 0;
  ------------------
  |  Branch (142:13): [True: 0, False: 0]
  ------------------
  143|      8|    } else {
  144|      8|        void* const internalBuffer = ZSTD_customMalloc(dictSize, ddict->cMem);
  145|      8|        ddict->dictBuffer = internalBuffer;
  146|      8|        ddict->dictContent = internalBuffer;
  147|      8|        if (!internalBuffer) return ERROR(memory_allocation);
  ------------------
  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  ------------------
  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (147:13): [True: 0, False: 8]
  ------------------
  148|      8|        ZSTD_memcpy(internalBuffer, dict, dictSize);
  ------------------
  |  |   44|      8|# define ZSTD_memcpy(d,s,l) __builtin_memcpy((d),(s),(l))
  ------------------
  149|      8|    }
  150|      8|    ddict->dictSize = dictSize;
  151|      8|    ddict->entropy.hufTable[0] = (HUF_DTable)((ZSTD_HUFFDTABLE_CAPACITY_LOG)*0x1000001);  /* cover both little and big endian */
  ------------------
  |  |   78|      8|#define ZSTD_HUFFDTABLE_CAPACITY_LOG 12
  ------------------
  152|       |
  153|       |    /* parse dictionary content */
  154|      8|    FORWARD_IF_ERROR( ZSTD_loadEntropy_intoDDict(ddict, dictContentType) , "");
  ------------------
  |  |  146|      8|    do {                                                                           \
  |  |  147|      8|        size_t const err_code = (err);                                             \
  |  |  148|      8|        if (ERR_isError(err_code)) {                                               \
  |  |  ------------------
  |  |  |  Branch (148:13): [True: 0, False: 8]
  |  |  ------------------
  |  |  149|      0|            RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s",                 \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|      0|                  __FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
  |  |  151|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                                 \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  152|      0|            RAWLOG(3, ": " __VA_ARGS__);                                           \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  153|      0|            RAWLOG(3, "\n");                                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  154|      0|            return err_code;                                                       \
  |  |  155|      0|        }                                                                          \
  |  |  156|      8|    } while(0)
  |  |  ------------------
  |  |  |  Branch (156:13): [Folded, False: 8]
  |  |  ------------------
  ------------------
  155|       |
  156|      8|    return 0;
  157|      8|}
zstd_ddict.c:ZSTD_loadEntropy_intoDDict:
  100|      8|{
  101|      8|    ddict->dictID = 0;
  102|      8|    ddict->dictHeaderSize = 0;
  103|      8|    ddict->entropyPresent = 0;
  104|      8|    if (dictContentType == ZSTD_dct_rawContent) return 0;
  ------------------
  |  Branch (104:9): [True: 0, False: 8]
  ------------------
  105|       |
  106|      8|    if (ddict->dictSize < 8) {
  ------------------
  |  Branch (106:9): [True: 2, False: 6]
  ------------------
  107|      2|        if (dictContentType == ZSTD_dct_fullDict)
  ------------------
  |  Branch (107:13): [True: 0, False: 2]
  ------------------
  108|      0|            return ERROR(dictionary_corrupted);   /* only accept specified dictionaries */
  ------------------
  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  ------------------
  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|      2|        return 0;   /* pure content mode */
  110|      2|    }
  111|      6|    {   U32 const magic = MEM_readLE32(ddict->dictContent);
  112|      6|        if (magic != ZSTD_MAGIC_DICTIONARY) {
  ------------------
  |  |  143|      6|#define ZSTD_MAGIC_DICTIONARY       0xEC30A437    /* valid since v0.7.0 */
  ------------------
  |  Branch (112:13): [True: 6, False: 0]
  ------------------
  113|      6|            if (dictContentType == ZSTD_dct_fullDict)
  ------------------
  |  Branch (113:17): [True: 0, False: 6]
  ------------------
  114|      0|                return ERROR(dictionary_corrupted);   /* only accept specified dictionaries */
  ------------------
  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  ------------------
  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  115|      6|            return 0;   /* pure content mode */
  116|      6|        }
  117|      6|    }
  118|      0|    ddict->dictID = MEM_readLE32((const char*)ddict->dictContent + ZSTD_FRAMEIDSIZE);
  ------------------
  |  |   82|      0|#define ZSTD_FRAMEIDSIZE 4   /* magic number size */
  ------------------
  119|       |
  120|       |    /* load entropy tables */
  121|      0|    {   size_t const headerSize = ZSTD_loadDEntropy(
  122|      0|                &ddict->entropy, ddict->dictContent, ddict->dictSize);
  123|      0|        RETURN_ERROR_IF(ZSTD_isError(headerSize), dictionary_corrupted, "");
  ------------------
  |  |  114|      0|    do {                                                                       \
  |  |  115|      0|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  124|      0|        assert(headerSize <= ddict->dictSize);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
  125|      0|        ddict->dictHeaderSize = headerSize;
  126|      0|    }
  127|      0|    ddict->entropyPresent = 1;
  128|      0|    return 0;
  129|      0|}

ZSTD_sizeof_DCtx:
  218|     10|{
  219|     10|    if (dctx==NULL) return 0;   /* support sizeof NULL */
  ------------------
  |  Branch (219:9): [True: 0, False: 10]
  ------------------
  220|     10|    return sizeof(*dctx)
  221|     10|           + ZSTD_sizeof_DDict(dctx->ddictLocal)
  222|     10|           + dctx->inBuffSize + dctx->outBuffSize;
  223|     10|}
ZSTD_createDCtx:
  309|     11|{
  310|     11|    DEBUGLOG(3, "ZSTD_createDCtx");
  ------------------
  |  |  104|     11|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 11]
  |  |  ------------------
  ------------------
  311|     11|    return ZSTD_createDCtx_internal(ZSTD_defaultCMem);
  312|     11|}
ZSTD_freeDCtx:
  349|     11|{
  350|     11|    if (dctx==NULL) return 0;   /* support free on NULL */
  ------------------
  |  Branch (350:9): [True: 0, False: 11]
  ------------------
  351|     11|    RETURN_ERROR_IF(dctx->staticSize, memory_allocation, "not compatible with static DCtx");
  ------------------
  |  |  114|     11|    do {                                                                       \
  |  |  115|     11|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 11]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|     11|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 11]
  |  |  ------------------
  ------------------
  352|     11|    {   ZSTD_customMem const cMem = dctx->customMem;
  353|     11|        ZSTD_clearDict(dctx);
  354|     11|        ZSTD_customFree(dctx->inBuff, cMem);
  355|     11|        dctx->inBuff = NULL;
  356|       |#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
  357|       |        if (dctx->legacyContext)
  358|       |            ZSTD_freeLegacyStreamContext(dctx->legacyContext, dctx->previousLegacyVersion);
  359|       |#endif
  360|     11|        ZSTD_clearDDictSet(dctx);
  361|     11|        ZSTD_customFree(dctx, cMem);
  362|     11|        return 0;
  363|     11|    }
  364|     11|}
ZSTD_getFrameHeader_advanced:
  463|      9|{
  464|      9|    const BYTE* ip = (const BYTE*)src;
  465|      9|    size_t const minInputSize = ZSTD_startingInputLength(format);
  466|       |
  467|      9|    DEBUGLOG(5, "ZSTD_getFrameHeader_advanced: minInputSize = %zu, srcSize = %zu", minInputSize, srcSize);
  ------------------
  |  |  104|      9|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 9]
  |  |  ------------------
  ------------------
  468|       |
  469|      9|    if (srcSize > 0) {
  ------------------
  |  Branch (469:9): [True: 9, False: 0]
  ------------------
  470|       |        /* note : technically could be considered an assert(), since it's an invalid entry */
  471|      9|        RETURN_ERROR_IF(src==NULL, GENERIC, "invalid parameter : src==NULL, but srcSize>0");
  ------------------
  |  |  114|      9|    do {                                                                       \
  |  |  115|      9|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 9]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      9|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 9]
  |  |  ------------------
  ------------------
  472|      9|    }
  473|      9|    if (srcSize < minInputSize) {
  ------------------
  |  Branch (473:9): [True: 0, False: 9]
  ------------------
  474|      0|        if (srcSize > 0 && format != ZSTD_f_zstd1_magicless) {
  ------------------
  |  Branch (474:13): [True: 0, False: 0]
  |  Branch (474:28): [True: 0, False: 0]
  ------------------
  475|       |            /* when receiving less than @minInputSize bytes,
  476|       |             * control these bytes at least correspond to a supported magic number
  477|       |             * in order to error out early if they don't.
  478|       |            **/
  479|      0|            size_t const toCopy = MIN(4, srcSize);
  ------------------
  |  |   54|      0|#define MIN(a,b) ((a)<(b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (54:19): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  480|      0|            unsigned char hbuf[4]; MEM_writeLE32(hbuf, ZSTD_MAGICNUMBER);
  ------------------
  |  |  142|      0|#define ZSTD_MAGICNUMBER            0xFD2FB528    /* valid since v0.8.0 */
  ------------------
  481|      0|            assert(src != NULL);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
  482|      0|            ZSTD_memcpy(hbuf, src, toCopy);
  ------------------
  |  |   44|      0|# define ZSTD_memcpy(d,s,l) __builtin_memcpy((d),(s),(l))
  ------------------
  483|      0|            if ( MEM_readLE32(hbuf) != ZSTD_MAGICNUMBER ) {
  ------------------
  |  |  142|      0|#define ZSTD_MAGICNUMBER            0xFD2FB528    /* valid since v0.8.0 */
  ------------------
  |  Branch (483:18): [True: 0, False: 0]
  ------------------
  484|       |                /* not a zstd frame : let's check if it's a skippable frame */
  485|      0|                MEM_writeLE32(hbuf, ZSTD_MAGIC_SKIPPABLE_START);
  ------------------
  |  |  144|      0|#define ZSTD_MAGIC_SKIPPABLE_START  0x184D2A50    /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */
  ------------------
  486|      0|                ZSTD_memcpy(hbuf, src, toCopy);
  ------------------
  |  |   44|      0|# define ZSTD_memcpy(d,s,l) __builtin_memcpy((d),(s),(l))
  ------------------
  487|      0|                if ((MEM_readLE32(hbuf) & ZSTD_MAGIC_SKIPPABLE_MASK) != ZSTD_MAGIC_SKIPPABLE_START) {
  ------------------
  |  |  145|      0|#define ZSTD_MAGIC_SKIPPABLE_MASK   0xFFFFFFF0
  ------------------
                              if ((MEM_readLE32(hbuf) & ZSTD_MAGIC_SKIPPABLE_MASK) != ZSTD_MAGIC_SKIPPABLE_START) {
  ------------------
  |  |  144|      0|#define ZSTD_MAGIC_SKIPPABLE_START  0x184D2A50    /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */
  ------------------
  |  Branch (487:21): [True: 0, False: 0]
  ------------------
  488|      0|                    RETURN_ERROR(prefix_unknown,
  ------------------
  |  |  131|      0|    do {                                                                     \
  |  |  132|      0|        RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  133|      0|              __FILE__, __LINE__, ERR_QUOTE(ERROR(err)));                    \
  |  |  134|      0|        _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                               \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  135|      0|        RAWLOG(3, ": " __VA_ARGS__);                                         \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  136|      0|        RAWLOG(3, "\n");                                                     \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  137|      0|        return ERROR(err);                                                   \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  138|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (138:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  489|      0|                                "first bytes don't correspond to any supported magic number");
  490|      0|        }   }   }
  491|      0|        return minInputSize;
  492|      0|    }
  493|       |
  494|      9|    ZSTD_memset(zfhPtr, 0, sizeof(*zfhPtr));   /* not strictly necessary, but static analyzers may not understand that zfhPtr will be read only if return value is zero, since they are 2 different signals */
  ------------------
  |  |   46|      9|# define ZSTD_memset(p,v,l) __builtin_memset((p),(v),(l))
  ------------------
  495|      9|    if ( (format != ZSTD_f_zstd1_magicless)
  ------------------
  |  Branch (495:10): [True: 9, False: 0]
  ------------------
  496|      9|      && (MEM_readLE32(src) != ZSTD_MAGICNUMBER) ) {
  ------------------
  |  |  142|      9|#define ZSTD_MAGICNUMBER            0xFD2FB528    /* valid since v0.8.0 */
  ------------------
  |  Branch (496:10): [True: 9, False: 0]
  ------------------
  497|      9|        if ((MEM_readLE32(src) & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
  ------------------
  |  |  145|      9|#define ZSTD_MAGIC_SKIPPABLE_MASK   0xFFFFFFF0
  ------------------
                      if ((MEM_readLE32(src) & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
  ------------------
  |  |  144|      9|#define ZSTD_MAGIC_SKIPPABLE_START  0x184D2A50    /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */
  ------------------
  |  Branch (497:13): [True: 0, False: 9]
  ------------------
  498|       |            /* skippable frame */
  499|      0|            if (srcSize < ZSTD_SKIPPABLEHEADERSIZE)
  ------------------
  |  | 1360|      0|#define ZSTD_SKIPPABLEHEADERSIZE    8
  ------------------
  |  Branch (499:17): [True: 0, False: 0]
  ------------------
  500|      0|                return ZSTD_SKIPPABLEHEADERSIZE; /* magic number + frame length */
  ------------------
  |  | 1360|      0|#define ZSTD_SKIPPABLEHEADERSIZE    8
  ------------------
  501|      0|            ZSTD_memset(zfhPtr, 0, sizeof(*zfhPtr));
  ------------------
  |  |   46|      0|# define ZSTD_memset(p,v,l) __builtin_memset((p),(v),(l))
  ------------------
  502|      0|            zfhPtr->frameType = ZSTD_skippableFrame;
  503|      0|            zfhPtr->dictID = MEM_readLE32(src) - ZSTD_MAGIC_SKIPPABLE_START;
  ------------------
  |  |  144|      0|#define ZSTD_MAGIC_SKIPPABLE_START  0x184D2A50    /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */
  ------------------
  504|      0|            zfhPtr->headerSize = ZSTD_SKIPPABLEHEADERSIZE;
  ------------------
  |  | 1360|      0|#define ZSTD_SKIPPABLEHEADERSIZE    8
  ------------------
  505|      0|            zfhPtr->frameContentSize = MEM_readLE32((const char *)src + ZSTD_FRAMEIDSIZE);
  ------------------
  |  |   82|      0|#define ZSTD_FRAMEIDSIZE 4   /* magic number size */
  ------------------
  506|      0|            return 0;
  507|      0|        }
  508|      9|        RETURN_ERROR(prefix_unknown, "");
  ------------------
  |  |  131|      9|    do {                                                                     \
  |  |  132|      9|        RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", \
  |  |  ------------------
  |  |  |  |  103|      9|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  133|      9|              __FILE__, __LINE__, ERR_QUOTE(ERROR(err)));                    \
  |  |  134|      9|        _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                               \
  |  |  ------------------
  |  |  |  |   98|      9|    do {                                           \
  |  |  |  |   99|      9|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      9|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  135|      9|        RAWLOG(3, ": " __VA_ARGS__);                                         \
  |  |  ------------------
  |  |  |  |  103|      9|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  136|      9|        RAWLOG(3, "\n");                                                     \
  |  |  ------------------
  |  |  |  |  103|      9|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  137|      9|        return ERROR(err);                                                   \
  |  |  ------------------
  |  |  |  |   49|      9|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      9|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      9|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  138|      9|    } while(0)
  |  |  ------------------
  |  |  |  Branch (138:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  509|      9|    }
  510|       |
  511|       |    /* ensure there is enough `srcSize` to fully read/decode frame header */
  512|      0|    {   size_t const fhsize = ZSTD_frameHeaderSize_internal(src, srcSize, format);
  513|      0|        if (srcSize < fhsize) return fhsize;
  ------------------
  |  Branch (513:13): [True: 0, False: 0]
  ------------------
  514|      0|        zfhPtr->headerSize = (U32)fhsize;
  515|      0|    }
  516|       |
  517|      0|    {   BYTE const fhdByte = ip[minInputSize-1];
  518|      0|        size_t pos = minInputSize;
  519|      0|        U32 const dictIDSizeCode = fhdByte&3;
  520|      0|        U32 const checksumFlag = (fhdByte>>2)&1;
  521|      0|        U32 const singleSegment = (fhdByte>>5)&1;
  522|      0|        U32 const fcsID = fhdByte>>6;
  523|      0|        U64 windowSize = 0;
  524|      0|        U32 dictID = 0;
  525|      0|        U64 frameContentSize = ZSTD_CONTENTSIZE_UNKNOWN;
  ------------------
  |  |  203|      0|#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
  ------------------
  526|      0|        RETURN_ERROR_IF((fhdByte & 0x08) != 0, frameParameter_unsupported,
  ------------------
  |  |  114|      0|    do {                                                                       \
  |  |  115|      0|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  527|      0|                        "reserved bits, must be zero");
  528|       |
  529|      0|        if (!singleSegment) {
  ------------------
  |  Branch (529:13): [True: 0, False: 0]
  ------------------
  530|      0|            BYTE const wlByte = ip[pos++];
  531|      0|            U32 const windowLog = (wlByte >> 3) + ZSTD_WINDOWLOG_ABSOLUTEMIN;
  ------------------
  |  |   78|      0|#define ZSTD_WINDOWLOG_ABSOLUTEMIN 10
  ------------------
  532|      0|            RETURN_ERROR_IF(windowLog > ZSTD_WINDOWLOG_MAX, frameParameter_windowTooLarge, "");
  ------------------
  |  |  114|      0|    do {                                                                       \
  |  |  115|      0|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [Folded, False: 0]
  |  |  |  Branch (115:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  533|      0|            windowSize = (1ULL << windowLog);
  534|      0|            windowSize += (windowSize >> 3) * (wlByte&7);
  535|      0|        }
  536|      0|        switch(dictIDSizeCode)
  537|      0|        {
  538|      0|            default:
  ------------------
  |  Branch (538:13): [True: 0, False: 0]
  ------------------
  539|      0|                assert(0);  /* impossible */
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
  540|      0|                ZSTD_FALLTHROUGH;
  ------------------
  |  |  288|      0|#  define ZSTD_FALLTHROUGH ; __attribute__((__fallthrough__))
  ------------------
  541|      0|            case 0 : break;
  ------------------
  |  Branch (541:13): [True: 0, False: 0]
  ------------------
  542|      0|            case 1 : dictID = ip[pos]; pos++; break;
  ------------------
  |  Branch (542:13): [True: 0, False: 0]
  ------------------
  543|      0|            case 2 : dictID = MEM_readLE16(ip+pos); pos+=2; break;
  ------------------
  |  Branch (543:13): [True: 0, False: 0]
  ------------------
  544|      0|            case 3 : dictID = MEM_readLE32(ip+pos); pos+=4; break;
  ------------------
  |  Branch (544:13): [True: 0, False: 0]
  ------------------
  545|      0|        }
  546|      0|        switch(fcsID)
  547|      0|        {
  548|      0|            default:
  ------------------
  |  Branch (548:13): [True: 0, False: 0]
  ------------------
  549|      0|                assert(0);  /* impossible */
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
  550|      0|                ZSTD_FALLTHROUGH;
  ------------------
  |  |  288|      0|#  define ZSTD_FALLTHROUGH ; __attribute__((__fallthrough__))
  ------------------
  551|      0|            case 0 : if (singleSegment) frameContentSize = ip[pos]; break;
  ------------------
  |  Branch (551:13): [True: 0, False: 0]
  |  Branch (551:26): [True: 0, False: 0]
  ------------------
  552|      0|            case 1 : frameContentSize = MEM_readLE16(ip+pos)+256; break;
  ------------------
  |  Branch (552:13): [True: 0, False: 0]
  ------------------
  553|      0|            case 2 : frameContentSize = MEM_readLE32(ip+pos); break;
  ------------------
  |  Branch (553:13): [True: 0, False: 0]
  ------------------
  554|      0|            case 3 : frameContentSize = MEM_readLE64(ip+pos); break;
  ------------------
  |  Branch (554:13): [True: 0, False: 0]
  ------------------
  555|      0|        }
  556|      0|        if (singleSegment) windowSize = frameContentSize;
  ------------------
  |  Branch (556:13): [True: 0, False: 0]
  ------------------
  557|       |
  558|      0|        zfhPtr->frameType = ZSTD_frame;
  559|      0|        zfhPtr->frameContentSize = frameContentSize;
  560|      0|        zfhPtr->windowSize = windowSize;
  561|      0|        zfhPtr->blockSizeMax = (unsigned) MIN(windowSize, ZSTD_BLOCKSIZE_MAX);
  ------------------
  |  |   54|      0|#define MIN(a,b) ((a)<(b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (54:19): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  562|      0|        zfhPtr->dictID = dictID;
  563|      0|        zfhPtr->checksumFlag = checksumFlag;
  564|      0|    }
  565|      0|    return 0;
  566|      0|}
ZSTD_decompressDCtx:
 1231|      4|{
 1232|       |    /* Reset first: this may discard a prefix abandoned by an unfinished
 1233|       |     * stream, which must happen before the dictionary is resolved. */
 1234|      4|    ZSTD_DCtx_resetSession(dctx);
 1235|      4|    if (dctx->refMultipleDDicts && dctx->ddictSet)
  ------------------
  |  Branch (1235:9): [True: 0, False: 4]
  |  Branch (1235:36): [True: 0, False: 0]
  ------------------
 1236|      0|        return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize,
 1237|      0|                                         NULL, 0, NULL, 1);
 1238|       |    /* Preserve the single-dictionary behavior: resolve once for the entire
 1239|       |     * call, including concatenated frames and single-use prefixes. */
 1240|      4|    return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize,
 1241|       |                                     NULL, 0, ZSTD_getDDict(dctx), 0);
 1242|      4|}
ZSTD_decompressBegin:
 1620|     10|{
 1621|     10|    assert(dctx != NULL);
  ------------------
  |  |   70|     10|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1622|     10|#if ZSTD_TRACE
 1623|     10|    dctx->traceCtx = (ZSTD_trace_decompress_begin != NULL) ? ZSTD_trace_decompress_begin(dctx) : 0;
  ------------------
  |  Branch (1623:22): [True: 0, False: 10]
  ------------------
 1624|     10|    dctx->traceDictSize = 0;
 1625|     10|#endif
 1626|     10|    dctx->expected = ZSTD_startingInputLength(dctx->format);  /* dctx->format must be properly set */
 1627|     10|    dctx->stage = ZSTDds_getFrameHeaderSize;
 1628|     10|    dctx->processedCSize = 0;
 1629|     10|    dctx->decodedSize = 0;
 1630|     10|    dctx->previousDstEnd = NULL;
 1631|     10|    dctx->prefixStart = NULL;
 1632|     10|    dctx->virtualStart = NULL;
 1633|     10|    dctx->dictEnd = NULL;
 1634|     10|    dctx->entropy.hufTable[0] = (HUF_DTable)((ZSTD_HUFFDTABLE_CAPACITY_LOG)*0x1000001);  /* cover both little and big endian */
  ------------------
  |  |   78|     10|#define ZSTD_HUFFDTABLE_CAPACITY_LOG 12
  ------------------
 1635|     10|    dctx->litEntropy = dctx->fseEntropy = 0;
 1636|     10|    dctx->dictID = 0;
 1637|     10|    dctx->bType = bt_reserved;
 1638|     10|    dctx->isFrameDecompression = 1;
 1639|     10|    ZSTD_STATIC_ASSERT(sizeof(dctx->entropy.rep) == sizeof(repStartValue));
  ------------------
  |  |   43|     10|#define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c)
  |  |  ------------------
  |  |  |  |   39|     10|#define DEBUG_STATIC_ASSERT(c) (void)sizeof(char[(c) ? 1 : -1])
  |  |  ------------------
  ------------------
 1640|     10|    ZSTD_memcpy(dctx->entropy.rep, repStartValue, sizeof(repStartValue));  /* initial repcodes */
  ------------------
  |  |   44|     10|# define ZSTD_memcpy(d,s,l) __builtin_memcpy((d),(s),(l))
  ------------------
 1641|     10|    dctx->LLTptr = dctx->entropy.LLTable;
 1642|     10|    dctx->MLTptr = dctx->entropy.MLTable;
 1643|     10|    dctx->OFTptr = dctx->entropy.OFTable;
 1644|     10|    dctx->HUFptr = dctx->entropy.hufTable;
 1645|     10|    return 0;
 1646|     10|}
ZSTD_decompressBegin_usingDict:
 1649|      4|{
 1650|      4|    FORWARD_IF_ERROR( ZSTD_decompressBegin(dctx) , "");
  ------------------
  |  |  146|      4|    do {                                                                           \
  |  |  147|      4|        size_t const err_code = (err);                                             \
  |  |  148|      4|        if (ERR_isError(err_code)) {                                               \
  |  |  ------------------
  |  |  |  Branch (148:13): [True: 0, False: 4]
  |  |  ------------------
  |  |  149|      0|            RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s",                 \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|      0|                  __FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
  |  |  151|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                                 \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  152|      0|            RAWLOG(3, ": " __VA_ARGS__);                                           \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  153|      0|            RAWLOG(3, "\n");                                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  154|      0|            return err_code;                                                       \
  |  |  155|      0|        }                                                                          \
  |  |  156|      4|    } while(0)
  |  |  ------------------
  |  |  |  Branch (156:13): [Folded, False: 4]
  |  |  ------------------
  ------------------
 1651|      4|    if (dict && dictSize)
  ------------------
  |  Branch (1651:9): [True: 0, False: 4]
  |  Branch (1651:17): [True: 0, False: 0]
  ------------------
 1652|      0|        RETURN_ERROR_IF(
  ------------------
  |  |  114|      0|    do {                                                                       \
  |  |  115|      0|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1653|      4|            ZSTD_isError(ZSTD_decompress_insertDictionary(dctx, dict, dictSize)),
 1654|      4|            dictionary_corrupted, "");
 1655|      4|#if ZSTD_TRACE
 1656|      4|    dctx->traceDictSize = dict ? dictSize : 0;
  ------------------
  |  Branch (1656:27): [True: 0, False: 4]
  ------------------
 1657|      4|#endif
 1658|      4|    return 0;
 1659|      4|}
ZSTD_decompressBegin_usingDDict:
 1665|      6|{
 1666|      6|    DEBUGLOG(4, "ZSTD_decompressBegin_usingDDict");
  ------------------
  |  |  104|      6|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 6]
  |  |  ------------------
  ------------------
 1667|      6|    assert(dctx != NULL);
  ------------------
  |  |   70|      6|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1668|      6|    if (ddict) {
  ------------------
  |  Branch (1668:9): [True: 6, False: 0]
  ------------------
 1669|      6|        const char* const dictStart = (const char*)ZSTD_DDict_dictContent(ddict);
 1670|      6|        size_t const dictSize = ZSTD_DDict_dictSize(ddict);
 1671|       |        /* An empty DDict may have NULL content. */
 1672|      6|        const void* const dictEnd = dictSize != 0 ? dictStart + dictSize : dictStart;
  ------------------
  |  Branch (1672:37): [True: 6, False: 0]
  ------------------
 1673|      6|        dctx->ddictIsCold = (dctx->dictEnd != dictEnd);
 1674|      6|        DEBUGLOG(4, "DDict is %s",
  ------------------
  |  |  104|      6|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 6]
  |  |  ------------------
  ------------------
 1675|      6|                    dctx->ddictIsCold ? "~cold~" : "hot!");
 1676|      6|    }
 1677|      6|    FORWARD_IF_ERROR( ZSTD_decompressBegin(dctx) , "");
  ------------------
  |  |  146|      6|    do {                                                                           \
  |  |  147|      6|        size_t const err_code = (err);                                             \
  |  |  148|      6|        if (ERR_isError(err_code)) {                                               \
  |  |  ------------------
  |  |  |  Branch (148:13): [True: 0, False: 6]
  |  |  ------------------
  |  |  149|      0|            RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s",                 \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|      0|                  __FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
  |  |  151|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                                 \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  152|      0|            RAWLOG(3, ": " __VA_ARGS__);                                           \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  153|      0|            RAWLOG(3, "\n");                                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  154|      0|            return err_code;                                                       \
  |  |  155|      0|        }                                                                          \
  |  |  156|      6|    } while(0)
  |  |  ------------------
  |  |  |  Branch (156:13): [Folded, False: 6]
  |  |  ------------------
  ------------------
 1678|      6|    if (ddict) {   /* NULL ddict is equivalent to no dictionary */
  ------------------
  |  Branch (1678:9): [True: 6, False: 0]
  ------------------
 1679|      6|        ZSTD_copyDDictParameters(dctx, ddict);
 1680|      6|#if ZSTD_TRACE
 1681|      6|        dctx->traceDictSize = ZSTD_DDict_dictSize(ddict);
 1682|      6|#endif
 1683|      6|    }
 1684|      6|    return 0;
 1685|      6|}
ZSTD_decompress_usingDDict:
 1727|      7|{
 1728|      7|    ZSTD_DCtx_resetSession(dctx);
 1729|      7|    return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize,
 1730|       |                                     NULL, 0,
 1731|      7|                                     ddict, 0);
 1732|      7|}
zstd_decompress.c:ZSTD_initDCtx_internal:
  249|     11|{
  250|     11|    dctx->customMem   = customMem;
  251|     11|    dctx->staticSize  = 0;
  252|     11|    dctx->ddict       = NULL;
  253|     11|    dctx->ddictLocal  = NULL;
  254|     11|    dctx->dictEnd     = NULL;
  255|     11|    dctx->ddictIsCold = 0;
  256|     11|    dctx->dictUses = ZSTD_dont_use;
  257|     11|    dctx->inBuff      = NULL;
  258|     11|    dctx->inBuffSize  = 0;
  259|     11|    dctx->outBuffSize = 0;
  260|     11|    dctx->streamStage = zdss_init;
  261|     11|    dctx->stage       = ZSTDds_getFrameHeaderSize;
  262|     11|    dctx->expected    = 0;   /* ZSTD_decompressContinue() requires ZSTD_decompressBegin() first */
  263|       |#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
  264|       |    dctx->legacyContext = NULL;
  265|       |    dctx->previousLegacyVersion = 0;
  266|       |#endif
  267|     11|    dctx->noForwardProgress = 0;
  268|     11|    dctx->oversizedDuration = 0;
  269|     11|    dctx->isFrameDecompression = 1;
  270|     11|#if DYNAMIC_BMI2
  271|     11|    ZSTD_SET_BMI2(dctx->bmi2, ZSTD_cpuSupportsBmi2());
  ------------------
  |  |   37|     11|#  define ZSTD_SET_BMI2(state, value) do { (state) = (value); } while (0)
  |  |  ------------------
  |  |  |  Branch (37:72): [Folded, False: 11]
  |  |  ------------------
  ------------------
  272|     11|#endif
  273|     11|    dctx->ddictSet = NULL;
  274|     11|    ZSTD_DCtx_resetParameters(dctx);
  275|     11|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  276|       |    dctx->dictContentEndForFuzzing = NULL;
  277|     11|#endif
  278|     11|}
zstd_decompress.c:ZSTD_createDCtx_internal:
  293|     11|static ZSTD_DCtx* ZSTD_createDCtx_internal(ZSTD_customMem customMem) {
  294|     11|    if ((!customMem.customAlloc) ^ (!customMem.customFree)) return NULL;
  ------------------
  |  Branch (294:9): [True: 0, False: 11]
  ------------------
  295|       |
  296|     11|    {   ZSTD_DCtx* const dctx = (ZSTD_DCtx*)ZSTD_customMalloc(sizeof(*dctx), customMem);
  297|     11|        if (!dctx) return NULL;
  ------------------
  |  Branch (297:13): [True: 0, False: 11]
  ------------------
  298|     11|        ZSTD_initDCtx_internal(dctx, customMem);
  299|     11|        return dctx;
  300|     11|    }
  301|     11|}
zstd_decompress.c:ZSTD_clearDict:
  315|     15|{
  316|     15|    ZSTD_freeDDict(dctx->ddictLocal);
  317|     15|    dctx->ddictLocal = NULL;
  318|       |    dctx->ddict = NULL;
  319|     15|    dctx->dictUses = ZSTD_dont_use;
  320|     15|}
zstd_decompress.c:ZSTD_clearDDictSet:
  340|     11|{
  341|     11|    if (dctx->ddictSet != NULL) {
  ------------------
  |  Branch (341:9): [True: 0, False: 11]
  ------------------
  342|      0|        assert(!dctx->staticSize);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
  343|      0|        ZSTD_freeDDictHashSet(dctx->ddictSet, dctx->customMem);
  344|       |        dctx->ddictSet = NULL;
  345|      0|    }
  346|     11|}
zstd_decompress.c:ZSTD_frameHeaderSize_internal:
  432|      9|{
  433|      9|    size_t const minInputSize = ZSTD_startingInputLength(format);
  434|      9|    RETURN_ERROR_IF(srcSize < minInputSize, srcSize_wrong, "");
  ------------------
  |  |  114|      9|    do {                                                                       \
  |  |  115|      9|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 9]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      9|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 9]
  |  |  ------------------
  ------------------
  435|       |
  436|      9|    {   BYTE const fhd = ((const BYTE*)src)[minInputSize-1];
  437|      9|        U32 const dictID= fhd & 3;
  438|      9|        U32 const singleSegment = (fhd >> 5) & 1;
  439|      9|        U32 const fcsId = fhd >> 6;
  440|      9|        return minInputSize + !singleSegment
  441|      9|             + ZSTD_did_fieldSize[dictID] + ZSTD_fcs_fieldSize[fcsId]
  442|      9|             + (singleSegment && !fcsId);
  ------------------
  |  Branch (442:17): [True: 7, False: 2]
  |  Branch (442:34): [True: 0, False: 7]
  ------------------
  443|      9|    }
  444|      9|}
zstd_decompress.c:ZSTD_startingInputLength:
  229|     39|{
  230|     39|    size_t const startingInputLength = ZSTD_FRAMEHEADERSIZE_PREFIX(format);
  ------------------
  |  | 1357|     39|#define ZSTD_FRAMEHEADERSIZE_PREFIX(format) ((format) == ZSTD_f_zstd1 ? 5 : 1)   /* minimum input size required to query frame header size */
  |  |  ------------------
  |  |  |  Branch (1357:46): [True: 39, False: 0]
  |  |  ------------------
  ------------------
  231|       |    /* only supports formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless */
  232|     39|    assert( (format == ZSTD_f_zstd1) || (format == ZSTD_f_zstd1_magicless) );
  ------------------
  |  |   70|     39|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
  233|     39|    return startingInputLength;
  234|     39|}
zstd_decompress.c:ZSTD_DCtx_resetSession:
  328|     11|{
  329|       |    /* A prefix is only used once : if a frame was started, it is abandoned now,
  330|       |     * so the prefix must not leak into the next frame */
  331|     11|    if (dctx->streamStage != zdss_init && dctx->dictUses == ZSTD_use_once)
  ------------------
  |  Branch (331:9): [True: 0, False: 11]
  |  Branch (331:43): [True: 0, False: 0]
  ------------------
  332|      0|        ZSTD_clearDict(dctx);
  333|     11|    dctx->streamStage = zdss_init;
  334|     11|    dctx->noForwardProgress = 0;
  335|     11|    dctx->isFrameDecompression = 1;
  336|     11|}
zstd_decompress.c:ZSTD_decompressMultiFrame:
 1093|     11|{
 1094|     11|    void* const dststart = dst;
 1095|     11|    int moreThan1Frame = 0;
 1096|       |
 1097|     11|    DEBUGLOG(5, "ZSTD_decompressMultiFrame");
  ------------------
  |  |  104|     11|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 11]
  |  |  ------------------
  ------------------
 1098|     11|    assert(dict==NULL || ddict==NULL);  /* either dict or ddict set, not both */
  ------------------
  |  |   70|     11|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1099|       |
 1100|     11|    assert(!useDDictSet || (dctx->refMultipleDDicts && dctx->ddictSet
  ------------------
  |  |   70|     11|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1101|     11|                           && dctx->ddictLocal == NULL && dctx->ddict == NULL
 1102|     11|                           && dict == NULL && ddict == NULL));
 1103|       |
 1104|     11|    while (srcSize >= ZSTD_startingInputLength(dctx->format)) {
  ------------------
  |  Branch (1104:12): [True: 10, False: 1]
  ------------------
 1105|     10|        const ZSTD_DDict* frameDDict = ddict;
 1106|       |
 1107|       |#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
 1108|       |        if (dctx->format == ZSTD_f_zstd1 && ZSTD_isLegacy(src, srcSize)) {
 1109|       |            size_t decodedSize;
 1110|       |            const void* const legacyDict = ddict ? ZSTD_DDict_dictContent(ddict) : dict;
 1111|       |            size_t const legacyDictSize = ddict ? ZSTD_DDict_dictSize(ddict) : dictSize;
 1112|       |            size_t frameSize;
 1113|       |            RETURN_ERROR_IF(useDDictSet, parameter_unsupported,
 1114|       |                            "DDict-set selection is not supported for legacy frames");
 1115|       |            frameSize = ZSTD_findFrameCompressedSizeLegacy(src, srcSize);
 1116|       |            if (ZSTD_isError(frameSize)) return frameSize;
 1117|       |            RETURN_ERROR_IF(dctx->staticSize, memory_allocation,
 1118|       |                "legacy support is not compatible with static dctx");
 1119|       |
 1120|       |            decodedSize = ZSTD_decompressLegacy(dst, dstCapacity, src, frameSize, legacyDict, legacyDictSize);
 1121|       |            if (ZSTD_isError(decodedSize)) return decodedSize;
 1122|       |
 1123|       |            {
 1124|       |                unsigned long long const expectedSize = ZSTD_getFrameContentSize(src, srcSize);
 1125|       |                RETURN_ERROR_IF(expectedSize == ZSTD_CONTENTSIZE_ERROR, corruption_detected, "Corrupted frame header!");
 1126|       |                if (expectedSize != ZSTD_CONTENTSIZE_UNKNOWN) {
 1127|       |                    RETURN_ERROR_IF(expectedSize != decodedSize, corruption_detected,
 1128|       |                        "Frame header size does not match decoded size!");
 1129|       |                }
 1130|       |            }
 1131|       |
 1132|       |            assert(decodedSize <= dstCapacity);
 1133|       |            dst = (BYTE*)dst + decodedSize;
 1134|       |            dstCapacity -= decodedSize;
 1135|       |
 1136|       |            src = (const BYTE*)src + frameSize;
 1137|       |            srcSize -= frameSize;
 1138|       |
 1139|       |            continue;
 1140|       |        }
 1141|       |#endif
 1142|       |
 1143|     10|        if (dctx->format == ZSTD_f_zstd1 && srcSize >= 4) {
  ------------------
  |  Branch (1143:13): [True: 10, False: 0]
  |  Branch (1143:45): [True: 10, False: 0]
  ------------------
 1144|     10|            U32 const magicNumber = MEM_readLE32(src);
 1145|     10|            DEBUGLOG(5, "reading magic number %08X", (unsigned)magicNumber);
  ------------------
  |  |  104|     10|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 10]
  |  |  ------------------
  ------------------
 1146|     10|            if ((magicNumber & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
  ------------------
  |  |  145|     10|#define ZSTD_MAGIC_SKIPPABLE_MASK   0xFFFFFFF0
  ------------------
                          if ((magicNumber & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
  ------------------
  |  |  144|     10|#define ZSTD_MAGIC_SKIPPABLE_START  0x184D2A50    /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */
  ------------------
  |  Branch (1146:17): [True: 0, False: 10]
  ------------------
 1147|       |                /* skippable frame detected : skip it */
 1148|      0|                size_t const skippableSize = readSkippableFrameSize(src, srcSize);
 1149|      0|                FORWARD_IF_ERROR(skippableSize, "invalid skippable frame");
  ------------------
  |  |  146|      0|    do {                                                                           \
  |  |  147|      0|        size_t const err_code = (err);                                             \
  |  |  148|      0|        if (ERR_isError(err_code)) {                                               \
  |  |  ------------------
  |  |  |  Branch (148:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  149|      0|            RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s",                 \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|      0|                  __FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
  |  |  151|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                                 \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  152|      0|            RAWLOG(3, ": " __VA_ARGS__);                                           \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  153|      0|            RAWLOG(3, "\n");                                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  154|      0|            return err_code;                                                       \
  |  |  155|      0|        }                                                                          \
  |  |  156|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (156:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1150|      0|                assert(skippableSize <= srcSize);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1151|       |
 1152|      0|                src = (const BYTE *)src + skippableSize;
 1153|      0|                srcSize -= skippableSize;
 1154|      0|                continue; /* check next frame */
 1155|      0|        }   }
 1156|       |
 1157|     10|        if (useDDictSet) {
  ------------------
  |  Branch (1157:13): [True: 0, False: 10]
  ------------------
 1158|      0|            ZSTD_FrameHeader zfh;
 1159|      0|            size_t const hSize = ZSTD_getFrameHeader_advanced(&zfh, src, srcSize, dctx->format);
 1160|       |            /* Invalid/incomplete headers must not change dictionary selection.
 1161|       |             * ZSTD_decompressFrame() will report the header error. */
 1162|      0|            if (hSize == 0 && zfh.frameType == ZSTD_frame)
  ------------------
  |  Branch (1162:17): [True: 0, False: 0]
  |  Branch (1162:31): [True: 0, False: 0]
  ------------------
 1163|      0|                FORWARD_IF_ERROR(ZSTD_DCtx_getFrameDDict(dctx, zfh.dictID, &frameDDict), "");
  ------------------
  |  |  146|      0|    do {                                                                           \
  |  |  147|      0|        size_t const err_code = (err);                                             \
  |  |  148|      0|        if (ERR_isError(err_code)) {                                               \
  |  |  ------------------
  |  |  |  Branch (148:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  149|      0|            RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s",                 \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|      0|                  __FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
  |  |  151|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                                 \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  152|      0|            RAWLOG(3, ": " __VA_ARGS__);                                           \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  153|      0|            RAWLOG(3, "\n");                                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  154|      0|            return err_code;                                                       \
  |  |  155|      0|        }                                                                          \
  |  |  156|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (156:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1164|      0|        }
 1165|     10|        if (frameDDict) {
  ------------------
  |  Branch (1165:13): [True: 6, False: 4]
  ------------------
 1166|       |            /* Use either the explicit DDict or the one selected from the set. */
 1167|      6|            FORWARD_IF_ERROR(ZSTD_decompressBegin_usingDDict(dctx, frameDDict), "");
  ------------------
  |  |  146|      6|    do {                                                                           \
  |  |  147|      6|        size_t const err_code = (err);                                             \
  |  |  148|      6|        if (ERR_isError(err_code)) {                                               \
  |  |  ------------------
  |  |  |  Branch (148:13): [True: 0, False: 6]
  |  |  ------------------
  |  |  149|      0|            RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s",                 \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|      0|                  __FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
  |  |  151|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                                 \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  152|      0|            RAWLOG(3, ": " __VA_ARGS__);                                           \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  153|      0|            RAWLOG(3, "\n");                                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  154|      0|            return err_code;                                                       \
  |  |  155|      0|        }                                                                          \
  |  |  156|      6|    } while(0)
  |  |  ------------------
  |  |  |  Branch (156:13): [Folded, False: 6]
  |  |  ------------------
  ------------------
 1168|      6|        } else {
 1169|       |            /* this will initialize correctly with no dict if dict == NULL, so
 1170|       |             * use this in all cases but ddict */
 1171|      4|            FORWARD_IF_ERROR(ZSTD_decompressBegin_usingDict(dctx, dict, dictSize), "");
  ------------------
  |  |  146|      4|    do {                                                                           \
  |  |  147|      4|        size_t const err_code = (err);                                             \
  |  |  148|      4|        if (ERR_isError(err_code)) {                                               \
  |  |  ------------------
  |  |  |  Branch (148:13): [True: 0, False: 4]
  |  |  ------------------
  |  |  149|      0|            RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s",                 \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|      0|                  __FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
  |  |  151|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                                 \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  152|      0|            RAWLOG(3, ": " __VA_ARGS__);                                           \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  153|      0|            RAWLOG(3, "\n");                                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  154|      0|            return err_code;                                                       \
  |  |  155|      0|        }                                                                          \
  |  |  156|      4|    } while(0)
  |  |  ------------------
  |  |  |  Branch (156:13): [Folded, False: 4]
  |  |  ------------------
  ------------------
 1172|      4|        }
 1173|     10|        ZSTD_checkContinuity(dctx, dst, dstCapacity);
 1174|       |
 1175|     10|        {   const size_t res = ZSTD_decompressFrame(dctx, dst, dstCapacity,
 1176|     10|                                                    &src, &srcSize);
 1177|     10|            RETURN_ERROR_IF(
  ------------------
  |  |  114|     10|    do {                                                                       \
  |  |  115|     29|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 9, False: 1]
  |  |  |  Branch (115:13): [True: 0, False: 9]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|     10|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 10]
  |  |  ------------------
  ------------------
 1178|     10|                (ZSTD_getErrorCode(res) == ZSTD_error_prefix_unknown)
 1179|     10|             && (moreThan1Frame==1),
 1180|     10|                srcSize_wrong,
 1181|     10|                "At least one frame successfully completed, "
 1182|     10|                "but following bytes are garbage: "
 1183|     10|                "it's more likely to be a srcSize error, "
 1184|     10|                "specifying more input bytes than size of frame(s). "
 1185|     10|                "Note: one could be unlucky, it might be a corruption error instead, "
 1186|     10|                "happening right at the place where we expect zstd magic bytes. "
 1187|     10|                "But this is _much_ less likely than a srcSize field error.");
 1188|     10|            if (ZSTD_isError(res)) return res;
  ------------------
  |  |   44|     10|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (1188:17): [True: 10, False: 0]
  ------------------
 1189|      0|            assert(res <= dstCapacity);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1190|      0|            if (res != 0)
  ------------------
  |  Branch (1190:17): [True: 0, False: 0]
  ------------------
 1191|      0|                dst = (BYTE*)dst + res;
 1192|      0|            dstCapacity -= res;
 1193|      0|        }
 1194|      0|        moreThan1Frame = 1;
 1195|      0|    }  /* while (srcSize >= ZSTD_frameHeaderSize_prefix) */
 1196|       |
 1197|      1|    RETURN_ERROR_IF(srcSize, srcSize_wrong, "input not entirely consumed");
  ------------------
  |  |  114|      1|    do {                                                                       \
  |  |  115|      1|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 1, False: 0]
  |  |  ------------------
  |  |  116|      1|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      1|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      1|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      1|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      1|    do {                                           \
  |  |  |  |   99|      1|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      1|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      1|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      1|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      1|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      1|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      1|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      1|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      1|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      1|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      1|        }                                                                      \
  |  |  123|      1|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1198|       |
 1199|      0|    return (size_t)((BYTE*)dst - (BYTE*)dststart);
 1200|      1|}
zstd_decompress.c:ZSTD_decompressFrame:
  972|     10|{
  973|     10|    const BYTE* const istart = (const BYTE*)(*srcPtr);
  974|     10|    const BYTE* ip = istart;
  975|     10|    BYTE* const ostart = (BYTE*)dst;
  976|     10|    BYTE* const oend = dstCapacity != 0 ? ostart + dstCapacity : ostart;
  ------------------
  |  Branch (976:24): [True: 10, False: 0]
  ------------------
  977|     10|    BYTE* op = ostart;
  978|     10|    size_t remainingSrcSize = *srcSizePtr;
  979|       |
  980|     10|    DEBUGLOG(4, "ZSTD_decompressFrame (srcSize:%i)", (int)*srcSizePtr);
  ------------------
  |  |  104|     10|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 10]
  |  |  ------------------
  ------------------
  981|       |
  982|       |    /* check */
  983|     10|    RETURN_ERROR_IF(
  ------------------
  |  |  114|     10|    do {                                                                       \
  |  |  115|     30|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 10, False: 0]
  |  |  |  Branch (115:13): [True: 1, False: 9]
  |  |  ------------------
  |  |  116|      1|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      1|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      1|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      1|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      1|    do {                                           \
  |  |  |  |   99|      1|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      1|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      1|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      1|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      1|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      1|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      1|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      1|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      1|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      1|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      1|        }                                                                      \
  |  |  123|     10|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 9]
  |  |  ------------------
  ------------------
  984|     10|        remainingSrcSize < ZSTD_FRAMEHEADERSIZE_MIN(dctx->format)+ZSTD_blockHeaderSize,
  985|     10|        srcSize_wrong, "");
  986|       |
  987|       |    /* Frame Header */
  988|      9|    {   size_t const frameHeaderSize = ZSTD_frameHeaderSize_internal(
  989|      9|                ip, ZSTD_FRAMEHEADERSIZE_PREFIX(dctx->format), dctx->format);
  ------------------
  |  | 1357|      9|#define ZSTD_FRAMEHEADERSIZE_PREFIX(format) ((format) == ZSTD_f_zstd1 ? 5 : 1)   /* minimum input size required to query frame header size */
  |  |  ------------------
  |  |  |  Branch (1357:46): [True: 9, False: 0]
  |  |  ------------------
  ------------------
  990|      9|        if (ZSTD_isError(frameHeaderSize)) return frameHeaderSize;
  ------------------
  |  |   44|      9|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (990:13): [True: 0, False: 9]
  ------------------
  991|      9|        RETURN_ERROR_IF(remainingSrcSize < frameHeaderSize+ZSTD_blockHeaderSize,
  ------------------
  |  |  114|      9|    do {                                                                       \
  |  |  115|      9|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 9]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      9|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 9]
  |  |  ------------------
  ------------------
  992|      9|                        srcSize_wrong, "");
  993|      9|        FORWARD_IF_ERROR( ZSTD_decodeFrameHeader(dctx, ip, frameHeaderSize) , "");
  ------------------
  |  |  146|      9|    do {                                                                           \
  |  |  147|      9|        size_t const err_code = (err);                                             \
  |  |  148|      9|        if (ERR_isError(err_code)) {                                               \
  |  |  ------------------
  |  |  |  Branch (148:13): [True: 9, False: 0]
  |  |  ------------------
  |  |  149|      9|            RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s",                 \
  |  |  ------------------
  |  |  |  |  103|      9|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|      9|                  __FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
  |  |  151|      9|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                                 \
  |  |  ------------------
  |  |  |  |   98|      9|    do {                                           \
  |  |  |  |   99|      9|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      9|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  152|      9|            RAWLOG(3, ": " __VA_ARGS__);                                           \
  |  |  ------------------
  |  |  |  |  103|      9|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  153|      9|            RAWLOG(3, "\n");                                                       \
  |  |  ------------------
  |  |  |  |  103|      9|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  154|      9|            return err_code;                                                       \
  |  |  155|      9|        }                                                                          \
  |  |  156|      9|    } while(0)
  |  |  ------------------
  |  |  |  Branch (156:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  994|      0|        ip += frameHeaderSize; remainingSrcSize -= frameHeaderSize;
  995|      0|    }
  996|       |
  997|       |    /* Shrink the blockSizeMax if enabled */
  998|      0|    if (dctx->maxBlockSizeParam != 0)
  ------------------
  |  Branch (998:9): [True: 0, False: 0]
  ------------------
  999|      0|        dctx->fParams.blockSizeMax = MIN(dctx->fParams.blockSizeMax, (unsigned)dctx->maxBlockSizeParam);
  ------------------
  |  |   54|      0|#define MIN(a,b) ((a)<(b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (54:19): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1000|       |
 1001|       |    /* Loop on each block */
 1002|      0|    while (1) {
  ------------------
  |  Branch (1002:12): [True: 0, Folded]
  ------------------
 1003|      0|        BYTE* oBlockEnd = oend;
 1004|      0|        size_t decodedSize;
 1005|      0|        blockProperties_t blockProperties;
 1006|      0|        size_t const cBlockSize = ZSTD_getcBlockSize(ip, remainingSrcSize, &blockProperties);
 1007|      0|        if (ZSTD_isError(cBlockSize)) return cBlockSize;
  ------------------
  |  |   44|      0|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (1007:13): [True: 0, False: 0]
  ------------------
 1008|       |
 1009|      0|        ip += ZSTD_blockHeaderSize;
 1010|      0|        remainingSrcSize -= ZSTD_blockHeaderSize;
 1011|      0|        RETURN_ERROR_IF(cBlockSize > remainingSrcSize, srcSize_wrong, "");
  ------------------
  |  |  114|      0|    do {                                                                       \
  |  |  115|      0|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1012|       |
 1013|      0|        if (ip >= op && ip < oBlockEnd) {
  ------------------
  |  Branch (1013:13): [True: 0, False: 0]
  |  Branch (1013:25): [True: 0, False: 0]
  ------------------
 1014|       |            /* We are decompressing in-place. Limit the output pointer so that we
 1015|       |             * don't overwrite the block that we are currently reading. This will
 1016|       |             * fail decompression if the input & output pointers aren't spaced
 1017|       |             * far enough apart.
 1018|       |             *
 1019|       |             * This is important to set, even when the pointers are far enough
 1020|       |             * apart, because ZSTD_decompressBlock_internal() can decide to store
 1021|       |             * literals in the output buffer, after the block it is decompressing.
 1022|       |             * Since we don't want anything to overwrite our input, we have to tell
 1023|       |             * ZSTD_decompressBlock_internal to never write past ip.
 1024|       |             *
 1025|       |             * See ZSTD_allocateLiteralsBuffer() for reference.
 1026|       |             */
 1027|      0|            oBlockEnd = op + (ip - op);
 1028|      0|        }
 1029|       |
 1030|      0|        switch(blockProperties.blockType)
 1031|      0|        {
 1032|      0|        case bt_compressed:
  ------------------
  |  Branch (1032:9): [True: 0, False: 0]
  ------------------
 1033|      0|            assert(dctx->isFrameDecompression == 1);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1034|      0|            decodedSize = ZSTD_decompressBlock_internal(dctx, op, (size_t)(oBlockEnd-op), ip, cBlockSize, not_streaming);
 1035|      0|            break;
 1036|      0|        case bt_raw :
  ------------------
  |  Branch (1036:9): [True: 0, False: 0]
  ------------------
 1037|       |            /* Use oend instead of oBlockEnd because this function is safe to overlap. It uses memmove. */
 1038|      0|            decodedSize = ZSTD_copyRawBlock(op, (size_t)(oend-op), ip, cBlockSize);
 1039|      0|            break;
 1040|      0|        case bt_rle :
  ------------------
  |  Branch (1040:9): [True: 0, False: 0]
  ------------------
 1041|      0|            decodedSize = ZSTD_setRleBlock(op, (size_t)(oBlockEnd-op), *ip, blockProperties.origSize);
 1042|      0|            break;
 1043|      0|        case bt_reserved :
  ------------------
  |  Branch (1043:9): [True: 0, False: 0]
  ------------------
 1044|      0|        default:
  ------------------
  |  Branch (1044:9): [True: 0, False: 0]
  ------------------
 1045|      0|            RETURN_ERROR(corruption_detected, "invalid block type");
  ------------------
  |  |  131|      0|    do {                                                                     \
  |  |  132|      0|        RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  133|      0|              __FILE__, __LINE__, ERR_QUOTE(ERROR(err)));                    \
  |  |  134|      0|        _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                               \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  135|      0|        RAWLOG(3, ": " __VA_ARGS__);                                         \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  136|      0|        RAWLOG(3, "\n");                                                     \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  137|      0|        return ERROR(err);                                                   \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  138|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (138:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1046|      0|        }
 1047|      0|        FORWARD_IF_ERROR(decodedSize, "Block decompression failure");
  ------------------
  |  |  146|      0|    do {                                                                           \
  |  |  147|      0|        size_t const err_code = (err);                                             \
  |  |  148|      0|        if (ERR_isError(err_code)) {                                               \
  |  |  ------------------
  |  |  |  Branch (148:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  149|      0|            RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s",                 \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|      0|                  __FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
  |  |  151|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                                 \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  152|      0|            RAWLOG(3, ": " __VA_ARGS__);                                           \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  153|      0|            RAWLOG(3, "\n");                                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  154|      0|            return err_code;                                                       \
  |  |  155|      0|        }                                                                          \
  |  |  156|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (156:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1048|      0|        RETURN_ERROR_IF(decodedSize > dctx->fParams.blockSizeMax, corruption_detected, "Decompressed Block Size Exceeds Maximum");
  ------------------
  |  |  114|      0|    do {                                                                       \
  |  |  115|      0|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1049|      0|        DEBUGLOG(5, "Decompressed block of dSize = %u", (unsigned)decodedSize);
  ------------------
  |  |  104|      0|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1050|      0|        if (dctx->validateChecksum) {
  ------------------
  |  Branch (1050:13): [True: 0, False: 0]
  ------------------
 1051|      0|            XXH64_update(&dctx->xxhState, op, decodedSize);
  ------------------
  |  |  460|      0|#  define XXH64_update XXH_NAME2(XXH_NAMESPACE, XXH64_update)
  |  |  ------------------
  |  |  |  |  443|      0|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  442|      0|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1052|      0|        }
 1053|      0|        if (decodedSize) /* support dst = NULL,0 */ {
  ------------------
  |  Branch (1053:13): [True: 0, False: 0]
  ------------------
 1054|      0|            op += decodedSize;
 1055|      0|        }
 1056|      0|        assert(ip != NULL);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1057|      0|        ip += cBlockSize;
 1058|      0|        remainingSrcSize -= cBlockSize;
 1059|      0|        if (blockProperties.lastBlock) break;
  ------------------
  |  Branch (1059:13): [True: 0, False: 0]
  ------------------
 1060|      0|    }
 1061|       |
 1062|      0|    if (dctx->fParams.frameContentSize != ZSTD_CONTENTSIZE_UNKNOWN) {
  ------------------
  |  |  203|      0|#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
  ------------------
  |  Branch (1062:9): [True: 0, False: 0]
  ------------------
 1063|      0|        RETURN_ERROR_IF((U64)(op-ostart) != dctx->fParams.frameContentSize,
  ------------------
  |  |  114|      0|    do {                                                                       \
  |  |  115|      0|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1064|      0|                        corruption_detected, "");
 1065|      0|    }
 1066|      0|    if (dctx->fParams.checksumFlag) { /* Frame content checksum verification */
  ------------------
  |  Branch (1066:9): [True: 0, False: 0]
  ------------------
 1067|      0|        RETURN_ERROR_IF(remainingSrcSize<4, checksum_wrong, "");
  ------------------
  |  |  114|      0|    do {                                                                       \
  |  |  115|      0|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1068|      0|        if (!dctx->forceIgnoreChecksum) {
  ------------------
  |  Branch (1068:13): [True: 0, False: 0]
  ------------------
 1069|      0|            U32 const checkCalc = (U32)XXH64_digest(&dctx->xxhState);
  ------------------
  |  |  461|      0|#  define XXH64_digest XXH_NAME2(XXH_NAMESPACE, XXH64_digest)
  |  |  ------------------
  |  |  |  |  443|      0|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  442|      0|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1070|      0|            U32 checkRead;
 1071|      0|            checkRead = MEM_readLE32(ip);
 1072|      0|            RETURN_ERROR_IF(checkRead != checkCalc, checksum_wrong, "");
  ------------------
  |  |  114|      0|    do {                                                                       \
  |  |  115|      0|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1073|      0|        }
 1074|      0|        ip += 4;
 1075|      0|        remainingSrcSize -= 4;
 1076|      0|    }
 1077|      0|    ZSTD_DCtx_trace_end(dctx, (U64)(op-ostart), (U64)(ip-istart), /* streaming */ 0);
 1078|       |    /* Allow caller to get size read */
 1079|      0|    DEBUGLOG(4, "ZSTD_decompressFrame: decompressed frame of size %i, consuming %i bytes of input", (int)(op-ostart), (int)(ip - (const BYTE*)*srcPtr));
  ------------------
  |  |  104|      0|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1080|      0|    *srcPtr = ip;
 1081|      0|    *srcSizePtr = remainingSrcSize;
 1082|      0|    return (size_t)(op-ostart);
 1083|      0|}
zstd_decompress.c:ZSTD_getDDict:
 1213|      4|{
 1214|      4|    assert(dctx->ddictSet == NULL);
  ------------------
  |  |   70|      4|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1215|      4|    switch (dctx->dictUses) {
 1216|      0|    default:
  ------------------
  |  Branch (1216:5): [True: 0, False: 4]
  ------------------
 1217|      0|        assert(0 /* Impossible */);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1218|      0|        ZSTD_FALLTHROUGH;
  ------------------
  |  |  288|      0|#  define ZSTD_FALLTHROUGH ; __attribute__((__fallthrough__))
  ------------------
 1219|      4|    case ZSTD_dont_use:
  ------------------
  |  Branch (1219:5): [True: 4, False: 0]
  ------------------
 1220|      4|        ZSTD_clearDict(dctx);
 1221|      4|        return NULL;
 1222|      0|    case ZSTD_use_indefinitely:
  ------------------
  |  Branch (1222:5): [True: 0, False: 4]
  ------------------
 1223|      0|        return dctx->ddict;
 1224|      0|    case ZSTD_use_once:
  ------------------
  |  Branch (1224:5): [True: 0, False: 4]
  ------------------
 1225|      0|        dctx->dictUses = ZSTD_dont_use;
 1226|      0|        return dctx->ddict;
 1227|      4|    }
 1228|      4|}
zstd_decompress.c:ZSTD_decodeFrameHeader:
  718|      9|{
  719|      9|    size_t const result = ZSTD_getFrameHeader_advanced(&(dctx->fParams), src, headerSize, dctx->format);
  720|      9|    if (ZSTD_isError(result)) return result;    /* invalid header */
  ------------------
  |  |   44|      9|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (720:9): [True: 9, False: 0]
  ------------------
  721|      0|    RETURN_ERROR_IF(result>0, srcSize_wrong, "headerSize too small");
  ------------------
  |  |  114|      0|    do {                                                                       \
  |  |  115|      0|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|            RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s",          \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  117|      0|                  __FILE__, __LINE__, ERR_QUOTE(cond), ERR_QUOTE(ERROR(err))); \
  |  |  118|      0|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                             \
  |  |  ------------------
  |  |  |  |   98|      0|    do {                                           \
  |  |  |  |   99|      0|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|      0|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  119|      0|            RAWLOG(3, ": " __VA_ARGS__);                                       \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  120|      0|            RAWLOG(3, "\n");                                                   \
  |  |  ------------------
  |  |  |  |  103|      0|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  121|      0|            return ERROR(err);                                                 \
  |  |  ------------------
  |  |  |  |   49|      0|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  122|      0|        }                                                                      \
  |  |  123|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  722|       |
  723|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  724|       |    /* Skip the dictID check in fuzzing mode, because it makes the search
  725|       |     * harder.
  726|       |     */
  727|       |    RETURN_ERROR_IF(dctx->fParams.dictID && (dctx->dictID != dctx->fParams.dictID),
  728|       |                    dictionary_wrong, "");
  729|       |#endif
  730|      0|    dctx->validateChecksum = (dctx->fParams.checksumFlag && !dctx->forceIgnoreChecksum) ? 1 : 0;
  ------------------
  |  Branch (730:31): [True: 0, False: 0]
  |  Branch (730:61): [True: 0, False: 0]
  ------------------
  731|      0|    if (dctx->validateChecksum) XXH64_reset(&dctx->xxhState, 0);
  ------------------
  |  |  459|      0|#  define XXH64_reset XXH_NAME2(XXH_NAMESPACE, XXH64_reset)
  |  |  ------------------
  |  |  |  |  443|      0|#  define XXH_NAME2(A,B) XXH_CAT(A,B)
  |  |  |  |  ------------------
  |  |  |  |  |  |  442|      0|#  define XXH_CAT(A,B) A##B
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (731:9): [True: 0, False: 0]
  ------------------
  732|      0|    return 0;
  733|      0|}
zstd_decompress.c:ZSTD_DCtx_resetParameters:
  237|     11|{
  238|     11|    assert(dctx->streamStage == zdss_init);
  ------------------
  |  |   70|     11|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
  239|     11|    dctx->format = ZSTD_f_zstd1;
  240|     11|    dctx->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT;
  ------------------
  |  |   40|     11|#  define ZSTD_MAXWINDOWSIZE_DEFAULT (((U32)1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT) + 1)
  |  |  ------------------
  |  |  |  | 1387|     11|#define ZSTD_WINDOWLOG_LIMIT_DEFAULT 27   /* by default, the streaming decoder will refuse any frame
  |  |  ------------------
  ------------------
  241|     11|    dctx->outBufferMode = ZSTD_bm_buffered;
  242|     11|    dctx->forceIgnoreChecksum = ZSTD_d_validateChecksum;
  243|     11|    dctx->refMultipleDDicts = ZSTD_rmd_refSingleDDict;
  244|     11|    dctx->disableHufAsm = 0;
  245|     11|    dctx->maxBlockSizeParam = 0;
  246|     11|}

ZSTD_checkContinuity:
 2304|     10|{
 2305|     10|    if (dst != dctx->previousDstEnd && dstSize > 0) {   /* not contiguous */
  ------------------
  |  Branch (2305:9): [True: 10, False: 0]
  |  Branch (2305:40): [True: 10, False: 0]
  ------------------
 2306|     10|        dctx->dictEnd = dctx->previousDstEnd;
 2307|     10|        dctx->virtualStart = (const char*)dst - ((const char*)(dctx->previousDstEnd) - (const char*)(dctx->prefixStart));
 2308|     10|        dctx->prefixStart = dst;
 2309|     10|        dctx->previousDstEnd = dst;
 2310|     10|    }
 2311|       |    /* The external dictionary and current prefix share the frame window.
 2312|       |     * As the prefix grows after a wrap, retaining a full external window
 2313|       |     * could let corrupt offsets alias the destination and expose stale literals.
 2314|       |     * decodedSize > 0 ensures the frame header has initialized windowSize.
 2315|       |     * Only kicks in after decoding windowSize bytes because the entire dictionary is
 2316|       |     * valid as long as a single byte of the dictionary is in the window.
 2317|       |     */
 2318|     10|    if (dstSize > 0 && dctx->isFrameDecompression && dctx->decodedSize > 0 && dctx->decodedSize >= dctx->fParams.windowSize) {
  ------------------
  |  Branch (2318:9): [True: 10, False: 0]
  |  Branch (2318:24): [True: 10, False: 0]
  |  Branch (2318:54): [True: 0, False: 10]
  |  Branch (2318:79): [True: 0, False: 0]
  ------------------
 2319|      0|        size_t const prefixSize = (size_t)((const char*)dctx->previousDstEnd - (const char*)dctx->prefixStart);
 2320|      0|        size_t const extDictSize = (size_t)((const char*)dctx->prefixStart - (const char*)dctx->virtualStart);
 2321|      0|        U64 const maxExtDictSize = prefixSize < dctx->fParams.windowSize ? dctx->fParams.windowSize - prefixSize : 0;
  ------------------
  |  Branch (2321:36): [True: 0, False: 0]
  ------------------
 2322|      0|        dctx->virtualStart = (const char*)dctx->prefixStart - (size_t)MIN((U64)extDictSize, maxExtDictSize);
  ------------------
  |  |   54|      0|#define MIN(a,b) ((a)<(b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (54:19): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2323|      0|    }
 2324|     10|}

b2nd_serialize_meta:
   43|  8.53k|                        uint8_t **smeta) {
   44|  8.53k|  if (dtype == NULL) {
  ------------------
  |  Branch (44:7): [True: 0, False: 8.53k]
  ------------------
   45|      0|    dtype = B2ND_DEFAULT_DTYPE;
  ------------------
  |  |   61|      0|#define B2ND_DEFAULT_DTYPE "|u1"
  ------------------
   46|      0|  }
   47|       |  // dtype checks
   48|  8.53k|  if (dtype_format < 0) {
  ------------------
  |  Branch (48:7): [True: 0, False: 8.53k]
  ------------------
   49|      0|    BLOSC_TRACE_ERROR("dtype_format cannot be negative");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   50|      0|    BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
   51|      0|  }
   52|  8.53k|  size_t dtype_len0 = strlen(dtype);
   53|  8.53k|  if (dtype_len0 > INT32_MAX) {
  ------------------
  |  Branch (53:7): [True: 0, False: 8.53k]
  ------------------
   54|      0|    BLOSC_TRACE_ERROR("dtype is too large (len > %d)", INT32_MAX);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   54|      0|    BLOSC_TRACE_ERROR("dtype is too large (len > %d)", INT32_MAX);
  |  |  |  |  ------------------
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|      0|    BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
   56|      0|  }
   57|  8.53k|  const int32_t dtype_len = (int32_t) dtype_len0;
   58|       |  // Allocate space for b2nd metalayer
   59|  8.53k|  int32_t max_smeta_len = (int32_t) (1 + 1 + 1 + (1 + ndim * (1 + sizeof(int64_t))) +
   60|  8.53k|                                     (1 + ndim * (1 + sizeof(int32_t))) + (1 + ndim * (1 + sizeof(int32_t))) +
   61|  8.53k|                                     1 + 1 + sizeof(int32_t) + dtype_len);
   62|  8.53k|  *smeta = malloc((size_t) max_smeta_len);
   63|  8.53k|  BLOSC_ERROR_NULL(*smeta, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  8.53k|    do {                                            \
  |  |  105|  8.53k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 8.53k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  8.53k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8.53k]
  |  |  ------------------
  ------------------
   64|  8.53k|  uint8_t *pmeta = *smeta;
   65|       |
   66|       |  // Build an array with 7 entries (version, ndim, shape, chunkshape, blockshape, dtype_format, dtype)
   67|  8.53k|  *pmeta++ = 0x90 + 7;
   68|       |
   69|       |  // version entry
   70|  8.53k|  *pmeta++ = B2ND_METALAYER_VERSION;  // positive fixnum (7-bit positive integer)
  ------------------
  |  |   47|  8.53k|#define B2ND_METALAYER_VERSION 0
  ------------------
   71|       |
   72|       |  // ndim entry
   73|  8.53k|  *pmeta++ = (uint8_t) ndim;  // positive fixnum (7-bit positive integer)
   74|       |
   75|       |  // shape entry
   76|  8.53k|  *pmeta++ = (uint8_t) (0x90) + ndim;  // fix array with ndim elements
   77|  38.8k|  for (uint8_t i = 0; i < ndim; i++) {
  ------------------
  |  Branch (77:23): [True: 30.2k, False: 8.53k]
  ------------------
   78|  30.2k|    *pmeta++ = 0xd3;  // int64
   79|  30.2k|    swap_store(pmeta, shape + i, sizeof(int64_t));
   80|  30.2k|    pmeta += sizeof(int64_t);
   81|  30.2k|  }
   82|       |
   83|       |  // chunkshape entry
   84|  8.53k|  *pmeta++ = (uint8_t) (0x90) + ndim;  // fix array with ndim elements
   85|  38.8k|  for (uint8_t i = 0; i < ndim; i++) {
  ------------------
  |  Branch (85:23): [True: 30.2k, False: 8.53k]
  ------------------
   86|  30.2k|    *pmeta++ = 0xd2;  // int32
   87|  30.2k|    swap_store(pmeta, chunkshape + i, sizeof(int32_t));
   88|  30.2k|    pmeta += sizeof(int32_t);
   89|  30.2k|  }
   90|       |
   91|       |  // blockshape entry
   92|  8.53k|  *pmeta++ = (uint8_t) (0x90) + ndim;  // fix array with ndim elements
   93|  38.8k|  for (uint8_t i = 0; i < ndim; i++) {
  ------------------
  |  Branch (93:23): [True: 30.2k, False: 8.53k]
  ------------------
   94|  30.2k|    *pmeta++ = 0xd2;  // int32
   95|  30.2k|    swap_store(pmeta, blockshape + i, sizeof(int32_t));
   96|  30.2k|    pmeta += sizeof(int32_t);
   97|  30.2k|  }
   98|       |
   99|       |  // dtype entry
  100|  8.53k|  *pmeta++ = dtype_format;  // positive fixint (7-bit positive integer)
  101|  8.53k|  *pmeta++ = (uint8_t) (0xdb);  // str with up to 2^31 elements
  102|  8.53k|  swap_store(pmeta, &dtype_len, sizeof(int32_t));
  103|  8.53k|  pmeta += sizeof(int32_t);
  104|  8.53k|  memcpy(pmeta, dtype, dtype_len);
  105|  8.53k|  pmeta += dtype_len;
  106|       |
  107|  8.53k|  int32_t slen = (int32_t) (pmeta - *smeta);
  108|  8.53k|  if (max_smeta_len != slen) {
  ------------------
  |  Branch (108:7): [True: 0, False: 8.53k]
  ------------------
  109|      0|    BLOSC_TRACE_ERROR("meta length is inconsistent!");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  110|      0|    return BLOSC2_ERROR_FAILURE;
  111|      0|  }
  112|       |
  113|  8.53k|  return (int)slen;
  114|  8.53k|}
b2nd_deserialize_meta:
  118|  4.29k|                          int32_t *chunkshape, int32_t *blockshape, char **dtype, int8_t *dtype_format) {
  119|  4.29k|  return b2nd_deserialize_meta_inline(smeta, smeta_len, ndim, shape, chunkshape, blockshape, dtype, dtype_format);
  120|  4.29k|}
update_shape:
  302|  10.0k|                 const int32_t *chunkshape, const int32_t *blockshape) {
  303|  10.0k|  BLOSC_ERROR(update_shape_struct(array, ndim, shape, chunkshape, blockshape));
  ------------------
  |  |  111|  10.0k|    do {                                            \
  |  |  112|  10.0k|        int rc_ = (rc);                             \
  |  |  113|  10.0k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 10.0k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  10.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 10.0k]
  |  |  ------------------
  ------------------
  304|  10.0k|  return publish_shape_meta(array);
  305|  10.0k|}
array_without_schunk:
  380|  8.67k|int array_without_schunk(b2nd_context_t *ctx, b2nd_array_t **array) {
  381|       |  /* Create a b2nd_array_t buffer */
  382|  8.67k|  (*array) = (b2nd_array_t *) malloc(sizeof(b2nd_array_t));
  383|  8.67k|  BLOSC_ERROR_NULL(*array, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  8.67k|    do {                                            \
  |  |  105|  8.67k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 8.67k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  8.67k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8.67k]
  |  |  ------------------
  ------------------
  384|       |
  385|  8.67k|  (*array)->sc = NULL;
  386|  8.67k|  (*array)->last_tick = 0;
  387|       |
  388|  8.67k|  (*array)->ndim = ctx->ndim;
  389|  8.67k|  int64_t *shape = ctx->shape;
  390|  8.67k|  int32_t *chunkshape = ctx->chunkshape;
  391|  8.67k|  int32_t *blockshape = ctx->blockshape;
  392|       |  // update_shape() rejects shapes whose products overflow, so this can fail on
  393|       |  // crafted metadata.  Hand back NULL rather than the half-built array, which
  394|       |  // would otherwise leak and leave callers with a non-NULL pointer on error.
  395|  8.67k|  int rc = update_shape(*array, ctx->ndim, shape, chunkshape, blockshape);
  396|  8.67k|  if (rc < 0) {
  ------------------
  |  Branch (396:7): [True: 0, False: 8.67k]
  ------------------
  397|      0|    free(*array);
  398|      0|    *array = NULL;
  399|      0|    BLOSC_ERROR(rc);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  400|      0|  }
  401|       |
  402|  8.67k|  if (ctx->dtype != NULL) {
  ------------------
  |  Branch (402:7): [True: 8.67k, False: 0]
  ------------------
  403|  8.67k|    (*array)->dtype = malloc(strlen(ctx->dtype) + 1);
  404|  8.67k|    strcpy((*array)->dtype, ctx->dtype);
  405|  8.67k|  } else {
  406|      0|    (*array)->dtype = NULL;
  407|      0|  }
  408|       |
  409|  8.67k|  (*array)->dtype_format = ctx->dtype_format;
  410|       |
  411|       |  // The partition cache (empty initially)
  412|  8.67k|  (*array)->chunk_cache.data = NULL;
  413|  8.67k|  (*array)->chunk_cache.nchunk = -1;  // means no valid cache yet
  414|       |
  415|  8.67k|  return BLOSC2_ERROR_SUCCESS;
  416|  8.67k|}
array_new:
  419|  7.20k|int array_new(b2nd_context_t *ctx, int special_value, b2nd_array_t **array) {
  420|  7.20k|  BLOSC_ERROR(array_without_schunk(ctx, array));
  ------------------
  |  |  111|  7.20k|    do {                                            \
  |  |  112|  7.20k|        int rc_ = (rc);                             \
  |  |  113|  7.20k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 7.20k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  7.20k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 7.20k]
  |  |  ------------------
  ------------------
  421|       |
  422|  7.20k|  int rc = BLOSC2_ERROR_FAILURE;
  423|  7.20k|  blosc2_schunk *sc = blosc2_schunk_new(ctx->b2_storage);
  424|  7.20k|  if (sc == NULL) {
  ------------------
  |  Branch (424:7): [True: 0, False: 7.20k]
  ------------------
  425|      0|    BLOSC_TRACE_ERROR("Pointer is NULL");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  426|      0|    goto failed;
  427|      0|  }
  428|       |  // Freed with the array on failure
  429|  7.20k|  (*array)->sc = sc;
  430|       |  // Set the chunksize for the schunk, as it cannot be derived from storage
  431|  7.20k|  if (sc->typesize <= 0) {
  ------------------
  |  Branch (431:7): [True: 0, False: 7.20k]
  ------------------
  432|      0|    BLOSC_TRACE_ERROR("Invalid chunk parameters");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|      0|    rc = BLOSC2_ERROR_INVALID_PARAM;
  434|      0|    goto failed;
  435|      0|  }
  436|  7.20k|  if ((*array)->extchunknitems < 0) {
  ------------------
  |  Branch (436:7): [True: 0, False: 7.20k]
  ------------------
  437|      0|    BLOSC_TRACE_ERROR("Invalid chunk parameters");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  438|      0|    rc = BLOSC2_ERROR_INVALID_PARAM;
  439|      0|    goto failed;
  440|      0|  }
  441|  7.20k|  if ((uint64_t)(*array)->extchunknitems > (uint64_t)SIZE_MAX) {
  ------------------
  |  Branch (441:7): [True: 0, False: 7.20k]
  ------------------
  442|      0|    BLOSC_TRACE_ERROR("extchunknitems too large");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  443|      0|    rc = BLOSC2_ERROR_INVALID_PARAM;
  444|      0|    goto failed;
  445|      0|  }
  446|  7.20k|  size_t chunkbytes_size = 0;
  447|  7.20k|  if (!blosc2_checked_mul_size((size_t)(*array)->extchunknitems, (size_t)sc->typesize, &chunkbytes_size)) {
  ------------------
  |  Branch (447:7): [True: 0, False: 7.20k]
  ------------------
  448|      0|    BLOSC_TRACE_ERROR("Chunksize overflows size limits");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  449|      0|    rc = BLOSC2_ERROR_INVALID_PARAM;
  450|      0|    goto failed;
  451|      0|  }
  452|  7.20k|  if (chunkbytes_size > BLOSC2_MAX_BUFFERSIZE || chunkbytes_size > INT32_MAX) {
  ------------------
  |  Branch (452:7): [True: 0, False: 7.20k]
  |  Branch (452:50): [True: 0, False: 7.20k]
  ------------------
  453|      0|    BLOSC_TRACE_ERROR("Chunksize exceeds maximum of %d", BLOSC2_MAX_BUFFERSIZE);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  454|      0|    rc = BLOSC2_ERROR_MAX_BUFSIZE_EXCEEDED;
  455|      0|    goto failed;
  456|      0|  }
  457|  7.20k|  int32_t chunksize = (int32_t)chunkbytes_size;
  458|  7.20k|  sc->chunksize = chunksize;
  459|       |
  460|       |  // Serialize the dimension info
  461|  7.20k|  if (sc->nmetalayers >= BLOSC2_MAX_METALAYERS) {
  ------------------
  |  | 1895|  7.20k|#define BLOSC2_MAX_METALAYERS 16
  ------------------
  |  Branch (461:7): [True: 0, False: 7.20k]
  ------------------
  462|      0|    BLOSC_TRACE_ERROR("the number of metalayers for this schunk has been exceeded");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  463|      0|    goto failed;
  464|      0|  }
  465|  7.20k|  uint8_t *smeta = NULL;
  466|  7.20k|  int32_t smeta_len = b2nd_serialize_meta(ctx->ndim,
  467|  7.20k|                                          (*array)->shape,
  468|  7.20k|                                          (*array)->chunkshape,
  469|  7.20k|                                          (*array)->blockshape,
  470|  7.20k|                                          (*array)->dtype,
  471|  7.20k|                                          (*array)->dtype_format,
  472|  7.20k|                                          &smeta);
  473|  7.20k|  if (smeta_len < 0) {
  ------------------
  |  Branch (473:7): [True: 0, False: 7.20k]
  ------------------
  474|      0|    BLOSC_TRACE_ERROR("error during serializing dims info for Blosc2 NDim");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  475|      0|    goto failed;
  476|      0|  }
  477|       |
  478|       |  // And store it in b2nd metalayer
  479|  7.20k|  int meta_rc = blosc2_meta_add(sc, "b2nd", smeta, smeta_len);
  480|  7.20k|  free(smeta);
  481|  7.20k|  if (meta_rc < 0) {
  ------------------
  |  Branch (481:7): [True: 0, False: 7.20k]
  ------------------
  482|      0|    goto failed;
  483|      0|  }
  484|       |
  485|  7.20k|  for (int i = 0; i < ctx->nmetalayers; ++i) {
  ------------------
  |  Branch (485:19): [True: 0, False: 7.20k]
  ------------------
  486|      0|    char *name = ctx->metalayers[i].name;
  487|      0|    uint8_t *data = ctx->metalayers[i].content;
  488|      0|    int32_t size = ctx->metalayers[i].content_len;
  489|      0|    if (blosc2_meta_add(sc, name, data, size) < 0) {
  ------------------
  |  Branch (489:9): [True: 0, False: 0]
  ------------------
  490|      0|      goto failed;
  491|      0|    }
  492|      0|  }
  493|       |
  494|       |  // Fill schunk with uninit values
  495|  7.20k|  if ((*array)->nitems != 0) {
  ------------------
  |  Branch (495:7): [True: 6.08k, False: 1.12k]
  ------------------
  496|  6.08k|    int64_t nchunks = (*array)->extnitems / (*array)->chunknitems;
  497|  6.08k|    int64_t nitems = nchunks * (*array)->extchunknitems;
  498|  6.08k|    if (blosc2_schunk_fill_special(sc, nitems, special_value, chunksize) < 0) {
  ------------------
  |  Branch (498:9): [True: 0, False: 6.08k]
  ------------------
  499|      0|      BLOSC_TRACE_ERROR("Error filling the super-chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  500|      0|      goto failed;
  501|      0|    }
  502|  6.08k|  }
  503|       |
  504|  7.20k|  return BLOSC2_ERROR_SUCCESS;
  505|       |
  506|      0|  failed:
  507|      0|  b2nd_free(*array);
  508|       |  *array = NULL;
  509|      0|  return rc;
  510|  7.20k|}
b2nd_empty:
  523|  2.76k|int b2nd_empty(b2nd_context_t *ctx, b2nd_array_t **array) {
  524|  2.76k|  BLOSC_ERROR_NULL(ctx, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.76k|    do {                                            \
  |  |  105|  2.76k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.76k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  2.76k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.76k]
  |  |  ------------------
  ------------------
  525|  2.76k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.76k|    do {                                            \
  |  |  105|  2.76k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.76k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  2.76k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.76k]
  |  |  ------------------
  ------------------
  526|       |
  527|       |  // Fill with zeros to avoid variable cratios
  528|  2.76k|  BLOSC_ERROR(array_new(ctx, BLOSC2_SPECIAL_ZERO, array));
  ------------------
  |  |  111|  2.76k|    do {                                            \
  |  |  112|  2.76k|        int rc_ = (rc);                             \
  |  |  113|  2.76k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 2.76k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  2.76k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 2.76k]
  |  |  ------------------
  ------------------
  529|       |
  530|  2.76k|  return BLOSC2_ERROR_SUCCESS;
  531|  2.76k|}
b2nd_zeros:
  534|  4.43k|int b2nd_zeros(b2nd_context_t *ctx, b2nd_array_t **array) {
  535|  4.43k|  BLOSC_ERROR_NULL(ctx, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.43k|    do {                                            \
  |  |  105|  4.43k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.43k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.43k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.43k]
  |  |  ------------------
  ------------------
  536|  4.43k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.43k|    do {                                            \
  |  |  105|  4.43k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.43k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.43k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.43k]
  |  |  ------------------
  ------------------
  537|       |
  538|  4.43k|  BLOSC_ERROR(array_new(ctx, BLOSC2_SPECIAL_ZERO, array));
  ------------------
  |  |  111|  4.43k|    do {                                            \
  |  |  112|  4.43k|        int rc_ = (rc);                             \
  |  |  113|  4.43k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 4.43k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  4.43k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 4.43k]
  |  |  ------------------
  ------------------
  539|       |
  540|  4.43k|  return BLOSC2_ERROR_SUCCESS;
  541|  4.43k|}
b2nd_full:
  561|    309|int b2nd_full(b2nd_context_t *ctx, b2nd_array_t **array, const void *fill_value) {
  562|    309|  BLOSC_ERROR_NULL(ctx, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|    309|    do {                                            \
  |  |  105|    309|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 309]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|    309|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 309]
  |  |  ------------------
  ------------------
  563|    309|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|    309|    do {                                            \
  |  |  105|    309|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 309]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|    309|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 309]
  |  |  ------------------
  ------------------
  564|       |
  565|    309|  BLOSC_ERROR(b2nd_empty(ctx, array));
  ------------------
  |  |  111|    309|    do {                                            \
  |  |  112|    309|        int rc_ = (rc);                             \
  |  |  113|    309|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 309]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|    309|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 309]
  |  |  ------------------
  ------------------
  566|       |
  567|    309|  if ((*array)->sc->typesize <= 0) {
  ------------------
  |  Branch (567:7): [True: 0, False: 309]
  ------------------
  568|      0|    BLOSC_TRACE_ERROR("Invalid chunk parameters");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  569|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  570|      0|  }
  571|    309|  if ((*array)->extchunknitems < 0) {
  ------------------
  |  Branch (571:7): [True: 0, False: 309]
  ------------------
  572|      0|    BLOSC_TRACE_ERROR("Invalid chunk parameters");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  573|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  574|      0|  }
  575|    309|  if ((uint64_t)(*array)->extchunknitems > (uint64_t)SIZE_MAX) {
  ------------------
  |  Branch (575:7): [True: 0, False: 309]
  ------------------
  576|      0|    BLOSC_TRACE_ERROR("extchunknitems too large");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  577|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  578|      0|  }
  579|    309|  size_t chunkbytes_size = 0;
  580|    309|  if (!blosc2_checked_mul_size((size_t)(*array)->extchunknitems, (size_t)(*array)->sc->typesize, &chunkbytes_size)) {
  ------------------
  |  Branch (580:7): [True: 0, False: 309]
  ------------------
  581|      0|    BLOSC_TRACE_ERROR("Chunk bytes overflows size limits");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  582|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  583|      0|  }
  584|    309|  if (chunkbytes_size > BLOSC2_MAX_BUFFERSIZE || chunkbytes_size > INT32_MAX) {
  ------------------
  |  Branch (584:7): [True: 0, False: 309]
  |  Branch (584:50): [True: 0, False: 309]
  ------------------
  585|      0|    BLOSC_TRACE_ERROR("Chunk bytes exceeds maximum of %d", BLOSC2_MAX_BUFFERSIZE);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  586|      0|    return BLOSC2_ERROR_MAX_BUFSIZE_EXCEEDED;
  587|      0|  }
  588|    309|  int32_t chunkbytes = (int32_t)chunkbytes_size;
  589|       |
  590|    309|  blosc2_cparams *cparams;
  591|    309|  if (blosc2_schunk_get_cparams((*array)->sc, &cparams) != 0) {
  ------------------
  |  Branch (591:7): [True: 0, False: 309]
  ------------------
  592|      0|    BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  593|      0|  }
  594|       |
  595|    309|  int32_t chunksize = BLOSC_EXTENDED_HEADER_LENGTH + (*array)->sc->typesize;
  596|    309|  uint8_t *chunk = malloc(chunksize);
  597|    309|  BLOSC_ERROR_NULL(chunk, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|    309|    do {                                            \
  |  |  105|    309|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 309]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|    309|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 309]
  |  |  ------------------
  ------------------
  598|    309|  int rc = blosc2_chunk_repeatval(*cparams, chunkbytes, chunk, chunksize, fill_value);
  599|    309|  free(cparams);
  600|  8.25k|  for (int64_t i = 0; rc >= 0 && i < (*array)->sc->nchunks; ++i) {
  ------------------
  |  Branch (600:23): [True: 8.25k, False: 0]
  |  Branch (600:34): [True: 7.94k, False: 309]
  ------------------
  601|  7.94k|    if (blosc2_schunk_update_chunk((*array)->sc, i, chunk, true) < 0) {
  ------------------
  |  Branch (601:9): [True: 0, False: 7.94k]
  ------------------
  602|      0|      rc = BLOSC2_ERROR_FAILURE;
  603|      0|    }
  604|  7.94k|  }
  605|    309|  free(chunk);
  606|    309|  if (rc < 0) {
  ------------------
  |  Branch (606:7): [True: 0, False: 309]
  ------------------
  607|      0|    BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  608|      0|  }
  609|       |
  610|    309|  return BLOSC2_ERROR_SUCCESS;
  611|    309|}
b2nd_from_schunk:
  643|  1.47k|int b2nd_from_schunk(blosc2_schunk *schunk, b2nd_array_t **array) {
  644|  1.47k|  BLOSC_ERROR_NULL(schunk, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
  645|  1.47k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
  646|       |
  647|  1.47k|  if (schunk == NULL) {
  ------------------
  |  Branch (647:7): [True: 0, False: 1.47k]
  ------------------
  648|      0|    BLOSC_TRACE_ERROR("Schunk is null");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  649|      0|    return BLOSC2_ERROR_NULL_POINTER;
  650|      0|  }
  651|       |
  652|  1.47k|  blosc2_cparams *cparams;
  653|  1.47k|  if (blosc2_schunk_get_cparams(schunk, &cparams) < 0) {
  ------------------
  |  Branch (653:7): [True: 0, False: 1.47k]
  ------------------
  654|      0|    BLOSC_TRACE_ERROR("Blosc error");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  655|      0|    return BLOSC2_ERROR_NULL_POINTER;
  656|      0|  }
  657|  1.47k|  free(cparams);
  658|       |
  659|  1.47k|  b2nd_context_t params = {0};
  660|  1.47k|  params.b2_storage = schunk->storage;
  661|       |
  662|       |  // Deserialize the b2nd metalayer
  663|  1.47k|  uint8_t *smeta;
  664|  1.47k|  int32_t smeta_len;
  665|  1.47k|  if (blosc2_meta_get(schunk, "b2nd", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (665:7): [True: 1, False: 1.47k]
  ------------------
  666|       |    // Try with a caterva metalayer; we are meant to be backward compatible with it
  667|      1|    if (blosc2_meta_get(schunk, "caterva", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (667:9): [True: 1, False: 0]
  ------------------
  668|      1|      BLOSC_ERROR(BLOSC2_ERROR_METALAYER_NOT_FOUND);
  ------------------
  |  |  111|      1|    do {                                            \
  |  |  112|      1|        int rc_ = (rc);                             \
  |  |  113|      1|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 1, False: 0]
  |  |  ------------------
  |  |  114|      1|            char *error_msg = print_error(rc_);     \
  |  |  115|      1|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      1|            return rc_;                             \
  |  |  117|      1|        }                                           \
  |  |  118|      1|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  669|      1|    }
  670|      1|  }
  671|  1.47k|  int rc_meta = b2nd_deserialize_meta(smeta, smeta_len, &params.ndim, params.shape,
  672|  1.47k|                                      params.chunkshape, params.blockshape, &params.dtype,
  673|  1.47k|                                      &params.dtype_format);
  674|  1.47k|  free(smeta);
  675|  1.47k|  BLOSC_ERROR(rc_meta);
  ------------------
  |  |  111|  1.47k|    do {                                            \
  |  |  112|  1.47k|        int rc_ = (rc);                             \
  |  |  113|  1.47k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
  676|       |
  677|       |  // Reject crafted metalayers that pair shape[i]>0 with chunkshape[i]==0 or
  678|       |  // blockshape[i]==0.  validate_shape_chunkshape_blockshape is intentionally
  679|       |  // lenient about chunkshape==0/blockshape==0 to support the placeholder
  680|       |  // pattern in b2nd_create_ctx (see example_empty_shape.c), where the
  681|       |  // companion shape entry is also 0 so no divide-by-zero ever materializes.
  682|       |  // Crafted on-wire metadata can violate that pairing, and many code paths
  683|       |  // downstream (b2nd_get_slice, b2nd_set_slice, set/get_orthogonal_selection,
  684|       |  // squeeze, resize) divide or mod by chunkshape[i] / blockshape[i] without
  685|       |  // re-checking.  Enforce the pairing here so the deserialization path is
  686|       |  // strict even when the create-ctx path remains permissive.
  687|  7.10k|  for (int i = 0; i < params.ndim; ++i) {
  ------------------
  |  Branch (687:19): [True: 5.63k, False: 1.47k]
  ------------------
  688|  5.63k|    if (params.shape[i] != 0 &&
  ------------------
  |  Branch (688:9): [True: 5.61k, False: 21]
  ------------------
  689|  5.61k|        (params.chunkshape[i] == 0 || params.blockshape[i] == 0)) {
  ------------------
  |  Branch (689:10): [True: 0, False: 5.61k]
  |  Branch (689:39): [True: 0, False: 5.61k]
  ------------------
  690|      0|      BLOSC_TRACE_ERROR("b2nd metalayer: shape[%d] is non-zero but "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  691|      0|                        "chunkshape[%d] or blockshape[%d] is zero", i, i, i);
  692|      0|      free(params.dtype);
  693|      0|      return BLOSC2_ERROR_INVALID_PARAM;
  694|      0|    }
  695|  5.63k|  }
  696|       |
  697|       |  // Free the deserialized dtype whether or not the array could be built; the
  698|       |  // rejection path is now reachable for crafted shapes (see #795)
  699|  1.47k|  int rc = array_without_schunk(&params, array);
  700|  1.47k|  free(params.dtype);
  701|  1.47k|  BLOSC_ERROR(rc);
  ------------------
  |  |  111|  1.47k|    do {                                            \
  |  |  112|  1.47k|        int rc_ = (rc);                             \
  |  |  113|  1.47k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
  702|       |
  703|  1.47k|  rc = check_schunk_matches_meta(schunk, *array);
  704|  1.47k|  if (rc < 0) {
  ------------------
  |  Branch (704:7): [True: 0, False: 1.47k]
  ------------------
  705|       |    // The schunk stays with the caller
  706|      0|    b2nd_free(*array);
  707|      0|    *array = NULL;
  708|      0|    BLOSC_ERROR(rc);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  709|      0|  }
  710|       |
  711|  1.47k|  (*array)->sc = schunk;
  712|  1.47k|  (*array)->last_tick = schunk->change_tick;
  713|       |
  714|  1.47k|  if ((*array) == NULL) {
  ------------------
  |  Branch (714:7): [True: 0, False: 1.47k]
  ------------------
  715|      0|    BLOSC_TRACE_ERROR("Error creating a b2nd container from a frame");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  716|      0|    return BLOSC2_ERROR_NULL_POINTER;
  717|      0|  }
  718|       |
  719|  1.47k|  return BLOSC2_ERROR_SUCCESS;
  720|  1.47k|}
b2nd_to_cframe:
  724|  1.47k|                   bool *needs_free) {
  725|  1.47k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
  726|  1.47k|  BLOSC_ERROR_NULL(cframe, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
  727|  1.47k|  BLOSC_ERROR_NULL(cframe_len, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
  728|  1.47k|  BLOSC_ERROR_NULL(needs_free, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
  729|       |
  730|  1.47k|  *cframe_len = blosc2_schunk_to_buffer(array->sc, cframe, needs_free);
  731|  1.47k|  if (*cframe_len <= 0) {
  ------------------
  |  Branch (731:7): [True: 0, False: 1.47k]
  ------------------
  732|      0|    BLOSC_TRACE_ERROR("Error serializing the b2nd array");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  733|      0|    return BLOSC2_ERROR_FAILURE;
  734|      0|  }
  735|  1.47k|  return BLOSC2_ERROR_SUCCESS;
  736|  1.47k|}
b2nd_from_cframe:
  739|  3.39k|int b2nd_from_cframe(uint8_t *cframe, int64_t cframe_len, bool copy, b2nd_array_t **array) {
  740|  3.39k|  BLOSC_ERROR_NULL(cframe, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  3.39k|    do {                                            \
  |  |  105|  3.39k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 3.39k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  3.39k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.39k]
  |  |  ------------------
  ------------------
  741|  3.39k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  3.39k|    do {                                            \
  |  |  105|  3.39k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 3.39k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  3.39k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.39k]
  |  |  ------------------
  ------------------
  742|       |
  743|  3.39k|  blosc2_schunk *sc = blosc2_schunk_from_buffer(cframe, cframe_len, copy);
  744|  3.39k|  if (sc == NULL) {
  ------------------
  |  Branch (744:7): [True: 1.92k, False: 1.47k]
  ------------------
  745|  1.92k|    BLOSC_TRACE_ERROR("Blosc error");
  ------------------
  |  |   93|  1.92k|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|  1.92k|    do {                                            \
  |  |  |  |   98|  1.92k|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|  1.92k|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1.92k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|  1.92k|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  746|  1.92k|    return BLOSC2_ERROR_FAILURE;
  747|  1.92k|  }
  748|       |  // ...and create a b2nd array out of it
  749|  1.47k|  int rc = b2nd_from_schunk(sc, array);
  750|  1.47k|  if (rc < 0) {
  ------------------
  |  Branch (750:7): [True: 1, False: 1.47k]
  ------------------
  751|      1|    blosc2_schunk_free(sc);
  752|      1|    return rc;
  753|      1|  }
  754|       |
  755|  1.47k|  return BLOSC2_ERROR_SUCCESS;
  756|  1.47k|}
b2nd_free:
  799|  8.67k|int b2nd_free(b2nd_array_t *array) {
  800|  8.67k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  8.67k|    do {                                            \
  |  |  105|  8.67k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 8.67k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  8.67k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8.67k]
  |  |  ------------------
  ------------------
  801|       |
  802|  8.67k|  int rc = BLOSC2_ERROR_SUCCESS;
  803|  8.67k|  if (array) {
  ------------------
  |  Branch (803:7): [True: 8.67k, False: 0]
  ------------------
  804|  8.67k|    if (array->sc != NULL) {
  ------------------
  |  Branch (804:9): [True: 8.67k, False: 0]
  ------------------
  805|  8.67k|      rc = blosc2_schunk_free(array->sc);
  806|  8.67k|      if (rc > 0) {
  ------------------
  |  Branch (806:11): [True: 0, False: 8.67k]
  ------------------
  807|      0|        rc = BLOSC2_ERROR_FAILURE;
  808|      0|      }
  809|  8.67k|    }
  810|  8.67k|    free(array->dtype);
  811|  8.67k|    free(array);
  812|  8.67k|  }
  813|  8.67k|  return rc;
  814|  8.67k|}
b2nd_from_cbuffer:
  823|    879|int b2nd_from_cbuffer(b2nd_context_t *ctx, b2nd_array_t **array, const void *buffer, int64_t buffersize) {
  824|    879|  BLOSC_ERROR_NULL(ctx, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|    879|    do {                                            \
  |  |  105|    879|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 879]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|    879|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 879]
  |  |  ------------------
  ------------------
  825|    879|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|    879|    do {                                            \
  |  |  105|    879|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 879]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|    879|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 879]
  |  |  ------------------
  ------------------
  826|    879|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|    879|    do {                                            \
  |  |  105|    879|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 879]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|    879|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 879]
  |  |  ------------------
  ------------------
  827|       |
  828|    879|  BLOSC_ERROR(b2nd_empty(ctx, array));
  ------------------
  |  |  111|    879|    do {                                            \
  |  |  112|    879|        int rc_ = (rc);                             \
  |  |  113|    879|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 879]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|    879|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 879]
  |  |  ------------------
  ------------------
  829|       |
  830|    879|  if (buffersize < (int64_t) (*array)->nitems * (*array)->sc->typesize) {
  ------------------
  |  Branch (830:7): [True: 0, False: 879]
  ------------------
  831|      0|    BLOSC_TRACE_ERROR("The buffersize (%lld) is smaller than the array size (%lld)",
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  832|      0|                        (long long) buffersize, (long long) (*array)->nitems * (*array)->sc->typesize);
  833|      0|    BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  834|      0|  }
  835|       |
  836|    879|  if ((*array)->nitems == 0) {
  ------------------
  |  Branch (836:7): [True: 16, False: 863]
  ------------------
  837|     16|    return BLOSC2_ERROR_SUCCESS;
  838|     16|  }
  839|       |
  840|    863|  int64_t start[B2ND_MAX_DIM] = {0};
  841|    863|  int64_t *stop = (*array)->shape;
  842|    863|  int64_t *shape = (*array)->shape;
  843|    863|  BLOSC_ERROR(b2nd_set_slice_cbuffer(buffer, shape, buffersize, start, stop, *array));
  ------------------
  |  |  111|    863|    do {                                            \
  |  |  112|    863|        int rc_ = (rc);                             \
  |  |  113|    863|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 863]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|    863|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 863]
  |  |  ------------------
  ------------------
  844|       |
  845|    863|  return BLOSC2_ERROR_SUCCESS;
  846|    863|}
b2nd_to_cbuffer:
  850|  4.29k|                    int64_t buffersize) {
  851|  4.29k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.29k|    do {                                            \
  |  |  105|  4.29k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  852|  4.29k|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.29k|    do {                                            \
  |  |  105|  4.29k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  853|  4.29k|  BLOSC_ERROR(refresh_if_stale((b2nd_array_t *) array));
  ------------------
  |  |  111|  4.29k|    do {                                            \
  |  |  112|  4.29k|        int rc_ = (rc);                             \
  |  |  113|  4.29k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  4.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  854|       |
  855|  4.29k|  if (buffersize < (int64_t) array->nitems * array->sc->typesize) {
  ------------------
  |  Branch (855:7): [True: 1, False: 4.29k]
  ------------------
  856|      1|    BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      1|    do {                                            \
  |  |  112|      1|        int rc_ = (rc);                             \
  |  |  113|      1|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 1, False: 0]
  |  |  ------------------
  |  |  114|      1|            char *error_msg = print_error(rc_);     \
  |  |  115|      1|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      1|            return rc_;                             \
  |  |  117|      1|        }                                           \
  |  |  118|      1|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  857|      1|  }
  858|       |
  859|  4.29k|  if (array->nitems == 0) {
  ------------------
  |  Branch (859:7): [True: 1.10k, False: 3.18k]
  ------------------
  860|  1.10k|    return BLOSC2_ERROR_SUCCESS;
  861|  1.10k|  }
  862|       |
  863|  3.18k|  int64_t start[B2ND_MAX_DIM] = {0};
  864|  3.18k|  const int64_t *stop = array->shape;
  865|  3.18k|  BLOSC_ERROR(b2nd_get_slice_cbuffer(array, start, stop, buffer, array->shape, buffersize));
  ------------------
  |  |  111|  3.18k|    do {                                            \
  |  |  112|  3.18k|        int rc_ = (rc);                             \
  |  |  113|  3.18k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 3.18k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  3.18k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 3.18k]
  |  |  ------------------
  ------------------
  866|  3.18k|  return BLOSC2_ERROR_SUCCESS;
  867|  3.18k|}
get_set_slice:
 1541|  96.2k|                  prefetch_batch *prefetch) {
 1542|  96.2k|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  96.2k|    do {                                            \
  |  |  105|  96.2k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 96.2k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  96.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 96.2k]
  |  |  ------------------
  ------------------
 1543|  96.2k|  BLOSC_ERROR_NULL(start, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  96.2k|    do {                                            \
  |  |  105|  96.2k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 96.2k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  96.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 96.2k]
  |  |  ------------------
  ------------------
 1544|  96.2k|  BLOSC_ERROR_NULL(stop, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  96.2k|    do {                                            \
  |  |  105|  96.2k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 96.2k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  96.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 96.2k]
  |  |  ------------------
  ------------------
 1545|  96.2k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  96.2k|    do {                                            \
  |  |  105|  96.2k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 96.2k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  96.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 96.2k]
  |  |  ------------------
  ------------------
 1546|  96.2k|  if (buffersize < 0) {
  ------------------
  |  Branch (1546:7): [True: 0, False: 96.2k]
  ------------------
 1547|      0|    BLOSC_TRACE_ERROR("buffersize is < 0");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|      0|    BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1549|      0|  }
 1550|       |
 1551|  96.2k|  uint8_t *buffer_b = buffer;
 1552|  96.2k|  int8_t ndim = array->ndim;
 1553|       |
 1554|       |  // 0-dim case
 1555|  96.2k|  if (ndim == 0) {
  ------------------
  |  Branch (1555:7): [True: 0, False: 96.2k]
  ------------------
 1556|      0|    if (set_slice) {
  ------------------
  |  Branch (1556:9): [True: 0, False: 0]
  ------------------
 1557|      0|      int32_t chunk_size = array->sc->typesize + BLOSC2_MAX_OVERHEAD;
 1558|      0|      uint8_t *chunk = malloc(chunk_size);
 1559|      0|      BLOSC_ERROR_NULL(chunk, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|      0|    do {                                            \
  |  |  105|      0|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1560|      0|      if (blosc2_compress_ctx(array->sc->cctx, buffer_b, array->sc->typesize, chunk, chunk_size) < 0 ||
  ------------------
  |  Branch (1560:11): [True: 0, False: 0]
  ------------------
 1561|      0|          blosc2_schunk_update_chunk(array->sc, 0, chunk, false) < 0) {
  ------------------
  |  Branch (1561:11): [True: 0, False: 0]
  ------------------
 1562|       |        // Neither a failed compression nor a failed update took the chunk
 1563|      0|        free(chunk);
 1564|      0|        BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1565|      0|      }
 1566|       |
 1567|      0|    } else {
 1568|       |      // The item is the whole slice: zero it first (an uninitialized chunk
 1569|       |      // decompresses to nothing), with slice_only nothing else
 1570|      0|      memset(buffer_b, 0, slice_only ? (size_t)array->sc->typesize : (size_t)buffersize);
  ------------------
  |  Branch (1570:27): [True: 0, False: 0]
  ------------------
 1571|      0|      if (blosc2_schunk_decompress_chunk(array->sc, 0, buffer_b, array->sc->typesize) < 0) {
  ------------------
  |  Branch (1571:11): [True: 0, False: 0]
  ------------------
 1572|      0|        BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1573|      0|      }
 1574|      0|    }
 1575|      0|    return BLOSC2_ERROR_SUCCESS;
 1576|      0|  }
 1577|       |
 1578|  96.2k|  if (array->nitems == 0) {
  ------------------
  |  Branch (1578:7): [True: 25.7k, False: 70.4k]
  ------------------
 1579|  25.7k|    if (!set_slice && !slice_only) {
  ------------------
  |  Branch (1579:9): [True: 25.7k, False: 44]
  |  Branch (1579:23): [True: 25.7k, False: 0]
  ------------------
 1580|  25.7k|      memset(buffer_b, 0, (size_t)buffersize);
 1581|  25.7k|    }
 1582|  25.7k|    return BLOSC2_ERROR_SUCCESS;
 1583|  25.7k|  }
 1584|       |
 1585|  70.4k|  int64_t nelems_slice = 1;
 1586|   286k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (1586:19): [True: 216k, False: 70.4k]
  ------------------
 1587|   216k|    if (stop[i] - start[i] > shape[i]) {
  ------------------
  |  Branch (1587:9): [True: 0, False: 216k]
  ------------------
 1588|      0|      BLOSC_TRACE_ERROR("The buffer shape can not be smaller than the slice shape");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1589|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 1590|      0|    }
 1591|   216k|    nelems_slice *= stop[i] - start[i];
 1592|   216k|  }
 1593|  70.4k|  int64_t slice_nbytes = nelems_slice * array->sc->typesize;
 1594|       |  // Compute in 64 bits and range-check: the cast used to bind to extchunknitems
 1595|       |  // alone, truncating it before the multiply and sizing buffers from the
 1596|       |  // wrapped value while offsets kept using the full extent (see #795)
 1597|  70.4k|  int64_t data_nbytes_64 = 0;
 1598|  70.4k|  if (!blosc2_checked_mul_i64_nonneg(array->extchunknitems, array->sc->typesize, &data_nbytes_64) ||
  ------------------
  |  Branch (1598:7): [True: 0, False: 70.4k]
  ------------------
 1599|  70.4k|      data_nbytes_64 > INT32_MAX) {
  ------------------
  |  Branch (1599:7): [True: 0, False: 70.4k]
  ------------------
 1600|      0|    BLOSC_TRACE_ERROR("Chunk buffer size overflows the maximum of %d bytes", INT32_MAX);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 1600|      0|    BLOSC_TRACE_ERROR("Chunk buffer size overflows the maximum of %d bytes", INT32_MAX);
  |  |  |  |  ------------------
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1601|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 1602|      0|  }
 1603|  70.4k|  int32_t data_nbytes = (int32_t) data_nbytes_64;
 1604|       |
 1605|  70.4k|  if (buffersize < slice_nbytes) {
  ------------------
  |  Branch (1605:7): [True: 0, False: 70.4k]
  ------------------
 1606|      0|    BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1607|      0|  }
 1608|       |
 1609|  70.4k|  int64_t buffer_strides[B2ND_MAX_DIM];
 1610|  70.4k|  buffer_strides[ndim - 1] = 1;
 1611|   216k|  for (int i = ndim - 2; i >= 0; --i) {
  ------------------
  |  Branch (1611:26): [True: 145k, False: 70.4k]
  ------------------
 1612|   145k|    buffer_strides[i] = buffer_strides[i + 1] * shape[i + 1];
 1613|   145k|  }
 1614|       |
 1615|  70.4k|  bool prefault = false;
 1616|  70.4k|  bool slice_zeroed = false;  // all items of the slice are zeros in the buffer already
 1617|  70.4k|  if (!set_slice && slice_only) {
  ------------------
  |  Branch (1617:7): [True: 22.9k, False: 47.4k]
  |  Branch (1617:21): [True: 0, False: 22.9k]
  ------------------
 1618|       |    // Only the slice's box gets written, but a fresh buffer still wants its
 1619|       |    // pages faulted in before several threads decompress into it (see
 1620|       |    // buffer_wants_prefault()).  That maps pages and changes no byte.
 1621|      0|    int64_t last = 0;
 1622|      0|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1622:21): [True: 0, False: 0]
  ------------------
 1623|      0|      last += (stop[i] - start[i] - 1) * buffer_strides[i];
 1624|      0|    }
 1625|      0|    prefault = buffer_wants_prefault(buffer_b, (last + 1) * array->sc->typesize, array->sc->dctx->nthreads);
 1626|      0|  }
 1627|  70.4k|  else if (!set_slice) {
  ------------------
  |  Branch (1627:12): [True: 22.9k, False: 47.4k]
  ------------------
 1628|  22.9k|    bool slice_fills_buffer = true;
 1629|       |    // The get paths below write every item of the slice, so only buffer
 1630|       |    // bytes outside of it need to be pre-initialized to be defined and
 1631|       |    // deterministic.  Skipping the rest saves a pass over the buffer, which
 1632|       |    // for a freshly allocated one is also where all its page faults hit.
 1633|  45.2k|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1633:21): [True: 40.8k, False: 4.46k]
  ------------------
 1634|  40.8k|      if (start[i] < 0 || stop[i] < start[i] || stop[i] > array->shape[i] ||
  ------------------
  |  Branch (1634:11): [True: 0, False: 40.8k]
  |  Branch (1634:27): [True: 0, False: 40.8k]
  |  Branch (1634:49): [True: 18.4k, False: 22.3k]
  ------------------
 1635|  22.3k|          stop[i] - start[i] != shape[i]) {
  ------------------
  |  Branch (1635:11): [True: 0, False: 22.3k]
  ------------------
 1636|  18.4k|        slice_fills_buffer = false;
 1637|  18.4k|        break;
 1638|  18.4k|      }
 1639|  40.8k|    }
 1640|  22.9k|    if (slice_fills_buffer) {
  ------------------
  |  Branch (1640:9): [True: 4.46k, False: 18.4k]
  ------------------
 1641|  4.46k|      memset(buffer_b + slice_nbytes, 0, (size_t)(buffersize - slice_nbytes));
 1642|  4.46k|      prefault = buffer_wants_prefault(buffer_b, slice_nbytes, array->sc->dctx->nthreads);
 1643|  4.46k|    }
 1644|  18.4k|    else {
 1645|  18.4k|      memset(buffer_b, 0, (size_t)buffersize);
 1646|  18.4k|      slice_zeroed = true;
 1647|  18.4k|    }
 1648|  22.9k|  }
 1649|       |
 1650|       |  // Chunk-sized scratch (see scratch_malloc()), allocated lazily: the compact
 1651|       |  // get path below never needs it, and for large chunks just the malloc/free
 1652|       |  // pair costs O(chunksize) in page-table work (it is way above the malloc
 1653|       |  // mmap threshold), which would dominate small reads.
 1654|  70.4k|  uint8_t *data = NULL;
 1655|  70.4k|  size_t data_capacity = 0;
 1656|       |  // Block-sized scratch for the compact get path (lazily allocated too).
 1657|  70.4k|  uint8_t *block_data = NULL;
 1658|  70.4k|  size_t block_data_capacity = 0;
 1659|  70.4k|  int32_t block_nbytes = (int32_t) (array->blocknitems * array->sc->typesize);
 1660|  70.4k|  bool *block_maskout = NULL;
 1661|  70.4k|  int rc = BLOSC2_ERROR_SUCCESS;
 1662|       |
 1663|  70.4k|  int64_t chunks_in_array[B2ND_MAX_DIM] = {0};
 1664|   286k|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1664:19): [True: 216k, False: 70.4k]
  ------------------
 1665|   216k|    chunks_in_array[i] = array->extshape[i] / array->chunkshape[i];
 1666|   216k|  }
 1667|       |
 1668|  70.4k|  int64_t chunks_in_array_strides[B2ND_MAX_DIM];
 1669|  70.4k|  chunks_in_array_strides[ndim - 1] = 1;
 1670|   216k|  for (int i = ndim - 2; i >= 0; --i) {
  ------------------
  |  Branch (1670:26): [True: 145k, False: 70.4k]
  ------------------
 1671|   145k|    chunks_in_array_strides[i] = chunks_in_array_strides[i + 1] * chunks_in_array[i + 1];
 1672|   145k|  }
 1673|       |
 1674|  70.4k|  int64_t blocks_in_chunk[B2ND_MAX_DIM] = {0};
 1675|   286k|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1675:19): [True: 216k, False: 70.4k]
  ------------------
 1676|   216k|    blocks_in_chunk[i] = array->extchunkshape[i] / array->blockshape[i];
 1677|   216k|  }
 1678|  70.4k|  int32_t nblocks = (int32_t) array->extchunknitems / array->blocknitems;
 1679|  70.4k|  int64_t blockshape[B2ND_MAX_DIM];
 1680|   286k|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1680:19): [True: 216k, False: 70.4k]
  ------------------
 1681|   216k|    blockshape[i] = array->blockshape[i];
 1682|   216k|  }
 1683|       |
 1684|  70.4k|  bool blocks_in_c_order = chunk_blocks_in_c_order(array);
 1685|  70.4k|  bool has_delta = filters_contain(array->sc->filters, BLOSC_DELTA);
 1686|  70.4k|  blosc2_context *dctx = array->sc->dctx;
 1687|       |  // The scatter get path brings its own postfilter, so it cannot serve
 1688|       |  // handles that have one (e.g. python-blosc2's lazy UDFs).
 1689|  70.4k|  bool can_scatter = !has_delta && dctx->postfilter == NULL;
  ------------------
  |  Branch (1689:22): [True: 70.4k, False: 0]
  |  Branch (1689:36): [True: 70.4k, False: 0]
  ------------------
 1690|       |  // Likewise for the gather set path and prefilters (python-blosc2 installs
 1691|       |  // some for lazy expressions); DELTA encodes against the first block of the
 1692|       |  // compressor input, which the gather does not fill.
 1693|  70.4k|  blosc2_context *cctx = array->sc->cctx;
 1694|  70.4k|  bool can_gather = cctx->prefilter == NULL && !filters_contain(cctx->filters, BLOSC_DELTA);
  ------------------
  |  Branch (1694:21): [True: 70.4k, False: 0]
  |  Branch (1694:48): [True: 70.4k, False: 0]
  ------------------
 1695|       |
 1696|       |  // Compute the number of chunks to update
 1697|  70.4k|  int64_t update_start[B2ND_MAX_DIM];
 1698|  70.4k|  int64_t update_shape[B2ND_MAX_DIM];
 1699|       |
 1700|  70.4k|  int64_t update_nchunks = 1;
 1701|   286k|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1701:19): [True: 216k, False: 70.4k]
  ------------------
 1702|   216k|    int64_t pos = 0;
 1703|  2.13M|    while (pos <= start[i]) {
  ------------------
  |  Branch (1703:12): [True: 1.91M, False: 216k]
  ------------------
 1704|  1.91M|      pos += array->chunkshape[i];
 1705|  1.91M|    }
 1706|   216k|    update_start[i] = pos / array->chunkshape[i] - 1;
 1707|  1.24M|    while (pos < stop[i]) {
  ------------------
  |  Branch (1707:12): [True: 1.02M, False: 216k]
  ------------------
 1708|  1.02M|      pos += array->chunkshape[i];
 1709|  1.02M|    }
 1710|   216k|    update_shape[i] = pos / array->chunkshape[i] - update_start[i];
 1711|   216k|    update_nchunks *= update_shape[i];
 1712|   216k|  }
 1713|       |
 1714|  70.4k|  prefetch_batch *own_prefetch = set_slice || prefetch != NULL ? NULL : prefetch_slice(array, start, stop);
  ------------------
  |  Branch (1714:34): [True: 47.4k, False: 22.9k]
  |  Branch (1714:47): [True: 0, False: 22.9k]
  ------------------
 1715|  70.4k|  prefetch = own_prefetch != NULL ? own_prefetch : prefetch;
  ------------------
  |  Branch (1715:14): [True: 0, False: 70.4k]
  ------------------
 1716|       |
 1717|       |  // Chunks of zeros (b2nd_zeros(), sparse data) and uninitialized ones read
 1718|       |  // as zeros without decompression.  Find them from the index first; if they
 1719|       |  // hold a good part of the slice, zero the slice in one pass and skip them
 1720|       |  // (zeroing chunk by chunk writes many short rows: an all-zero 384^3 float16
 1721|       |  // box took 24 ms that way, 1.9 ms in one pass), else zero their boxes only.
 1722|       |  // Not with a postfilter, which may compute the items of special chunks,
 1723|       |  // and not for slices smaller than a block, where decompressing is cheap.
 1724|  70.4k|  int64_t *slice_chunks = NULL;  // the slice's chunks in loop order, then...
 1725|  70.4k|  uint8_t *zero_chunk = NULL;  // ...whether each reads as zeros (same allocation)
 1726|  70.4k|  if (!set_slice && dctx->postfilter == NULL && nelems_slice >= array->blocknitems) {
  ------------------
  |  Branch (1726:7): [True: 22.9k, False: 47.4k]
  |  Branch (1726:21): [True: 22.9k, False: 0]
  |  Branch (1726:49): [True: 2.38k, False: 20.5k]
  ------------------
 1727|  2.38k|    slice_chunks = malloc((size_t) update_nchunks * (sizeof(int64_t) + 1));
 1728|  2.38k|    if (slice_chunks == NULL) {
  ------------------
  |  Branch (1728:9): [True: 0, False: 2.38k]
  ------------------
 1729|      0|      rc = BLOSC2_ERROR_MEMORY_ALLOC;
 1730|      0|      goto out;
 1731|      0|    }
 1732|  2.38k|    zero_chunk = (uint8_t *) (slice_chunks + update_nchunks);
 1733|   629k|    for (int64_t u = 0; u < update_nchunks; ++u) {
  ------------------
  |  Branch (1733:25): [True: 626k, False: 2.38k]
  ------------------
 1734|   626k|      int64_t idx[B2ND_MAX_DIM] = {0};
 1735|   626k|      blosc2_unidim_to_multidim(ndim, update_shape, u, idx);
 1736|  3.20M|      for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1736:23): [True: 2.57M, False: 626k]
  ------------------
 1737|  2.57M|        idx[i] += update_start[i];
 1738|  2.57M|      }
 1739|   626k|      blosc2_multidim_to_unidim(idx, ndim, chunks_in_array_strides, &slice_chunks[u]);
 1740|   626k|    }
 1741|  2.38k|    if (chunks_special(array->sc, slice_chunks, update_nchunks, zero_chunk) < 0) {
  ------------------
  |  Branch (1741:9): [True: 249, False: 2.13k]
  ------------------
 1742|    249|      memset(zero_chunk, 0, (size_t) update_nchunks);  // the normal path reports what is wrong
 1743|    249|    }
 1744|  2.38k|    int64_t zero_nitems = 0;
 1745|   629k|    for (int64_t u = 0; u < update_nchunks; ++u) {
  ------------------
  |  Branch (1745:25): [True: 626k, False: 2.38k]
  ------------------
 1746|   626k|      zero_chunk[u] = zero_chunk[u] == BLOSC2_SPECIAL_ZERO || zero_chunk[u] == BLOSC2_SPECIAL_UNINIT;
  ------------------
  |  Branch (1746:23): [True: 112k, False: 513k]
  |  Branch (1746:63): [True: 0, False: 513k]
  ------------------
 1747|   626k|      if (zero_chunk[u]) {
  ------------------
  |  Branch (1747:11): [True: 112k, False: 513k]
  ------------------
 1748|   112k|        int64_t cstart[B2ND_MAX_DIM], cstop[B2ND_MAX_DIM], bstart[B2ND_MAX_DIM], bstop[B2ND_MAX_DIM];
 1749|   112k|        chunk_box(array, slice_chunks[u], start, stop, cstart, cstop);
 1750|   112k|        zero_nitems += chunk_slice_box(ndim, cstart, cstop, start, stop, bstart, bstop);
 1751|   112k|      }
 1752|   626k|    }
 1753|  2.38k|    if (!slice_zeroed && 4 * zero_nitems >= nelems_slice) {
  ------------------
  |  Branch (1753:9): [True: 1.96k, False: 413]
  |  Branch (1753:26): [True: 733, False: 1.23k]
  ------------------
 1754|       |      // The slice's box of the buffer (the whole buffer unless slice_only; one memset() then)
 1755|    733|      int64_t zstart[B2ND_MAX_DIM] = {0};
 1756|    733|      int64_t zstop[B2ND_MAX_DIM];
 1757|  2.54k|      for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1757:23): [True: 1.80k, False: 733]
  ------------------
 1758|  1.80k|        zstop[i] = stop[i] - start[i];
 1759|  1.80k|      }
 1760|    733|      b2nd_zero_box(ndim, array->sc->typesize, buffer_b, shape, zstart, zstop);
 1761|    733|      slice_zeroed = true;
 1762|    733|    }
 1763|  2.38k|  }
 1764|       |
 1765|  1.40M|  for (int64_t update_nchunk = 0; update_nchunk < update_nchunks; ++update_nchunk) {
  ------------------
  |  Branch (1765:35): [True: 1.33M, False: 69.9k]
  ------------------
 1766|  1.33M|    int64_t nchunk_ndim[B2ND_MAX_DIM] = {0};
 1767|  1.33M|    blosc2_unidim_to_multidim(ndim, update_shape, update_nchunk, nchunk_ndim);
 1768|  7.55M|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1768:21): [True: 6.21M, False: 1.33M]
  ------------------
 1769|  6.21M|      nchunk_ndim[i] += update_start[i];
 1770|  6.21M|    }
 1771|  1.33M|    int64_t nchunk;
 1772|  1.33M|    blosc2_multidim_to_unidim(nchunk_ndim, ndim, chunks_in_array_strides, &nchunk);
 1773|       |
 1774|       |    // Check if the chunk needs to be updated
 1775|  1.33M|    int64_t chunk_start[B2ND_MAX_DIM] = {0};
 1776|  1.33M|    int64_t chunk_stop[B2ND_MAX_DIM] = {0};
 1777|  7.55M|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1777:21): [True: 6.21M, False: 1.33M]
  ------------------
 1778|  6.21M|      chunk_start[i] = nchunk_ndim[i] * array->chunkshape[i];
 1779|  6.21M|      chunk_stop[i] = chunk_start[i] + array->chunkshape[i];
 1780|  6.21M|      if (chunk_stop[i] > array->shape[i]) {
  ------------------
  |  Branch (1780:11): [True: 3.95M, False: 2.26M]
  ------------------
 1781|  3.95M|        chunk_stop[i] = array->shape[i];
 1782|  3.95M|      }
 1783|  6.21M|    }
 1784|  1.33M|    bool chunk_empty = false;
 1785|  7.55M|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1785:21): [True: 6.21M, False: 1.33M]
  ------------------
 1786|  6.21M|      chunk_empty |= (chunk_stop[i] <= start[i] || chunk_start[i] >= stop[i]);
  ------------------
  |  Branch (1786:23): [True: 692k, False: 5.52M]
  |  Branch (1786:52): [True: 67.2k, False: 5.46M]
  ------------------
 1787|  6.21M|    }
 1788|  1.33M|    if (chunk_empty) {
  ------------------
  |  Branch (1788:9): [True: 83.1k, False: 1.25M]
  ------------------
 1789|  83.1k|      continue;
 1790|  83.1k|    }
 1791|  1.25M|    if (zero_chunk != NULL && zero_chunk[update_nchunk]) {
  ------------------
  |  Branch (1791:9): [True: 619k, False: 634k]
  |  Branch (1791:31): [True: 112k, False: 506k]
  ------------------
 1792|   112k|      if (!slice_zeroed) {
  ------------------
  |  Branch (1792:11): [True: 30.9k, False: 82.0k]
  ------------------
 1793|  30.9k|        int64_t box_start[B2ND_MAX_DIM];
 1794|  30.9k|        int64_t box_stop[B2ND_MAX_DIM];
 1795|  30.9k|        chunk_slice_box(ndim, chunk_start, chunk_stop, start, stop, box_start, box_stop);
 1796|  30.9k|        b2nd_zero_box(ndim, array->sc->typesize, buffer_b, shape, box_start, box_stop);
 1797|  30.9k|      }
 1798|   112k|      continue;
 1799|   112k|    }
 1800|       |    // Decompress each chunk as soon as it has been read ahead, while the later ones are still coming in
 1801|  1.14M|    prefetch_batch_wait(prefetch, nchunk);
 1802|  1.14M|    slice_chunk_t slice_chunk;
 1803|  1.14M|    memset(&slice_chunk, 0, sizeof(slice_chunk));
 1804|  1.14M|    slice_chunk.array = array;
 1805|  1.14M|    slice_chunk.buffer = buffer_b;
 1806|  1.14M|    slice_chunk.buffershape = shape;
 1807|  1.14M|    slice_chunk.start = start;
 1808|  1.14M|    slice_chunk.stop = stop;
 1809|  1.14M|    slice_chunk.chunk_start = chunk_start;
 1810|  1.14M|    slice_chunk.chunk_stop = chunk_stop;
 1811|  1.14M|    slice_chunk.blocks_in_chunk = blocks_in_chunk;
 1812|  1.14M|    slice_chunk.blockshape = blockshape;
 1813|       |
 1814|       |    // A whole chunk that is one run of the buffer in its decompressed layout
 1815|       |    // is (de)compressed straight from/into the buffer.
 1816|  1.14M|    int64_t run_offset;
 1817|  1.14M|    if (blocks_in_c_order &&
  ------------------
  |  Branch (1817:9): [True: 88.2k, False: 1.05M]
  ------------------
 1818|  88.2k|        chunk_contiguous_in_buffer(array, chunk_start, start, stop, shape, &run_offset)) {
  ------------------
  |  Branch (1818:9): [True: 52.8k, False: 35.3k]
  ------------------
 1819|  52.8k|      uint8_t *run = buffer_b + run_offset;
 1820|  52.8k|      if (set_slice) {
  ------------------
  |  Branch (1820:11): [True: 26.3k, False: 26.5k]
  ------------------
 1821|  26.3k|        rc = compress_update_chunk(array, nchunk, run, data_nbytes, NULL);
 1822|  26.3k|        if (rc < 0) {
  ------------------
  |  Branch (1822:13): [True: 0, False: 26.3k]
  ------------------
 1823|      0|          goto out;
 1824|      0|        }
 1825|  26.3k|      }
 1826|  26.5k|      else {
 1827|       |        // All threads start writing their blocks at once; with shares
 1828|       |        // below a huge page several of them hit each one
 1829|  26.5k|        if (prefault && data_nbytes / dctx->nthreads < (1 << 20) &&
  ------------------
  |  Branch (1829:13): [True: 0, False: 26.5k]
  |  Branch (1829:25): [True: 0, False: 0]
  ------------------
 1830|      0|            block_nbytes < (1 << 20)) {
  ------------------
  |  Branch (1830:13): [True: 0, False: 0]
  ------------------
 1831|      0|          prefault_range(run, data_nbytes);
 1832|      0|        }
 1833|  26.5k|        rc = blosc2_schunk_decompress_chunk(array->sc, nchunk, run, data_nbytes);
 1834|  26.5k|        if (rc < 0) {
  ------------------
  |  Branch (1834:13): [True: 0, False: 26.5k]
  ------------------
 1835|      0|          BLOSC_TRACE_ERROR("Error decompressing chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1836|      0|          goto out;
 1837|      0|        }
 1838|  26.5k|        if (decoded_nothing(dctx, rc)) {
  ------------------
  |  Branch (1838:13): [True: 0, False: 26.5k]
  ------------------
 1839|      0|          memset(run, 0, (size_t)data_nbytes);
 1840|      0|        }
 1841|  26.5k|        rc = BLOSC2_ERROR_SUCCESS;
 1842|  26.5k|      }
 1843|  52.8k|      continue;
 1844|  52.8k|    }
 1845|       |
 1846|       |    // Compact get path state for this chunk (see below).
 1847|  1.14M|    bool use_compact = false;
 1848|  1.08M|    uint8_t *lazychunk = NULL;
 1849|  1.08M|    bool lazychunk_needs_free = false;
 1850|  1.08M|    int32_t lazychunk_cbytes = 0;
 1851|  1.08M|    if (set_slice) {
  ------------------
  |  Branch (1851:9): [True: 581k, False: 505k]
  ------------------
 1852|   581k|      if (data == NULL) {
  ------------------
  |  Branch (1852:11): [True: 21.0k, False: 560k]
  ------------------
 1853|  21.0k|        data = scratch_malloc(array, data_nbytes, &data_capacity);
 1854|  21.0k|        if (data == NULL) {
  ------------------
  |  Branch (1854:13): [True: 0, False: 21.0k]
  ------------------
 1855|      0|          rc = BLOSC2_ERROR_MEMORY_ALLOC;
 1856|      0|          goto out;
 1857|      0|        }
 1858|  21.0k|      }
 1859|       |      // Check if all the chunk is going to be updated and avoid the decompression
 1860|   581k|      bool decompress_chunk = false;
 1861|  3.05M|      for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1861:23): [True: 2.46M, False: 581k]
  ------------------
 1862|  2.46M|        decompress_chunk |= (chunk_start[i] < start[i] || chunk_stop[i] > stop[i]);
  ------------------
  |  Branch (1862:30): [True: 19.7k, False: 2.44M]
  |  Branch (1862:59): [True: 275, False: 2.44M]
  ------------------
 1863|  2.46M|      }
 1864|       |
 1865|       |      // On a partly overwritten chunk the gather copies every block that
 1866|       |      // keeps old items once more, so it only pays when the slice covers a
 1867|       |      // good part of the chunk.
 1868|   581k|      int64_t box_start[B2ND_MAX_DIM];
 1869|   581k|      int64_t box_stop[B2ND_MAX_DIM];
 1870|   581k|      int64_t overlap_nitems = chunk_slice_box(ndim, chunk_start, chunk_stop, start, stop,
 1871|   581k|                                               box_start, box_stop);
 1872|   581k|      if (can_gather && (!decompress_chunk || 2 * overlap_nitems >= array->extchunknitems)) {
  ------------------
  |  Branch (1872:11): [True: 581k, False: 0]
  |  Branch (1872:26): [True: 562k, False: 18.9k]
  |  Branch (1872:47): [True: 1.06k, False: 17.9k]
  ------------------
 1873|       |        // Gather path: the compression threads take the new items straight
 1874|       |        // from the buffer.  Only blocks keeping some old items need the old
 1875|       |        // chunk, and when there are none `data` stays untouched.
 1876|   563k|        if (decompress_chunk) {
  ------------------
  |  Branch (1876:13): [True: 1.06k, False: 562k]
  ------------------
 1877|  1.06k|          if (block_maskout == NULL) {
  ------------------
  |  Branch (1877:15): [True: 120, False: 945]
  ------------------
 1878|    120|            block_maskout = malloc(nblocks);
 1879|    120|            if (block_maskout == NULL) {
  ------------------
  |  Branch (1879:17): [True: 0, False: 120]
  ------------------
 1880|      0|              rc = BLOSC2_ERROR_MEMORY_ALLOC;
 1881|      0|              goto out;
 1882|      0|            }
 1883|    120|          }
 1884|  5.42k|          for (int nblock = 0; nblock < nblocks; ++nblock) {
  ------------------
  |  Branch (1884:32): [True: 4.35k, False: 1.06k]
  ------------------
 1885|  4.35k|            block_overlap_t overlap;
 1886|  4.35k|            block_maskout[nblock] = block_slice_overlap(&slice_chunk, nblock, &overlap) &&
  ------------------
  |  Branch (1886:37): [True: 4.17k, False: 185]
  ------------------
 1887|  4.17k|                                    overlap.whole_block;
  ------------------
  |  Branch (1887:37): [True: 1.75k, False: 2.41k]
  ------------------
 1888|  4.35k|          }
 1889|  1.06k|          int err = schunk_decompress_masked(array->sc, nchunk, NULL, 0, block_maskout, nblocks,
 1890|  1.06k|                                             NULL, NULL, data, data_nbytes);
 1891|  1.06k|          if (err < 0) {
  ------------------
  |  Branch (1891:15): [True: 0, False: 1.06k]
  ------------------
 1892|      0|            BLOSC_TRACE_ERROR("Error decompressing chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1893|      0|            rc = BLOSC2_ERROR_FAILURE;
 1894|      0|            goto out;
 1895|      0|          }
 1896|  1.06k|          if (decoded_nothing(dctx, err)) {
  ------------------
  |  Branch (1896:15): [True: 0, False: 1.06k]
  ------------------
 1897|      0|            memset(data, 0, data_nbytes);
 1898|      0|          }
 1899|  1.06k|        }
 1900|   563k|        slice_chunk.keep_old = decompress_chunk;
 1901|   563k|        rc = compress_update_chunk(array, nchunk, data, data_nbytes, &slice_chunk);
 1902|   563k|        if (rc < 0) {
  ------------------
  |  Branch (1902:13): [True: 20, False: 563k]
  ------------------
 1903|     20|          goto out;
 1904|     20|        }
 1905|   563k|        continue;
 1906|   563k|      }
 1907|       |
 1908|  17.9k|      if (decompress_chunk) {
  ------------------
  |  Branch (1908:11): [True: 17.9k, False: 0]
  ------------------
 1909|  17.9k|        int err = blosc2_schunk_decompress_chunk(array->sc, nchunk, data, data_nbytes);
 1910|  17.9k|        if (err < 0) {
  ------------------
  |  Branch (1910:13): [True: 189, False: 17.7k]
  ------------------
 1911|    189|          BLOSC_TRACE_ERROR("Error decompressing chunk");
  ------------------
  |  |   93|    189|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    189|    do {                                            \
  |  |  |  |   98|    189|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    189|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 189, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    189|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1912|    189|          rc = BLOSC2_ERROR_FAILURE;
 1913|    189|          goto out;
 1914|    189|        }
 1915|  17.7k|        if (decoded_nothing(dctx, err)) {
  ------------------
  |  Branch (1915:13): [True: 0, False: 17.7k]
  ------------------
 1916|      0|          memset(data, 0, data_nbytes);
 1917|      0|        }
 1918|  17.7k|      } else {
 1919|       |        // Avoid writing non zero padding from previous chunk
 1920|      0|        memset(data, 0, data_nbytes);
 1921|      0|      }
 1922|   505k|    } else {
 1923|   505k|      if (block_maskout == NULL) {
  ------------------
  |  Branch (1923:11): [True: 5.33k, False: 500k]
  ------------------
 1924|  5.33k|        block_maskout = malloc(nblocks);
 1925|  5.33k|        if (block_maskout == NULL) {
  ------------------
  |  Branch (1925:13): [True: 0, False: 5.33k]
  ------------------
 1926|      0|          rc = BLOSC2_ERROR_MEMORY_ALLOC;
 1927|      0|          goto out;
 1928|      0|        }
 1929|  5.33k|      }
 1930|       |      // Delta filter encodes subsequent blocks relative to the reference block (block 0): if any block in the chunk
 1931|       |      // is needed, block 0 must be decompressed as reference
 1932|   505k|      int32_t nblocks_needed = (int32_t) slice_chunk_maskout(&slice_chunk, nblocks, has_delta, block_maskout);
 1933|       |
 1934|       |      // Compact get path: when only a fraction of the chunk's blocks is
 1935|       |      // needed, decompress just those blocks -- one at a time, straight
 1936|       |      // from the (lazy)chunk -- instead of decompressing into a chunk-sized
 1937|       |      // scratch.  This keeps the working buffer at one block, so small reads
 1938|       |      // from arrays with large chunks stay O(request), not O(chunksize).
 1939|       |      // Larger requests keep the maskout path, which decompresses the needed
 1940|       |      // blocks in parallel.
 1941|       |      //
 1942|       |      // The threshold depends on the storage backend.  On disk, the maskout
 1943|       |      // path reads the *whole* compressed chunk per call while the compact
 1944|       |      // path only reads the touched blocks, so compact wins by 10-100x well
 1945|       |      // past needed == nblocks/4 for typical data.  In memory there is no
 1946|       |      // I/O to save: for poorly-compressible data the maskout path's
 1947|       |      // parallel decompression overtakes the compact path's serial one at
 1948|       |      // around 2-4 needed blocks, so stay conservative there (1/16 keeps
 1949|       |      // the possible loss window narrow while still capturing the common
 1950|       |      // 1-2 block reads, where compact always wins or ties).
 1951|       |      //
 1952|       |      // If DELTA is used, blocks cannot be decompressed independently; keep maskout path.
 1953|   505k|      use_compact = slice_chunk_compact(array, nblocks_needed, has_delta);
 1954|   505k|      if (use_compact) {
  ------------------
  |  Branch (1954:11): [True: 60.4k, False: 445k]
  ------------------
 1955|  60.4k|        lazychunk_cbytes = blosc2_schunk_get_lazychunk(array->sc, nchunk, &lazychunk,
 1956|  60.4k|                                                       &lazychunk_needs_free);
 1957|  60.4k|        if (lazychunk_cbytes < 0) {
  ------------------
  |  Branch (1957:13): [True: 327, False: 60.1k]
  ------------------
 1958|    327|          BLOSC_TRACE_ERROR("Error getting the lazy chunk");
  ------------------
  |  |   93|    327|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    327|    do {                                            \
  |  |  |  |   98|    327|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    327|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 327, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    327|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1959|    327|          rc = BLOSC2_ERROR_FAILURE;
 1960|    327|          goto out;
 1961|    327|        }
 1962|  60.1k|        if (block_data == NULL) {
  ------------------
  |  Branch (1962:13): [True: 798, False: 59.3k]
  ------------------
 1963|    798|          block_data = scratch_malloc(array, block_nbytes, &block_data_capacity);
 1964|    798|          if (block_data == NULL) {
  ------------------
  |  Branch (1964:15): [True: 0, False: 798]
  ------------------
 1965|      0|            if (lazychunk_needs_free) {
  ------------------
  |  Branch (1965:17): [True: 0, False: 0]
  ------------------
 1966|      0|              free(lazychunk);
 1967|      0|            }
 1968|      0|            rc = BLOSC2_ERROR_MEMORY_ALLOC;
 1969|      0|            goto out;
 1970|      0|          }
 1971|    798|        }
 1972|   445k|      } else {
 1973|   445k|        if (data == NULL) {
  ------------------
  |  Branch (1973:13): [True: 4.73k, False: 440k]
  ------------------
 1974|  4.73k|          data = scratch_malloc(array, data_nbytes, &data_capacity);
 1975|  4.73k|          if (data == NULL) {
  ------------------
  |  Branch (1975:15): [True: 0, False: 4.73k]
  ------------------
 1976|      0|            rc = BLOSC2_ERROR_MEMORY_ALLOC;
 1977|      0|            goto out;
 1978|      0|          }
 1979|  4.73k|        }
 1980|   445k|        bool scattered = false;
 1981|   445k|        if (can_scatter) {
  ------------------
  |  Branch (1981:13): [True: 445k, False: 0]
  ------------------
 1982|       |          // Scatter path: the needed blocks go from the worker threads that
 1983|       |          // decode them straight to the buffer.  `data` only satisfies the
 1984|       |          // decompressor's destination size and stays untouched.
 1985|   445k|          int64_t box_start[B2ND_MAX_DIM];
 1986|   445k|          int64_t box_stop[B2ND_MAX_DIM];
 1987|   445k|          chunk_slice_box(ndim, chunk_start, chunk_stop, start, stop, box_start, box_stop);
 1988|   445k|          if (prefault) {
  ------------------
  |  Branch (1988:15): [True: 0, False: 445k]
  ------------------
 1989|      0|            int64_t box_last[B2ND_MAX_DIM];
 1990|      0|            for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1990:29): [True: 0, False: 0]
  ------------------
 1991|      0|              box_last[i] = box_stop[i] - 1;
 1992|      0|            }
 1993|      0|            int64_t first;
 1994|      0|            int64_t last;
 1995|      0|            blosc2_multidim_to_unidim(box_start, ndim, buffer_strides, &first);
 1996|      0|            blosc2_multidim_to_unidim(box_last, ndim, buffer_strides, &last);
 1997|      0|            prefault_range(buffer_b + first * array->sc->typesize,
 1998|      0|                           (last + 1 - first) * array->sc->typesize);
 1999|      0|          }
 2000|   445k|          int err = schunk_decompress_masked(array->sc, nchunk, NULL, 0, block_maskout, nblocks,
 2001|   445k|                                             slice_scatter_postfilter, &slice_chunk, data, data_nbytes);
 2002|   445k|          if (err < 0) {
  ------------------
  |  Branch (2002:15): [True: 0, False: 445k]
  ------------------
 2003|      0|            BLOSC_TRACE_ERROR("Error decompressing chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2004|      0|            rc = BLOSC2_ERROR_FAILURE;
 2005|      0|            goto out;
 2006|      0|          }
 2007|   445k|          if (err == 0) {
  ------------------
  |  Branch (2007:15): [True: 0, False: 445k]
  ------------------
 2008|       |            // Missing chunk: nothing was decoded
 2009|      0|            b2nd_zero_box(ndim, array->sc->typesize, buffer_b, shape, box_start, box_stop);
 2010|      0|          }
 2011|   445k|          scattered = err == 0 || !scatter_unsupported(dctx);
  ------------------
  |  Branch (2011:23): [True: 0, False: 445k]
  |  Branch (2011:35): [True: 445k, False: 0]
  ------------------
 2012|   445k|        }
 2013|   445k|        if (scattered) {
  ------------------
  |  Branch (2013:13): [True: 445k, False: 0]
  ------------------
 2014|   445k|          continue;
 2015|   445k|        }
 2016|      0|        int err = schunk_decompress_masked(array->sc, nchunk, NULL, 0, block_maskout, nblocks,
 2017|      0|                                           NULL, NULL, data, data_nbytes);
 2018|      0|        if (err < 0) {
  ------------------
  |  Branch (2018:13): [True: 0, False: 0]
  ------------------
 2019|      0|          BLOSC_TRACE_ERROR("Error decompressing chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2020|      0|          rc = BLOSC2_ERROR_FAILURE;
 2021|      0|          goto out;
 2022|      0|        }
 2023|      0|        if (decoded_nothing(dctx, err)) {
  ------------------
  |  Branch (2023:13): [True: 0, False: 0]
  ------------------
 2024|      0|          memset(data, 0, data_nbytes);
 2025|      0|        }
 2026|      0|      }
 2027|   505k|    }
 2028|       |
 2029|       |    // Iterate over blocks
 2030|       |
 2031|  3.60M|    for (int nblock = 0; nblock < nblocks; ++nblock) {
  ------------------
  |  Branch (2031:26): [True: 3.52M, False: 77.8k]
  ------------------
 2032|  3.52M|      block_overlap_t overlap;
 2033|  3.52M|      if (!block_slice_overlap(&slice_chunk, nblock, &overlap)) {
  ------------------
  |  Branch (2033:11): [True: 3.46M, False: 62.5k]
  ------------------
 2034|  3.46M|        continue;
 2035|  3.46M|      }
 2036|       |
 2037|  62.5k|      uint8_t *dst;
 2038|  62.5k|      if (use_compact) {
  ------------------
  |  Branch (2038:11): [True: 57.3k, False: 5.28k]
  ------------------
 2039|       |        // Decompress just this block from the (lazy)chunk.
 2040|  57.3k|        int grc = blosc2_getitem_bytes_ctx(array->sc->dctx, lazychunk, lazychunk_cbytes,
 2041|  57.3k|                                           (int32_t) ((int64_t) nblock * block_nbytes), block_nbytes,
 2042|  57.3k|                                           block_data, block_nbytes);
 2043|  57.3k|        if (grc < 0) {
  ------------------
  |  Branch (2043:13): [True: 0, False: 57.3k]
  ------------------
 2044|      0|          BLOSC_TRACE_ERROR("Error decompressing block");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2045|      0|          if (lazychunk_needs_free) {
  ------------------
  |  Branch (2045:15): [True: 0, False: 0]
  ------------------
 2046|      0|            free(lazychunk);
 2047|      0|          }
 2048|      0|          rc = BLOSC2_ERROR_FAILURE;
 2049|      0|          goto out;
 2050|      0|        }
 2051|  57.3k|        if (decoded_nothing(dctx, grc)) {
  ------------------
  |  Branch (2051:13): [True: 0, False: 57.3k]
  ------------------
 2052|      0|          memset(block_data, 0, block_nbytes);
 2053|      0|        }
 2054|  57.3k|        dst = block_data;
 2055|  57.3k|      } else {
 2056|  5.28k|        dst = &data[nblock * array->blocknitems * array->sc->typesize];
 2057|  5.28k|      }
 2058|       |
 2059|  62.5k|      if (set_slice) {
  ------------------
  |  Branch (2059:11): [True: 5.28k, False: 57.3k]
  ------------------
 2060|  5.28k|        b2nd_copy_buffer2(ndim, array->sc->typesize,
 2061|  5.28k|                          buffer_b, shape, overlap.dst_start, overlap.dst_stop,
 2062|  5.28k|                          dst, blockshape, overlap.src_start);
 2063|  57.3k|      } else {
 2064|  57.3k|        b2nd_copy_buffer2(ndim, array->sc->typesize,
 2065|  57.3k|                          dst, blockshape, overlap.src_start, overlap.src_stop,
 2066|  57.3k|                          buffer_b, shape, overlap.dst_start);
 2067|  57.3k|      }
 2068|  62.5k|    }
 2069|       |
 2070|  77.8k|    if (use_compact && lazychunk_needs_free) {
  ------------------
  |  Branch (2070:9): [True: 60.1k, False: 17.7k]
  |  Branch (2070:24): [True: 118, False: 59.9k]
  ------------------
 2071|    118|      free(lazychunk);
 2072|    118|    }
 2073|       |
 2074|  77.8k|    if (set_slice) {
  ------------------
  |  Branch (2074:9): [True: 17.7k, False: 60.1k]
  ------------------
 2075|  17.7k|      rc = compress_update_chunk(array, nchunk, data, data_nbytes, NULL);
 2076|  17.7k|      if (rc < 0) {
  ------------------
  |  Branch (2076:11): [True: 0, False: 17.7k]
  ------------------
 2077|      0|        goto out;
 2078|      0|      }
 2079|  17.7k|    }
 2080|  77.8k|  }
 2081|       |
 2082|  70.4k|  out:
 2083|  70.4k|  free(slice_chunks);
 2084|  70.4k|  prefetch_batch_free(own_prefetch);
 2085|  70.4k|  blosc2_tmp_free(data, data_capacity);
 2086|  70.4k|  blosc2_tmp_free(block_data, block_data_capacity);
 2087|  70.4k|  free(block_maskout);
 2088|       |
 2089|  70.4k|  return rc;
 2090|  70.4k|}
b2nd_get_slice_cbuffer:
 2130|  4.65k|                           void *buffer, const int64_t *buffershape, int64_t buffersize) {
 2131|  4.65k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.65k|    do {                                            \
  |  |  105|  4.65k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.65k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.65k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.65k]
  |  |  ------------------
  ------------------
 2132|  4.65k|  BLOSC_ERROR_NULL(start, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.65k|    do {                                            \
  |  |  105|  4.65k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.65k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.65k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.65k]
  |  |  ------------------
  ------------------
 2133|  4.65k|  BLOSC_ERROR_NULL(stop, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.65k|    do {                                            \
  |  |  105|  4.65k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.65k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.65k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.65k]
  |  |  ------------------
  ------------------
 2134|  4.65k|  BLOSC_ERROR_NULL(buffershape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.65k|    do {                                            \
  |  |  105|  4.65k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.65k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.65k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.65k]
  |  |  ------------------
  ------------------
 2135|  4.65k|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.65k|    do {                                            \
  |  |  105|  4.65k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.65k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.65k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.65k]
  |  |  ------------------
  ------------------
 2136|       |
 2137|  4.65k|  return locked_get_set_slice(buffer, buffersize, start, stop, buffershape, (b2nd_array_t *) array,
 2138|  4.65k|                              false, false, NULL);
 2139|  4.65k|}
b2nd_set_slice_cbuffer:
 2189|  47.5k|                           b2nd_array_t *array) {
 2190|  47.5k|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  47.5k|    do {                                            \
  |  |  105|  47.5k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 47.5k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  47.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 47.5k]
  |  |  ------------------
  ------------------
 2191|  47.5k|  BLOSC_ERROR_NULL(start, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  47.5k|    do {                                            \
  |  |  105|  47.5k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 47.5k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  47.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 47.5k]
  |  |  ------------------
  ------------------
 2192|  47.5k|  BLOSC_ERROR_NULL(stop, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  47.5k|    do {                                            \
  |  |  105|  47.5k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 47.5k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  47.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 47.5k]
  |  |  ------------------
  ------------------
 2193|  47.5k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  47.5k|    do {                                            \
  |  |  105|  47.5k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 47.5k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  47.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 47.5k]
  |  |  ------------------
  ------------------
 2194|       |
 2195|  47.5k|  return locked_get_set_slice((void *) buffer, buffersize, start, stop, buffershape, array, true, false, NULL);
 2196|  47.5k|}
b2nd_get_slice:
 2204|  1.47k|                   const int64_t *stop) {
 2205|  1.47k|  BLOSC_ERROR_NULL(src, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
 2206|  1.47k|  BLOSC_ERROR_NULL(start, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
 2207|  1.47k|  BLOSC_ERROR_NULL(stop, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
 2208|  1.47k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
 2209|  1.47k|  BLOSC_ERROR(refresh_if_stale((b2nd_array_t *) src));
  ------------------
  |  |  111|  1.47k|    do {                                            \
  |  |  112|  1.47k|        int rc_ = (rc);                             \
  |  |  113|  1.47k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
 2210|       |
 2211|  1.47k|  ctx->ndim = src->ndim;
 2212|  7.10k|  for (int i = 0; i < src->ndim; ++i) {
  ------------------
  |  Branch (2212:19): [True: 5.63k, False: 1.47k]
  ------------------
 2213|  5.63k|    ctx->shape[i] = stop[i] - start[i];
 2214|  5.63k|  }
 2215|       |
 2216|       |  // Add data
 2217|  1.47k|  BLOSC_ERROR(b2nd_empty(ctx, array));
  ------------------
  |  |  111|  1.47k|    do {                                            \
  |  |  112|  1.47k|        int rc_ = (rc);                             \
  |  |  113|  1.47k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
 2218|       |
 2219|  1.47k|  if ((*array)->nitems == 0) {
  ------------------
  |  Branch (2219:7): [True: 1.05k, False: 416]
  ------------------
 2220|  1.05k|    return BLOSC2_ERROR_SUCCESS;
 2221|  1.05k|  }
 2222|       |
 2223|       |  // Read the chunks of the whole source slice ahead, not only those of one result chunk at a time
 2224|    416|  prefetch_batch *prefetch = prefetch_slice(src, start, stop);
 2225|    416|  int rc = get_slice_chunks(ctx, array, src, start, prefetch);
 2226|    416|  prefetch_batch_free(prefetch);
 2227|    416|  return rc;
 2228|  1.47k|}
view_new:
 2325|  4.25k|int view_new(const b2nd_array_t *array, b2nd_array_t **view, b2nd_context_t *ctx1) {
 2326|       |
 2327|  4.25k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.25k|    do {                                            \
  |  |  105|  4.25k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.25k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.25k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.25k]
  |  |  ------------------
  ------------------
 2328|  4.25k|  BLOSC_ERROR_NULL(view, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.25k|    do {                                            \
  |  |  105|  4.25k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.25k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.25k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.25k]
  |  |  ------------------
  ------------------
 2329|       |
 2330|       |  // The view is not contiguous (points to the original contiguous cframe which has different shape)
 2331|       |  // so we set contiguous to false, which forces a copy when calling to_cframe
 2332|  4.25k|  ctx1->b2_storage->contiguous = false;
 2333|       |
 2334|       |
 2335|       |  /* Fill view with zeros */
 2336|  4.25k|  BLOSC_ERROR(b2nd_zeros(ctx1, view));
  ------------------
  |  |  111|  4.25k|    do {                                            \
  |  |  112|  4.25k|        int rc_ = (rc);                             \
  |  |  113|  4.25k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 4.25k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  4.25k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 4.25k]
  |  |  ------------------
  ------------------
 2337|       |
 2338|       |  /* Deep-copy variable-length metalayers before marking the view as aliasing
 2339|       |     base data/frame so any allocation failure frees only the view cleanly. */
 2340|  4.25k|  for (int i = 0; i < array->sc->nvlmetalayers; i++) {
  ------------------
  |  Branch (2340:19): [True: 0, False: 4.25k]
  ------------------
 2341|      0|    blosc2_metalayer *src_vl = array->sc->vlmetalayers[i];
 2342|      0|    if (src_vl == NULL) {
  ------------------
  |  Branch (2342:9): [True: 0, False: 0]
  ------------------
 2343|      0|      continue;
 2344|      0|    }
 2345|      0|    if ((*view)->sc->nvlmetalayers >= BLOSC2_MAX_VLMETALAYERS) {
  ------------------
  |  | 1901|      0|#define BLOSC2_MAX_VLMETALAYERS (8 * 1024)
  ------------------
  |  Branch (2345:9): [True: 0, False: 0]
  ------------------
 2346|      0|      b2nd_free(*view);
 2347|      0|      *view = NULL;
 2348|      0|      return BLOSC2_ERROR_FAILURE;
 2349|      0|    }
 2350|      0|    blosc2_metalayer *dst_vl = calloc(1, sizeof(blosc2_metalayer));
 2351|      0|    if (dst_vl == NULL) {
  ------------------
  |  Branch (2351:9): [True: 0, False: 0]
  ------------------
 2352|      0|      b2nd_free(*view);
 2353|      0|      *view = NULL;
 2354|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 2355|      0|    }
 2356|      0|    dst_vl->name = strdup(src_vl->name);
 2357|      0|    if (dst_vl->name == NULL) {
  ------------------
  |  Branch (2357:9): [True: 0, False: 0]
  ------------------
 2358|      0|      free(dst_vl);
 2359|      0|      b2nd_free(*view);
 2360|      0|      *view = NULL;
 2361|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 2362|      0|    }
 2363|      0|    if (src_vl->content_len > 0 && src_vl->content != NULL) {
  ------------------
  |  Branch (2363:9): [True: 0, False: 0]
  |  Branch (2363:36): [True: 0, False: 0]
  ------------------
 2364|      0|      dst_vl->content = malloc((size_t) src_vl->content_len);
 2365|      0|      if (dst_vl->content == NULL) {
  ------------------
  |  Branch (2365:11): [True: 0, False: 0]
  ------------------
 2366|      0|        free(dst_vl->name);
 2367|      0|        free(dst_vl);
 2368|      0|        b2nd_free(*view);
 2369|      0|        *view = NULL;
 2370|      0|        return BLOSC2_ERROR_MEMORY_ALLOC;
 2371|      0|      }
 2372|      0|      memcpy(dst_vl->content, src_vl->content, (size_t) src_vl->content_len);
 2373|      0|      dst_vl->content_len = src_vl->content_len;
 2374|      0|    }
 2375|      0|    (*view)->sc->vlmetalayers[(*view)->sc->nvlmetalayers++] = dst_vl;
 2376|      0|  }
 2377|       |
 2378|       |  // Free the chunks in base array
 2379|  1.55M|  for (int i = 0; i < (*view)->sc->nchunks; i++) {
  ------------------
  |  Branch (2379:19): [True: 1.55M, False: 4.25k]
  ------------------
 2380|  1.55M|    free((*view)->sc->data[i]);
 2381|  1.55M|  }
 2382|  4.25k|  free((*view)->sc->data);
 2383|  4.25k|  (*view)->sc->view = true;
 2384|  4.25k|  (*view)->sc->data = array->sc->data; // point view to the same data
 2385|  4.25k|  (*view)->sc->frame = array->sc->frame; // if original array is contiguous, point to frame
 2386|       |
 2387|  4.25k|  return BLOSC2_ERROR_SUCCESS;
 2388|  4.25k|}
b2nd_expand_dims:
 2390|  1.39k|int b2nd_expand_dims(const b2nd_array_t *array, b2nd_array_t **view, const bool *axis, const uint8_t final_dims) {
 2391|  1.39k|  BLOSC_ERROR(refresh_if_stale((b2nd_array_t *) array));
  ------------------
  |  |  111|  1.39k|    do {                                            \
  |  |  112|  1.39k|        int rc_ = (rc);                             \
  |  |  113|  1.39k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.39k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.39k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.39k]
  |  |  ------------------
  ------------------
 2392|  2.79k|  for (int i = 0; i < array->sc->nmetalayers; ++i) {
  ------------------
  |  Branch (2392:19): [True: 1.39k, False: 1.39k]
  ------------------
 2393|  1.39k|    if (strcmp(array->sc->metalayers[i]->name, "b2nd") != 0) {
  ------------------
  |  Branch (2393:9): [True: 0, False: 1.39k]
  ------------------
 2394|      0|      BLOSC_TRACE_ERROR("Cannot expand dimensions of an array with non-b2nd metalayers");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2395|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2396|      0|    }
 2397|  1.39k|  }
 2398|  1.39k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.39k|    do {                                            \
  |  |  105|  1.39k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.39k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.39k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.39k]
  |  |  ------------------
  ------------------
 2399|  1.39k|  BLOSC_ERROR_NULL(view, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.39k|    do {                                            \
  |  |  105|  1.39k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.39k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.39k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.39k]
  |  |  ------------------
  ------------------
 2400|       |
 2401|  1.39k|  uint8_t old_idx = 0;
 2402|  1.39k|  int64_t newshape[B2ND_MAX_DIM];
 2403|  1.39k|  int32_t newchunkshape[B2ND_MAX_DIM];
 2404|  1.39k|  int32_t newblockshape[B2ND_MAX_DIM];
 2405|       |
 2406|  8.70k|  for (int i = 0; i < final_dims; ++i) {
  ------------------
  |  Branch (2406:19): [True: 7.30k, False: 1.39k]
  ------------------
 2407|  7.30k|    if (axis[i] == true) {
  ------------------
  |  Branch (2407:9): [True: 2.79k, False: 4.51k]
  ------------------
 2408|  2.79k|      newshape[i] = 1;
 2409|  2.79k|      newchunkshape[i] = 1;
 2410|  2.79k|      newblockshape[i] = 1;
 2411|  2.79k|    }
 2412|  4.51k|    else {
 2413|  4.51k|      if (old_idx == array->ndim) {
  ------------------
  |  Branch (2413:11): [True: 0, False: 4.51k]
  ------------------
 2414|      0|        BLOSC_TRACE_ERROR("Error in axis list: original array has fewer dimensions than the axis list implies!");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2415|      0|        return BLOSC2_ERROR_INVALID_PARAM;
 2416|      0|      }
 2417|  4.51k|      newshape[i] = array->shape[old_idx];
 2418|  4.51k|      newchunkshape[i] = array->chunkshape[old_idx];
 2419|  4.51k|      newblockshape[i] = array->blockshape[old_idx];
 2420|  4.51k|      old_idx++;
 2421|  4.51k|    }
 2422|  7.30k|  }
 2423|       |
 2424|       |  //views only deal with cparams/dparams; storage is always in-memory (ephemeral).
 2425|  1.39k|  blosc2_cparams cparams = *(array->sc->storage->cparams);
 2426|  1.39k|  blosc2_dparams dparams = *(array->sc->storage->dparams);
 2427|  1.39k|  blosc2_storage b2_storage1 = {.cparams=&cparams, .dparams=&dparams};
 2428|       |
 2429|  1.39k|  b2nd_context_t *ctx1 = b2nd_create_ctx(&b2_storage1, final_dims, newshape,
 2430|  1.39k|                                        newchunkshape, newblockshape, array->dtype,
 2431|  1.39k|                                        array->dtype_format, NULL, 0);
 2432|       |
 2433|  1.39k|  int rc = view_new(array, view, ctx1);
 2434|  1.39k|  b2nd_free_ctx(ctx1);
 2435|       |
 2436|  1.39k|  return rc;
 2437|  1.39k|}
b2nd_squeeze:
 2440|  1.47k|int b2nd_squeeze(b2nd_array_t *array, b2nd_array_t **view) {
 2441|  1.47k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
 2442|  1.47k|  BLOSC_ERROR_NULL(view, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
 2443|       |
 2444|  1.47k|  bool index[B2ND_MAX_DIM];
 2445|       |
 2446|  7.10k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (2446:19): [True: 5.63k, False: 1.47k]
  ------------------
 2447|  5.63k|    if (array->shape[i] != 1) {
  ------------------
  |  Branch (2447:9): [True: 2.88k, False: 2.74k]
  ------------------
 2448|  2.88k|      index[i] = false;
 2449|  2.88k|    } else {
 2450|  2.74k|      index[i] = true;
 2451|  2.74k|    }
 2452|  5.63k|  }
 2453|  1.47k|  BLOSC_ERROR(b2nd_squeeze_index(array, view, index));
  ------------------
  |  |  111|  1.47k|    do {                                            \
  |  |  112|  1.47k|        int rc_ = (rc);                             \
  |  |  113|  1.47k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
 2454|       |
 2455|  1.47k|  return BLOSC2_ERROR_SUCCESS;
 2456|  1.47k|}
b2nd_squeeze_index:
 2459|  2.94k|int b2nd_squeeze_index(b2nd_array_t *array, b2nd_array_t **view, const bool *index) {
 2460|  2.94k|  BLOSC_ERROR(refresh_if_stale(array));
  ------------------
  |  |  111|  2.94k|    do {                                            \
  |  |  112|  2.94k|        int rc_ = (rc);                             \
  |  |  113|  2.94k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 2.94k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  2.94k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 2.94k]
  |  |  ------------------
  ------------------
 2461|  5.88k|  for (int i = 0; i < array->sc->nmetalayers; ++i) {
  ------------------
  |  Branch (2461:19): [True: 2.94k, False: 2.94k]
  ------------------
 2462|  2.94k|    if (strcmp(array->sc->metalayers[i]->name, "b2nd") != 0) {
  ------------------
  |  Branch (2462:9): [True: 0, False: 2.94k]
  ------------------
 2463|      0|      BLOSC_TRACE_ERROR("Cannot squeeze dimensions of an array with non-b2nd metalayers");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2464|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2465|      0|    }
 2466|  2.94k|  }
 2467|  2.94k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.94k|    do {                                            \
  |  |  105|  2.94k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.94k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  2.94k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.94k]
  |  |  ------------------
  ------------------
 2468|  2.94k|  BLOSC_ERROR_NULL(view, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.94k|    do {                                            \
  |  |  105|  2.94k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.94k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  2.94k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.94k]
  |  |  ------------------
  ------------------
 2469|       |
 2470|  2.94k|  uint8_t nones = 0;
 2471|  2.94k|  int64_t newshape[B2ND_MAX_DIM];
 2472|  2.94k|  int32_t newchunkshape[B2ND_MAX_DIM];
 2473|  2.94k|  int32_t newblockshape[B2ND_MAX_DIM];
 2474|       |
 2475|  13.8k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (2475:19): [True: 11.0k, False: 2.86k]
  ------------------
 2476|  11.0k|    if (index[i] == true) {
  ------------------
  |  Branch (2476:9): [True: 5.35k, False: 5.67k]
  ------------------
 2477|  5.35k|      if (array->shape[i] != 1) {
  ------------------
  |  Branch (2477:11): [True: 82, False: 5.27k]
  ------------------
 2478|     82|        BLOSC_ERROR(BLOSC2_ERROR_INVALID_INDEX);
  ------------------
  |  |  111|     82|    do {                                            \
  |  |  112|     82|        int rc_ = (rc);                             \
  |  |  113|     82|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 82, False: 0]
  |  |  ------------------
  |  |  114|     82|            char *error_msg = print_error(rc_);     \
  |  |  115|     82|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|     82|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|     82|    do {                                            \
  |  |  |  |  |  |   98|     82|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|     82|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 82, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|     82|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|     82|            return rc_;                             \
  |  |  117|     82|        }                                           \
  |  |  118|     82|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2479|     82|      }
 2480|  5.67k|    } else {
 2481|  5.67k|      newshape[nones] = array->shape[i];
 2482|  5.67k|      newchunkshape[nones] = array->chunkshape[i];
 2483|  5.67k|      newblockshape[nones] = array->blockshape[i];
 2484|  5.67k|      nones += 1;
 2485|  5.67k|    }
 2486|  11.0k|  }
 2487|       |
 2488|       |  //views only deal with cparams/dparams; storage is always in-memory (ephemeral).
 2489|  2.86k|  blosc2_cparams cparams = *(array->sc->storage->cparams);
 2490|  2.86k|  blosc2_dparams dparams = *(array->sc->storage->dparams);
 2491|  2.86k|  blosc2_storage b2_storage1 = {.cparams=&cparams, .dparams=&dparams};
 2492|       |
 2493|  2.86k|  b2nd_context_t *ctx1 = b2nd_create_ctx(&b2_storage1, nones, newshape,
 2494|  2.86k|                                        newchunkshape, newblockshape, array->dtype,
 2495|  2.86k|                                        array->dtype_format, NULL, 0);
 2496|       |
 2497|  2.86k|  int rc = view_new(array, view, ctx1);
 2498|  2.86k|  b2nd_free_ctx(ctx1);
 2499|       |
 2500|  2.86k|  return rc;
 2501|  2.94k|}
extend_shape:
 2807|  1.41k|int extend_shape(b2nd_array_t *array, const int64_t *new_shape, const int64_t *start) {
 2808|  1.41k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.41k|    do {                                            \
  |  |  105|  1.41k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.41k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.41k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.41k]
  |  |  ------------------
  ------------------
 2809|  1.41k|  BLOSC_ERROR_NULL(new_shape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.41k|    do {                                            \
  |  |  105|  1.41k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.41k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.41k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.41k]
  |  |  ------------------
  ------------------
 2810|       |
 2811|  1.41k|  int8_t ndim = array->ndim;
 2812|  1.41k|  int64_t diffs_shape[B2ND_MAX_DIM];
 2813|  1.41k|  int64_t diffs_sum = 0;
 2814|  7.53k|  for (int i = 0; i < ndim; i++) {
  ------------------
  |  Branch (2814:19): [True: 6.12k, False: 1.41k]
  ------------------
 2815|  6.12k|    diffs_shape[i] = new_shape[i] - array->shape[i];
 2816|  6.12k|    diffs_sum += diffs_shape[i];
 2817|  6.12k|    if (diffs_shape[i] < 0) {
  ------------------
  |  Branch (2817:9): [True: 0, False: 6.12k]
  ------------------
 2818|      0|      BLOSC_TRACE_ERROR("The new shape must be greater than the old one");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2819|      0|      BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2820|      0|    }
 2821|  6.12k|    if (array->shape[i] == INT64_MAX) {
  ------------------
  |  Branch (2821:9): [True: 0, False: 6.12k]
  ------------------
 2822|      0|      BLOSC_TRACE_ERROR("Cannot extend array with shape[%d] = %" PRId64, i, (int64_t)INT64_MAX);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 2822|      0|      BLOSC_TRACE_ERROR("Cannot extend array with shape[%d] = %" PRId64, i, (int64_t)INT64_MAX);
  |  |  |  |  ------------------
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2823|      0|      BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2824|      0|    }
 2825|  6.12k|  }
 2826|  1.41k|  if (diffs_sum == 0) {
  ------------------
  |  Branch (2826:7): [True: 80, False: 1.33k]
  ------------------
 2827|       |    // Shapes are equal. Do nothing.
 2828|     80|    return BLOSC2_ERROR_SUCCESS;
 2829|     80|  }
 2830|       |
 2831|  1.33k|  int64_t old_nchunks = array->sc->nchunks;
 2832|       |  // aux array to keep old shapes
 2833|  1.33k|  b2nd_array_t *aux = malloc(sizeof(b2nd_array_t));
 2834|  1.33k|  BLOSC_ERROR_NULL(aux, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  1.33k|    do {                                            \
  |  |  105|  1.33k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.33k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.33k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.33k]
  |  |  ------------------
  ------------------
 2835|  1.33k|  aux->sc = NULL;
 2836|  1.33k|  BLOSC_ERROR(update_shape(aux, ndim, array->shape, array->chunkshape, array->blockshape));
  ------------------
  |  |  111|  1.33k|    do {                                            \
  |  |  112|  1.33k|        int rc_ = (rc);                             \
  |  |  113|  1.33k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.33k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.33k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.33k]
  |  |  ------------------
  ------------------
 2837|       |
 2838|       |  // SWMR ordering for growth: make the data (special chunks) exist first and
 2839|       |  // publish the new shape in the metalayer last, so a concurrent reader never
 2840|       |  // sees a shape that points at chunks that are not there yet.
 2841|  1.33k|  BLOSC_ERROR(update_shape_struct(array, ndim, new_shape, array->chunkshape, array->blockshape));
  ------------------
  |  |  111|  1.33k|    do {                                            \
  |  |  112|  1.33k|        int rc_ = (rc);                             \
  |  |  113|  1.33k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.33k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.33k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.33k]
  |  |  ------------------
  ------------------
 2842|       |
 2843|  1.33k|  int64_t nchunks = array->extnitems / array->chunknitems;
 2844|  1.33k|  int64_t nchunks_;
 2845|  1.33k|  int64_t nchunk_ndim[B2ND_MAX_DIM];
 2846|  1.33k|  blosc2_cparams *cparams;
 2847|  1.33k|  BLOSC_ERROR(blosc2_schunk_get_cparams(array->sc, &cparams));
  ------------------
  |  |  111|  1.33k|    do {                                            \
  |  |  112|  1.33k|        int rc_ = (rc);                             \
  |  |  113|  1.33k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.33k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.33k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.33k]
  |  |  ------------------
  ------------------
 2848|  1.33k|  void *chunk;
 2849|  1.33k|  int64_t csize;
 2850|  1.33k|  if (nchunks != old_nchunks) {
  ------------------
  |  Branch (2850:7): [True: 1.25k, False: 73]
  ------------------
 2851|  1.25k|    if (start == NULL) {
  ------------------
  |  Branch (2851:9): [True: 711, False: 546]
  ------------------
 2852|    711|      start = aux->shape;
 2853|    711|    }
 2854|  1.25k|    int64_t chunks_in_array[B2ND_MAX_DIM] = {0};
 2855|  6.85k|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (2855:21): [True: 5.60k, False: 1.25k]
  ------------------
 2856|  5.60k|      chunks_in_array[i] = array->extshape[i] / array->chunkshape[i];
 2857|  5.60k|    }
 2858|   834k|    for (int64_t i = 0; i < nchunks; ++i) {
  ------------------
  |  Branch (2858:25): [True: 832k, False: 1.25k]
  ------------------
 2859|   832k|      blosc2_unidim_to_multidim(ndim, chunks_in_array, i, nchunk_ndim);
 2860|  2.17M|      for (int j = 0; j < ndim; ++j) {
  ------------------
  |  Branch (2860:23): [True: 1.87M, False: 300k]
  ------------------
 2861|  1.87M|        if (start[j] <= (array->chunkshape[j] * nchunk_ndim[j])
  ------------------
  |  Branch (2861:13): [True: 1.77M, False: 97.1k]
  ------------------
 2862|  1.77M|            && (array->chunkshape[j] * nchunk_ndim[j]) < (start[j] + new_shape[j] - aux->shape[j])) {
  ------------------
  |  Branch (2862:16): [True: 532k, False: 1.24M]
  ------------------
 2863|   532k|          chunk = malloc(BLOSC_EXTENDED_HEADER_LENGTH);
 2864|   532k|          BLOSC_ERROR_NULL(chunk, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|   532k|    do {                                            \
  |  |  105|   532k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 532k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|   532k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 532k]
  |  |  ------------------
  ------------------
 2865|   532k|          csize = blosc2_chunk_zeros(*cparams, array->sc->chunksize, chunk, BLOSC_EXTENDED_HEADER_LENGTH);
 2866|   532k|          if (csize < 0) {
  ------------------
  |  Branch (2866:15): [True: 0, False: 532k]
  ------------------
 2867|      0|            free(aux);
 2868|      0|            free(cparams);
 2869|      0|            BLOSC_TRACE_ERROR("Blosc error when creating a chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2870|      0|            return BLOSC2_ERROR_FAILURE;
 2871|      0|          }
 2872|   532k|          nchunks_ = blosc2_schunk_insert_chunk(array->sc, i, chunk, false);
 2873|   532k|          if (nchunks_ < 0) {
  ------------------
  |  Branch (2873:15): [True: 0, False: 532k]
  ------------------
 2874|       |            // A failed insert leaves the chunk to us
 2875|      0|            free(chunk);
 2876|      0|            free(aux);
 2877|      0|            free(cparams);
 2878|      0|            BLOSC_TRACE_ERROR("Blosc error when inserting a chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2879|      0|            return BLOSC2_ERROR_FAILURE;
 2880|      0|          }
 2881|   532k|          break;
 2882|   532k|        }
 2883|  1.87M|      }
 2884|   832k|    }
 2885|  1.25k|  }
 2886|  1.33k|  free(aux);
 2887|  1.33k|  free(cparams);
 2888|       |
 2889|       |  // Data is in place; now publish the grown shape (shape last, see above)
 2890|  1.33k|  BLOSC_ERROR(publish_shape_meta(array));
  ------------------
  |  |  111|  1.33k|    do {                                            \
  |  |  112|  1.33k|        int rc_ = (rc);                             \
  |  |  113|  1.33k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.33k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.33k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.33k]
  |  |  ------------------
  ------------------
 2891|       |
 2892|  1.33k|  return BLOSC2_ERROR_SUCCESS;
 2893|  1.33k|}
shrink_shape:
 2896|  1.41k|int shrink_shape(b2nd_array_t *array, const int64_t *new_shape, const int64_t *start) {
 2897|  1.41k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.41k|    do {                                            \
  |  |  105|  1.41k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.41k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.41k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.41k]
  |  |  ------------------
  ------------------
 2898|  1.41k|  BLOSC_ERROR_NULL(new_shape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.41k|    do {                                            \
  |  |  105|  1.41k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.41k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.41k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.41k]
  |  |  ------------------
  ------------------
 2899|       |
 2900|  1.41k|  int8_t ndim = array->ndim;
 2901|  1.41k|  int64_t diffs_shape[B2ND_MAX_DIM];
 2902|  1.41k|  int64_t diffs_sum = 0;
 2903|  7.53k|  for (int i = 0; i < ndim; i++) {
  ------------------
  |  Branch (2903:19): [True: 6.12k, False: 1.41k]
  ------------------
 2904|  6.12k|    diffs_shape[i] = new_shape[i] - array->shape[i];
 2905|  6.12k|    diffs_sum += diffs_shape[i];
 2906|  6.12k|    if (diffs_shape[i] > 0) {
  ------------------
  |  Branch (2906:9): [True: 0, False: 6.12k]
  ------------------
 2907|      0|      BLOSC_TRACE_ERROR("The new shape must be smaller than the old one");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2908|      0|      BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2909|      0|    }
 2910|  6.12k|    if (array->shape[i] == 0) {
  ------------------
  |  Branch (2910:9): [True: 38, False: 6.08k]
  ------------------
 2911|     38|      continue;
 2912|     38|    }
 2913|  6.12k|  }
 2914|  1.41k|  if (diffs_sum == 0) {
  ------------------
  |  Branch (2914:7): [True: 1.41k, False: 0]
  ------------------
 2915|       |    // Shapes are equal. Do nothing.
 2916|  1.41k|    return BLOSC2_ERROR_SUCCESS;
 2917|  1.41k|  }
 2918|       |
 2919|      0|  int64_t old_nchunks = array->sc->nchunks;
 2920|       |  // aux array to keep old shapes
 2921|      0|  b2nd_array_t *aux = malloc(sizeof(b2nd_array_t));
 2922|      0|  BLOSC_ERROR_NULL(aux, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|      0|    do {                                            \
  |  |  105|      0|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2923|      0|  aux->sc = NULL;
 2924|      0|  BLOSC_ERROR(update_shape(aux, ndim, array->shape, array->chunkshape, array->blockshape));
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2925|       |
 2926|      0|  BLOSC_ERROR(update_shape(array, ndim, new_shape, array->chunkshape, array->blockshape));
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2927|       |
 2928|       |  // Delete chunks if needed
 2929|      0|  int64_t chunks_in_array_old[B2ND_MAX_DIM] = {0};
 2930|      0|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (2930:19): [True: 0, False: 0]
  ------------------
 2931|      0|    chunks_in_array_old[i] = aux->extshape[i] / aux->chunkshape[i];
 2932|      0|  }
 2933|      0|  if (start == NULL) {
  ------------------
  |  Branch (2933:7): [True: 0, False: 0]
  ------------------
 2934|      0|    start = new_shape;
 2935|      0|  }
 2936|       |
 2937|      0|  int64_t nchunk_ndim[B2ND_MAX_DIM] = {0};
 2938|      0|  int64_t nchunks_;
 2939|      0|  for (int i = (int) old_nchunks - 1; i >= 0; --i) {
  ------------------
  |  Branch (2939:39): [True: 0, False: 0]
  ------------------
 2940|      0|    blosc2_unidim_to_multidim(ndim, chunks_in_array_old, i, nchunk_ndim);
 2941|      0|    for (int j = 0; j < ndim; ++j) {
  ------------------
  |  Branch (2941:21): [True: 0, False: 0]
  ------------------
 2942|      0|      if (start[j] <= (array->chunkshape[j] * nchunk_ndim[j])
  ------------------
  |  Branch (2942:11): [True: 0, False: 0]
  ------------------
 2943|      0|          && (array->chunkshape[j] * nchunk_ndim[j]) < (start[j] + aux->shape[j] - new_shape[j])) {
  ------------------
  |  Branch (2943:14): [True: 0, False: 0]
  ------------------
 2944|      0|        nchunks_ = blosc2_schunk_delete_chunk(array->sc, i);
 2945|      0|        if (nchunks_ < 0) {
  ------------------
  |  Branch (2945:13): [True: 0, False: 0]
  ------------------
 2946|      0|          free(aux);
 2947|      0|          BLOSC_TRACE_ERROR("Blosc error when deleting a chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2948|      0|          return BLOSC2_ERROR_FAILURE;
 2949|      0|        }
 2950|      0|        break;
 2951|      0|      }
 2952|      0|    }
 2953|      0|  }
 2954|      0|  free(aux);
 2955|       |
 2956|      0|  return BLOSC2_ERROR_SUCCESS;
 2957|      0|}
b2nd_resize:
 2961|  2.49k|                const int64_t *start) {
 2962|  2.49k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.49k|    do {                                            \
  |  |  105|  2.49k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.49k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  2.49k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.49k]
  |  |  ------------------
  ------------------
 2963|  2.49k|  BLOSC_ERROR_NULL(new_shape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.49k|    do {                                            \
  |  |  105|  2.49k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.49k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  2.49k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.49k]
  |  |  ------------------
  ------------------
 2964|  2.49k|  BLOSC_ERROR(refresh_if_stale(array));
  ------------------
  |  |  111|  2.49k|    do {                                            \
  |  |  112|  2.49k|        int rc_ = (rc);                             \
  |  |  113|  2.49k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 2.49k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  2.49k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 2.49k]
  |  |  ------------------
  ------------------
 2965|       |
 2966|  11.9k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (2966:19): [True: 9.47k, False: 2.49k]
  ------------------
 2967|  9.47k|    if (new_shape[i] < 0) {
  ------------------
  |  Branch (2967:9): [True: 0, False: 9.47k]
  ------------------
 2968|      0|      BLOSC_TRACE_ERROR("`new_shape` cannot have negative entries");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2969|      0|      BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2970|      0|    }
 2971|  9.47k|    if (new_shape[i] != array->shape[i] && (array->chunkshape[i] <= 0 || array->chunknitems <= 0)) {
  ------------------
  |  Branch (2971:9): [True: 3.77k, False: 5.70k]
  |  Branch (2971:45): [True: 0, False: 3.77k]
  |  Branch (2971:74): [True: 0, False: 3.77k]
  ------------------
 2972|      0|      BLOSC_TRACE_ERROR("Cannot resize array with zero chunkshape");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2973|      0|      BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2974|      0|    }
 2975|  9.47k|  }
 2976|       |
 2977|  2.49k|  if (start != NULL) {
  ------------------
  |  Branch (2977:7): [True: 1.71k, False: 773]
  ------------------
 2978|  4.52k|    for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (2978:21): [True: 3.88k, False: 637]
  ------------------
 2979|  3.88k|      if (start[i] < 0 || start[i] > array->shape[i]) {
  ------------------
  |  Branch (2979:11): [True: 0, False: 3.88k]
  |  Branch (2979:27): [True: 63, False: 3.82k]
  ------------------
 2980|     63|        BLOSC_TRACE_ERROR("`start` must be in [0, shape] in all dims");
  ------------------
  |  |   93|     63|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     63|    do {                                            \
  |  |  |  |   98|     63|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     63|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 63, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     63|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2981|     63|        BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|     63|    do {                                            \
  |  |  112|     63|        int rc_ = (rc);                             \
  |  |  113|     63|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 63, False: 0]
  |  |  ------------------
  |  |  114|     63|            char *error_msg = print_error(rc_);     \
  |  |  115|     63|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|     63|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|     63|    do {                                            \
  |  |  |  |  |  |   98|     63|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|     63|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 63, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|     63|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|     63|            return rc_;                             \
  |  |  117|     63|        }                                           \
  |  |  118|     63|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2982|     63|      }
 2983|  3.82k|      if ((new_shape[i] > array->shape[i] && start[i] != array->shape[i])
  ------------------
  |  Branch (2983:12): [True: 1.59k, False: 2.22k]
  |  Branch (2983:46): [True: 1.56k, False: 34]
  ------------------
 2984|  2.26k|          || (new_shape[i] < array->shape[i]
  ------------------
  |  Branch (2984:15): [True: 0, False: 2.26k]
  ------------------
 2985|  1.56k|              && (start[i] + array->shape[i] - new_shape[i]) != array->shape[i])) {
  ------------------
  |  Branch (2985:18): [True: 0, False: 0]
  ------------------
 2986|       |        // Chunks cannot be cut unless they are in the last position
 2987|  1.56k|        if (array->chunkshape[i] <= 0 || start[i] % array->chunkshape[i] != 0) {
  ------------------
  |  Branch (2987:13): [True: 0, False: 1.56k]
  |  Branch (2987:42): [True: 758, False: 805]
  ------------------
 2988|    758|          BLOSC_TRACE_ERROR("If array end is not being modified "
  ------------------
  |  |   93|    758|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    758|    do {                                            \
  |  |  |  |   98|    758|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    758|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 758, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    758|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2989|    758|                              "`start` must be a multiple of chunkshape in all dims");
 2990|    758|          BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|    758|    do {                                            \
  |  |  112|    758|        int rc_ = (rc);                             \
  |  |  113|    758|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 758, False: 0]
  |  |  ------------------
  |  |  114|    758|            char *error_msg = print_error(rc_);     \
  |  |  115|    758|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|    758|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|    758|    do {                                            \
  |  |  |  |  |  |   98|    758|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|    758|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 758, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|    758|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|    758|            return rc_;                             \
  |  |  117|    758|        }                                           \
  |  |  118|    758|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2991|    758|        }
 2992|    805|        if ((new_shape[i] - array->shape[i]) % array->chunkshape[i] != 0) {
  ------------------
  |  Branch (2992:13): [True: 261, False: 544]
  ------------------
 2993|    261|          BLOSC_TRACE_ERROR("If array end is not being modified "
  ------------------
  |  |   93|    261|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    261|    do {                                            \
  |  |  |  |   98|    261|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    261|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 261, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    261|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2994|    261|                              "`(new_shape - shape)` must be multiple of chunkshape in all dims");
 2995|    261|          BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|    261|    do {                                            \
  |  |  112|    261|        int rc_ = (rc);                             \
  |  |  113|    261|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 261, False: 0]
  |  |  ------------------
  |  |  114|    261|            char *error_msg = print_error(rc_);     \
  |  |  115|    261|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|    261|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|    261|    do {                                            \
  |  |  |  |  |  |   98|    261|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|    261|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 261, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|    261|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|    261|            return rc_;                             \
  |  |  117|    261|        }                                           \
  |  |  118|    261|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2996|    261|        }
 2997|    805|      }
 2998|  3.82k|    }
 2999|  1.71k|  }
 3000|       |
 3001|       |  // Get shrunk shape
 3002|  1.41k|  int64_t shrunk_shape[B2ND_MAX_DIM] = {0};
 3003|  7.53k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (3003:19): [True: 6.12k, False: 1.41k]
  ------------------
 3004|  6.12k|    if (new_shape[i] <= array->shape[i]) {
  ------------------
  |  Branch (3004:9): [True: 4.78k, False: 1.34k]
  ------------------
 3005|  4.78k|      shrunk_shape[i] = new_shape[i];
 3006|  4.78k|    } else {
 3007|  1.34k|      shrunk_shape[i] = array->shape[i];
 3008|  1.34k|    }
 3009|  6.12k|  }
 3010|       |
 3011|       |  // A resize is a sequence (metalayer update + chunk inserts/deletes); hold
 3012|       |  // the exclusive frame lock across it so locked handles see it atomically.
 3013|       |  // For unlocked handles this is a no-op and the data-first/shape-last
 3014|       |  // ordering in extend_shape/shrink_shape keeps readers safe.  The updated
 3015|       |  // boundary chunks leave holes until the end (see locked_get_set_slice()).
 3016|  1.41k|  blosc2_frame_s *frame = (blosc2_frame_s *) array->sc->frame;
 3017|  1.41k|  BLOSC_ERROR(frame_begin_updates(frame));
  ------------------
  |  |  111|  1.41k|    do {                                            \
  |  |  112|  1.41k|        int rc_ = (rc);                             \
  |  |  113|  1.41k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.41k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.41k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.41k]
  |  |  ------------------
  ------------------
 3018|  1.41k|  int rc = shrink_shape(array, shrunk_shape, start);
 3019|  1.41k|  if (rc >= 0) {
  ------------------
  |  Branch (3019:7): [True: 1.41k, False: 0]
  ------------------
 3020|  1.41k|    rc = extend_shape(array, new_shape, start);
 3021|  1.41k|  }
 3022|  1.41k|  int end_rc = frame_end_updates(frame, array->sc);
 3023|  1.41k|  BLOSC_ERROR(rc);
  ------------------
  |  |  111|  1.41k|    do {                                            \
  |  |  112|  1.41k|        int rc_ = (rc);                             \
  |  |  113|  1.41k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.41k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.41k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.41k]
  |  |  ------------------
  ------------------
 3024|  1.41k|  BLOSC_ERROR(end_rc);
  ------------------
  |  |  111|  1.41k|    do {                                            \
  |  |  112|  1.41k|        int rc_ = (rc);                             \
  |  |  113|  1.41k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.41k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.41k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.41k]
  |  |  ------------------
  ------------------
 3025|       |
 3026|  1.41k|  return BLOSC2_ERROR_SUCCESS;
 3027|  1.41k|}
b2nd_insert:
 3031|  2.93k|                int8_t axis, int64_t insert_start) {
 3032|       |
 3033|  2.93k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.93k|    do {                                            \
  |  |  105|  2.93k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.93k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  2.93k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.93k]
  |  |  ------------------
  ------------------
 3034|  2.93k|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.93k|    do {                                            \
  |  |  105|  2.93k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.93k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  2.93k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.93k]
  |  |  ------------------
  ------------------
 3035|  2.93k|  BLOSC_ERROR(refresh_if_stale(array));
  ------------------
  |  |  111|  2.93k|    do {                                            \
  |  |  112|  2.93k|        int rc_ = (rc);                             \
  |  |  113|  2.93k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 2.93k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  2.93k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 2.93k]
  |  |  ------------------
  ------------------
 3036|       |
 3037|  2.93k|  if (axis < 0 || axis >= array->ndim) {
  ------------------
  |  Branch (3037:7): [True: 0, False: 2.93k]
  |  Branch (3037:19): [True: 0, False: 2.93k]
  ------------------
 3038|      0|    BLOSC_TRACE_ERROR("`axis` must be in [0, ndim)");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3039|      0|    BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3040|      0|  }
 3041|  2.93k|  if (insert_start < 0 || insert_start > array->shape[axis] || buffersize < 0) {
  ------------------
  |  Branch (3041:7): [True: 0, False: 2.93k]
  |  Branch (3041:27): [True: 0, False: 2.93k]
  |  Branch (3041:64): [True: 0, False: 2.93k]
  ------------------
 3042|      0|    BLOSC_TRACE_ERROR("`insert_start` must be in [0, shape[axis]] and `buffersize` non-negative");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3043|      0|    BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3044|      0|  }
 3045|       |
 3046|  2.93k|  int64_t axis_size = array->sc->typesize;
 3047|  2.93k|  int64_t buffershape[B2ND_MAX_DIM];
 3048|  14.1k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (3048:19): [True: 11.2k, False: 2.93k]
  ------------------
 3049|  11.2k|    if (i != axis) {
  ------------------
  |  Branch (3049:9): [True: 8.28k, False: 2.93k]
  ------------------
 3050|  8.28k|      axis_size *= array->shape[i];
 3051|  8.28k|      buffershape[i] = array->shape[i];
 3052|  8.28k|    }
 3053|  11.2k|  }
 3054|  2.93k|  if (axis_size <= 0 || buffersize % axis_size != 0) {
  ------------------
  |  Branch (3054:7): [True: 13, False: 2.92k]
  |  Branch (3054:25): [True: 1.39k, False: 1.53k]
  ------------------
 3055|  1.40k|    BLOSC_TRACE_ERROR("`buffersize` must be multiple of the array cross-section");
  ------------------
  |  |   93|  1.40k|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|  1.40k|    do {                                            \
  |  |  |  |   98|  1.40k|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|  1.40k|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1.40k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|  1.40k|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3056|  1.40k|    BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|  1.40k|    do {                                            \
  |  |  112|  1.40k|        int rc_ = (rc);                             \
  |  |  113|  1.40k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 1.40k, False: 0]
  |  |  ------------------
  |  |  114|  1.40k|            char *error_msg = print_error(rc_);     \
  |  |  115|  1.40k|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|  1.40k|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|  1.40k|    do {                                            \
  |  |  |  |  |  |   98|  1.40k|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|  1.40k|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 1.40k, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|  1.40k|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|  1.40k|            return rc_;                             \
  |  |  117|  1.40k|        }                                           \
  |  |  118|  1.40k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3057|  1.40k|  }
 3058|  1.53k|  int64_t newshape[B2ND_MAX_DIM];
 3059|  1.53k|  memcpy(newshape, array->shape, array->ndim * sizeof(int64_t));
 3060|  1.53k|  newshape[axis] += buffersize / axis_size;
 3061|  1.53k|  buffershape[axis] = newshape[axis] - array->shape[axis];
 3062|  1.53k|  int64_t start[B2ND_MAX_DIM] = {0};
 3063|  1.53k|  start[axis] = insert_start;
 3064|       |
 3065|  1.53k|  if (insert_start == array->shape[axis]) {
  ------------------
  |  Branch (3065:7): [True: 765, False: 766]
  ------------------
 3066|    765|    BLOSC_ERROR(b2nd_resize(array, newshape, NULL));
  ------------------
  |  |  111|    765|    do {                                            \
  |  |  112|    765|        int rc_ = (rc);                             \
  |  |  113|    765|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 765]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|    765|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 765]
  |  |  ------------------
  ------------------
 3067|    766|  } else {
 3068|    766|    BLOSC_ERROR(b2nd_resize(array, newshape, start));
  ------------------
  |  |  111|    766|    do {                                            \
  |  |  112|    766|        int rc_ = (rc);                             \
  |  |  113|    766|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 235, False: 531]
  |  |  ------------------
  |  |  114|    235|            char *error_msg = print_error(rc_);     \
  |  |  115|    235|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|    235|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|    235|    do {                                            \
  |  |  |  |  |  |   98|    235|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|    235|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 235, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|    235|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|    235|            return rc_;                             \
  |  |  117|    235|        }                                           \
  |  |  118|    766|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 531]
  |  |  ------------------
  ------------------
 3069|    766|  }
 3070|       |
 3071|  1.29k|  int64_t stop[B2ND_MAX_DIM];
 3072|  1.29k|  memcpy(stop, array->shape, sizeof(int64_t) * array->ndim);
 3073|  1.29k|  stop[axis] = start[axis] + buffershape[axis];
 3074|  1.29k|  BLOSC_ERROR(b2nd_set_slice_cbuffer(buffer, buffershape, buffersize, start, stop, array));
  ------------------
  |  |  111|  1.29k|    do {                                            \
  |  |  112|  1.29k|        int rc_ = (rc);                             \
  |  |  113|  1.29k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.29k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.29k]
  |  |  ------------------
  ------------------
 3075|       |
 3076|  1.29k|  return BLOSC2_ERROR_SUCCESS;
 3077|  1.29k|}
b2nd_append:
 3081|  1.47k|                int8_t axis) {
 3082|  1.47k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
 3083|  1.47k|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.47k|    do {                                            \
  |  |  105|  1.47k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
 3084|  1.47k|  BLOSC_ERROR(refresh_if_stale(array));
  ------------------
  |  |  111|  1.47k|    do {                                            \
  |  |  112|  1.47k|        int rc_ = (rc);                             \
  |  |  113|  1.47k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.47k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  1.47k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.47k]
  |  |  ------------------
  ------------------
 3085|       |
 3086|  1.47k|  if (axis < 0 || axis >= array->ndim || buffersize < 0) {
  ------------------
  |  Branch (3086:7): [True: 0, False: 1.47k]
  |  Branch (3086:19): [True: 0, False: 1.47k]
  |  Branch (3086:42): [True: 0, False: 1.47k]
  ------------------
 3087|      0|    BLOSC_TRACE_ERROR("`axis` must be in [0, ndim) and `buffersize` non-negative");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3088|      0|    BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3089|      0|  }
 3090|       |
 3091|  1.47k|  int32_t chunksize = array->sc->chunksize;
 3092|  1.47k|  if (chunksize <= 0) {
  ------------------
  |  Branch (3092:7): [True: 0, False: 1.47k]
  ------------------
 3093|      0|    BLOSC_TRACE_ERROR("Cannot append to array with non-positive chunksize");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3094|      0|    BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3095|      0|  }
 3096|  1.47k|  int64_t nchunks_append = buffersize / chunksize;
 3097|       |  // Check whether chunkshape and blockshape are compatible with accelerated path.
 3098|       |  // Essentially, we are checking whether the buffer is a multiple of the chunksize
 3099|       |  // and that the chunkshape and blockshape are the same, except for the first axis.
 3100|       |  // Also, axis needs to be the first one.
 3101|  1.47k|  bool compat_chunks_blocks = true;
 3102|  4.07k|  for (int i = 1; i < array->ndim; ++i) {
  ------------------
  |  Branch (3102:19): [True: 3.35k, False: 719]
  ------------------
 3103|  3.35k|    if (array->chunkshape[i] != array->blockshape[i]) {
  ------------------
  |  Branch (3103:9): [True: 752, False: 2.60k]
  ------------------
 3104|    752|      compat_chunks_blocks = false;
 3105|    752|      break;
 3106|    752|    }
 3107|  3.35k|  }
 3108|  1.47k|  if (axis > 0) {
  ------------------
  |  Branch (3108:7): [True: 0, False: 1.47k]
  ------------------
 3109|      0|    compat_chunks_blocks = false;
 3110|      0|  }
 3111|       |  // General case where a buffer has a different size than the chunksize
 3112|  1.47k|  if (!compat_chunks_blocks || buffersize % chunksize != 0 || nchunks_append != 1) {
  ------------------
  |  Branch (3112:7): [True: 752, False: 719]
  |  Branch (3112:32): [True: 547, False: 172]
  |  Branch (3112:63): [True: 164, False: 8]
  ------------------
 3113|  1.46k|    BLOSC_ERROR(b2nd_insert(array, buffer, buffersize, axis, array->shape[axis]));
  ------------------
  |  |  111|  1.46k|    do {                                            \
  |  |  112|  1.46k|        int rc_ = (rc);                             \
  |  |  113|  1.46k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 698, False: 765]
  |  |  ------------------
  |  |  114|    698|            char *error_msg = print_error(rc_);     \
  |  |  115|    698|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|    698|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|    698|    do {                                            \
  |  |  |  |  |  |   98|    698|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|    698|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 698, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|    698|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|    698|            return rc_;                             \
  |  |  117|    698|        }                                           \
  |  |  118|  1.46k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 765]
  |  |  ------------------
  ------------------
 3114|    765|    return BLOSC2_ERROR_SUCCESS;
 3115|  1.46k|  }
 3116|       |
 3117|       |  // Accelerated path for buffers that are of the same size as the chunksize
 3118|       |  // printf("accelerated path\n");
 3119|       |
 3120|       |  // Append the buffer to the underlying schunk. This is very fast, as
 3121|       |  // it doesn't need to do internal partitioning.
 3122|      8|  BLOSC_ERROR(blosc2_schunk_append_buffer(array->sc, (void*)buffer, buffersize));
  ------------------
  |  |  111|      8|    do {                                            \
  |  |  112|      8|        int rc_ = (rc);                             \
  |  |  113|      8|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 8]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      8|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 8]
  |  |  ------------------
  ------------------
 3123|       |
 3124|       |  // Finally, resize the array
 3125|      8|  int64_t newshape[B2ND_MAX_DIM];
 3126|      8|  memcpy(newshape, array->shape, array->ndim * sizeof(int64_t));
 3127|      8|  newshape[axis] += nchunks_append * array->chunkshape[axis];
 3128|      8|  BLOSC_ERROR(b2nd_resize(array, newshape, NULL));
  ------------------
  |  |  111|      8|    do {                                            \
  |  |  112|      8|        int rc_ = (rc);                             \
  |  |  113|      8|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 8]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      8|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 8]
  |  |  ------------------
  ------------------
 3129|       |
 3130|      8|  return BLOSC2_ERROR_SUCCESS;
 3131|      8|}
b2nd_create_ctx:
 3742|  5.73k|                int32_t nmetalayers) {
 3743|  5.73k|  if (ndim < 0 || ndim > B2ND_MAX_DIM) {
  ------------------
  |  |   50|  5.73k|#define B2ND_MAX_DIM 16
  ------------------
  |  Branch (3743:7): [True: 0, False: 5.73k]
  |  Branch (3743:19): [True: 0, False: 5.73k]
  ------------------
 3744|      0|    BLOSC_TRACE_ERROR("ndim must be in [0, %d]", B2ND_MAX_DIM);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 3744|      0|    BLOSC_TRACE_ERROR("ndim must be in [0, %d]", B2ND_MAX_DIM);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   50|      0|#define B2ND_MAX_DIM 16
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3745|      0|    return NULL;
 3746|      0|  }
 3747|       |
 3748|  5.73k|  if (ndim > 0) {
  ------------------
  |  Branch (3748:7): [True: 5.73k, False: 0]
  ------------------
 3749|  5.73k|    if (shape == NULL || chunkshape == NULL || blockshape == NULL) {
  ------------------
  |  Branch (3749:9): [True: 0, False: 5.73k]
  |  Branch (3749:26): [True: 0, False: 5.73k]
  |  Branch (3749:48): [True: 0, False: 5.73k]
  ------------------
 3750|      0|      BLOSC_TRACE_ERROR("shape, chunkshape and blockshape cannot be NULL when ndim > 0");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3751|      0|      return NULL;
 3752|      0|    }
 3753|  5.73k|    if (validate_shape_chunkshape_blockshape(ndim, shape, chunkshape, blockshape) < 0) {
  ------------------
  |  Branch (3753:9): [True: 0, False: 5.73k]
  ------------------
 3754|      0|      return NULL;
 3755|      0|    }
 3756|  5.73k|  }
 3757|       |
 3758|  5.73k|  b2nd_context_t *ctx = malloc(sizeof(b2nd_context_t));
 3759|  5.73k|  BLOSC_ERROR_NULL(ctx, NULL);
  ------------------
  |  |  104|  5.73k|    do {                                            \
  |  |  105|  5.73k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 5.73k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  5.73k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 5.73k]
  |  |  ------------------
  ------------------
 3760|  5.73k|  blosc2_storage *params_b2_storage = malloc(sizeof(blosc2_storage));
 3761|  5.73k|  BLOSC_ERROR_NULL(params_b2_storage, NULL);
  ------------------
  |  |  104|  5.73k|    do {                                            \
  |  |  105|  5.73k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 5.73k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  5.73k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 5.73k]
  |  |  ------------------
  ------------------
 3762|  5.73k|  if (b2_storage == NULL) {
  ------------------
  |  Branch (3762:7): [True: 0, False: 5.73k]
  ------------------
 3763|      0|    memcpy(params_b2_storage, &BLOSC2_STORAGE_DEFAULTS, sizeof(blosc2_storage));
 3764|      0|  }
 3765|  5.73k|  else {
 3766|  5.73k|    memcpy(params_b2_storage, b2_storage, sizeof(blosc2_storage));
 3767|  5.73k|  }
 3768|  5.73k|  blosc2_cparams *cparams = malloc(sizeof(blosc2_cparams));
 3769|  5.73k|  BLOSC_ERROR_NULL(cparams, NULL);
  ------------------
  |  |  104|  5.73k|    do {                                            \
  |  |  105|  5.73k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 5.73k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  5.73k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 5.73k]
  |  |  ------------------
  ------------------
 3770|       |  // We need a copy of cparams mainly to be able to modify blocksize
 3771|  5.73k|  if (params_b2_storage->cparams == NULL) {
  ------------------
  |  Branch (3771:7): [True: 0, False: 5.73k]
  ------------------
 3772|      0|    memcpy(cparams, &BLOSC2_CPARAMS_DEFAULTS, sizeof(blosc2_cparams));
 3773|      0|  }
 3774|  5.73k|  else {
 3775|  5.73k|    memcpy(cparams, params_b2_storage->cparams, sizeof(blosc2_cparams));
 3776|  5.73k|  }
 3777|       |
 3778|  5.73k|  if (dtype == NULL) {
  ------------------
  |  Branch (3778:7): [True: 1.47k, False: 4.25k]
  ------------------
 3779|       |    // ctx->dtype = strdup(B2ND_DEFAULT_DTYPE);
 3780|  1.47k|    char buf[16] = {0};
 3781|  1.47k|    snprintf(buf, sizeof(buf), "|S%d", cparams->typesize);
 3782|  1.47k|    ctx->dtype = strdup(buf);
 3783|  1.47k|  }
 3784|  4.25k|  else {
 3785|  4.25k|    ctx->dtype = strdup(dtype);
 3786|  4.25k|  }
 3787|  5.73k|  ctx->dtype_format = dtype_format;
 3788|       |
 3789|  5.73k|  params_b2_storage->cparams = cparams;
 3790|  5.73k|  ctx->b2_storage = params_b2_storage;
 3791|  5.73k|  ctx->ndim = ndim;
 3792|  5.73k|  int32_t blocknitems = 1;
 3793|  5.73k|  bool blocksize_overflow = false;
 3794|  24.3k|  for (int i = 0; i < ndim; i++) {
  ------------------
  |  Branch (3794:19): [True: 18.6k, False: 5.73k]
  ------------------
 3795|  18.6k|    ctx->shape[i] = shape[i];
 3796|  18.6k|    ctx->chunkshape[i] = chunkshape[i];
 3797|  18.6k|    ctx->blockshape[i] = blockshape[i];
 3798|  18.6k|    if (!blosc2_checked_mul_i32_nonneg(blocknitems, ctx->blockshape[i], &blocknitems)) {
  ------------------
  |  Branch (3798:9): [True: 0, False: 18.6k]
  ------------------
 3799|      0|      blocksize_overflow = true;
 3800|      0|      break;
 3801|      0|    }
 3802|  18.6k|  }
 3803|       |  // update_shape_struct() rejects this too, but only once an array is built out
 3804|       |  // of the context; catching it here keeps cparams->blocksize from wrapping
 3805|  5.73k|  if (blocksize_overflow ||
  ------------------
  |  Branch (3805:7): [True: 0, False: 5.73k]
  ------------------
 3806|  5.73k|      !blosc2_checked_mul_i32_nonneg(blocknitems, cparams->typesize, &cparams->blocksize)) {
  ------------------
  |  Branch (3806:7): [True: 0, False: 5.73k]
  ------------------
 3807|      0|    BLOSC_TRACE_ERROR("blockshape product overflows the maximum blocksize");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3808|      0|    free(ctx->dtype);
 3809|      0|    free(cparams);
 3810|      0|    free(params_b2_storage);
 3811|      0|    free(ctx);
 3812|      0|    return NULL;
 3813|      0|  }
 3814|       |
 3815|  5.73k|  ctx->nmetalayers = nmetalayers;
 3816|  5.73k|  for (int i = 0; i < nmetalayers; ++i) {
  ------------------
  |  Branch (3816:19): [True: 0, False: 5.73k]
  ------------------
 3817|      0|    ctx->metalayers[i] = metalayers[i];
 3818|      0|  }
 3819|       |
 3820|       |#if defined(HAVE_ZFP)
 3821|       |  #include "blosc2/codecs-registry.h"
 3822|       |  if ((ctx->b2_storage->cparams->compcode >= BLOSC_CODEC_ZFP_FIXED_ACCURACY) &&
 3823|       |      (ctx->b2_storage->cparams->compcode <= BLOSC_CODEC_ZFP_FIXED_RATE)) {
 3824|       |    for (int i = 0; i < BLOSC2_MAX_FILTERS; ++i) {
 3825|       |      if ((ctx->b2_storage->cparams->filters[i] == BLOSC_SHUFFLE) ||
 3826|       |          (ctx->b2_storage->cparams->filters[i] == BLOSC_BITSHUFFLE)) {
 3827|       |        BLOSC_TRACE_ERROR("ZFP cannot be run in presence of SHUFFLE / BITSHUFFLE");
 3828|       |        return NULL;
 3829|       |      }
 3830|       |    }
 3831|       |  }
 3832|       |#endif /* HAVE_ZFP */
 3833|       |
 3834|  5.73k|  return ctx;
 3835|  5.73k|}
b2nd_free_ctx:
 3838|  5.73k|int b2nd_free_ctx(b2nd_context_t *ctx) {
 3839|  5.73k|  ctx->b2_storage->cparams->schunk = NULL;
 3840|  5.73k|  free(ctx->b2_storage->cparams);
 3841|  5.73k|  free(ctx->b2_storage);
 3842|  5.73k|  free(ctx->dtype);
 3843|  5.73k|  free(ctx);
 3844|       |
 3845|  5.73k|  return BLOSC2_ERROR_SUCCESS;
 3846|  5.73k|}
b2nd.c:update_shape_struct:
  155|  14.1k|                               const int32_t *chunkshape, const int32_t *blockshape) {
  156|  14.1k|  BLOSC_ERROR(validate_shape_chunkshape_blockshape(ndim, shape, chunkshape, blockshape));
  ------------------
  |  |  111|  14.1k|    do {                                            \
  |  |  112|  14.1k|        int rc_ = (rc);                             \
  |  |  113|  14.1k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 14.1k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  14.1k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 14.1k]
  |  |  ------------------
  ------------------
  157|       |
  158|  14.1k|  array->ndim = ndim;
  159|  14.1k|  array->nitems = 1;
  160|  14.1k|  array->extnitems = 1;
  161|  14.1k|  array->extchunknitems = 1;
  162|  14.1k|  array->chunknitems = 1;
  163|  14.1k|  array->blocknitems = 1;
  164|   240k|  for (int i = 0; i < B2ND_MAX_DIM; ++i) {
  ------------------
  |  |   50|   240k|#define B2ND_MAX_DIM 16
  ------------------
  |  Branch (164:19): [True: 226k, False: 14.1k]
  ------------------
  165|   226k|    if (i < ndim) {
  ------------------
  |  Branch (165:9): [True: 52.9k, False: 173k]
  ------------------
  166|  52.9k|      array->shape[i] = shape[i];
  167|  52.9k|      array->chunkshape[i] = chunkshape[i];
  168|  52.9k|      array->blockshape[i] = blockshape[i];
  169|  52.9k|      if (array->chunkshape[i] != 0) {
  ------------------
  |  Branch (169:11): [True: 52.9k, False: 0]
  ------------------
  170|  52.9k|        if (shape[i] % array->chunkshape[i] == 0) {
  ------------------
  |  Branch (170:13): [True: 23.2k, False: 29.7k]
  ------------------
  171|  23.2k|          array->extshape[i] = shape[i];
  172|  29.7k|        } else {
  173|       |          // Rounding shape up to the next chunk must not wrap int64
  174|  29.7k|          if (shape[i] > INT64_MAX - chunkshape[i]) {
  ------------------
  |  Branch (174:15): [True: 0, False: 29.7k]
  ------------------
  175|      0|            BLOSC_TRACE_ERROR("shape[%d] is too large to round up to chunkshape[%d]", i, i);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  176|      0|            return BLOSC2_ERROR_INVALID_PARAM;
  177|      0|          }
  178|  29.7k|          array->extshape[i] = shape[i] + chunkshape[i] - shape[i] % chunkshape[i];
  179|  29.7k|        }
  180|  52.9k|        if (chunkshape[i] % blockshape[i] == 0) {
  ------------------
  |  Branch (180:13): [True: 38.5k, False: 14.4k]
  ------------------
  181|  38.5k|          array->extchunkshape[i] = chunkshape[i];
  182|  38.5k|        } else {
  183|       |          // Done in 64 bits: the sum of two int32 values does not fit in int32,
  184|       |          // and extchunkshape is int64 anyway
  185|  14.4k|          array->extchunkshape[i] =
  186|  14.4k|                  (int64_t) chunkshape[i] + blockshape[i] - chunkshape[i] % blockshape[i];
  187|  14.4k|        }
  188|  52.9k|      } else {
  189|      0|        array->extchunkshape[i] = chunkshape[i];
  190|      0|        array->extshape[i] = 0;
  191|      0|      }
  192|   173k|    } else {
  193|   173k|      array->blockshape[i] = 1;
  194|   173k|      array->chunkshape[i] = 1;
  195|   173k|      array->extshape[i] = 1;
  196|   173k|      array->extchunkshape[i] = 1;
  197|   173k|      array->shape[i] = 1;
  198|   173k|    }
  199|       |    // Crafted metadata can make any of these products wrap, which is UB and
  200|       |    // lands in divisors and allocation sizes downstream (see #795)
  201|   226k|    if (!blosc2_checked_mul_i64_nonneg(array->nitems, array->shape[i], &array->nitems) ||
  ------------------
  |  Branch (201:9): [True: 0, False: 226k]
  ------------------
  202|   226k|        !blosc2_checked_mul_i64_nonneg(array->extnitems, array->extshape[i], &array->extnitems) ||
  ------------------
  |  Branch (202:9): [True: 0, False: 226k]
  ------------------
  203|   226k|        !blosc2_checked_mul_i64_nonneg(array->extchunknitems, array->extchunkshape[i],
  ------------------
  |  Branch (203:9): [True: 0, False: 226k]
  ------------------
  204|   226k|                                       &array->extchunknitems) ||
  205|   226k|        !blosc2_checked_mul_i32_nonneg(array->chunknitems, array->chunkshape[i], &array->chunknitems) ||
  ------------------
  |  Branch (205:9): [True: 0, False: 226k]
  ------------------
  206|   226k|        !blosc2_checked_mul_i32_nonneg(array->blocknitems, array->blockshape[i], &array->blocknitems)) {
  ------------------
  |  Branch (206:9): [True: 0, False: 226k]
  ------------------
  207|      0|      BLOSC_TRACE_ERROR("shape, chunkshape or blockshape product overflows at dimension %d", i);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  208|      0|      return BLOSC2_ERROR_INVALID_PARAM;
  209|      0|    }
  210|   226k|  }
  211|       |
  212|       |  // Compute strides
  213|  14.1k|  if (ndim > 0) {
  ------------------
  |  Branch (213:7): [True: 14.1k, False: 0]
  ------------------
  214|  14.1k|    array->item_array_strides[ndim - 1] = 1;
  215|  14.1k|    array->item_extchunk_strides[ndim - 1] = 1;
  216|  14.1k|    array->item_chunk_strides[ndim - 1] = 1;
  217|  14.1k|    array->item_block_strides[ndim - 1] = 1;
  218|  14.1k|    array->block_chunk_strides[ndim - 1] = 1;
  219|  14.1k|    array->chunk_array_strides[ndim - 1] = 1;
  220|  14.1k|  }
  221|  52.9k|  for (int i = ndim - 2; i >= 0; --i) {
  ------------------
  |  Branch (221:26): [True: 38.7k, False: 14.1k]
  ------------------
  222|       |    // Treat (chunkshape[i+1] == 0) the same as (shape[i+1] == 0):  the
  223|       |    // dimension carries no actual chunking and any stride into it is moot.
  224|       |    // validate_shape_chunkshape_blockshape allows the chunkshape==0
  225|       |    // combination (paired with blockshape==0) as a placeholder for empty
  226|       |    // contexts (see example_empty_shape.c).  Without this guard a crafted
  227|       |    // b2nd metalayer with shape[i+1]>0 but chunkshape[i+1]==blockshape[i+1]==0
  228|       |    // -- accepted by the validator -- reaches the (extchunkshape / blockshape)
  229|       |    // division below as 0/0, which is undefined behaviour and aborts the
  230|       |    // process with SIGFPE on x86.  Crafted cframes loaded via b2nd_from_schunk
  231|       |    // / b2nd_open / b2nd_from_cframe would otherwise crash any consumer.
  232|  38.7k|    if (shape[i + 1] != 0 && array->chunkshape[i + 1] != 0 &&
  ------------------
  |  Branch (232:9): [True: 33.6k, False: 5.11k]
  |  Branch (232:30): [True: 33.6k, False: 0]
  ------------------
  233|  33.6k|        array->blockshape[i + 1] != 0) {
  ------------------
  |  Branch (233:9): [True: 33.6k, False: 0]
  ------------------
  234|  33.6k|      if (!blosc2_checked_mul_i64_nonneg(array->item_array_strides[i + 1], array->shape[i + 1],
  ------------------
  |  Branch (234:11): [True: 0, False: 33.6k]
  ------------------
  235|  33.6k|                                         &array->item_array_strides[i]) ||
  236|  33.6k|          !blosc2_checked_mul_i64_nonneg(array->item_extchunk_strides[i + 1], array->extchunkshape[i + 1],
  ------------------
  |  Branch (236:11): [True: 0, False: 33.6k]
  ------------------
  237|  33.6k|                                         &array->item_extchunk_strides[i]) ||
  238|  33.6k|          !blosc2_checked_mul_i64_nonneg(array->item_chunk_strides[i + 1], array->chunkshape[i + 1],
  ------------------
  |  Branch (238:11): [True: 0, False: 33.6k]
  ------------------
  239|  33.6k|                                         &array->item_chunk_strides[i]) ||
  240|  33.6k|          !blosc2_checked_mul_i64_nonneg(array->item_block_strides[i + 1], array->blockshape[i + 1],
  ------------------
  |  Branch (240:11): [True: 0, False: 33.6k]
  ------------------
  241|  33.6k|                                         &array->item_block_strides[i]) ||
  242|  33.6k|          !blosc2_checked_mul_i64_nonneg(array->block_chunk_strides[i + 1],
  ------------------
  |  Branch (242:11): [True: 0, False: 33.6k]
  ------------------
  243|  33.6k|                                         array->extchunkshape[i + 1] / array->blockshape[i + 1],
  244|  33.6k|                                         &array->block_chunk_strides[i])) {
  245|      0|        BLOSC_TRACE_ERROR("Dimension stride overflow in array shape");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|      0|        return BLOSC2_ERROR_INVALID_PARAM;
  247|      0|      }
  248|       |      // Unused here, and this product can overflow for large (or damaged)
  249|       |      // shapes: 0 then, as for an empty dimension
  250|  33.6k|      int64_t extent;
  251|  33.6k|      if (!blosc2_checked_mul_i64_nonneg(array->extshape[i + 1], array->chunkshape[i + 1], &extent) ||
  ------------------
  |  Branch (251:11): [True: 0, False: 33.6k]
  ------------------
  252|  33.6k|          !blosc2_checked_mul_i64_nonneg(array->chunk_array_strides[i + 1], extent,
  ------------------
  |  Branch (252:11): [True: 0, False: 33.6k]
  ------------------
  253|  33.6k|                                         &array->chunk_array_strides[i])) {
  254|      0|        array->chunk_array_strides[i] = 0;
  255|      0|      }
  256|  33.6k|    } else {
  257|  5.11k|      array->item_array_strides[i] = 0;
  258|  5.11k|      array->item_extchunk_strides[i] = 0;
  259|  5.11k|      array->item_chunk_strides[i] = 0;
  260|  5.11k|      array->item_block_strides[i] = 0;
  261|  5.11k|      array->block_chunk_strides[i] = 0;
  262|  5.11k|      array->chunk_array_strides[i] = 0;
  263|  5.11k|    }
  264|  38.7k|  }
  265|  14.1k|  return BLOSC2_ERROR_SUCCESS;
  266|  14.1k|}
b2nd.c:publish_shape_meta:
  270|  11.3k|static int publish_shape_meta(b2nd_array_t *array) {
  271|  11.3k|  if (!array->sc) {
  ------------------
  |  Branch (271:7): [True: 10.0k, False: 1.33k]
  ------------------
  272|  10.0k|    return BLOSC2_ERROR_SUCCESS;
  273|  10.0k|  }
  274|  1.33k|  uint8_t *smeta = NULL;
  275|       |  // Serialize the dimension info ...
  276|  1.33k|  int32_t smeta_len =
  277|  1.33k|          b2nd_serialize_meta(array->ndim, array->shape, array->chunkshape, array->blockshape,
  278|  1.33k|                              array->dtype, array->dtype_format, &smeta);
  279|  1.33k|  if (smeta_len < 0) {
  ------------------
  |  Branch (279:7): [True: 0, False: 1.33k]
  ------------------
  280|      0|    BLOSC_TRACE_ERROR("Error during serializing dims info for Blosc2 NDim");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  281|      0|    BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  282|      0|  }
  283|       |  // ... and update it in its metalayer
  284|  1.33k|  if (blosc2_meta_exists(array->sc, "b2nd") < 0) {
  ------------------
  |  Branch (284:7): [True: 0, False: 1.33k]
  ------------------
  285|      0|    if (blosc2_meta_add(array->sc, "b2nd", smeta, smeta_len) < 0) {
  ------------------
  |  Branch (285:9): [True: 0, False: 0]
  ------------------
  286|      0|      BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  287|      0|    }
  288|  1.33k|  } else {
  289|  1.33k|    if (blosc2_meta_update(array->sc, "b2nd", smeta, smeta_len) < 0) {
  ------------------
  |  Branch (289:9): [True: 0, False: 1.33k]
  ------------------
  290|      0|      BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  291|      0|    }
  292|  1.33k|  }
  293|  1.33k|  free(smeta);
  294|       |  // The meta mutation bumped the schunk change tick; this struct is in sync
  295|  1.33k|  array->last_tick = array->sc->change_tick;
  296|       |
  297|  1.33k|  return BLOSC2_ERROR_SUCCESS;
  298|  1.33k|}
b2nd.c:refresh_if_stale:
  313|   113k|static int refresh_if_stale(b2nd_array_t *array) {
  314|   113k|  blosc2_schunk *sc = array->sc;
  315|   113k|  if (sc == NULL || sc->frame == NULL) {
  ------------------
  |  Branch (315:7): [True: 0, False: 113k]
  |  Branch (315:21): [True: 0, False: 113k]
  ------------------
  316|      0|    return BLOSC2_ERROR_SUCCESS;
  317|      0|  }
  318|   113k|  BLOSC_ERROR(frame_check_stale((blosc2_frame_s *) sc->frame));
  ------------------
  |  |  111|   113k|    do {                                            \
  |  |  112|   113k|        int rc_ = (rc);                             \
  |  |  113|   113k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 113k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|   113k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 113k]
  |  |  ------------------
  ------------------
  319|   113k|  if (array->last_tick == sc->change_tick) {
  ------------------
  |  Branch (319:7): [True: 110k, False: 2.82k]
  ------------------
  320|   110k|    return BLOSC2_ERROR_SUCCESS;
  321|   110k|  }
  322|       |
  323|  2.82k|  uint8_t *smeta;
  324|  2.82k|  int32_t smeta_len;
  325|  2.82k|  if (blosc2_meta_get(sc, "b2nd", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (325:7): [True: 0, False: 2.82k]
  ------------------
  326|      0|    if (blosc2_meta_get(sc, "caterva", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (326:9): [True: 0, False: 0]
  ------------------
  327|       |      // blosc2_meta_get() itself is a pure in-memory lookup on
  328|       |      // schunk->metalayers[], but that array was just repopulated by
  329|       |      // frame_check_stale() -> frame_refresh_if_stale() -> frame_get_metalayers(),
  330|       |      // which does its *own*, fully independent disk read (its own fresh
  331|       |      // get_header_info() + header re-read, frame.c) -- separate from both
  332|       |      // frame_check_stale()'s header read and the trailer read a few lines
  333|       |      // up in this same call chain. Without locking, nothing holds these
  334|       |      // reads together atomically, so this one can catch the header mid
  335|       |      // rewrite just as easily as the other two; a b2nd array always has
  336|       |      // one of these two metalayers from creation, so a miss here reflects
  337|       |      // that specific read landing in a torn window, not a genuine
  338|       |      // absence. Same opportunistic treatment as those reads: keep the
  339|       |      // cached view and let the next poll (its own fresh, independent read)
  340|       |      // resolve it, instead of hard-erroring on what is normally transient.
  341|      0|      return BLOSC2_ERROR_SUCCESS;
  342|      0|    }
  343|      0|  }
  344|  2.82k|  int8_t ndim;
  345|  2.82k|  int64_t shape[B2ND_MAX_DIM];
  346|  2.82k|  int32_t chunkshape[B2ND_MAX_DIM];
  347|  2.82k|  int32_t blockshape[B2ND_MAX_DIM];
  348|  2.82k|  char *dtype;
  349|  2.82k|  int8_t dtype_format;
  350|  2.82k|  int rc = b2nd_deserialize_meta(smeta, smeta_len, &ndim, shape, chunkshape, blockshape,
  351|  2.82k|                                 &dtype, &dtype_format);
  352|  2.82k|  free(smeta);
  353|  2.82k|  BLOSC_ERROR(rc);
  ------------------
  |  |  111|  2.82k|    do {                                            \
  |  |  112|  2.82k|        int rc_ = (rc);                             \
  |  |  113|  2.82k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 2.82k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  2.82k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 2.82k]
  |  |  ------------------
  ------------------
  354|  2.82k|  free(dtype);
  355|       |
  356|       |  // Shape-only SWMR scope (matching HDF5): chunk/block geometry or ndim
  357|       |  // changing under a live handle is a misuse of the single-writer contract,
  358|       |  // not something to follow silently.
  359|  2.82k|  if (ndim != array->ndim ||
  ------------------
  |  Branch (359:7): [True: 0, False: 2.82k]
  ------------------
  360|  2.82k|      memcmp(chunkshape, array->chunkshape, ndim * sizeof(int32_t)) != 0 ||
  ------------------
  |  Branch (360:7): [True: 0, False: 2.82k]
  ------------------
  361|  2.82k|      memcmp(blockshape, array->blockshape, ndim * sizeof(int32_t)) != 0) {
  ------------------
  |  Branch (361:7): [True: 0, False: 2.82k]
  ------------------
  362|      0|    BLOSC_TRACE_ERROR("ndim/chunkshape/blockshape changed behind this handle; "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  363|      0|                      "only shape changes are followed");
  364|      0|    BLOSC_ERROR(BLOSC2_ERROR_DATA);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  365|      0|  }
  366|       |
  367|  2.82k|  BLOSC_ERROR(update_shape_struct(array, ndim, shape, chunkshape, blockshape));
  ------------------
  |  |  111|  2.82k|    do {                                            \
  |  |  112|  2.82k|        int rc_ = (rc);                             \
  |  |  113|  2.82k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 2.82k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  2.82k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 2.82k]
  |  |  ------------------
  ------------------
  368|  2.82k|  array->last_tick = sc->change_tick;
  369|       |
  370|  2.82k|  return 1;
  371|  2.82k|}
b2nd.c:check_schunk_matches_meta:
  620|  1.47k|static int check_schunk_matches_meta(const blosc2_schunk *schunk, const b2nd_array_t *array) {
  621|       |  // Every chunk the shape covers exists: arrays are created with all of them,
  622|       |  // and resizes add chunks before they publish a larger shape.  More are fine.
  623|  1.47k|  int64_t needed_nchunks = array->chunknitems == 0 ? 0 : array->extnitems / array->chunknitems;
  ------------------
  |  Branch (623:28): [True: 0, False: 1.47k]
  ------------------
  624|  1.47k|  if (schunk->nchunks < needed_nchunks) {
  ------------------
  |  Branch (624:7): [True: 0, False: 1.47k]
  ------------------
  625|      0|    BLOSC_TRACE_ERROR("The b2nd shape needs %" PRId64 " chunks, but the super-chunk holds %" PRId64,
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  626|      0|                      needed_nchunks, schunk->nchunks);
  627|      0|    return BLOSC2_ERROR_INVALID_HEADER;
  628|      0|  }
  629|       |  // The chunks hold the chunk shape (padded to whole blocks) in typesize items;
  630|       |  // a super-chunk without chunks or with chunks of varying size (<= 0) says nothing
  631|  1.47k|  int64_t chunkbytes;
  632|  1.47k|  if (schunk->nchunks > 0 && schunk->chunksize > 0 &&
  ------------------
  |  Branch (632:7): [True: 1.46k, False: 6]
  |  Branch (632:30): [True: 1.46k, False: 0]
  ------------------
  633|  1.46k|      (!blosc2_checked_mul_i64_nonneg(array->extchunknitems, schunk->typesize, &chunkbytes) ||
  ------------------
  |  Branch (633:8): [True: 0, False: 1.46k]
  ------------------
  634|  1.46k|       chunkbytes != schunk->chunksize)) {
  ------------------
  |  Branch (634:8): [True: 0, False: 1.46k]
  ------------------
  635|      0|    BLOSC_TRACE_ERROR("The b2nd chunk shape with typesize %d does not make the %d-byte chunks of the super-chunk",
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  636|      0|                      schunk->typesize, schunk->chunksize);
  637|      0|    return BLOSC2_ERROR_INVALID_HEADER;
  638|      0|  }
  639|  1.47k|  return BLOSC2_ERROR_SUCCESS;
  640|  1.47k|}
b2nd.c:buffer_wants_prefault:
 1216|  4.46k|static bool buffer_wants_prefault(const uint8_t *buffer, int64_t nbytes, int nthreads) {
 1217|  4.46k|#if defined(__linux__)
 1218|       |  // A huge page is 2 MB with 4 KB pages; other page sizes are not probed
 1219|  4.46k|  enum { huge_page = 2 << 20, small_page = 4096, npages = huge_page / small_page };
 1220|  4.46k|  if (nthreads < 2 || nbytes < 2 * huge_page || sysconf(_SC_PAGESIZE) != small_page) {
  ------------------
  |  Branch (1220:7): [True: 4.46k, False: 0]
  |  Branch (1220:23): [True: 0, False: 0]
  |  Branch (1220:49): [True: 0, False: 0]
  ------------------
 1221|  4.46k|    return false;
 1222|  4.46k|  }
 1223|       |  // The aligned huge page around the middle lies inside a buffer of 4 MB or more,
 1224|       |  // away from its first page, where malloc writes its chunk header
 1225|      0|  uint8_t *block = (uint8_t *) (((uintptr_t) buffer + (uintptr_t) (nbytes / 2)) & ~(uintptr_t) (huge_page - 1));
 1226|      0|  unsigned char resident[npages];
 1227|      0|  if (mincore(block, huge_page, resident) != 0) {
  ------------------
  |  Branch (1227:7): [True: 0, False: 0]
  ------------------
 1228|      0|    return false;
 1229|      0|  }
 1230|      0|  for (int i = 0; i < npages; i++) {
  ------------------
  |  Branch (1230:19): [True: 0, False: 0]
  ------------------
 1231|      0|    if (resident[i] & 1) {
  ------------------
  |  Branch (1231:9): [True: 0, False: 0]
  ------------------
 1232|      0|      return false;
 1233|      0|    }
 1234|      0|  }
 1235|       |  // Fault in one page as a write would, and see whether the whole huge page came
 1236|       |  // with it (best effort: kernels before 5.14 cannot, and then nothing is prefaulted)
 1237|      0|  if (madvise(block + huge_page / 2, small_page, MADV_POPULATE_WRITE) != 0 ||
  ------------------
  |  Branch (1237:7): [True: 0, False: 0]
  ------------------
 1238|      0|      mincore(block, huge_page, resident) != 0) {
  ------------------
  |  Branch (1238:7): [True: 0, False: 0]
  ------------------
 1239|      0|    return false;
 1240|      0|  }
 1241|      0|  for (int i = 0; i < npages; i++) {
  ------------------
  |  Branch (1241:19): [True: 0, False: 0]
  ------------------
 1242|      0|    if ((resident[i] & 1) == 0) {
  ------------------
  |  Branch (1242:9): [True: 0, False: 0]
  ------------------
 1243|      0|      return false;
 1244|      0|    }
 1245|      0|  }
 1246|      0|  return true;
 1247|       |#else
 1248|       |  BLOSC_UNUSED_PARAM(buffer);
 1249|       |  BLOSC_UNUSED_PARAM(nbytes);
 1250|       |  BLOSC_UNUSED_PARAM(nthreads);
 1251|       |  return false;
 1252|       |#endif
 1253|      0|}
b2nd.c:chunk_blocks_in_c_order:
 1078|  70.4k|static bool chunk_blocks_in_c_order(const b2nd_array_t *array) {
 1079|  70.4k|  int k = 0;
 1080|   164k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (1080:19): [True: 135k, False: 28.4k]
  ------------------
 1081|   135k|    if (array->chunkshape[i] % array->blockshape[i] != 0) {
  ------------------
  |  Branch (1081:9): [True: 41.5k, False: 94.0k]
  ------------------
 1082|  41.5k|      return false;
 1083|  41.5k|    }
 1084|  94.0k|    if (i > k && array->chunkshape[i] != array->blockshape[i]) {
  ------------------
  |  Branch (1084:9): [True: 9.29k, False: 84.8k]
  |  Branch (1084:18): [True: 464, False: 8.83k]
  ------------------
 1085|    464|      return false;
 1086|    464|    }
 1087|  93.6k|    if (i == k && array->blockshape[i] == 1) {
  ------------------
  |  Branch (1087:9): [True: 84.8k, False: 8.83k]
  |  Branch (1087:19): [True: 79.9k, False: 4.80k]
  ------------------
 1088|  79.9k|      k++;
 1089|  79.9k|    }
 1090|  93.6k|  }
 1091|  28.4k|  return true;
 1092|  70.4k|}
b2nd.c:prefetch_slice:
 1458|  23.3k|static prefetch_batch* prefetch_slice(const b2nd_array_t *array, const int64_t *start, const int64_t *stop) {
 1459|  23.3k|  blosc2_frame_s *frame = (blosc2_frame_s *) array->sc->frame;
 1460|  23.3k|  if (!prefetch_applies(frame)) {
  ------------------
  |  Branch (1460:7): [True: 23.3k, False: 0]
  ------------------
 1461|  23.3k|    return NULL;
 1462|  23.3k|  }
 1463|      0|  int8_t ndim = array->ndim;
 1464|      0|  int64_t nblocks = array->blocknitems > 0 ? array->extchunknitems / array->blocknitems : 0;
  ------------------
  |  Branch (1464:21): [True: 0, False: 0]
  ------------------
 1465|      0|  int64_t *nchunks = NULL;
 1466|      0|  int64_t n = b2nd_get_slice_nchunks(array, start, stop, &nchunks);
 1467|      0|  int64_t chunk_start[B2ND_MAX_DIM];
 1468|      0|  int64_t chunk_stop[B2ND_MAX_DIM];
 1469|      0|  int64_t npartial = 0;
 1470|      0|  for (int64_t c = 0; c < n && nblocks > 0; ++c) {
  ------------------
  |  Branch (1470:23): [True: 0, False: 0]
  |  Branch (1470:32): [True: 0, False: 0]
  ------------------
 1471|      0|    npartial += chunk_box(array, nchunks[c], start, stop, chunk_start, chunk_stop);
 1472|      0|  }
 1473|       |  // One maskout per chunk covered in part (NULL for a chunk read whole), all in one allocation
 1474|      0|  const bool **maskouts = NULL;
 1475|      0|  if (npartial > 0) {
  ------------------
  |  Branch (1475:7): [True: 0, False: 0]
  ------------------
 1476|      0|    maskouts = calloc(1, n * sizeof(bool *) + npartial * nblocks * sizeof(bool));
 1477|      0|  }
 1478|      0|  if (maskouts != NULL) {
  ------------------
  |  Branch (1478:7): [True: 0, False: 0]
  ------------------
 1479|      0|    bool *row = (bool *) (maskouts + n);
 1480|      0|    int64_t blocks_in_chunk[B2ND_MAX_DIM];
 1481|      0|    int64_t blockshape[B2ND_MAX_DIM];
 1482|      0|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1482:21): [True: 0, False: 0]
  ------------------
 1483|      0|      blocks_in_chunk[i] = array->extchunkshape[i] / array->blockshape[i];
 1484|      0|      blockshape[i] = array->blockshape[i];
 1485|      0|    }
 1486|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(array->sc->storage->io->id);
 1487|      0|    bool mapped = io_cb != NULL && !io_cb->is_allocation_necessary;
  ------------------
  |  Branch (1487:19): [True: 0, False: 0]
  |  Branch (1487:36): [True: 0, False: 0]
  ------------------
 1488|      0|    bool has_delta = filters_contain(array->sc->filters, BLOSC_DELTA);
 1489|      0|    slice_chunk_t slice_chunk;
 1490|      0|    memset(&slice_chunk, 0, sizeof(slice_chunk));
 1491|      0|    slice_chunk.array = array;
 1492|      0|    slice_chunk.start = start;
 1493|      0|    slice_chunk.stop = stop;
 1494|      0|    slice_chunk.chunk_start = chunk_start;
 1495|      0|    slice_chunk.chunk_stop = chunk_stop;
 1496|      0|    slice_chunk.blocks_in_chunk = blocks_in_chunk;
 1497|      0|    slice_chunk.blockshape = blockshape;
 1498|      0|    for (int64_t c = 0; c < n; ++c) {
  ------------------
  |  Branch (1498:25): [True: 0, False: 0]
  ------------------
 1499|      0|      if (!chunk_box(array, nchunks[c], start, stop, chunk_start, chunk_stop)) {
  ------------------
  |  Branch (1499:11): [True: 0, False: 0]
  ------------------
 1500|      0|        continue;  // read whole
 1501|      0|      }
 1502|      0|      int64_t nneeded = slice_chunk_maskout(&slice_chunk, nblocks, has_delta, row);
 1503|      0|      if (mapped || slice_chunk_compact(array, nneeded, has_delta)) {
  ------------------
  |  Branch (1503:11): [True: 0, False: 0]
  |  Branch (1503:21): [True: 0, False: 0]
  ------------------
 1504|      0|        maskouts[c] = row;
 1505|      0|        row += nblocks;
 1506|      0|      }
 1507|      0|    }
 1508|      0|  }
 1509|      0|  prefetch_batch *batch = prefetch_batch_new(frame, nchunks, n, maskouts, nblocks);
 1510|      0|  free(maskouts);
 1511|      0|  free(nchunks);
 1512|      0|  return batch;
 1513|  23.3k|}
b2nd.c:chunks_special:
 1520|  2.38k|static int chunks_special(blosc2_schunk *sc, const int64_t *nchunks, int64_t n, uint8_t *special) {
 1521|  2.38k|  if (sc->frame != NULL) {
  ------------------
  |  Branch (1521:7): [True: 2.38k, False: 0]
  ------------------
 1522|  2.38k|    return frame_get_chunks_special((blosc2_frame_s *) sc->frame, nchunks, n, special);
 1523|  2.38k|  }
 1524|      0|  for (int64_t k = 0; k < n; ++k) {
  ------------------
  |  Branch (1524:23): [True: 0, False: 0]
  ------------------
 1525|      0|    if (nchunks[k] < 0 || nchunks[k] >= sc->nchunks || sc->data[nchunks[k]] == NULL) {
  ------------------
  |  Branch (1525:9): [True: 0, False: 0]
  |  Branch (1525:27): [True: 0, False: 0]
  |  Branch (1525:56): [True: 0, False: 0]
  ------------------
 1526|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 1527|      0|    }
 1528|      0|    const uint8_t *chunk = sc->data[nchunks[k]];
 1529|      0|    special[k] = (uint8_t) chunk_special_in_offset(chunk, sw32_(chunk + BLOSC2_CHUNK_CBYTES));
 1530|      0|  }
 1531|      0|  return BLOSC2_ERROR_SUCCESS;
 1532|      0|}
b2nd.c:chunk_box:
 1436|   112k|                      int64_t *chunk_start, int64_t *chunk_stop) {
 1437|   112k|  int64_t chunks_in_array[B2ND_MAX_DIM];
 1438|   112k|  int64_t nchunk_ndim[B2ND_MAX_DIM];
 1439|   507k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (1439:19): [True: 394k, False: 112k]
  ------------------
 1440|   394k|    chunks_in_array[i] = array->extshape[i] / array->chunkshape[i];
 1441|   394k|  }
 1442|   112k|  blosc2_unidim_to_multidim(array->ndim, chunks_in_array, nchunk, nchunk_ndim);
 1443|   112k|  bool partial = false;
 1444|   507k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (1444:19): [True: 394k, False: 112k]
  ------------------
 1445|   394k|    chunk_start[i] = nchunk_ndim[i] * array->chunkshape[i];
 1446|   394k|    chunk_stop[i] = chunk_start[i] + array->chunkshape[i] < array->shape[i] ?
  ------------------
  |  Branch (1446:21): [True: 131k, False: 263k]
  ------------------
 1447|   263k|                    chunk_start[i] + array->chunkshape[i] : array->shape[i];
 1448|   394k|    partial |= start[i] > chunk_start[i] || stop[i] < chunk_stop[i];
  ------------------
  |  Branch (1448:16): [True: 1.13k, False: 393k]
  |  Branch (1448:45): [True: 710, False: 392k]
  ------------------
 1449|   394k|  }
 1450|   112k|  return partial;
 1451|   112k|}
b2nd.c:chunk_slice_box:
 1194|  1.17M|                               int64_t *box_stop) {
 1195|  1.17M|  int64_t nitems = 1;
 1196|  6.11M|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1196:19): [True: 4.93M, False: 1.17M]
  ------------------
 1197|  4.93M|    box_start[i] = (chunk_start[i] > start[i] ? chunk_start[i] : start[i]) - start[i];
  ------------------
  |  Branch (1197:21): [True: 1.29M, False: 3.64M]
  ------------------
 1198|  4.93M|    box_stop[i] = (chunk_stop[i] < stop[i] ? chunk_stop[i] : stop[i]) - start[i];
  ------------------
  |  Branch (1198:20): [True: 1.30M, False: 3.63M]
  ------------------
 1199|  4.93M|    nitems *= box_stop[i] - box_start[i];
 1200|  4.93M|  }
 1201|  1.17M|  return nitems;
 1202|  1.17M|}
b2nd.c:chunk_contiguous_in_buffer:
 1100|  88.2k|                                       const int64_t *shape, int64_t *offset) {
 1101|       |  // Leading dims where the chunk is one item wide can sit anywhere; past the
 1102|       |  // first wider dim the chunk has to span the buffer.
 1103|  88.2k|  bool must_span = false;
 1104|  88.2k|  int64_t off = 0;
 1105|   276k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (1105:19): [True: 223k, False: 52.8k]
  ------------------
 1106|   223k|    int64_t extent = array->chunkshape[i];
 1107|   223k|    if (chunk_start[i] < start[i] || chunk_start[i] + extent > stop[i] ||
  ------------------
  |  Branch (1107:9): [True: 782, False: 223k]
  |  Branch (1107:38): [True: 34.2k, False: 188k]
  ------------------
 1108|   188k|        chunk_start[i] + extent > array->shape[i]) {
  ------------------
  |  Branch (1108:9): [True: 45, False: 188k]
  ------------------
 1109|  35.0k|      return false;
 1110|  35.0k|    }
 1111|   188k|    if (must_span && extent != shape[i]) {
  ------------------
  |  Branch (1111:9): [True: 393, False: 188k]
  |  Branch (1111:22): [True: 292, False: 101]
  ------------------
 1112|    292|      return false;
 1113|    292|    }
 1114|   188k|    if (extent > 1) {
  ------------------
  |  Branch (1114:9): [True: 9.39k, False: 179k]
  ------------------
 1115|  9.39k|      must_span = true;
 1116|  9.39k|    }
 1117|   188k|    off = off * shape[i] + (chunk_start[i] - start[i]);
 1118|   188k|  }
 1119|  52.8k|  *offset = off * array->sc->typesize;
 1120|       |  return true;
 1121|  88.2k|}
b2nd.c:compress_update_chunk:
 1359|   608k|                                 int32_t nbytes, slice_chunk_t *gather) {
 1360|   608k|  int32_t chunk_nbytes = nbytes + BLOSC2_MAX_OVERHEAD;
 1361|   608k|  size_t chunk_capacity;
 1362|   608k|  uint8_t *chunk = scratch_malloc(array, chunk_nbytes, &chunk_capacity);
 1363|   608k|  BLOSC_ERROR_NULL(chunk, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|   608k|    do {                                            \
  |  |  105|   608k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 608k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|   608k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 608k]
  |  |  ------------------
  ------------------
 1364|       |  // Update current_chunk in case a prefilter is applied
 1365|   608k|  array->sc->current_nchunk = nchunk;
 1366|   608k|  blosc2_context *cctx = array->sc->cctx;
 1367|   608k|  blosc2_prefilter_params params;
 1368|   608k|  blosc2_prefilter_params *saved_preparams = cctx->preparams;
 1369|   608k|  bool saved_full_write = cctx->prefilter_full_write;
 1370|   608k|  if (gather != NULL) {
  ------------------
  |  Branch (1370:7): [True: 563k, False: 44.0k]
  ------------------
 1371|   563k|    memset(&params, 0, sizeof(params));
 1372|   563k|    params.user_data = gather;
 1373|   563k|    cctx->prefilter = slice_gather_prefilter;
 1374|   563k|    cctx->preparams = &params;
 1375|       |    /* The gather callback copies old contents or clears partial/padding blocks;
 1376|       |     * a whole-block slice copy needs no preliminary memset. */
 1377|   563k|    cctx->prefilter_full_write = true;
 1378|   563k|  }
 1379|   608k|  int brc = blosc2_compress_ctx(cctx, src, nbytes, chunk, chunk_nbytes);
 1380|   608k|  if (gather != NULL) {
  ------------------
  |  Branch (1380:7): [True: 563k, False: 44.0k]
  ------------------
 1381|   563k|    cctx->prefilter = NULL;
 1382|   563k|    cctx->preparams = saved_preparams;
 1383|   563k|    cctx->prefilter_full_write = saved_full_write;
 1384|   563k|  }
 1385|   608k|  if (brc < 0) {
  ------------------
  |  Branch (1385:7): [True: 0, False: 608k]
  ------------------
 1386|      0|    blosc2_tmp_free(chunk, chunk_capacity);
 1387|      0|    BLOSC_TRACE_ERROR("Blosc can not compress the data");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1388|      0|    return BLOSC2_ERROR_FAILURE;
 1389|      0|  }
 1390|       |  // A frame stores its own copy of the chunk, so it is lent a reused buffer; an
 1391|       |  // in-memory super-chunk keeps the buffer itself
 1392|   608k|  bool in_frame = array->sc->frame != NULL;
 1393|   608k|  int64_t brc_ = in_frame ? schunk_update_chunk_lent(array->sc, nchunk, chunk)
  ------------------
  |  Branch (1393:18): [True: 608k, False: 0]
  ------------------
 1394|   608k|                          : blosc2_schunk_update_chunk(array->sc, nchunk, chunk, false);
 1395|   608k|  if (in_frame || brc_ < 0) {
  ------------------
  |  Branch (1395:7): [True: 608k, False: 0]
  |  Branch (1395:19): [True: 0, False: 0]
  ------------------
 1396|       |    // A failed update leaves the chunk to us
 1397|   608k|    blosc2_tmp_free(chunk, chunk_capacity);
 1398|   608k|  }
 1399|   608k|  if (brc_ < 0) {
  ------------------
  |  Branch (1399:7): [True: 20, False: 608k]
  ------------------
 1400|     20|    BLOSC_TRACE_ERROR("Blosc can not update the chunk");
  ------------------
  |  |   93|     20|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     20|    do {                                            \
  |  |  |  |   98|     20|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     20|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     20|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1401|     20|    return BLOSC2_ERROR_FAILURE;
 1402|     20|  }
 1403|   608k|  return BLOSC2_ERROR_SUCCESS;
 1404|   608k|}
b2nd.c:slice_gather_prefilter:
 1322|  6.10M|static int slice_gather_prefilter(blosc2_prefilter_params *params) {
 1323|  6.10M|  const slice_chunk_t *c = params->user_data;
 1324|  6.10M|  const b2nd_array_t *array = c->array;
 1325|  6.10M|  int8_t ndim = array->ndim;
 1326|  6.10M|  int32_t typesize = array->sc->typesize;
 1327|  6.10M|  if (params->output_size != array->blocknitems * typesize) {
  ------------------
  |  Branch (1327:7): [True: 0, False: 6.10M]
  ------------------
 1328|      0|    BLOSC_TRACE_ERROR("Unexpected block size in b2nd chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1329|      0|    return BLOSC2_ERROR_FAILURE;
 1330|      0|  }
 1331|  6.10M|  block_overlap_t overlap;
 1332|  6.10M|  bool overlaps = block_slice_overlap(c, params->nblock, &overlap);
 1333|  6.10M|  if (!(overlaps && overlap.whole_block)) {
  ------------------
  |  Branch (1333:9): [True: 600k, False: 5.50M]
  |  Branch (1333:21): [True: 9.30k, False: 590k]
  ------------------
 1334|  6.09M|    if (c->keep_old) {
  ------------------
  |  Branch (1334:9): [True: 3.99k, False: 6.09M]
  ------------------
 1335|  3.99k|      memcpy(params->output, params->input, (size_t) params->output_size);
 1336|  6.09M|    } else {
 1337|  6.09M|      memset(params->output, 0, (size_t) params->output_size);
 1338|  6.09M|    }
 1339|  6.09M|  }
 1340|  6.10M|  if (!overlaps) {
  ------------------
  |  Branch (1340:7): [True: 5.50M, False: 600k]
  ------------------
 1341|  5.50M|    return 0;
 1342|  5.50M|  }
 1343|   600k|  return b2nd_copy_buffer2(ndim, typesize, c->buffer, c->buffershape, overlap.dst_start,
 1344|   600k|                           overlap.dst_stop, params->output, c->blockshape, overlap.src_start);
 1345|  6.10M|}
b2nd.c:decoded_nothing:
 1314|   102k|static bool decoded_nothing(const blosc2_context *dctx, int rc) {
 1315|   102k|  return rc == 0 || (dctx->special_type == BLOSC2_SPECIAL_UNINIT && dctx->postfilter == NULL);
  ------------------
  |  Branch (1315:10): [True: 0, False: 102k]
  |  Branch (1315:22): [True: 0, False: 102k]
  |  Branch (1315:69): [True: 0, False: 0]
  ------------------
 1316|   102k|}
b2nd.c:scratch_malloc:
 1350|   634k|static uint8_t *scratch_malloc(const b2nd_array_t *array, int32_t nbytes, size_t *capacity) {
 1351|   634k|  return schunk_scratch_malloc(array->sc, nbytes, capacity);
 1352|   634k|}
b2nd.c:block_slice_overlap:
 1159|  15.1M|static bool block_slice_overlap(const slice_chunk_t *c, int64_t nblock, block_overlap_t *overlap) {
 1160|  15.1M|  int8_t ndim = c->array->ndim;
 1161|  15.1M|  int64_t nblock_ndim[B2ND_MAX_DIM] = {0};
 1162|  15.1M|  blosc2_unidim_to_multidim(ndim, (int64_t *) c->blocks_in_chunk, nblock, nblock_ndim);
 1163|  15.1M|  bool whole_block = true;
 1164|  42.9M|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1164:19): [True: 41.2M, False: 1.67M]
  ------------------
 1165|  41.2M|    int64_t block_start = c->chunk_start[i] + nblock_ndim[i] * c->blockshape[i];
 1166|  41.2M|    int64_t block_stop = block_start + c->blockshape[i];
 1167|  41.2M|    if (block_stop > c->chunk_stop[i]) {
  ------------------
  |  Branch (1167:9): [True: 22.9M, False: 18.2M]
  ------------------
 1168|  22.9M|      block_stop = c->chunk_stop[i];
 1169|  22.9M|    }
 1170|  41.2M|    int64_t lo = block_start > c->start[i] ? block_start : c->start[i];
  ------------------
  |  Branch (1170:18): [True: 28.7M, False: 12.5M]
  ------------------
 1171|  41.2M|    int64_t hi = block_stop < c->stop[i] ? block_stop : c->stop[i];
  ------------------
  |  Branch (1171:18): [True: 15.8M, False: 25.3M]
  ------------------
 1172|  41.2M|    if (lo >= hi) {
  ------------------
  |  Branch (1172:9): [True: 13.5M, False: 27.7M]
  ------------------
 1173|  13.5M|      return false;
 1174|  13.5M|    }
 1175|  27.7M|    whole_block &= lo == block_start && hi == block_start + c->blockshape[i];
  ------------------
  |  Branch (1175:20): [True: 27.6M, False: 79.8k]
  |  Branch (1175:41): [True: 18.1M, False: 9.55M]
  ------------------
 1176|  27.7M|    if (overlap != NULL) {
  ------------------
  |  Branch (1176:9): [True: 18.4M, False: 9.27M]
  ------------------
 1177|  18.4M|      overlap->src_start[i] = lo - block_start;
 1178|  18.4M|      overlap->src_stop[i] = hi - block_start;
 1179|  18.4M|      overlap->dst_start[i] = lo - c->start[i];
 1180|  18.4M|      overlap->dst_stop[i] = hi - c->start[i];
 1181|  18.4M|    }
 1182|  27.7M|  }
 1183|  1.67M|  if (overlap != NULL) {
  ------------------
  |  Branch (1183:7): [True: 1.14M, False: 532k]
  ------------------
 1184|  1.14M|    overlap->whole_block = whole_block;
 1185|  1.14M|  }
 1186|       |  return true;
 1187|  15.1M|}
b2nd.c:slice_chunk_maskout:
 1409|   505k|static int64_t slice_chunk_maskout(const slice_chunk_t *c, int64_t nblocks, bool has_delta, bool *maskout) {
 1410|   505k|  int64_t nneeded = 0;
 1411|  5.58M|  for (int64_t nblock = 0; nblock < nblocks; ++nblock) {
  ------------------
  |  Branch (1411:28): [True: 5.08M, False: 505k]
  ------------------
 1412|  5.08M|    maskout[nblock] = !block_slice_overlap(c, nblock, NULL);
 1413|  5.08M|    nneeded += !maskout[nblock];
 1414|  5.08M|  }
 1415|   505k|  if (has_delta && nneeded > 0) {
  ------------------
  |  Branch (1415:7): [True: 0, False: 505k]
  |  Branch (1415:20): [True: 0, False: 0]
  ------------------
 1416|       |    maskout[0] = false;
 1417|      0|  }
 1418|   505k|  return nneeded;
 1419|   505k|}
b2nd.c:slice_chunk_compact:
 1424|   505k|static bool slice_chunk_compact(const b2nd_array_t *array, int64_t nblocks_needed, bool has_delta) {
 1425|   505k|  bool on_disk = array->sc->storage != NULL && array->sc->storage->urlpath != NULL;
  ------------------
  |  Branch (1425:18): [True: 505k, False: 0]
  |  Branch (1425:48): [True: 0, False: 505k]
  ------------------
 1426|   505k|  int64_t frac = on_disk ? 4 : 16;
  ------------------
  |  Branch (1426:18): [True: 0, False: 505k]
  ------------------
 1427|   505k|  int64_t block_nbytes = (int64_t) array->blocknitems * array->sc->typesize;
 1428|   505k|  int64_t data_nbytes = array->extchunknitems * array->sc->typesize;
 1429|   505k|  return !has_delta && nblocks_needed * block_nbytes * frac <= data_nbytes;
  ------------------
  |  Branch (1429:10): [True: 505k, False: 0]
  |  Branch (1429:24): [True: 60.4k, False: 445k]
  ------------------
 1430|   505k|}
b2nd.c:slice_scatter_postfilter:
 1279|   475k|static int slice_scatter_postfilter(blosc2_postfilter_params *params) {
 1280|   475k|  const slice_chunk_t *c = params->user_data;
 1281|   475k|  const b2nd_array_t *array = c->array;
 1282|   475k|  int8_t ndim = array->ndim;
 1283|   475k|  int32_t typesize = array->sc->typesize;
 1284|   475k|  if (params->size != array->blocknitems * typesize) {
  ------------------
  |  Branch (1284:7): [True: 0, False: 475k]
  ------------------
 1285|      0|    BLOSC_TRACE_ERROR("Unexpected block size in b2nd chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1286|      0|    return BLOSC2_ERROR_FAILURE;
 1287|      0|  }
 1288|   475k|  block_overlap_t overlap;
 1289|   475k|  if (!block_slice_overlap(c, params->nblock, &overlap)) {
  ------------------
  |  Branch (1289:7): [True: 0, False: 475k]
  ------------------
 1290|      0|    return 0;
 1291|      0|  }
 1292|   475k|  if (params->ctx->special_type == BLOSC2_SPECIAL_UNINIT) {
  ------------------
  |  Branch (1292:7): [True: 0, False: 475k]
  ------------------
 1293|       |    // Nothing was decoded into the input; hand out zeros rather than stale memory
 1294|      0|    b2nd_zero_box(ndim, typesize, c->buffer, c->buffershape, overlap.dst_start, overlap.dst_stop);
 1295|      0|    return 0;
 1296|      0|  }
 1297|   475k|  return b2nd_copy_buffer2(ndim, typesize, params->input, c->blockshape, overlap.src_start,
 1298|   475k|                           overlap.src_stop, c->buffer, c->buffershape, overlap.dst_start);
 1299|   475k|}
b2nd.c:scatter_unsupported:
 1305|   445k|static bool scatter_unsupported(const blosc2_context *dctx) {
 1306|   445k|  return (dctx->blosc2_flags & BLOSC2_INSTR_CODEC) || filters_contain(dctx->filters, BLOSC_DELTA);
  ------------------
  |  Branch (1306:10): [True: 0, False: 445k]
  |  Branch (1306:55): [True: 0, False: 445k]
  ------------------
 1307|   445k|}
b2nd.c:locked_get_set_slice:
 2109|  96.2k|                                bool set_slice, bool slice_only, prefetch_batch *prefetch) {
 2110|  96.2k|  blosc2_frame_s *frame = (blosc2_frame_s *) array->sc->frame;
 2111|  96.2k|  BLOSC_ERROR(set_slice ? frame_begin_updates(frame) : frame_lock(frame, false));
  ------------------
  |  |  111|  96.2k|    do {                                            \
  |  |  112|   192k|        int rc_ = (rc);                             \
  |  |  ------------------
  |  |  |  Branch (112:20): [True: 47.5k, False: 48.6k]
  |  |  ------------------
  |  |  113|  96.2k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 96.2k]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|  96.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 96.2k]
  |  |  ------------------
  ------------------
 2112|  96.2k|  int rc = refresh_if_stale(array);
 2113|  96.2k|  if (rc >= 0) {
  ------------------
  |  Branch (2113:7): [True: 96.2k, False: 0]
  ------------------
 2114|  96.2k|    rc = get_set_slice(buffer, buffersize, start, stop, shape, array, set_slice, slice_only, prefetch);
 2115|  96.2k|  }
 2116|  96.2k|  if (set_slice) {
  ------------------
  |  Branch (2116:7): [True: 47.5k, False: 48.6k]
  ------------------
 2117|  47.5k|    int end_rc = frame_end_updates(frame, array->sc);
 2118|  47.5k|    rc = (rc < 0) ? rc : end_rc;
  ------------------
  |  Branch (2118:10): [True: 209, False: 47.3k]
  ------------------
 2119|  47.5k|  }
 2120|  48.6k|  else {
 2121|  48.6k|    frame_unlock(frame);
 2122|  48.6k|  }
 2123|  96.2k|  BLOSC_ERROR(rc);
  ------------------
  |  |  111|  96.2k|    do {                                            \
  |  |  112|  96.2k|        int rc_ = (rc);                             \
  |  |  113|  96.2k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 536, False: 95.6k]
  |  |  ------------------
  |  |  114|    536|            char *error_msg = print_error(rc_);     \
  |  |  115|    536|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|    536|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|    536|    do {                                            \
  |  |  |  |  |  |   98|    536|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|    536|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 536, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|    536|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|    536|            return rc_;                             \
  |  |  117|    536|        }                                           \
  |  |  118|  96.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 95.6k]
  |  |  ------------------
  ------------------
 2124|       |
 2125|  95.6k|  return BLOSC2_ERROR_SUCCESS;
 2126|  96.2k|}
b2nd.c:get_slice_chunks:
 2236|    416|                            const int64_t *start, prefetch_batch *prefetch) {
 2237|    416|  int8_t ndim = (*array)->ndim;
 2238|    416|  int64_t chunks_in_array[B2ND_MAX_DIM] = {0};
 2239|  1.39k|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (2239:19): [True: 978, False: 416]
  ------------------
 2240|    978|    chunks_in_array[i] = (*array)->extshape[i] / (*array)->chunkshape[i];
 2241|    978|  }
 2242|    416|  int64_t nchunks = (*array)->sc->nchunks;
 2243|  44.3k|  for (int64_t nchunk = 0; nchunk < nchunks; ++nchunk) {
  ------------------
  |  Branch (2243:28): [True: 44.0k, False: 298]
  ------------------
 2244|  44.0k|    int64_t nchunk_ndim[B2ND_MAX_DIM] = {0};
 2245|  44.0k|    blosc2_unidim_to_multidim(ndim, chunks_in_array, nchunk, nchunk_ndim);
 2246|       |
 2247|       |    // Check if the chunk needs to be updated
 2248|  44.0k|    int64_t chunk_start[B2ND_MAX_DIM] = {0};
 2249|  44.0k|    int64_t chunk_stop[B2ND_MAX_DIM] = {0};
 2250|  44.0k|    int64_t chunk_shape[B2ND_MAX_DIM] = {0};
 2251|   175k|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (2251:21): [True: 131k, False: 44.0k]
  ------------------
 2252|   131k|      chunk_start[i] = nchunk_ndim[i] * (*array)->chunkshape[i];
 2253|   131k|      chunk_stop[i] = chunk_start[i] + (*array)->chunkshape[i];
 2254|   131k|      if (chunk_stop[i] > (*array)->shape[i]) {
  ------------------
  |  Branch (2254:11): [True: 20.4k, False: 110k]
  ------------------
 2255|  20.4k|        chunk_stop[i] = (*array)->shape[i];
 2256|  20.4k|      }
 2257|   131k|      chunk_shape[i] = chunk_stop[i] - chunk_start[i];
 2258|   131k|    }
 2259|       |
 2260|  44.0k|    int64_t src_start[B2ND_MAX_DIM] = {0};
 2261|  44.0k|    int64_t src_stop[B2ND_MAX_DIM] = {0};
 2262|   175k|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (2262:21): [True: 131k, False: 44.0k]
  ------------------
 2263|   131k|      src_start[i] = chunk_start[i] + start[i];
 2264|   131k|      src_stop[i] = chunk_stop[i] + start[i];
 2265|   131k|    }
 2266|  44.0k|    if (ctx->b2_storage->cparams->typesize <= 0) {
  ------------------
  |  Branch (2266:9): [True: 0, False: 44.0k]
  ------------------
 2267|      0|      BLOSC_TRACE_ERROR("Invalid typesize");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2268|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2269|      0|    }
 2270|  44.0k|    size_t buffersize = (size_t)ctx->b2_storage->cparams->typesize;
 2271|   175k|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (2271:21): [True: 131k, False: 44.0k]
  ------------------
 2272|   131k|      if (chunk_shape[i] < 0) {
  ------------------
  |  Branch (2272:11): [True: 0, False: 131k]
  ------------------
 2273|      0|        BLOSC_TRACE_ERROR("Invalid chunk shape");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2274|      0|        return BLOSC2_ERROR_INVALID_PARAM;
 2275|      0|      }
 2276|   131k|      if (!blosc2_checked_mul_size(buffersize, (size_t)chunk_shape[i], &buffersize)) {
  ------------------
  |  Branch (2276:11): [True: 0, False: 131k]
  ------------------
 2277|      0|        BLOSC_TRACE_ERROR("Buffer size overflows size limits");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2278|      0|        return BLOSC2_ERROR_INVALID_PARAM;
 2279|      0|      }
 2280|   131k|    }
 2281|  44.0k|    if (buffersize == 0 || buffersize > (size_t)INT64_MAX) {
  ------------------
  |  Branch (2281:9): [True: 0, False: 44.0k]
  |  Branch (2281:28): [True: 0, False: 44.0k]
  ------------------
 2282|      0|      BLOSC_TRACE_ERROR("Buffer size is out of range");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2283|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2284|      0|    }
 2285|  44.0k|    size_t capacity;
 2286|  44.0k|    uint8_t *buffer = blosc2_tmp_malloc(buffersize, &capacity);
 2287|  44.0k|    if (buffer == NULL) {
  ------------------
  |  Branch (2287:9): [True: 0, False: 44.0k]
  ------------------
 2288|      0|      b2nd_free(*array);
 2289|      0|      *array = NULL;
 2290|      0|      BLOSC_ERROR(BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2291|      0|    }
 2292|  44.0k|    int g_rc = locked_get_set_slice(buffer, (int64_t) buffersize, src_start, src_stop, chunk_shape,
 2293|  44.0k|                                    (b2nd_array_t *) src, false, false, prefetch);
 2294|  44.0k|    if (g_rc < 0) {
  ------------------
  |  Branch (2294:9): [True: 118, False: 43.9k]
  ------------------
 2295|    118|      blosc2_tmp_free(buffer, capacity);
 2296|    118|      b2nd_free(*array);
 2297|    118|      *array = NULL;
 2298|    118|      return g_rc;
 2299|    118|    }
 2300|  43.9k|    int s_rc = b2nd_set_slice_cbuffer(buffer, chunk_shape, (int64_t)buffersize, chunk_start,
 2301|  43.9k|                                      chunk_stop, *array);
 2302|  43.9k|    blosc2_tmp_free(buffer, capacity);
 2303|  43.9k|    if (s_rc < 0) {
  ------------------
  |  Branch (2303:9): [True: 0, False: 43.9k]
  ------------------
 2304|      0|      b2nd_free(*array);
 2305|      0|      *array = NULL;
 2306|      0|      return s_rc;
 2307|      0|    }
 2308|  43.9k|  }
 2309|       |
 2310|    298|  return BLOSC2_ERROR_SUCCESS;
 2311|    416|}
b2nd.c:validate_shape_chunkshape_blockshape:
  124|  19.8k|                                                const int32_t *chunkshape, const int32_t *blockshape) {
  125|  91.4k|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (125:19): [True: 71.5k, False: 19.8k]
  ------------------
  126|  71.5k|    if (shape[i] < 0) {
  ------------------
  |  Branch (126:9): [True: 0, False: 71.5k]
  ------------------
  127|      0|      BLOSC_TRACE_ERROR("shape[%d] cannot be negative", i);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|      0|      return BLOSC2_ERROR_INVALID_PARAM;
  129|      0|    }
  130|  71.5k|    if (chunkshape[i] < 0 || blockshape[i] < 0) {
  ------------------
  |  Branch (130:9): [True: 0, False: 71.5k]
  |  Branch (130:30): [True: 0, False: 71.5k]
  ------------------
  131|      0|      BLOSC_TRACE_ERROR("chunkshape[%d] and blockshape[%d] cannot be negative", i, i);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|      0|      return BLOSC2_ERROR_INVALID_PARAM;
  133|      0|    }
  134|       |
  135|  71.5k|    bool chunkshape_is_zero = (chunkshape[i] == 0);
  136|  71.5k|    bool blockshape_is_zero = (blockshape[i] == 0);
  137|       |
  138|       |    // Keep compatibility with contexts that use chunkshape=0 (e.g. empty slices).
  139|       |    // Reject only invalid tuples that can produce divide-by-zero when chunkshape is non-zero.
  140|  71.5k|    if (blockshape_is_zero && !chunkshape_is_zero) {
  ------------------
  |  Branch (140:9): [True: 0, False: 71.5k]
  |  Branch (140:31): [True: 0, False: 0]
  ------------------
  141|      0|      BLOSC_TRACE_ERROR("blockshape[%d] cannot be zero when chunkshape[%d] is non-zero", i, i);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  142|      0|      return BLOSC2_ERROR_INVALID_PARAM;
  143|      0|    }
  144|  71.5k|  }
  145|       |
  146|  19.8k|  return BLOSC2_ERROR_SUCCESS;
  147|  19.8k|}

b2nd_copy_buffer2:
  192|  1.13M|                      const int64_t *dst_start) {
  193|  1.13M|  int64_t copy_shape[B2ND_MAX_DIM];
  194|  6.01M|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (194:19): [True: 4.87M, False: 1.13M]
  ------------------
  195|  4.87M|    copy_shape[i] = src_stop[i] - src_start[i];
  196|  4.87M|    if (copy_shape[i] == 0) {
  ------------------
  |  Branch (196:9): [True: 0, False: 4.87M]
  ------------------
  197|      0|      return BLOSC2_ERROR_SUCCESS;
  198|      0|    }
  199|  4.87M|  }
  200|  1.13M|  copy_or_zero_box(ndim, itemsize, copy_shape, src, src_pad_shape, src_start, dst, dst_pad_shape, dst_start);
  201|       |
  202|  1.13M|  return BLOSC2_ERROR_SUCCESS;
  203|  1.13M|}
b2nd_zero_box:
  208|  31.6k|                   const int64_t *box_start, const int64_t *box_stop) {
  209|  31.6k|  int64_t box_shape[B2ND_MAX_DIM];
  210|   148k|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (210:19): [True: 117k, False: 31.6k]
  ------------------
  211|   117k|    box_shape[i] = box_stop[i] - box_start[i];
  212|   117k|    if (box_shape[i] <= 0) {
  ------------------
  |  Branch (212:9): [True: 0, False: 117k]
  ------------------
  213|      0|      return;
  214|      0|    }
  215|   117k|  }
  216|  31.6k|  copy_or_zero_box(ndim, itemsize, box_shape, NULL, dst_pad_shape, box_start, dst, dst_pad_shape, box_start);
  217|  31.6k|}
b2nd_utils.c:copy_or_zero_box:
  156|  1.16M|                             uint8_t *dst, const int64_t *dst_pad_shape, const int64_t *dst_start) {
  157|  1.16M|  int64_t src_strides[B2ND_MAX_DIM];
  158|  1.16M|  int64_t dst_strides[B2ND_MAX_DIM];
  159|  1.16M|  byte_strides(ndim, itemsize, src_pad_shape, src_strides);
  160|  1.16M|  byte_strides(ndim, itemsize, dst_pad_shape, dst_strides);
  161|  1.16M|  int64_t src_offset = 0;
  162|  1.16M|  int64_t dst_offset = 0;
  163|  6.15M|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (163:19): [True: 4.98M, False: 1.16M]
  ------------------
  164|  4.98M|    src_offset += src_start[i] * src_strides[i];
  165|  4.98M|    dst_offset += dst_start[i] * dst_strides[i];
  166|  4.98M|  }
  167|  1.16M|  dst += dst_offset;
  168|  1.16M|  if (src != NULL) {
  ------------------
  |  Branch (168:7): [True: 1.13M, False: 31.6k]
  ------------------
  169|  1.13M|    src += src_offset;
  170|  1.13M|  }
  171|       |
  172|  1.16M|  int64_t shape[B2ND_MAX_DIM];
  173|  1.16M|  int64_t src_bstrides[B2ND_MAX_DIM];
  174|  1.16M|  int64_t dst_bstrides[B2ND_MAX_DIM];
  175|  1.16M|  int ndim_bytes = simplify_box(ndim, itemsize, box_shape, src_strides, dst_strides, shape, src_bstrides,
  176|  1.16M|                                dst_bstrides);
  177|  1.16M|  if (ndim_bytes > 1) {
  ------------------
  |  Branch (177:7): [True: 478k, False: 691k]
  ------------------
  178|   478k|    copy_box(ndim_bytes, shape, src, src_bstrides, dst, dst_bstrides);
  179|   691k|  } else if (src == NULL) {
  ------------------
  |  Branch (179:14): [True: 30.9k, False: 660k]
  ------------------
  180|  30.9k|    memset(dst, 0, (size_t) shape[0]);
  181|   660k|  } else {
  182|   660k|    memcpy(dst, src, (size_t) shape[0]);
  183|   660k|  }
  184|  1.16M|}
b2nd_utils.c:byte_strides:
  143|  2.33M|static void byte_strides(int8_t ndim, int32_t itemsize, const int64_t *pad_shape, int64_t *strides) {
  144|  2.33M|  int64_t stride = itemsize;
  145|  12.3M|  for (int i = ndim - 1; i >= 0; --i) {
  ------------------
  |  Branch (145:26): [True: 9.97M, False: 2.33M]
  ------------------
  146|  9.97M|    strides[i] = stride;
  147|  9.97M|    stride *= pad_shape[i];
  148|  9.97M|  }
  149|  2.33M|}
b2nd_utils.c:simplify_box:
  114|  1.16M|                        int64_t *shape, int64_t *src_bstrides, int64_t *dst_bstrides) {
  115|  1.16M|  int n = 0;
  116|  1.16M|  int64_t extent = itemsize;
  117|  1.16M|  int64_t src_stride = 1;
  118|  1.16M|  int64_t dst_stride = 1;
  119|  6.15M|  for (int i = ndim - 1; i >= 0; --i) {
  ------------------
  |  Branch (119:26): [True: 4.98M, False: 1.16M]
  ------------------
  120|  4.98M|    if (box_shape[i] == 1) {
  ------------------
  |  Branch (120:9): [True: 4.28M, False: 706k]
  ------------------
  121|  4.28M|      continue;
  122|  4.28M|    }
  123|   706k|    if (src_strides[i] == src_stride * extent && dst_strides[i] == dst_stride * extent) {
  ------------------
  |  Branch (123:9): [True: 353k, False: 353k]
  |  Branch (123:50): [True: 123k, False: 230k]
  ------------------
  124|   123k|      extent *= box_shape[i];
  125|   123k|      continue;
  126|   123k|    }
  127|   583k|    shape[n] = extent;
  128|   583k|    src_bstrides[n] = src_stride;
  129|   583k|    dst_bstrides[n] = dst_stride;
  130|   583k|    ++n;
  131|   583k|    extent = box_shape[i];
  132|   583k|    src_stride = src_strides[i];
  133|   583k|    dst_stride = dst_strides[i];
  134|   583k|  }
  135|  1.16M|  shape[n] = extent;
  136|  1.16M|  src_bstrides[n] = src_stride;
  137|  1.16M|  dst_bstrides[n] = dst_stride;
  138|  1.16M|  return n + 1;
  139|  1.16M|}
b2nd_utils.c:copy_box:
   69|   478k|                     uint8_t *dst, const int64_t *dst_strides) {
   70|   478k|  const int64_t row_nbytes = shape[0];
   71|   478k|  const int64_t nrows = shape[1];
   72|   478k|  const int64_t src_row_stride = src_strides[1];
   73|   478k|  const int64_t dst_row_stride = dst_strides[1];
   74|   478k|  int64_t index[B2ND_MAX_DIM];
   75|   583k|  for (int i = 2; i < ndim; ++i) {
  ------------------
  |  Branch (75:19): [True: 105k, False: 478k]
  ------------------
   76|   105k|    index[i] = 0;
   77|   105k|  }
   78|  1.01M|  for (;;) {
   79|  1.01M|    int64_t src_offset = 0;
   80|  1.01M|    int64_t dst_offset = 0;
   81|  1.66M|    for (int i = 2; i < ndim; ++i) {
  ------------------
  |  Branch (81:21): [True: 647k, False: 1.01M]
  ------------------
   82|   647k|      src_offset += index[i] * src_strides[i];
   83|   647k|      dst_offset += index[i] * dst_strides[i];
   84|   647k|    }
   85|  1.01M|    if (src == NULL) {
  ------------------
  |  Branch (85:9): [True: 729, False: 1.01M]
  ------------------
   86|    729|      uint8_t *row = dst + dst_offset;
   87|  2.19k|      for (int64_t r = 0; r < nrows; ++r) {
  ------------------
  |  Branch (87:27): [True: 1.47k, False: 729]
  ------------------
   88|  1.47k|        memset(row, 0, (size_t) row_nbytes);
   89|  1.47k|        row += dst_row_stride;
   90|  1.47k|      }
   91|  1.01M|    } else {
   92|  1.01M|      copy_rows(dst + dst_offset, dst_row_stride, src + src_offset, src_row_stride, nrows, row_nbytes);
   93|  1.01M|    }
   94|  1.01M|    int i = 2;
   95|  1.12M|    while (i < ndim && ++index[i] == shape[i]) {
  ------------------
  |  Branch (95:12): [True: 643k, False: 478k]
  |  Branch (95:24): [True: 106k, False: 537k]
  ------------------
   96|   106k|      index[i] = 0;
   97|   106k|      ++i;
   98|   106k|    }
   99|  1.01M|    if (i == ndim) {
  ------------------
  |  Branch (99:9): [True: 478k, False: 537k]
  ------------------
  100|   478k|      break;
  101|   478k|    }
  102|  1.01M|  }
  103|   478k|}
b2nd_utils.c:copy_rows:
   23|  1.01M|                             int64_t nrows, int64_t row_nbytes) {
   24|  1.01M|#define COPY_ROWS(stmt)                     \
   25|  1.01M|  for (int64_t r = nrows; r > 0; --r) {     \
   26|  1.01M|    stmt;                                   \
   27|  1.01M|    dst += dst_stride;                      \
   28|  1.01M|    src += src_stride;                      \
   29|  1.01M|  }
   30|  1.01M|#define MOVE_2X(n)                                                     \
   31|  1.01M|  memcpy(dst, src, n);                                                 \
   32|  1.01M|  memcpy(dst + row_nbytes - (n), src + row_nbytes - (n), n)
   33|       |
   34|  1.01M|  if (row_nbytes > 64) {
  ------------------
  |  Branch (34:7): [True: 1.58k, False: 1.01M]
  ------------------
   35|  1.58k|    COPY_ROWS(memcpy(dst, src, (size_t) row_nbytes))
  ------------------
  |  |   25|  10.9k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 9.41k, False: 1.58k]
  |  |  ------------------
  |  |   26|  9.41k|    stmt;                                   \
  |  |   27|  9.41k|    dst += dst_stride;                      \
  |  |   28|  9.41k|    src += src_stride;                      \
  |  |   29|  9.41k|  }
  ------------------
   36|  1.01M|  } else if (row_nbytes > 32) {
  ------------------
  |  Branch (36:14): [True: 8.88k, False: 1.00M]
  ------------------
   37|  8.88k|    COPY_ROWS(MOVE_2X(32))
  ------------------
  |  |   25|  50.0k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 41.1k, False: 8.88k]
  |  |  ------------------
  |  |   26|  41.1k|    stmt;                                   \
  |  |   27|  41.1k|    dst += dst_stride;                      \
  |  |   28|  41.1k|    src += src_stride;                      \
  |  |   29|  41.1k|  }
  ------------------
   38|  1.00M|  } else if (row_nbytes == 32) {
  ------------------
  |  Branch (38:14): [True: 970, False: 1.00M]
  ------------------
   39|    970|    COPY_ROWS(memcpy(dst, src, 32))
  ------------------
  |  |   25|  5.93k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 4.96k, False: 970]
  |  |  ------------------
  |  |   26|  4.96k|    stmt;                                   \
  |  |   27|  4.96k|    dst += dst_stride;                      \
  |  |   28|  4.96k|    src += src_stride;                      \
  |  |   29|  4.96k|  }
  ------------------
   40|  1.00M|  } else if (row_nbytes > 16) {
  ------------------
  |  Branch (40:14): [True: 19.2k, False: 984k]
  ------------------
   41|  19.2k|    COPY_ROWS(MOVE_2X(16))
  ------------------
  |  |   25|  72.3k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 53.1k, False: 19.2k]
  |  |  ------------------
  |  |   26|  53.1k|    stmt;                                   \
  |  |   27|  53.1k|    dst += dst_stride;                      \
  |  |   28|  53.1k|    src += src_stride;                      \
  |  |   29|  53.1k|  }
  ------------------
   42|   984k|  } else if (row_nbytes == 16) {
  ------------------
  |  Branch (42:14): [True: 14.9k, False: 969k]
  ------------------
   43|  14.9k|    COPY_ROWS(memcpy(dst, src, 16))
  ------------------
  |  |   25|  47.0k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 32.1k, False: 14.9k]
  |  |  ------------------
  |  |   26|  32.1k|    stmt;                                   \
  |  |   27|  32.1k|    dst += dst_stride;                      \
  |  |   28|  32.1k|    src += src_stride;                      \
  |  |   29|  32.1k|  }
  ------------------
   44|   969k|  } else if (row_nbytes > 8) {
  ------------------
  |  Branch (44:14): [True: 4.48k, False: 964k]
  ------------------
   45|  4.48k|    COPY_ROWS(MOVE_2X(8))
  ------------------
  |  |   25|  22.6k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 18.1k, False: 4.48k]
  |  |  ------------------
  |  |   26|  18.1k|    stmt;                                   \
  |  |   27|  18.1k|    dst += dst_stride;                      \
  |  |   28|  18.1k|    src += src_stride;                      \
  |  |   29|  18.1k|  }
  ------------------
   46|   964k|  } else if (row_nbytes == 8) {
  ------------------
  |  Branch (46:14): [True: 2.14k, False: 962k]
  ------------------
   47|  2.14k|    COPY_ROWS(memcpy(dst, src, 8))
  ------------------
  |  |   25|  14.0k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 11.9k, False: 2.14k]
  |  |  ------------------
  |  |   26|  11.9k|    stmt;                                   \
  |  |   27|  11.9k|    dst += dst_stride;                      \
  |  |   28|  11.9k|    src += src_stride;                      \
  |  |   29|  11.9k|  }
  ------------------
   48|   962k|  } else if (row_nbytes > 4) {
  ------------------
  |  Branch (48:14): [True: 11.6k, False: 950k]
  ------------------
   49|  11.6k|    COPY_ROWS(MOVE_2X(4))
  ------------------
  |  |   25|   141k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 129k, False: 11.6k]
  |  |  ------------------
  |  |   26|   129k|    stmt;                                   \
  |  |   27|   129k|    dst += dst_stride;                      \
  |  |   28|   129k|    src += src_stride;                      \
  |  |   29|   129k|  }
  ------------------
   50|   950k|  } else if (row_nbytes == 4) {
  ------------------
  |  Branch (50:14): [True: 1.43k, False: 949k]
  ------------------
   51|  1.43k|    COPY_ROWS(memcpy(dst, src, 4))
  ------------------
  |  |   25|  6.75k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 5.32k, False: 1.43k]
  |  |  ------------------
  |  |   26|  5.32k|    stmt;                                   \
  |  |   27|  5.32k|    dst += dst_stride;                      \
  |  |   28|  5.32k|    src += src_stride;                      \
  |  |   29|  5.32k|  }
  ------------------
   52|   949k|  } else if (row_nbytes > 2) {
  ------------------
  |  Branch (52:14): [True: 10.3k, False: 939k]
  ------------------
   53|  10.3k|    COPY_ROWS(MOVE_2X(2))
  ------------------
  |  |   25|  45.0k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 34.7k, False: 10.3k]
  |  |  ------------------
  |  |   26|  34.7k|    stmt;                                   \
  |  |   27|  34.7k|    dst += dst_stride;                      \
  |  |   28|  34.7k|    src += src_stride;                      \
  |  |   29|  34.7k|  }
  ------------------
   54|   939k|  } else if (row_nbytes == 2) {
  ------------------
  |  Branch (54:14): [True: 7.62k, False: 931k]
  ------------------
   55|  7.62k|    COPY_ROWS(memcpy(dst, src, 2))
  ------------------
  |  |   25|  59.2k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 51.6k, False: 7.62k]
  |  |  ------------------
  |  |   26|  51.6k|    stmt;                                   \
  |  |   27|  51.6k|    dst += dst_stride;                      \
  |  |   28|  51.6k|    src += src_stride;                      \
  |  |   29|  51.6k|  }
  ------------------
   56|   931k|  } else {
   57|   931k|    COPY_ROWS(*dst = *src)
  ------------------
  |  |   25|  7.25M|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 6.32M, False: 931k]
  |  |  ------------------
  |  |   26|  6.32M|    stmt;                                   \
  |  |   27|  6.32M|    dst += dst_stride;                      \
  |  |   28|  6.32M|    src += src_stride;                      \
  |  |   29|  6.32M|  }
  ------------------
   58|   931k|  }
   59|  1.01M|#undef MOVE_2X
   60|  1.01M|#undef COPY_ROWS
   61|  1.01M|}

bshuf_trans_byte_bitrow_AVX:
  131|    193|                                    const size_t elem_size) {
  132|       |
  133|    193|  size_t hh, ii, jj, kk, mm;
  134|    193|  const char* in_b = (const char*) in;
  135|    193|  char* out_b = (char*) out;
  136|       |
  137|    193|  CHECK_MULT_EIGHT(size);
  ------------------
  |  |   35|    193|#define CHECK_MULT_EIGHT(n) if (n % 8) return -80;
  |  |  ------------------
  |  |  |  Branch (35:33): [True: 0, False: 193]
  |  |  ------------------
  ------------------
  138|       |
  139|    193|  size_t nrows = 8 * elem_size;
  140|    193|  size_t nbyte_row = size / 8;
  141|       |
  142|    193|  if (elem_size % 4) return bshuf_trans_byte_bitrow_SSE(in, out, size,
  ------------------
  |  Branch (142:7): [True: 99, False: 94]
  ------------------
  143|     99|                                                        elem_size);
  144|       |
  145|     94|  __m256i ymm_0[8];
  146|     94|  __m256i ymm_1[8];
  147|     94|  __m256i ymm_storeage[8][4];
  148|       |
  149|  20.7k|  for (jj = 0; jj + 31 < nbyte_row; jj += 32) {
  ------------------
  |  Branch (149:16): [True: 20.6k, False: 94]
  ------------------
  150|   320k|    for (ii = 0; ii + 3 < elem_size; ii += 4) {
  ------------------
  |  Branch (150:18): [True: 300k, False: 20.6k]
  ------------------
  151|  1.50M|      for (hh = 0; hh < 4; hh ++) {
  ------------------
  |  Branch (151:20): [True: 1.20M, False: 300k]
  ------------------
  152|       |
  153|  10.8M|        for (kk = 0; kk < 8; kk ++){
  ------------------
  |  Branch (153:22): [True: 9.60M, False: 1.20M]
  ------------------
  154|  9.60M|          ymm_0[kk] = _mm256_loadu_si256((__m256i *) &in_b[
  155|  9.60M|              (ii * 8 + hh * 8 + kk) * nbyte_row + jj]);
  156|  9.60M|        }
  157|       |
  158|  6.00M|        for (kk = 0; kk < 4; kk ++){
  ------------------
  |  Branch (158:22): [True: 4.80M, False: 1.20M]
  ------------------
  159|  4.80M|          ymm_1[kk] = _mm256_unpacklo_epi8(ymm_0[kk * 2],
  160|  4.80M|                                           ymm_0[kk * 2 + 1]);
  161|  4.80M|          ymm_1[kk + 4] = _mm256_unpackhi_epi8(ymm_0[kk * 2],
  162|  4.80M|                                               ymm_0[kk * 2 + 1]);
  163|  4.80M|        }
  164|       |
  165|  3.60M|        for (kk = 0; kk < 2; kk ++){
  ------------------
  |  Branch (165:22): [True: 2.40M, False: 1.20M]
  ------------------
  166|  7.20M|          for (mm = 0; mm < 2; mm ++){
  ------------------
  |  Branch (166:24): [True: 4.80M, False: 2.40M]
  ------------------
  167|  4.80M|            ymm_0[kk * 4 + mm] = _mm256_unpacklo_epi16(
  168|  4.80M|                ymm_1[kk * 4 + mm * 2],
  169|  4.80M|                ymm_1[kk * 4 + mm * 2 + 1]);
  170|  4.80M|            ymm_0[kk * 4 + mm + 2] = _mm256_unpackhi_epi16(
  171|  4.80M|                ymm_1[kk * 4 + mm * 2],
  172|  4.80M|                ymm_1[kk * 4 + mm * 2 + 1]);
  173|  4.80M|          }
  174|  2.40M|        }
  175|       |
  176|  6.00M|        for (kk = 0; kk < 4; kk ++){
  ------------------
  |  Branch (176:22): [True: 4.80M, False: 1.20M]
  ------------------
  177|  4.80M|          ymm_1[kk * 2] = _mm256_unpacklo_epi32(ymm_0[kk * 2],
  178|  4.80M|                                                ymm_0[kk * 2 + 1]);
  179|  4.80M|          ymm_1[kk * 2 + 1] = _mm256_unpackhi_epi32(ymm_0[kk * 2],
  180|  4.80M|                                                    ymm_0[kk * 2 + 1]);
  181|  4.80M|        }
  182|       |
  183|  10.8M|        for (kk = 0; kk < 8; kk ++){
  ------------------
  |  Branch (183:22): [True: 9.60M, False: 1.20M]
  ------------------
  184|  9.60M|          ymm_storeage[kk][hh] = ymm_1[kk];
  185|  9.60M|        }
  186|  1.20M|      }
  187|       |
  188|  2.70M|      for (mm = 0; mm < 8; mm ++) {
  ------------------
  |  Branch (188:20): [True: 2.40M, False: 300k]
  ------------------
  189|       |
  190|  12.0M|        for (kk = 0; kk < 4; kk ++){
  ------------------
  |  Branch (190:22): [True: 9.60M, False: 2.40M]
  ------------------
  191|  9.60M|          ymm_0[kk] = ymm_storeage[mm][kk];
  192|  9.60M|        }
  193|       |
  194|  2.40M|        ymm_1[0] = _mm256_unpacklo_epi64(ymm_0[0], ymm_0[1]);
  195|  2.40M|        ymm_1[1] = _mm256_unpacklo_epi64(ymm_0[2], ymm_0[3]);
  196|  2.40M|        ymm_1[2] = _mm256_unpackhi_epi64(ymm_0[0], ymm_0[1]);
  197|  2.40M|        ymm_1[3] = _mm256_unpackhi_epi64(ymm_0[2], ymm_0[3]);
  198|       |
  199|  2.40M|        ymm_0[0] = _mm256_permute2x128_si256(ymm_1[0], ymm_1[1], 32);
  200|  2.40M|        ymm_0[1] = _mm256_permute2x128_si256(ymm_1[2], ymm_1[3], 32);
  201|  2.40M|        ymm_0[2] = _mm256_permute2x128_si256(ymm_1[0], ymm_1[1], 49);
  202|  2.40M|        ymm_0[3] = _mm256_permute2x128_si256(ymm_1[2], ymm_1[3], 49);
  203|       |
  204|  2.40M|        _mm256_storeu_si256((__m256i *) &out_b[
  205|  2.40M|            (jj + mm * 2 + 0 * 16) * nrows + ii * 8], ymm_0[0]);
  206|  2.40M|        _mm256_storeu_si256((__m256i *) &out_b[
  207|  2.40M|            (jj + mm * 2 + 0 * 16 + 1) * nrows + ii * 8], ymm_0[1]);
  208|  2.40M|        _mm256_storeu_si256((__m256i *) &out_b[
  209|  2.40M|            (jj + mm * 2 + 1 * 16) * nrows + ii * 8], ymm_0[2]);
  210|  2.40M|        _mm256_storeu_si256((__m256i *) &out_b[
  211|  2.40M|            (jj + mm * 2 + 1 * 16 + 1) * nrows + ii * 8], ymm_0[3]);
  212|  2.40M|      }
  213|   300k|    }
  214|  20.6k|  }
  215|  53.3k|  for (ii = 0; ii < nrows; ii ++ ) {
  ------------------
  |  Branch (215:16): [True: 53.2k, False: 94]
  ------------------
  216|  1.01M|    for (jj = nbyte_row - nbyte_row % 32; jj < nbyte_row; jj ++) {
  ------------------
  |  Branch (216:43): [True: 966k, False: 53.2k]
  ------------------
  217|   966k|      out_b[jj * nrows + ii] = in_b[ii * nbyte_row + jj];
  218|   966k|    }
  219|  53.2k|  }
  220|     94|  return size * elem_size;
  221|    193|}
bshuf_shuffle_bit_eightelem_AVX:
  242|    193|                                        const size_t elem_size) {
  243|       |
  244|    193|  CHECK_MULT_EIGHT(size);
  ------------------
  |  |   35|    193|#define CHECK_MULT_EIGHT(n) if (n % 8) return -80;
  |  |  ------------------
  |  |  |  Branch (35:33): [True: 0, False: 193]
  |  |  ------------------
  ------------------
  245|       |
  246|       |  // With a bit of care, this could be written such that such that it is
  247|       |  // in_buf = out_buf safe.
  248|    193|  const char* in_b = (const char*) in;
  249|    193|  char* out_b = (char*) out;
  250|       |
  251|    193|  size_t ii, jj, kk;
  252|    193|  size_t nbyte = elem_size * size;
  253|       |
  254|    193|  __m256i ymm;
  255|    193|  int32_t bt;
  256|       |
  257|    193|  if (elem_size <= 2) {
  ------------------
  |  Branch (257:7): [True: 0, False: 193]
  ------------------
  258|       |    // Each 8-byte word holds the 8 bit rows of 8 one-byte elements, or of
  259|       |    // the low or the high bytes of 8 two-byte elements: transposing its
  260|       |    // bits gives those bytes.
  261|      0|    for (ii = 0; ii + 31 < nbyte; ii += 32) {
  ------------------
  |  Branch (261:18): [True: 0, False: 0]
  ------------------
  262|      0|      ymm = trans_bit_8x8_AVX(_mm256_loadu_si256((__m256i *) &in_b[ii]));
  263|      0|      if (elem_size == 2) {
  ------------------
  |  Branch (263:11): [True: 0, False: 0]
  ------------------
  264|       |        // Each 128-bit lane is [low bytes, high bytes] for ONE group of
  265|       |        // eight elements, not [low0, low1, high0, high1] across the vector.
  266|       |        // Lane-local unpacks therefore pair the corresponding bytes.
  267|      0|        ymm = _mm256_unpacklo_epi8(ymm, _mm256_unpackhi_epi64(ymm, ymm));
  268|      0|      }
  269|      0|      _mm256_storeu_si256((__m256i *) &out_b[ii], ymm);
  270|      0|    }
  271|      0|    if (ii < nbyte) {
  ------------------
  |  Branch (271:9): [True: 0, False: 0]
  ------------------
  272|      0|      bshuf_shuffle_bit_eightelem_SSE(&in_b[ii], &out_b[ii],
  273|      0|                                      (nbyte - ii) / elem_size, elem_size);
  274|      0|    }
  275|    193|  } else if (elem_size % 4) {
  ------------------
  |  Branch (275:14): [True: 99, False: 94]
  ------------------
  276|     99|    return bshuf_shuffle_bit_eightelem_SSE(in, out, size, elem_size);
  277|     99|  } else {
  278|  1.75k|    for (jj = 0; jj + 31 < 8 * elem_size; jj += 32) {
  ------------------
  |  Branch (278:18): [True: 1.66k, False: 94]
  ------------------
  279|  9.63M|      for (ii = 0; ii + 8 * elem_size - 1 < nbyte;
  ------------------
  |  Branch (279:20): [True: 9.63M, False: 1.66k]
  ------------------
  280|  9.63M|           ii += 8 * elem_size) {
  281|  9.63M|        ymm = _mm256_loadu_si256((__m256i *) &in_b[ii + jj]);
  282|  86.6M|        for (kk = 0; kk < 8; kk++) {
  ------------------
  |  Branch (282:22): [True: 77.0M, False: 9.63M]
  ------------------
  283|  77.0M|          bt = _mm256_movemask_epi8(ymm);
  284|  77.0M|          ymm = _mm256_slli_epi16(ymm, 1);
  285|  77.0M|          size_t ind = (ii + jj / 8 + (7 - kk) * elem_size);
  286|  77.0M|          * (int32_t *) &out_b[ind] = bt;
  287|  77.0M|        }
  288|  9.63M|      }
  289|  1.66k|    }
  290|     94|  }
  291|     94|  return size * elem_size;
  292|    193|}
bshuf_untrans_bit_elem_AVX:
  297|    408|                                   const size_t elem_size, void* tmp_buf) {
  298|       |
  299|    408|  int64_t count;
  300|       |
  301|    408|  CHECK_MULT_EIGHT(size);
  ------------------
  |  |   35|    408|#define CHECK_MULT_EIGHT(n) if (n % 8) return -80;
  |  |  ------------------
  |  |  |  Branch (35:33): [True: 0, False: 408]
  |  |  ------------------
  ------------------
  302|       |
  303|    408|  if (elem_size == 1) return bshuf_untrans_bit_byte_SSE(in, out, size);
  ------------------
  |  Branch (303:7): [True: 46, False: 362]
  ------------------
  304|    362|  if ((elem_size == 2 || elem_size == 4 || elem_size == 8 || elem_size == 16)
  ------------------
  |  Branch (304:8): [True: 49, False: 313]
  |  Branch (304:26): [True: 58, False: 255]
  |  Branch (304:44): [True: 33, False: 222]
  |  Branch (304:62): [True: 29, False: 193]
  ------------------
  305|    169|      && size <= INT32_MAX / elem_size) {
  ------------------
  |  Branch (305:10): [True: 169, False: 0]
  ------------------
  306|  1.22k|    for (size_t j = 0; j < elem_size; ++j) {
  ------------------
  |  Branch (306:24): [True: 1.05k, False: 169]
  ------------------
  307|  1.05k|      bshuf_untrans_bit_byte_SSE((const uint8_t*)in + j * size, (uint8_t*)tmp_buf + j * size, size);
  308|  1.05k|    }
  309|    169|    unshuffle_avx2((int32_t)elem_size, (int32_t)(size * elem_size), tmp_buf, out);
  310|    169|    return size * elem_size;
  311|    169|  }
  312|    193|  count = bshuf_trans_byte_bitrow_AVX(in, tmp_buf, size, elem_size);
  313|    193|  CHECK_ERR(count);
  ------------------
  |  |   40|    193|        do {                              \
  |  |   41|    193|          if ((count) < 0)                \
  |  |  ------------------
  |  |  |  Branch (41:15): [True: 0, False: 193]
  |  |  ------------------
  |  |   42|    193|            return count;                 \
  |  |   43|    193|         } while (0)
  |  |  ------------------
  |  |  |  Branch (43:19): [Folded, False: 193]
  |  |  ------------------
  ------------------
  314|    193|  count =  bshuf_shuffle_bit_eightelem_AVX(tmp_buf, out, size, elem_size);
  315|       |
  316|    193|  return count;
  317|    193|}

bshuf_shuffle_bit_eightelem_scal:
  194|     71|        const size_t size, const size_t elem_size) {
  195|       |
  196|     71|  const char *in_b;
  197|     71|  char *out_b;
  198|     71|  uint64_t x, t;
  199|     71|  size_t ii, jj, kk;
  200|     71|  size_t nbyte, out_index;
  201|       |
  202|     71|  uint64_t e=1;
  203|     71|  const int little_endian = *(uint8_t *) &e == 1;
  204|     71|  const size_t elem_skip = little_endian ? elem_size : -elem_size;
  ------------------
  |  Branch (204:28): [True: 71, False: 0]
  ------------------
  205|     71|  const uint64_t elem_offset = little_endian ? 0 : 7 * elem_size;
  ------------------
  |  Branch (205:32): [True: 71, False: 0]
  ------------------
  206|       |
  207|     71|  CHECK_MULT_EIGHT(size);
  ------------------
  |  |   35|     71|#define CHECK_MULT_EIGHT(n) if (n % 8) return -80;
  |  |  ------------------
  |  |  |  Branch (35:33): [True: 0, False: 71]
  |  |  ------------------
  ------------------
  208|       |
  209|     71|  in_b = (const char*) in;
  210|     71|  out_b = (char*) out;
  211|       |
  212|     71|  nbyte = elem_size * size;
  213|       |
  214|  3.97k|  for (jj = 0; jj < 8 * elem_size; jj += 8) {
  ------------------
  |  Branch (214:16): [True: 3.90k, False: 71]
  ------------------
  215|  15.9M|    for (ii = 0; ii + 8 * elem_size - 1 < nbyte; ii += 8 * elem_size) {
  ------------------
  |  Branch (215:18): [True: 15.9M, False: 3.90k]
  ------------------
  216|  15.9M|      x = *((uint64_t*) &in_b[ii + jj]);
  217|  15.9M|      if (little_endian) {
  ------------------
  |  Branch (217:11): [True: 15.9M, False: 0]
  ------------------
  218|  15.9M|        TRANS_BIT_8X8(x, t);
  ------------------
  |  |   54|  15.9M|#define TRANS_BIT_8X8(x, t) {                                               \
  |  |   55|  15.9M|        t = (x ^ (x >> 7)) & 0x00AA00AA00AA00AALL;                          \
  |  |   56|  15.9M|        x = x ^ t ^ (t << 7);                                               \
  |  |   57|  15.9M|        t = (x ^ (x >> 14)) & 0x0000CCCC0000CCCCLL;                         \
  |  |   58|  15.9M|        x = x ^ t ^ (t << 14);                                              \
  |  |   59|  15.9M|        t = (x ^ (x >> 28)) & 0x00000000F0F0F0F0LL;                         \
  |  |   60|  15.9M|        x = x ^ t ^ (t << 28);                                              \
  |  |   61|  15.9M|    }
  ------------------
  219|  15.9M|      } else {
  220|      0|        TRANS_BIT_8X8_BE(x, t);
  ------------------
  |  |   65|      0|#define TRANS_BIT_8X8_BE(x, t) {                                            \
  |  |   66|      0|        t = (x ^ (x >> 9)) & 0x0055005500550055LL;                          \
  |  |   67|      0|        x = x ^ t ^ (t << 9);                                               \
  |  |   68|      0|        t = (x ^ (x >> 18)) & 0x0000333300003333LL;                         \
  |  |   69|      0|        x = x ^ t ^ (t << 18);                                              \
  |  |   70|      0|        t = (x ^ (x >> 36)) & 0x000000000F0F0F0FLL;                         \
  |  |   71|      0|        x = x ^ t ^ (t << 36);                                              \
  |  |   72|      0|    }
  ------------------
  221|      0|      }
  222|   143M|      for (kk = 0; kk < 8; kk++) {
  ------------------
  |  Branch (222:20): [True: 127M, False: 15.9M]
  ------------------
  223|   127M|        out_index = ii + jj / 8 + elem_offset + kk * elem_skip;
  224|   127M|        *((uint8_t*) &out_b[out_index]) = x;
  225|   127M|        x = x >> 8;
  226|   127M|      }
  227|  15.9M|    }
  228|  3.90k|  }
  229|     71|  return size * elem_size;
  230|     71|}

bshuf_trans_byte_bitrow_SSE:
  456|     99|                                  const size_t elem_size) {
  457|       |  return trans_byte_bitrow_SSE(in, out, size, elem_size, false);
  458|     99|}
bshuf_untrans_bit_byte_SSE:
  461|  1.10k|int64_t bshuf_untrans_bit_byte_SSE(const void* in, void* out, const size_t size) {
  462|       |  return trans_byte_bitrow_SSE(in, out, size, 1, true);
  463|  1.10k|}
bshuf_shuffle_bit_eightelem_SSE:
  483|     99|                                        const size_t elem_size) {
  484|       |
  485|     99|  CHECK_MULT_EIGHT(size);
  ------------------
  |  |   35|     99|#define CHECK_MULT_EIGHT(n) if (n % 8) return -80;
  |  |  ------------------
  |  |  |  Branch (35:33): [True: 0, False: 99]
  |  |  ------------------
  ------------------
  486|       |
  487|       |  // With a bit of care, this could be written such that such that it is
  488|       |  // in_buf = out_buf safe.
  489|     99|  const char* in_b = (const char*) in;
  490|     99|  char* out_b = (char*) out;
  491|     99|  uint16_t* out_ui16 = (uint16_t*) out;
  492|       |
  493|     99|  size_t ii, jj, kk;
  494|     99|  size_t nbyte = elem_size * size;
  495|       |
  496|     99|  __m128i xmm;
  497|     99|  int32_t bt;
  498|       |
  499|     99|  if (elem_size <= 2) {
  ------------------
  |  Branch (499:7): [True: 0, False: 99]
  ------------------
  500|       |    // Each 8-byte word holds the 8 bit rows of 8 one-byte elements, or of
  501|       |    // the low or the high bytes of 8 two-byte elements: transposing its
  502|       |    // bits gives those bytes.
  503|      0|    for (ii = 0; ii + 15 < nbyte; ii += 16) {
  ------------------
  |  Branch (503:18): [True: 0, False: 0]
  ------------------
  504|      0|      xmm = trans_bit_8x8_SSE(_mm_loadu_si128((__m128i *) &in_b[ii]));
  505|      0|      if (elem_size == 2) {
  ------------------
  |  Branch (505:11): [True: 0, False: 0]
  ------------------
  506|       |        // interleave the low bytes (first word) and high bytes (second word)
  507|      0|        xmm = _mm_unpacklo_epi8(xmm, _mm_unpackhi_epi64(xmm, xmm));
  508|      0|      }
  509|      0|      _mm_storeu_si128((__m128i *) &out_b[ii], xmm);
  510|      0|    }
  511|      0|    if (ii < nbyte) {
  ------------------
  |  Branch (511:9): [True: 0, False: 0]
  ------------------
  512|      0|      bshuf_shuffle_bit_eightelem_scal(&in_b[ii], &out_b[ii],
  513|      0|                                       (nbyte - ii) / elem_size, elem_size);
  514|      0|    }
  515|     99|  } else if (elem_size % 2) {
  ------------------
  |  Branch (515:14): [True: 71, False: 28]
  ------------------
  516|     71|    bshuf_shuffle_bit_eightelem_scal(in, out, size, elem_size);
  517|     71|  } else {
  518|   198k|    for (ii = 0; ii + 8 * elem_size - 1 < nbyte;
  ------------------
  |  Branch (518:18): [True: 198k, False: 28]
  ------------------
  519|   198k|         ii += 8 * elem_size) {
  520|  9.68M|      for (jj = 0; jj + 15 < 8 * elem_size; jj += 16) {
  ------------------
  |  Branch (520:20): [True: 9.48M, False: 198k]
  ------------------
  521|  9.48M|        xmm = _mm_loadu_si128((__m128i *) &in_b[ii + jj]);
  522|  85.3M|        for (kk = 0; kk < 8; kk++) {
  ------------------
  |  Branch (522:22): [True: 75.8M, False: 9.48M]
  ------------------
  523|  75.8M|          bt = _mm_movemask_epi8(xmm);
  524|  75.8M|          xmm = _mm_slli_epi16(xmm, 1);
  525|  75.8M|          size_t ind = (ii + jj / 8 + (7 - kk) * elem_size);
  526|  75.8M|          out_ui16[ind / 2] = bt;
  527|  75.8M|        }
  528|  9.48M|      }
  529|   198k|    }
  530|     28|  }
  531|     99|  return size * elem_size;
  532|     99|}
bitshuffle-sse2.c:trans_byte_bitrow_SSE:
  337|  1.20k|                                     const size_t elem_size, const bool transpose_bits) {
  338|       |
  339|  1.20k|  size_t ii, jj;
  340|  1.20k|  const char* in_b = (const char*) in;
  341|  1.20k|  char* out_b = (char*) out;
  342|       |
  343|  1.20k|  CHECK_MULT_EIGHT(size);
  ------------------
  |  |   35|  1.20k|#define CHECK_MULT_EIGHT(n) if (n % 8) return -80;
  |  |  ------------------
  |  |  |  Branch (35:33): [True: 0, False: 1.20k]
  |  |  ------------------
  ------------------
  344|       |
  345|  1.20k|  size_t nrows = 8 * elem_size;
  346|  1.20k|  size_t nbyte_row = size / 8;
  347|       |
  348|  1.20k|  __m128i a0, b0, c0, d0, e0, f0, g0, h0;
  349|  1.20k|  __m128i a1, b1, c1, d1, e1, f1, g1, h1;
  350|  1.20k|  __m128 *as, *bs, *cs, *ds, *es, *fs, *gs, *hs;
  351|       |
  352|  7.86k|  for (ii = 0; ii + 7 < nrows; ii += 8) {
  ------------------
  |  Branch (352:16): [True: 6.66k, False: 1.20k]
  ------------------
  353|  14.6M|    for (jj = 0; jj + 15 < nbyte_row; jj += 16) {
  ------------------
  |  Branch (353:18): [True: 14.6M, False: 6.66k]
  ------------------
  354|  14.6M|      a0 = _mm_loadu_si128((__m128i *) &in_b[(ii + 0)*nbyte_row + jj]);
  355|  14.6M|      b0 = _mm_loadu_si128((__m128i *) &in_b[(ii + 1)*nbyte_row + jj]);
  356|  14.6M|      c0 = _mm_loadu_si128((__m128i *) &in_b[(ii + 2)*nbyte_row + jj]);
  357|  14.6M|      d0 = _mm_loadu_si128((__m128i *) &in_b[(ii + 3)*nbyte_row + jj]);
  358|  14.6M|      e0 = _mm_loadu_si128((__m128i *) &in_b[(ii + 4)*nbyte_row + jj]);
  359|  14.6M|      f0 = _mm_loadu_si128((__m128i *) &in_b[(ii + 5)*nbyte_row + jj]);
  360|  14.6M|      g0 = _mm_loadu_si128((__m128i *) &in_b[(ii + 6)*nbyte_row + jj]);
  361|  14.6M|      h0 = _mm_loadu_si128((__m128i *) &in_b[(ii + 7)*nbyte_row + jj]);
  362|       |
  363|       |
  364|  14.6M|      a1 = _mm_unpacklo_epi8(a0, b0);
  365|  14.6M|      b1 = _mm_unpacklo_epi8(c0, d0);
  366|  14.6M|      c1 = _mm_unpacklo_epi8(e0, f0);
  367|  14.6M|      d1 = _mm_unpacklo_epi8(g0, h0);
  368|  14.6M|      e1 = _mm_unpackhi_epi8(a0, b0);
  369|  14.6M|      f1 = _mm_unpackhi_epi8(c0, d0);
  370|  14.6M|      g1 = _mm_unpackhi_epi8(e0, f0);
  371|  14.6M|      h1 = _mm_unpackhi_epi8(g0, h0);
  372|       |
  373|       |
  374|  14.6M|      a0 = _mm_unpacklo_epi16(a1, b1);
  375|  14.6M|      b0 = _mm_unpacklo_epi16(c1, d1);
  376|  14.6M|      c0 = _mm_unpackhi_epi16(a1, b1);
  377|  14.6M|      d0 = _mm_unpackhi_epi16(c1, d1);
  378|       |
  379|  14.6M|      e0 = _mm_unpacklo_epi16(e1, f1);
  380|  14.6M|      f0 = _mm_unpacklo_epi16(g1, h1);
  381|  14.6M|      g0 = _mm_unpackhi_epi16(e1, f1);
  382|  14.6M|      h0 = _mm_unpackhi_epi16(g1, h1);
  383|       |
  384|       |
  385|  14.6M|      a1 = _mm_unpacklo_epi32(a0, b0);
  386|  14.6M|      b1 = _mm_unpackhi_epi32(a0, b0);
  387|       |
  388|  14.6M|      c1 = _mm_unpacklo_epi32(c0, d0);
  389|  14.6M|      d1 = _mm_unpackhi_epi32(c0, d0);
  390|       |
  391|  14.6M|      e1 = _mm_unpacklo_epi32(e0, f0);
  392|  14.6M|      f1 = _mm_unpackhi_epi32(e0, f0);
  393|       |
  394|  14.6M|      g1 = _mm_unpacklo_epi32(g0, h0);
  395|  14.6M|      h1 = _mm_unpackhi_epi32(g0, h0);
  396|       |
  397|  14.6M|      if (transpose_bits) {
  ------------------
  |  Branch (397:11): [True: 12.4M, False: 2.17M]
  ------------------
  398|  12.4M|#define STORE_BYTES(v, k) _mm_storeu_si128((__m128i*)(out_b + (jj + (k)) * 8), trans_bit_8x8_SSE(v))
  399|  12.4M|        STORE_BYTES(a1, 0); STORE_BYTES(b1, 2);
  ------------------
  |  |  398|  12.4M|#define STORE_BYTES(v, k) _mm_storeu_si128((__m128i*)(out_b + (jj + (k)) * 8), trans_bit_8x8_SSE(v))
  ------------------
                      STORE_BYTES(a1, 0); STORE_BYTES(b1, 2);
  ------------------
  |  |  398|  12.4M|#define STORE_BYTES(v, k) _mm_storeu_si128((__m128i*)(out_b + (jj + (k)) * 8), trans_bit_8x8_SSE(v))
  ------------------
  400|  12.4M|        STORE_BYTES(c1, 4); STORE_BYTES(d1, 6);
  ------------------
  |  |  398|  12.4M|#define STORE_BYTES(v, k) _mm_storeu_si128((__m128i*)(out_b + (jj + (k)) * 8), trans_bit_8x8_SSE(v))
  ------------------
                      STORE_BYTES(c1, 4); STORE_BYTES(d1, 6);
  ------------------
  |  |  398|  12.4M|#define STORE_BYTES(v, k) _mm_storeu_si128((__m128i*)(out_b + (jj + (k)) * 8), trans_bit_8x8_SSE(v))
  ------------------
  401|  12.4M|        STORE_BYTES(e1, 8); STORE_BYTES(f1, 10);
  ------------------
  |  |  398|  12.4M|#define STORE_BYTES(v, k) _mm_storeu_si128((__m128i*)(out_b + (jj + (k)) * 8), trans_bit_8x8_SSE(v))
  ------------------
                      STORE_BYTES(e1, 8); STORE_BYTES(f1, 10);
  ------------------
  |  |  398|  12.4M|#define STORE_BYTES(v, k) _mm_storeu_si128((__m128i*)(out_b + (jj + (k)) * 8), trans_bit_8x8_SSE(v))
  ------------------
  402|  12.4M|        STORE_BYTES(g1, 12); STORE_BYTES(h1, 14);
  ------------------
  |  |  398|  12.4M|#define STORE_BYTES(v, k) _mm_storeu_si128((__m128i*)(out_b + (jj + (k)) * 8), trans_bit_8x8_SSE(v))
  ------------------
                      STORE_BYTES(g1, 12); STORE_BYTES(h1, 14);
  ------------------
  |  |  398|  12.4M|#define STORE_BYTES(v, k) _mm_storeu_si128((__m128i*)(out_b + (jj + (k)) * 8), trans_bit_8x8_SSE(v))
  ------------------
  403|  12.4M|#undef STORE_BYTES
  404|  12.4M|        continue;
  405|  12.4M|      }
  406|       |      // We don't have a storeh instruction for integers, so interpret
  407|       |      // as a float. Have a storel (_mm_storel_epi64).
  408|  2.17M|      as = (__m128 *) &a1;
  409|  2.17M|      bs = (__m128 *) &b1;
  410|  2.17M|      cs = (__m128 *) &c1;
  411|  2.17M|      ds = (__m128 *) &d1;
  412|  2.17M|      es = (__m128 *) &e1;
  413|  2.17M|      fs = (__m128 *) &f1;
  414|  2.17M|      gs = (__m128 *) &g1;
  415|  2.17M|      hs = (__m128 *) &h1;
  416|       |
  417|  2.17M|      _mm_storel_pi((__m64 *) &out_b[(jj + 0) * nrows + ii], *as);
  418|  2.17M|      _mm_storel_pi((__m64 *) &out_b[(jj + 2) * nrows + ii], *bs);
  419|  2.17M|      _mm_storel_pi((__m64 *) &out_b[(jj + 4) * nrows + ii], *cs);
  420|  2.17M|      _mm_storel_pi((__m64 *) &out_b[(jj + 6) * nrows + ii], *ds);
  421|  2.17M|      _mm_storel_pi((__m64 *) &out_b[(jj + 8) * nrows + ii], *es);
  422|  2.17M|      _mm_storel_pi((__m64 *) &out_b[(jj + 10) * nrows + ii], *fs);
  423|  2.17M|      _mm_storel_pi((__m64 *) &out_b[(jj + 12) * nrows + ii], *gs);
  424|  2.17M|      _mm_storel_pi((__m64 *) &out_b[(jj + 14) * nrows + ii], *hs);
  425|       |
  426|  2.17M|      _mm_storeh_pi((__m64 *) &out_b[(jj + 1) * nrows + ii], *as);
  427|  2.17M|      _mm_storeh_pi((__m64 *) &out_b[(jj + 3) * nrows + ii], *bs);
  428|  2.17M|      _mm_storeh_pi((__m64 *) &out_b[(jj + 5) * nrows + ii], *cs);
  429|  2.17M|      _mm_storeh_pi((__m64 *) &out_b[(jj + 7) * nrows + ii], *ds);
  430|  2.17M|      _mm_storeh_pi((__m64 *) &out_b[(jj + 9) * nrows + ii], *es);
  431|  2.17M|      _mm_storeh_pi((__m64 *) &out_b[(jj + 11) * nrows + ii], *fs);
  432|  2.17M|      _mm_storeh_pi((__m64 *) &out_b[(jj + 13) * nrows + ii], *gs);
  433|  2.17M|      _mm_storeh_pi((__m64 *) &out_b[(jj + 15) * nrows + ii], *hs);
  434|  2.17M|    }
  435|  38.4k|    for (jj = nbyte_row - nbyte_row % 16; jj < nbyte_row; jj ++) {
  ------------------
  |  Branch (435:43): [True: 31.7k, False: 6.66k]
  ------------------
  436|  31.7k|      out_b[jj * nrows + ii + 0] = in_b[(ii + 0)*nbyte_row + jj];
  437|  31.7k|      out_b[jj * nrows + ii + 1] = in_b[(ii + 1)*nbyte_row + jj];
  438|  31.7k|      out_b[jj * nrows + ii + 2] = in_b[(ii + 2)*nbyte_row + jj];
  439|  31.7k|      out_b[jj * nrows + ii + 3] = in_b[(ii + 3)*nbyte_row + jj];
  440|  31.7k|      out_b[jj * nrows + ii + 4] = in_b[(ii + 4)*nbyte_row + jj];
  441|  31.7k|      out_b[jj * nrows + ii + 5] = in_b[(ii + 5)*nbyte_row + jj];
  442|  31.7k|      out_b[jj * nrows + ii + 6] = in_b[(ii + 6)*nbyte_row + jj];
  443|  31.7k|      out_b[jj * nrows + ii + 7] = in_b[(ii + 7)*nbyte_row + jj];
  444|  31.7k|      if (transpose_bits) {
  ------------------
  |  Branch (444:11): [True: 3.90k, False: 27.8k]
  ------------------
  445|  3.90k|        uint64_t x, t;
  446|  3.90k|        memcpy(&x, out_b + jj * 8, 8);
  447|  3.90k|        TRANS_BIT_8X8(x, t);
  ------------------
  |  |   54|  3.90k|#define TRANS_BIT_8X8(x, t) {                                               \
  |  |   55|  3.90k|        t = (x ^ (x >> 7)) & 0x00AA00AA00AA00AALL;                          \
  |  |   56|  3.90k|        x = x ^ t ^ (t << 7);                                               \
  |  |   57|  3.90k|        t = (x ^ (x >> 14)) & 0x0000CCCC0000CCCCLL;                         \
  |  |   58|  3.90k|        x = x ^ t ^ (t << 14);                                              \
  |  |   59|  3.90k|        t = (x ^ (x >> 28)) & 0x00000000F0F0F0F0LL;                         \
  |  |   60|  3.90k|        x = x ^ t ^ (t << 28);                                              \
  |  |   61|  3.90k|    }
  ------------------
  448|  3.90k|        memcpy(out_b + jj * 8, &x, 8);
  449|  3.90k|      }
  450|  31.7k|    }
  451|  6.66k|  }
  452|  1.20k|  return size * elem_size;
  453|  1.20k|}
bitshuffle-sse2.c:trans_bit_8x8_SSE:
  466|  99.9M|static inline __m128i trans_bit_8x8_SSE(__m128i x) {
  467|  99.9M|  __m128i t;
  468|  99.9M|  t = _mm_and_si128(_mm_xor_si128(x, _mm_srli_epi64(x, 7)),
  469|  99.9M|                    _mm_set1_epi64x(0x00AA00AA00AA00AALL));
  470|  99.9M|  x = _mm_xor_si128(x, _mm_xor_si128(t, _mm_slli_epi64(t, 7)));
  471|  99.9M|  t = _mm_and_si128(_mm_xor_si128(x, _mm_srli_epi64(x, 14)),
  472|  99.9M|                    _mm_set1_epi64x(0x0000CCCC0000CCCCLL));
  473|  99.9M|  x = _mm_xor_si128(x, _mm_xor_si128(t, _mm_slli_epi64(t, 14)));
  474|  99.9M|  t = _mm_and_si128(_mm_xor_si128(x, _mm_srli_epi64(x, 28)),
  475|  99.9M|                    _mm_set1_epi64x(0x00000000F0F0F0F0LL));
  476|  99.9M|  x = _mm_xor_si128(x, _mm_xor_si128(t, _mm_slli_epi64(t, 28)));
  477|  99.9M|  return x;
  478|  99.9M|}

blosc2.c:blosc2_checked_mul_size:
   41|  1.58M|static inline bool blosc2_checked_mul_size(size_t a, size_t b, size_t *out) {
   42|  1.58M|  if (a != 0 && b > SIZE_MAX / a) {
  ------------------
  |  Branch (42:7): [True: 1.58M, False: 0]
  |  Branch (42:17): [True: 0, False: 1.58M]
  ------------------
   43|      0|    return false;
   44|      0|  }
   45|  1.58M|  if (out != NULL) {
  ------------------
  |  Branch (45:7): [True: 1.58M, False: 0]
  ------------------
   46|  1.58M|    *out = a * b;
   47|  1.58M|  }
   48|       |  return true;
   49|  1.58M|}
blosc2.c:blosc2_checked_add_size:
   31|  1.58M|static inline bool blosc2_checked_add_size(size_t a, size_t b, size_t *out) {
   32|  1.58M|  if (a > SIZE_MAX - b) {
  ------------------
  |  Branch (32:7): [True: 0, False: 1.58M]
  ------------------
   33|      0|    return false;
   34|      0|  }
   35|  1.58M|  if (out != NULL) {
  ------------------
  |  Branch (35:7): [True: 1.58M, False: 0]
  ------------------
   36|  1.58M|    *out = a + b;
   37|  1.58M|  }
   38|       |  return true;
   39|  1.58M|}
schunk.c:blosc2_checked_mul_i64_nonneg:
   71|  6.08k|static inline bool blosc2_checked_mul_i64_nonneg(int64_t a, int64_t b, int64_t *out) {
   72|  6.08k|  if (a < 0 || b < 0 || (a != 0 && b > INT64_MAX / a)) {
  ------------------
  |  Branch (72:7): [True: 0, False: 6.08k]
  |  Branch (72:16): [True: 0, False: 6.08k]
  |  Branch (72:26): [True: 6.08k, False: 0]
  |  Branch (72:36): [True: 0, False: 6.08k]
  ------------------
   73|      0|    return false;
   74|      0|  }
   75|  6.08k|  if (out != NULL) {
  ------------------
  |  Branch (75:7): [True: 0, False: 6.08k]
  ------------------
   76|      0|    *out = a * b;
   77|      0|  }
   78|       |  return true;
   79|  6.08k|}
frame.c:blosc2_checked_add_i64_nonneg:
   61|   769k|static inline bool blosc2_checked_add_i64_nonneg(int64_t a, int64_t b, int64_t *out) {
   62|   769k|  if (a < 0 || b < 0 || a > INT64_MAX - b) {
  ------------------
  |  Branch (62:7): [True: 0, False: 769k]
  |  Branch (62:16): [True: 0, False: 769k]
  |  Branch (62:25): [True: 0, False: 769k]
  ------------------
   63|      0|    return false;
   64|      0|  }
   65|   769k|  if (out != NULL) {
  ------------------
  |  Branch (65:7): [True: 769k, False: 0]
  ------------------
   66|   769k|    *out = a + b;
   67|   769k|  }
   68|       |  return true;
   69|   769k|}
b2nd.c:blosc2_checked_mul_size:
   41|   138k|static inline bool blosc2_checked_mul_size(size_t a, size_t b, size_t *out) {
   42|   138k|  if (a != 0 && b > SIZE_MAX / a) {
  ------------------
  |  Branch (42:7): [True: 138k, False: 0]
  |  Branch (42:17): [True: 0, False: 138k]
  ------------------
   43|      0|    return false;
   44|      0|  }
   45|   138k|  if (out != NULL) {
  ------------------
  |  Branch (45:7): [True: 138k, False: 0]
  ------------------
   46|   138k|    *out = a * b;
   47|   138k|  }
   48|       |  return true;
   49|   138k|}
b2nd.c:blosc2_checked_mul_i64_nonneg:
   71|   987k|static inline bool blosc2_checked_mul_i64_nonneg(int64_t a, int64_t b, int64_t *out) {
   72|   987k|  if (a < 0 || b < 0 || (a != 0 && b > INT64_MAX / a)) {
  ------------------
  |  Branch (72:7): [True: 0, False: 987k]
  |  Branch (72:16): [True: 0, False: 987k]
  |  Branch (72:26): [True: 913k, False: 73.6k]
  |  Branch (72:36): [True: 0, False: 913k]
  ------------------
   73|      0|    return false;
   74|      0|  }
   75|   987k|  if (out != NULL) {
  ------------------
  |  Branch (75:7): [True: 987k, False: 0]
  ------------------
   76|   987k|    *out = a * b;
   77|   987k|  }
   78|       |  return true;
   79|   987k|}
b2nd.c:blosc2_checked_mul_i32_nonneg:
   81|   477k|static inline bool blosc2_checked_mul_i32_nonneg(int32_t a, int32_t b, int32_t *out) {
   82|   477k|  if (a < 0 || b < 0 || (a != 0 && b > INT32_MAX / a)) {
  ------------------
  |  Branch (82:7): [True: 0, False: 477k]
  |  Branch (82:16): [True: 0, False: 477k]
  |  Branch (82:26): [True: 477k, False: 0]
  |  Branch (82:36): [True: 0, False: 477k]
  ------------------
   83|      0|    return false;
   84|      0|  }
   85|   477k|  if (out != NULL) {
  ------------------
  |  Branch (85:7): [True: 477k, False: 0]
  ------------------
   86|   477k|    *out = a * b;
   87|   477k|  }
   88|       |  return true;
   89|   477k|}

blosc2.c:is_little_endian:
   42|  55.8M|static bool is_little_endian(void) {
   43|  55.8M|  static const int i = 1;
   44|  55.8M|  char* p = (char*)&i;
   45|       |
   46|  55.8M|  if (p[0] == 1) {
  ------------------
  |  Branch (46:7): [True: 55.8M, False: 0]
  ------------------
   47|  55.8M|    return true;
   48|  55.8M|  }
   49|      0|  else {
   50|       |    return false;
   51|      0|  }
   52|  55.8M|}
blosc2.c:load_lib:
  439|      4|static inline void* load_lib(char *plugin_name, char *libpath) {
  440|      4|  if (!blosc2_valid_plugin_name(plugin_name)) {
  ------------------
  |  Branch (440:7): [True: 0, False: 4]
  ------------------
  441|      0|    BLOSC_TRACE_ERROR("Invalid plugin name");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  442|      0|    return NULL;
  443|      0|  }
  444|       |    // Attempt to directly load the library by name
  445|       |#if defined(_WIN32)
  446|       |    // Windows dynamic library (DLL) format
  447|       |    snprintf(libpath, PATH_MAX, "blosc2_%s.dll", plugin_name);
  448|       |#else
  449|       |    // Unix/Linux/Mac OS dynamic library (.so) format
  450|      4|    snprintf(libpath, PATH_MAX, "libblosc2_%s.so", plugin_name);
  451|      4|#endif
  452|      4|    void* loaded_lib = dlopen(libpath, RTLD_LAZY);
  453|      4|    if (loaded_lib != NULL) {
  ------------------
  |  Branch (453:9): [True: 0, False: 4]
  ------------------
  454|      0|        BLOSC_TRACE_INFO("Successfully loaded %s directly\n", libpath);
  ------------------
  |  |   95|      0|#define BLOSC_TRACE_INFO(msg, ...) BLOSC_TRACE(info, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  455|      0|        return loaded_lib;
  456|      4|    } else {
  457|       |#if defined(_WIN32)
  458|       |        BLOSC_TRACE_INFO("Failed to load %s directly, error: %lu\n", libpath, GetLastError());
  459|       |#else
  460|      4|        BLOSC_TRACE_INFO("Failed to load %s directly, error: %s\n", libpath, dlerror());
  ------------------
  |  |   95|      4|#define BLOSC_TRACE_INFO(msg, ...) BLOSC_TRACE(info, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      4|    do {                                            \
  |  |  |  |   98|      4|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      4|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      4|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  461|      4|#endif
  462|      4|    }
  463|       |    // If direct loading fails, fallback to using Python to find the library path
  464|      4|    if (get_libpath(plugin_name, libpath, "") < 0 && get_libpath(plugin_name, libpath, "3") < 0) {
  ------------------
  |  Branch (464:9): [True: 4, False: 0]
  |  Branch (464:54): [True: 4, False: 0]
  ------------------
  465|      4|        BLOSC_TRACE_ERROR("Problems when running python or python3 for getting plugin path");
  ------------------
  |  |   93|      4|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      4|    do {                                            \
  |  |  |  |   98|      4|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      4|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      4|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  466|      4|        return NULL;
  467|      4|    }
  468|       |
  469|      0|    if (strlen(libpath) == 0) {
  ------------------
  |  Branch (469:9): [True: 0, False: 0]
  ------------------
  470|      0|        BLOSC_TRACE_ERROR("Could not find plugin libpath");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  471|      0|        return NULL;
  472|      0|    }
  473|       |
  474|       |    // Try to load the library again with the path from Python
  475|      0|    loaded_lib = dlopen(libpath, RTLD_LAZY);
  476|      0|    if (loaded_lib == NULL) {
  ------------------
  |  Branch (476:9): [True: 0, False: 0]
  ------------------
  477|      0|        BLOSC_TRACE_ERROR("Attempt to load plugin in path '%s' failed with error: %s", libpath, dlerror());
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  478|      0|    } else {
  479|      0|        BLOSC_TRACE_INFO("Successfully loaded library with Python path: %s\n", libpath);
  ------------------
  |  |   95|      0|#define BLOSC_TRACE_INFO(msg, ...) BLOSC_TRACE(info, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|      0|    }
  481|       |
  482|      0|    return loaded_lib;
  483|      0|}
blosc2.c:blosc2_valid_plugin_name:
  397|     12|static inline bool blosc2_valid_plugin_name(const char *plugin_name) {
  398|     12|  if (plugin_name == NULL || plugin_name[0] == '\0') {
  ------------------
  |  Branch (398:7): [True: 0, False: 12]
  |  Branch (398:30): [True: 0, False: 12]
  ------------------
  399|      0|    return false;
  400|      0|  }
  401|     78|  for (const unsigned char *p = (const unsigned char *)plugin_name; *p != '\0'; ++p) {
  ------------------
  |  Branch (401:69): [True: 66, False: 12]
  ------------------
  402|     66|    if (!isalnum(*p) && *p != '_') {
  ------------------
  |  Branch (402:9): [True: 0, False: 66]
  |  Branch (402:25): [True: 0, False: 0]
  ------------------
  403|      0|      return false;
  404|      0|    }
  405|     66|  }
  406|     12|  return true;
  407|     12|}
blosc2.c:get_libpath:
  410|      8|static inline int get_libpath(char *plugin_name, char *libpath, char *python_version) {
  411|      8|  BLOSC_TRACE_INFO("Trying to get plugin path with python%s\n", python_version);
  ------------------
  |  |   95|      8|#define BLOSC_TRACE_INFO(msg, ...) BLOSC_TRACE(info, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      8|    do {                                            \
  |  |  |  |   98|      8|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      8|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      8|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|      8|  char python_cmd[PATH_MAX] = {0};
  413|      8|  if (!blosc2_valid_plugin_name(plugin_name)) {
  ------------------
  |  Branch (413:7): [True: 0, False: 8]
  ------------------
  414|      0|    BLOSC_TRACE_ERROR("Invalid plugin name");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  415|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  416|      0|  }
  417|      8|  int written = snprintf(python_cmd, sizeof(python_cmd),
  418|      8|                         "python%s -c \"import blosc2_%s; blosc2_%s.print_libpath()\"",
  419|      8|                         python_version, plugin_name, plugin_name);
  420|      8|  if (written < 0 || (size_t)written >= sizeof(python_cmd)) {
  ------------------
  |  Branch (420:7): [True: 0, False: 8]
  |  Branch (420:22): [True: 0, False: 8]
  ------------------
  421|      0|    BLOSC_TRACE_ERROR("Python command is too long");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|      0|    return BLOSC2_ERROR_FAILURE;
  423|      0|  }
  424|      8|  FILE *fp = popen(python_cmd, "r");
  425|      8|  if (fp == NULL) {
  ------------------
  |  Branch (425:7): [True: 0, False: 8]
  ------------------
  426|      0|    BLOSC_TRACE_ERROR("Could not run python");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  427|      0|    return BLOSC2_ERROR_FAILURE;
  428|      0|  }
  429|      8|  if (fgets(libpath, PATH_MAX, fp) == NULL) {
  ------------------
  |  Branch (429:7): [True: 8, False: 0]
  ------------------
  430|      8|    BLOSC_TRACE_ERROR("Could not read python output");
  ------------------
  |  |   93|      8|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      8|    do {                                            \
  |  |  |  |   98|      8|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      8|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      8|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  431|      8|    pclose(fp);
  432|      8|    return BLOSC2_ERROR_FAILURE;
  433|      8|  }
  434|      0|  pclose(fp);
  435|       |
  436|      0|  return BLOSC2_ERROR_SUCCESS;
  437|      8|}
blosc2.c:_sw32:
  241|  15.7M|static inline void _sw32(void* dest, int32_t a) {
  242|  15.7M|  uint8_t* dest_ = (uint8_t*)dest;
  243|  15.7M|  uint8_t* pa = (uint8_t*)&a;
  244|       |
  245|  15.7M|  bool little_endian = is_little_endian();
  246|  15.7M|  if (little_endian) {
  ------------------
  |  Branch (246:7): [True: 15.7M, False: 0]
  ------------------
  247|  15.7M|    memcpy(dest_, &a, sizeof(a));;
  248|  15.7M|  }
  249|      0|  else {
  250|      0|#if defined (__GNUC__)
  251|      0|    *(int32_t *)dest_ = __builtin_bswap32(*(unsigned int *)pa);
  252|       |#elif defined (_MSC_VER) /* Visual Studio */
  253|       |    *(int32_t *)dest_ = _byteswap_ulong(*(unsigned int *)pa);
  254|       |#else
  255|       |    dest_[0] = pa[3];
  256|       |    dest_[1] = pa[2];
  257|       |    dest_[2] = pa[1];
  258|       |    dest_[3] = pa[0];
  259|       |#endif
  260|      0|  }
  261|  15.7M|}
blosc2.c:sw32_:
  216|  10.7M|static inline int32_t sw32_(const void* pa) {
  217|  10.7M|  int32_t idest;
  218|       |
  219|  10.7M|  bool little_endian = is_little_endian();
  220|  10.7M|  if (little_endian) {
  ------------------
  |  Branch (220:7): [True: 10.7M, False: 0]
  ------------------
  221|  10.7M|    memcpy(&idest, pa, sizeof(idest));
  222|  10.7M|  }
  223|      0|  else {
  224|      0|#if defined (__GNUC__)
  225|      0|    return __builtin_bswap32(*(unsigned int *)pa);
  226|       |#elif defined (_MSC_VER) /* Visual Studio */
  227|       |    return _byteswap_ulong(*(unsigned int *)pa);
  228|       |#else
  229|       |    const uint8_t *pa_ = (const uint8_t *)pa;
  230|       |    uint8_t *dest = (uint8_t *)&idest;
  231|       |    dest[0] = pa_[3];
  232|       |    dest[1] = pa_[2];
  233|       |    dest[2] = pa_[1];
  234|       |    dest[3] = pa_[0];
  235|       |#endif
  236|      0|  }
  237|  10.7M|  return idest;
  238|  10.7M|}
blosc2.c:filters_contain:
  131|  3.32M|static inline bool filters_contain(const uint8_t *filters, uint8_t id) {
  132|  23.2M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (132:19): [True: 19.9M, False: 3.32M]
  ------------------
  133|  19.9M|    if (filters[i] == id) {
  ------------------
  |  Branch (133:9): [True: 7, False: 19.9M]
  ------------------
  134|      7|      return true;
  135|      7|    }
  136|  19.9M|  }
  137|  3.32M|  return false;
  138|  3.32M|}
schunk.c:blosc2_nchunks_to_offsets_nbytes:
  103|  1.84k|static inline bool blosc2_nchunks_to_offsets_nbytes(int64_t nchunks, int32_t *off_nbytes) {
  104|  1.84k|  const int64_t max_nchunks = INT32_MAX / (int64_t)sizeof(int64_t);
  105|  1.84k|  if (nchunks < 0 || nchunks > max_nchunks) {
  ------------------
  |  Branch (105:7): [True: 0, False: 1.84k]
  |  Branch (105:22): [True: 0, False: 1.84k]
  ------------------
  106|      0|    return false;
  107|      0|  }
  108|  1.84k|  if (off_nbytes != NULL) {
  ------------------
  |  Branch (108:7): [True: 0, False: 1.84k]
  ------------------
  109|      0|    *off_nbytes = (int32_t)(nchunks * (int64_t)sizeof(int64_t));
  110|      0|  }
  111|       |  return true;
  112|  1.84k|}
schunk.c:get_chunk_flags2:
  121|  5.40M|static inline uint8_t get_chunk_flags2(const uint8_t *chunk, int32_t chunk_cbytes) {
  122|  5.40M|  uint8_t flags = chunk[BLOSC2_CHUNK_FLAGS];
  123|  5.40M|  bool extended_header = (flags & BLOSC_DOSHUFFLE) && (flags & BLOSC_DOBITSHUFFLE);
  ------------------
  |  Branch (123:26): [True: 5.40M, False: 0]
  |  Branch (123:55): [True: 5.40M, False: 0]
  ------------------
  124|  5.40M|  if (!extended_header || chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (124:7): [True: 0, False: 5.40M]
  |  Branch (124:27): [True: 0, False: 5.40M]
  ------------------
  125|      0|    return 0;
  126|      0|  }
  127|  5.40M|  return chunk[BLOSC2_CHUNK_BLOSC2_FLAGS2];
  128|  5.40M|}
schunk.c:chunksize_after_adding:
  166|  2.08M|                                         int32_t nbytes, bool at_end) {
  167|  2.08M|  if (*chunksize == 0) {
  ------------------
  |  Branch (167:7): [True: 0, False: 2.08M]
  ------------------
  168|      0|    return true;
  169|      0|  }
  170|  2.08M|  int32_t size = (*chunksize == -1) ? nbytes : *chunksize;
  ------------------
  |  Branch (170:18): [True: 0, False: 2.08M]
  ------------------
  171|  2.08M|  if (nchunks > 0 && (last_nbytes < size || nbytes > size || (!at_end && nbytes != size))) {
  ------------------
  |  Branch (171:7): [True: 2.08M, False: 4.27k]
  |  Branch (171:23): [True: 0, False: 2.08M]
  |  Branch (171:45): [True: 0, False: 2.08M]
  |  Branch (171:63): [True: 264k, False: 1.81M]
  |  Branch (171:74): [True: 0, False: 264k]
  ------------------
  172|      0|    *chunksize = 0;
  173|      0|    return true;
  174|      0|  }
  175|  2.08M|  if (size > 0 && nbytes > size) {
  ------------------
  |  Branch (175:7): [True: 2.08M, False: 0]
  |  Branch (175:19): [True: 0, False: 2.08M]
  ------------------
  176|      0|    return false;
  177|      0|  }
  178|  2.08M|  *chunksize = size;
  179|       |  return true;
  180|  2.08M|}
schunk.c:chunk_special_in_offset:
  143|  1.14M|static inline int chunk_special_in_offset(const uint8_t *chunk, int32_t cbytes) {
  144|  1.14M|  if (cbytes < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (144:7): [True: 0, False: 1.14M]
  ------------------
  145|      0|    return 0;
  146|      0|  }
  147|  1.14M|  int special_value = (chunk[BLOSC2_CHUNK_BLOSC2_FLAGS] >> 4) & BLOSC2_SPECIAL_MASK;
  148|  1.14M|  switch (special_value) {
  149|   639k|    case BLOSC2_SPECIAL_ZERO:
  ------------------
  |  Branch (149:5): [True: 639k, False: 508k]
  ------------------
  150|   639k|    case BLOSC2_SPECIAL_NAN:
  ------------------
  |  Branch (150:5): [True: 0, False: 1.14M]
  ------------------
  151|   639k|    case BLOSC2_SPECIAL_UNINIT:
  ------------------
  |  Branch (151:5): [True: 0, False: 1.14M]
  ------------------
  152|   639k|      return special_value;
  153|   508k|    default:
  ------------------
  |  Branch (153:5): [True: 508k, False: 639k]
  ------------------
  154|   508k|      return 0;
  155|  1.14M|  }
  156|  1.14M|}
frame.c:endian_handler:
   56|  58.7M|{
   57|  58.7M|  bool little_endian = is_little_endian();
   58|  58.7M|  if (little_endian == little) {
  ------------------
  |  Branch (58:7): [True: 639k, False: 58.1M]
  ------------------
   59|   639k|    memcpy(dest, pa, size);
   60|   639k|  }
   61|  58.1M|  else {
   62|  58.1M|    uint8_t* pa_ = (uint8_t*)pa;
   63|  58.1M|    uint8_t pa2_[8];
   64|  58.1M|    switch (size) {
   65|  20.1M|      case 8:
  ------------------
  |  Branch (65:7): [True: 20.1M, False: 38.0M]
  ------------------
   66|  20.1M|        pa2_[0] = pa_[7];
   67|  20.1M|        pa2_[1] = pa_[6];
   68|  20.1M|        pa2_[2] = pa_[5];
   69|  20.1M|        pa2_[3] = pa_[4];
   70|  20.1M|        pa2_[4] = pa_[3];
   71|  20.1M|        pa2_[5] = pa_[2];
   72|  20.1M|        pa2_[6] = pa_[1];
   73|  20.1M|        pa2_[7] = pa_[0];
   74|  20.1M|        break;
   75|  28.7M|      case 4:
  ------------------
  |  Branch (75:7): [True: 28.7M, False: 29.3M]
  ------------------
   76|  28.7M|        pa2_[0] = pa_[3];
   77|  28.7M|        pa2_[1] = pa_[2];
   78|  28.7M|        pa2_[2] = pa_[1];
   79|  28.7M|        pa2_[3] = pa_[0];
   80|  28.7M|        break;
   81|  9.26M|      case 2:
  ------------------
  |  Branch (81:7): [True: 9.26M, False: 48.8M]
  ------------------
   82|  9.26M|        pa2_[0] = pa_[1];
   83|  9.26M|        pa2_[1] = pa_[0];
   84|  9.26M|        break;
   85|  3.42k|      case 1:
  ------------------
  |  Branch (85:7): [True: 3.42k, False: 58.1M]
  ------------------
   86|  3.42k|        pa2_[0] = pa_[0];
   87|  3.42k|        break;
   88|      0|      default:
  ------------------
  |  Branch (88:7): [True: 0, False: 58.1M]
  ------------------
   89|      0|        BLOSC_TRACE_ERROR("Unhandled size: %d.", size);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   90|  58.1M|    }
   91|  58.1M|    memcpy(dest, pa2_, size);
   92|  58.1M|  }
   93|  58.7M|}
frame.c:is_little_endian:
   42|  58.7M|static bool is_little_endian(void) {
   43|  58.7M|  static const int i = 1;
   44|  58.7M|  char* p = (char*)&i;
   45|       |
   46|  58.7M|  if (p[0] == 1) {
  ------------------
  |  Branch (46:7): [True: 58.7M, False: 0]
  ------------------
   47|  58.7M|    return true;
   48|  58.7M|  }
   49|      0|  else {
   50|       |    return false;
   51|      0|  }
   52|  58.7M|}
frame.c:blosc2_nchunks_to_offsets_nbytes:
  103|  9.77M|static inline bool blosc2_nchunks_to_offsets_nbytes(int64_t nchunks, int32_t *off_nbytes) {
  104|  9.77M|  const int64_t max_nchunks = INT32_MAX / (int64_t)sizeof(int64_t);
  105|  9.77M|  if (nchunks < 0 || nchunks > max_nchunks) {
  ------------------
  |  Branch (105:7): [True: 0, False: 9.77M]
  |  Branch (105:22): [True: 37, False: 9.77M]
  ------------------
  106|     37|    return false;
  107|     37|  }
  108|  9.77M|  if (off_nbytes != NULL) {
  ------------------
  |  Branch (108:7): [True: 9.77M, False: 0]
  ------------------
  109|  9.77M|    *off_nbytes = (int32_t)(nchunks * (int64_t)sizeof(int64_t));
  110|  9.77M|  }
  111|       |  return true;
  112|  9.77M|}
frame.c:chunk_special_in_offset:
  143|  1.14M|static inline int chunk_special_in_offset(const uint8_t *chunk, int32_t cbytes) {
  144|  1.14M|  if (cbytes < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (144:7): [True: 0, False: 1.14M]
  ------------------
  145|      0|    return 0;
  146|      0|  }
  147|  1.14M|  int special_value = (chunk[BLOSC2_CHUNK_BLOSC2_FLAGS] >> 4) & BLOSC2_SPECIAL_MASK;
  148|  1.14M|  switch (special_value) {
  149|   639k|    case BLOSC2_SPECIAL_ZERO:
  ------------------
  |  Branch (149:5): [True: 639k, False: 508k]
  ------------------
  150|   639k|    case BLOSC2_SPECIAL_NAN:
  ------------------
  |  Branch (150:5): [True: 0, False: 1.14M]
  ------------------
  151|   639k|    case BLOSC2_SPECIAL_UNINIT:
  ------------------
  |  Branch (151:5): [True: 0, False: 1.14M]
  ------------------
  152|   639k|      return special_value;
  153|   508k|    default:
  ------------------
  |  Branch (153:5): [True: 508k, False: 639k]
  ------------------
  154|   508k|      return 0;
  155|  1.14M|  }
  156|  1.14M|}
b2nd.c:filters_contain:
  131|   585k|static inline bool filters_contain(const uint8_t *filters, uint8_t id) {
  132|  4.10M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (132:19): [True: 3.51M, False: 585k]
  ------------------
  133|  3.51M|    if (filters[i] == id) {
  ------------------
  |  Branch (133:9): [True: 0, False: 3.51M]
  ------------------
  134|      0|      return true;
  135|      0|    }
  136|  3.51M|  }
  137|   585k|  return false;
  138|   585k|}

blosc2_stdio_destroy:
  272|  10.1k|int blosc2_stdio_destroy(void* params) {
  273|  10.1k|  BLOSC_UNUSED_PARAM(params);
  ------------------
  |  |   28|  10.1k|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  274|  10.1k|  return 0;
  275|  10.1k|}

do_nothing:
  815|   133M|int do_nothing(const blosc2_context* context, int i, char cmode) {
  816|   133M|  uint8_t filter = context->filters[i];
  817|   133M|  if (filter == BLOSC_SHUFFLE) {
  ------------------
  |  Branch (817:7): [True: 32.8M, False: 100M]
  ------------------
  818|       |    // Shuffling single bytes is the identity, so skip it instead of copying the block
  819|  32.8M|    return shuffle_size(context, i) == 1;
  820|  32.8M|  }
  821|   100M|  if (cmode == 'c') {
  ------------------
  |  Branch (821:7): [True: 72.5M, False: 28.2M]
  ------------------
  822|  72.5M|    return (filter == BLOSC_NOFILTER);
  823|  72.5M|  } else {
  824|       |    // TRUNC_PREC do not have to be applied during decompression
  825|  28.2M|    return ((filter == BLOSC_NOFILTER) || (filter == BLOSC_TRUNC_PREC));
  ------------------
  |  Branch (825:13): [True: 28.2M, False: 7.84k]
  |  Branch (825:43): [True: 278, False: 7.56k]
  ------------------
  826|  28.2M|  }
  827|   100M|}
next_filter:
  830|  8.88M|int next_filter(const blosc2_context* context, int current_filter, char cmode) {
  831|  11.5M|  for (int i = current_filter - 1; i >= 0; i--) {
  ------------------
  |  Branch (831:36): [True: 11.0M, False: 439k]
  ------------------
  832|  11.0M|    if (!do_nothing(context, i, cmode)) {
  ------------------
  |  Branch (832:9): [True: 8.44M, False: 2.63M]
  ------------------
  833|  8.44M|      return context->filters[i];
  834|  8.44M|    }
  835|  11.0M|  }
  836|   439k|  return BLOSC_NOFILTER;
  837|  8.88M|}
last_filter:
  840|  12.4M|int last_filter(const blosc2_context* context, char cmode) {
  841|  12.4M|  int last_index = -1;
  842|  86.7M|  for (int i = BLOSC2_MAX_FILTERS - 1; i >= 0; i--) {
  ------------------
  |  Branch (842:40): [True: 74.3M, False: 12.4M]
  ------------------
  843|  74.3M|    if (!do_nothing(context, i, cmode))  {
  ------------------
  |  Branch (843:9): [True: 6.36M, False: 67.9M]
  ------------------
  844|  6.36M|      last_index = i;
  845|  6.36M|    }
  846|  74.3M|  }
  847|  12.4M|  return last_index;
  848|  12.4M|}
read_chunk_header:
  927|  27.6M|{
  928|  27.6M|  memset(header, 0, sizeof(blosc_header));
  929|       |
  930|  27.6M|  if (srcsize < BLOSC_MIN_HEADER_LENGTH) {
  ------------------
  |  Branch (930:7): [True: 0, False: 27.6M]
  ------------------
  931|      0|    BLOSC_TRACE_ERROR("Not enough space to read Blosc header.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  932|      0|    return BLOSC2_ERROR_READ_BUFFER;
  933|      0|  }
  934|       |
  935|  27.6M|  memcpy(header, src, BLOSC_MIN_HEADER_LENGTH);
  936|       |
  937|  27.6M|  bool little_endian = is_little_endian();
  938|       |
  939|  27.6M|  if (!little_endian) {
  ------------------
  |  Branch (939:7): [True: 0, False: 27.6M]
  ------------------
  940|      0|    header->nbytes = bswap32_(header->nbytes);
  941|      0|    header->blocksize = bswap32_(header->blocksize);
  942|      0|    header->cbytes = bswap32_(header->cbytes);
  943|      0|  }
  944|       |
  945|  27.6M|  if (header->cbytes < BLOSC_MIN_HEADER_LENGTH) {
  ------------------
  |  Branch (945:7): [True: 24, False: 27.6M]
  ------------------
  946|     24|    BLOSC_TRACE_ERROR("`cbytes` is too small to read min header.");
  ------------------
  |  |   93|     24|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     24|    do {                                            \
  |  |  |  |   98|     24|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     24|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 24, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     24|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  947|     24|    return BLOSC2_ERROR_INVALID_HEADER;
  948|     24|  }
  949|  27.6M|  if (header->blocksize <= 0) {
  ------------------
  |  Branch (949:7): [True: 22, False: 27.6M]
  ------------------
  950|     22|    BLOSC_TRACE_ERROR("`blocksize` is zero");
  ------------------
  |  |   93|     22|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     22|    do {                                            \
  |  |  |  |   98|     22|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     22|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 22, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     22|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  951|     22|    return BLOSC2_ERROR_INVALID_HEADER;
  952|     22|  }
  953|  27.6M|  if (header->blocksize > BLOSC2_MAXBLOCKSIZE) {
  ------------------
  |  Branch (953:7): [True: 0, False: 27.6M]
  ------------------
  954|      0|    BLOSC_TRACE_ERROR("`blocksize` greater than maximum allowed");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  955|      0|    return BLOSC2_ERROR_INVALID_HEADER;
  956|      0|  }
  957|  27.6M|  if (header->typesize == 0) {
  ------------------
  |  Branch (957:7): [True: 0, False: 27.6M]
  ------------------
  958|      0|    BLOSC_TRACE_ERROR("`typesize` is zero.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  959|      0|    return BLOSC2_ERROR_INVALID_HEADER;
  960|      0|  }
  961|       |
  962|       |  /* Read extended header if it is wanted */
  963|  27.6M|  if ((extended_header) && (header->flags & BLOSC_DOSHUFFLE) && (header->flags & BLOSC_DOBITSHUFFLE)) {
  ------------------
  |  Branch (963:7): [True: 4.54M, False: 23.0M]
  |  Branch (963:28): [True: 4.54M, False: 256]
  |  Branch (963:65): [True: 4.54M, False: 23]
  ------------------
  964|  4.54M|    if (header->cbytes < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (964:9): [True: 1, False: 4.54M]
  ------------------
  965|      1|      BLOSC_TRACE_ERROR("`cbytes` is too small to read extended header.");
  ------------------
  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  966|      1|      return BLOSC2_ERROR_INVALID_HEADER;
  967|      1|    }
  968|  4.54M|    if (srcsize < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (968:9): [True: 0, False: 4.54M]
  ------------------
  969|      0|      BLOSC_TRACE_ERROR("Not enough space to read Blosc extended header.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  970|      0|      return BLOSC2_ERROR_READ_BUFFER;
  971|      0|    }
  972|       |
  973|  4.54M|    memcpy((uint8_t *)header + BLOSC_MIN_HEADER_LENGTH, src + BLOSC_MIN_HEADER_LENGTH,
  974|  4.54M|      BLOSC_EXTENDED_HEADER_LENGTH - BLOSC_MIN_HEADER_LENGTH);
  975|       |
  976|  4.54M|    if ((header->blosc2_flags2 & BLOSC2_VL_BLOCKS) && (header->blosc2_flags != 0)) {
  ------------------
  |  Branch (976:9): [True: 126, False: 4.54M]
  |  Branch (976:55): [True: 114, False: 12]
  ------------------
  977|    114|      int32_t special_type = (header->blosc2_flags >> 4) & BLOSC2_SPECIAL_MASK;
  978|    114|      if (special_type != 0) {
  ------------------
  |  Branch (978:11): [True: 0, False: 114]
  ------------------
  979|      0|        BLOSC_TRACE_ERROR("VL-block chunks cannot use special chunk encodings.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  980|      0|        return BLOSC2_ERROR_INVALID_HEADER;
  981|      0|      }
  982|    114|    }
  983|       |
  984|  4.54M|    int32_t special_type = (header->blosc2_flags >> 4) & BLOSC2_SPECIAL_MASK;
  985|  4.54M|    if (special_type != 0) {
  ------------------
  |  Branch (985:9): [True: 31.2k, False: 4.51M]
  ------------------
  986|  31.2k|      if (special_type == BLOSC2_SPECIAL_VALUE) {
  ------------------
  |  Branch (986:11): [True: 24.3k, False: 6.95k]
  ------------------
  987|       |        // In this case, the actual type size must be derived from the cbytes
  988|  24.3k|        int32_t typesize = header->cbytes - BLOSC_EXTENDED_HEADER_LENGTH;
  989|  24.3k|        if (typesize <= 0) {
  ------------------
  |  Branch (989:13): [True: 1, False: 24.3k]
  ------------------
  990|      1|          BLOSC_TRACE_ERROR("`typesize` is zero or negative");
  ------------------
  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  991|      1|          return BLOSC2_ERROR_INVALID_HEADER;
  992|      1|        }
  993|  24.3k|        if (typesize > BLOSC2_MAXTYPESIZE) {
  ------------------
  |  Branch (993:13): [True: 0, False: 24.3k]
  ------------------
  994|      0|          BLOSC_TRACE_ERROR("`typesize` is greater than maximum allowed");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  995|      0|          return BLOSC2_ERROR_INVALID_HEADER;
  996|      0|        }
  997|  24.3k|        if (typesize > header->nbytes) {
  ------------------
  |  Branch (997:13): [True: 0, False: 24.3k]
  ------------------
  998|      0|          BLOSC_TRACE_ERROR("`typesize` is greater than `nbytes`");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  999|      0|          return BLOSC2_ERROR_INVALID_HEADER;
 1000|      0|        }
 1001|  24.3k|        if (header->nbytes % typesize != 0) {
  ------------------
  |  Branch (1001:13): [True: 2, False: 24.3k]
  ------------------
 1002|      2|          BLOSC_TRACE_ERROR("`nbytes` is not a multiple of typesize");
  ------------------
  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1003|      2|          return BLOSC2_ERROR_INVALID_HEADER;
 1004|      2|        }
 1005|  24.3k|      }
 1006|  6.95k|      else {
 1007|       |        // All-zero chunks fill with memset, which works regardless of element alignment.
 1008|  6.95k|        if (special_type != BLOSC2_SPECIAL_ZERO
  ------------------
  |  Branch (1008:13): [True: 64, False: 6.89k]
  ------------------
 1009|     64|            && header->nbytes % header->typesize != 0) {
  ------------------
  |  Branch (1009:16): [True: 2, False: 62]
  ------------------
 1010|      2|          BLOSC_TRACE_ERROR("`nbytes` is not a multiple of typesize");
  ------------------
  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1011|      2|          return BLOSC2_ERROR_INVALID_HEADER;
 1012|      2|        }
 1013|  6.95k|      }
 1014|  31.2k|    }
 1015|       |    // The number of filters depends on the version of the header. Blosc2 alpha series
 1016|       |    // did not initialize filters to zero beyond the max supported.
 1017|  4.54M|    if (header->version == BLOSC2_VERSION_FORMAT_ALPHA) {
  ------------------
  |  Branch (1017:9): [True: 128, False: 4.54M]
  ------------------
 1018|    128|      header->filters[5] = 0;
 1019|    128|      header->filters_meta[5] = 0;
 1020|    128|    }
 1021|  4.54M|  }
 1022|  23.0M|  else {
 1023|  23.0M|    flags_to_filters(header->flags, header->filters);
 1024|  23.0M|  }
 1025|  27.6M|  if (header->version > BLOSC2_VERSION_FORMAT &&
  ------------------
  |  Branch (1025:7): [True: 2.71M, False: 24.9M]
  ------------------
 1026|  2.71M|      (header->blosc2_flags2 & (uint8_t)~BLOSC2_VL_BLOCKS) != 0) {
  ------------------
  |  Branch (1026:7): [True: 2, False: 2.71M]
  ------------------
 1027|       |    /* Version from future with unsupported chunk features. */
 1028|      2|    return BLOSC2_ERROR_VERSION_SUPPORT;
 1029|      2|  }
 1030|  27.6M|  if ((header->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0 &&
  ------------------
  |  Branch (1030:7): [True: 125, False: 27.6M]
  ------------------
 1031|    125|      (header->flags & (uint8_t)BLOSC_MEMCPYED) != 0) {
  ------------------
  |  Branch (1031:7): [True: 1, False: 124]
  ------------------
 1032|      1|    BLOSC_TRACE_ERROR("VL-block chunks cannot be memcpyed.");
  ------------------
  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1033|      1|    return BLOSC2_ERROR_INVALID_HEADER;
 1034|      1|  }
 1035|  27.6M|  if ((header->blosc2_flags2 & BLOSC2_VL_BLOCKS) == 0 &&
  ------------------
  |  Branch (1035:7): [True: 27.6M, False: 124]
  ------------------
 1036|  27.6M|      header->nbytes > 0 && header->blocksize > header->nbytes) {
  ------------------
  |  Branch (1036:7): [True: 27.6M, False: 48]
  |  Branch (1036:29): [True: 2.77k, False: 27.6M]
  ------------------
 1037|  2.77k|    header->blocksize = header->nbytes;
 1038|  2.77k|  }
 1039|  27.6M|  return 0;
 1040|  27.6M|}
fill_codec:
 1196|      4|int fill_codec(blosc2_codec *codec) {
 1197|      4|  int rc = BLOSC2_ERROR_SUCCESS;
 1198|      4|  static_lock(&g_plugin_lock);
  ------------------
  |  |  132|      4|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 1199|       |  /* Unless another thread loaded it meanwhile */
 1200|      4|  if (codec->encoder == NULL || codec->decoder == NULL) {
  ------------------
  |  Branch (1200:7): [True: 4, False: 0]
  |  Branch (1200:33): [True: 0, False: 0]
  ------------------
 1201|      4|    rc = load_codec_locked(codec);
 1202|      4|  }
 1203|      4|  static_unlock(&g_plugin_lock);
  ------------------
  |  |  133|      4|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 1204|      4|  return rc;
 1205|      4|}
pipeline_forward:
 1336|  7.54M|                          uint8_t* dest, uint8_t* tmp) {
 1337|  7.54M|  blosc2_context* context = thread_context->parent_context;
 1338|  7.54M|  uint8_t* _src = (uint8_t*)src + offset;
 1339|  7.54M|  uint8_t* _tmp = tmp;
 1340|  7.54M|  uint8_t* _dest = dest;
 1341|  7.54M|  int32_t typesize = context->typesize;
 1342|  7.54M|  uint8_t* filters = context->filters;
 1343|  7.54M|  uint8_t* filters_meta = context->filters_meta;
 1344|  7.54M|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 1345|  7.54M|  bool output_is_disposable = (context->preparams != NULL) ? context->preparams->output_is_disposable : false;
  ------------------
  |  Branch (1345:31): [True: 6.10M, False: 1.43M]
  ------------------
 1346|       |
 1347|       |  /* Prefilter function */
 1348|  7.54M|  if (context->prefilter != NULL) {
  ------------------
  |  Branch (1348:7): [True: 6.10M, False: 1.43M]
  ------------------
 1349|       |    // Create new prefilter parameters for this block (must be private for each thread)
 1350|  6.10M|    blosc2_prefilter_params preparams;
 1351|  6.10M|    memcpy(&preparams, context->preparams, sizeof(preparams));
 1352|       |    // Calculate output_size based on number of elements and output typesize
 1353|  6.10M|    int32_t nelems = bsize / typesize;  // number of elements in the input block
 1354|       |    // If output_typesize is not set (0), default to input typesize (no type conversion)
 1355|  6.10M|    int32_t output_typesize_actual = (preparams.output_typesize > 0) ? preparams.output_typesize : typesize;
  ------------------
  |  Branch (1355:38): [True: 0, False: 6.10M]
  ------------------
 1356|  6.10M|    int32_t output_size = nelems * output_typesize_actual;  // output size in bytes
 1357|  6.10M|    preparams.output_typesize = output_typesize_actual;  // ensure it's set
 1358|       |    /* Legacy callbacks may leave bytes unwritten or accumulate into the output.
 1359|       |     * Only audited full-write callbacks may bypass this initialization. */
 1360|  6.10M|    if (!output_is_disposable && !context->prefilter_full_write) {
  ------------------
  |  Branch (1360:9): [True: 6.10M, False: 0]
  |  Branch (1360:34): [True: 0, False: 6.10M]
  ------------------
 1361|      0|      memset(_dest, 0, output_size);
 1362|      0|    }
 1363|  6.10M|    preparams.input = _src;
 1364|  6.10M|    preparams.output = _dest;
 1365|  6.10M|    preparams.output_size = output_size;
 1366|  6.10M|    preparams.output_offset = offset;
 1367|  6.10M|    preparams.nblock = offset / context->blocksize;
 1368|  6.10M|    preparams.nchunk = context->schunk != NULL ? context->schunk->current_nchunk : -1;
  ------------------
  |  Branch (1368:24): [True: 6.10M, False: 0]
  ------------------
 1369|  6.10M|    preparams.tid = thread_context->tid;
 1370|  6.10M|    preparams.ttmp = thread_context->tmp;
 1371|  6.10M|    preparams.ttmp_nbytes = thread_context->tmp_nbytes;
 1372|  6.10M|    preparams.ctx = context;
 1373|  6.10M|    preparams.output_is_disposable = output_is_disposable;
 1374|       |
 1375|  6.10M|    if (context->prefilter(&preparams) != 0) {
  ------------------
  |  Branch (1375:9): [True: 0, False: 6.10M]
  ------------------
 1376|      0|      if (output_is_disposable) {
  ------------------
  |  Branch (1376:11): [True: 0, False: 0]
  ------------------
 1377|       |        // Output is going to be discarded; no more filters are required
 1378|      0|        return _dest;
 1379|      0|      }
 1380|      0|      BLOSC_TRACE_ERROR("Execution of prefilter function failed");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1381|      0|      return NULL;
 1382|      0|    }
 1383|       |
 1384|  6.10M|    if (memcpyed) {
  ------------------
  |  Branch (1384:9): [True: 644k, False: 5.46M]
  ------------------
 1385|       |      // No more filters are required
 1386|   644k|      return _dest;
 1387|   644k|    }
 1388|  5.46M|    _cycle_buffers_forward(&_src, &_dest, &_tmp, src + offset);
 1389|  5.46M|  }
 1390|       |
 1391|       |  /* Process the filter pipeline */
 1392|  48.3M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (1392:19): [True: 41.3M, False: 6.92M]
  ------------------
 1393|  41.3M|    int rc = BLOSC2_ERROR_SUCCESS;
 1394|  41.3M|    if (do_nothing(context, i, 'c')) {
  ------------------
  |  Branch (1394:9): [True: 39.2M, False: 2.12M]
  ------------------
 1395|  39.2M|      continue;
 1396|  39.2M|    }
 1397|  2.12M|#ifdef BLOSC_USE_FUSED_SHUFFLE_BYTEDELTA
 1398|  2.12M|    int fused_size = fused_shuffle_bytedelta_size(context, i);
 1399|  2.12M|    if (fused_size && shuffle_bytedelta_forward(_src, _dest, bsize, fused_size)) {
  ------------------
  |  Branch (1399:9): [True: 0, False: 2.12M]
  |  Branch (1399:23): [True: 0, False: 0]
  ------------------
 1400|      0|      i++;
 1401|      0|      _cycle_buffers_forward(&_src, &_dest, &_tmp, src + offset);
 1402|      0|      continue;
 1403|      0|    }
 1404|  2.12M|#endif
 1405|  2.14M|    if (filters[i] <= BLOSC2_DEFINED_FILTERS_STOP) {
  ------------------
  |  Branch (1405:9): [True: 2.14M, False: 18.4E]
  ------------------
 1406|  2.14M|      switch (filters[i]) {
 1407|  2.14M|        case BLOSC_SHUFFLE:
  ------------------
  |  Branch (1407:9): [True: 2.14M, False: 18.4E]
  ------------------
 1408|  2.14M|          blosc2_shuffle(shuffle_size(context, i), bsize, _src, _dest);
 1409|  2.14M|          break;
 1410|      0|        case BLOSC_BITSHUFFLE:
  ------------------
  |  Branch (1410:9): [True: 0, False: 2.14M]
  ------------------
 1411|      0|          if (context->blosc1_format && ((bsize / typesize) % 8) != 0) {
  ------------------
  |  Branch (1411:15): [True: 0, False: 0]
  |  Branch (1411:41): [True: 0, False: 0]
  ------------------
 1412|       |            // Format version 2 (Blosc1) only bit-shuffles blocks whose number of
 1413|       |            // elements is a multiple of 8; other blocks are stored unshuffled.
 1414|      0|            memcpy(_dest, _src, (size_t)bsize);
 1415|      0|          }
 1416|      0|          else if (bitshuffle(typesize, bsize, _src, _dest, bitshuffle_scratch(thread_context, bsize)) < 0) {
  ------------------
  |  Branch (1416:20): [True: 0, False: 0]
  ------------------
 1417|      0|            return NULL;
 1418|      0|          }
 1419|      0|          break;
 1420|      0|        case BLOSC_DELTA:
  ------------------
  |  Branch (1420:9): [True: 0, False: 2.14M]
  ------------------
 1421|      0|          delta_encoder(offset == 0 ? _src : src, offset, bsize, typesize, _src, _dest);
  ------------------
  |  Branch (1421:25): [True: 0, False: 0]
  ------------------
 1422|      0|          break;
 1423|      0|        case BLOSC_TRUNC_PREC:
  ------------------
  |  Branch (1423:9): [True: 0, False: 2.14M]
  ------------------
 1424|      0|          if (truncate_precision(filters_meta[i], typesize, bsize, _src, _dest) < 0) {
  ------------------
  |  Branch (1424:15): [True: 0, False: 0]
  ------------------
 1425|      0|            return NULL;
 1426|      0|          }
 1427|      0|          break;
 1428|      0|        default:
  ------------------
  |  Branch (1428:9): [True: 0, False: 2.14M]
  ------------------
 1429|      0|          BLOSC_TRACE_ERROR("Filter %d not handled during compression\n", filters[i]);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1430|      0|          return NULL;
 1431|  2.14M|      }
 1432|  2.14M|    }
 1433|  18.4E|    else {
 1434|       |      // Look for the filters_meta in user filters and run it
 1435|  18.4E|      for (uint64_t j = 0; j < g_nfilters; ++j) {
  ------------------
  |  Branch (1435:28): [True: 0, False: 18.4E]
  ------------------
 1436|      0|        if (g_filters[j].id == filters[i]) {
  ------------------
  |  Branch (1436:13): [True: 0, False: 0]
  ------------------
 1437|      0|          if (load_acquire_ptr(&g_filters[j].backward) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (1437:15): [True: 0, False: 0]
  ------------------
 1438|       |            // Dynamically load library
 1439|      0|            if (fill_filter(&g_filters[j]) < 0) {
  ------------------
  |  Branch (1439:17): [True: 0, False: 0]
  ------------------
 1440|      0|              BLOSC_TRACE_ERROR("Could not load filter %d\n", g_filters[j].id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1441|      0|              return NULL;
 1442|      0|            }
 1443|      0|          }
 1444|      0|          if (g_filters[j].forward != NULL) {
  ------------------
  |  Branch (1444:15): [True: 0, False: 0]
  ------------------
 1445|      0|            blosc2_cparams cparams;
 1446|      0|            blosc2_ctx_get_cparams(context, &cparams);
 1447|      0|            rc = g_filters[j].forward(_src, _dest, bsize, filters_meta[i], &cparams, g_filters[j].id);
 1448|      0|          } else {
 1449|      0|            BLOSC_TRACE_ERROR("Forward function is NULL");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1450|      0|            return NULL;
 1451|      0|          }
 1452|      0|          if (rc != BLOSC2_ERROR_SUCCESS) {
  ------------------
  |  Branch (1452:15): [True: 0, False: 0]
  ------------------
 1453|      0|            BLOSC_TRACE_ERROR("User-defined filter %d failed during compression\n", filters[i]);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1454|      0|            return NULL;
 1455|      0|          }
 1456|      0|          goto urfiltersuccess;
 1457|      0|        }
 1458|      0|      }
 1459|  18.4E|      BLOSC_TRACE_ERROR("User-defined filter %d not found during compression\n", filters[i]);
  ------------------
  |  |   93|  18.4E|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|  18.4E|    do {                                            \
  |  |  |  |   98|  18.4E|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|  18.4E|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 18.4E]
  |  |  |  |  ------------------
  |  |  |  |  100|  18.4E|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|  18.4E|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 18.4E]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1460|  18.4E|      return NULL;
 1461|       |
 1462|      0|      urfiltersuccess:;
 1463|       |
 1464|      0|    }
 1465|       |
 1466|       |    // do_nothing() skipped the filters that leave the block as it is
 1467|  2.14M|    _cycle_buffers_forward(&_src, &_dest, &_tmp, src + offset);
 1468|  2.14M|  }
 1469|  6.92M|  return _src;
 1470|  6.89M|}
pipeline_backward:
 1884|  4.66M|                      uint8_t* tmp2, int last_filter_index, int32_t nblock) {
 1885|  4.66M|  (void)tmp2;
 1886|  4.66M|  blosc2_context* context = thread_context->parent_context;
 1887|  4.66M|  int32_t typesize = context->typesize;
 1888|  4.66M|  uint8_t* filters = context->filters;
 1889|  4.66M|  uint8_t* filters_meta = context->filters_meta;
 1890|  4.66M|  uint8_t* _src = (next_filter(context, BLOSC2_MAX_FILTERS, 'd') == BLOSC_DELTA &&
  ------------------
  |  Branch (1890:20): [True: 297, False: 4.65M]
  ------------------
 1891|  4.65M|                   context->postfilter == NULL) ? (dest + offset) : src;
  ------------------
  |  Branch (1891:20): [True: 297, False: 0]
  ------------------
 1892|  4.66M|  uint8_t* _dest = tmp;
 1893|  4.66M|  int errcode = 0;
 1894|       |
 1895|  7.30M|  for (int i = BLOSC2_MAX_FILTERS - 1; i >= 0; i--) {
  ------------------
  |  Branch (1895:40): [True: 6.86M, False: 439k]
  ------------------
 1896|  6.86M|    if (do_nothing(context, i, 'd')) {
  ------------------
  |  Branch (1896:9): [True: 2.63M, False: 4.22M]
  ------------------
 1897|  2.63M|      continue;
 1898|  2.63M|    }
 1899|  4.22M|    int first_index = i;
 1900|  4.22M|#ifdef BLOSC_USE_FUSED_SHUFFLE_BYTEDELTA
 1901|  4.22M|    int fused_size = fused_shuffle_bytedelta_size(context, i - 1);
 1902|  4.22M|    if (fused_size) {
  ------------------
  |  Branch (1902:9): [True: 100, False: 4.22M]
  ------------------
 1903|    100|      first_index = i - 1;
 1904|    100|    }
 1905|  4.22M|#endif
 1906|       |    // Delta filter requires the whole chunk ready. A fused inverse ends at
 1907|       |    // SHUFFLE's position, so select its sink using the pair's first index.
 1908|  4.22M|    int last_copy_filter = (last_filter_index == first_index) || (filters[i] == BLOSC_DELTA) ||
  ------------------
  |  Branch (1908:28): [True: 4.22M, False: 1.25k]
  |  Branch (1908:66): [True: 362, False: 894]
  ------------------
 1909|    894|                           (next_filter(context, first_index, 'd') == BLOSC_DELTA);
  ------------------
  |  Branch (1909:28): [True: 292, False: 602]
  ------------------
 1910|  4.22M|    if (last_copy_filter && context->postfilter == NULL &&
  ------------------
  |  Branch (1910:9): [True: 4.22M, False: 602]
  |  Branch (1910:29): [True: 4.21M, False: 7.96k]
  ------------------
 1911|  4.21M|        (filters[i] == BLOSC_DELTA || _src != dest + offset)) {
  ------------------
  |  Branch (1911:10): [True: 769, False: 4.21M]
  |  Branch (1911:39): [True: 4.21M, False: 130]
  ------------------
 1912|  4.21M|      _dest = dest + offset;
 1913|  4.21M|    } else {
 1914|  8.69k|      _dest = (_src == src) ? tmp : src;
  ------------------
  |  Branch (1914:15): [True: 8.36k, False: 329]
  ------------------
 1915|  8.69k|    }
 1916|  4.22M|    int rc = BLOSC2_ERROR_SUCCESS;
 1917|  4.22M|#ifdef BLOSC_USE_FUSED_SHUFFLE_BYTEDELTA
 1918|  4.22M|    if (fused_size && shuffle_bytedelta_backward(_src, _dest, bsize, fused_size)) {
  ------------------
  |  Branch (1918:9): [True: 100, False: 4.22M]
  |  Branch (1918:23): [True: 100, False: 0]
  ------------------
 1919|    100|      i--;
 1920|    100|      _src = _dest;
 1921|    100|      if (last_filter_index == i) {
  ------------------
  |  Branch (1921:11): [True: 76, False: 24]
  ------------------
 1922|     76|        break;
 1923|     76|      }
 1924|     24|      continue;
 1925|    100|    }
 1926|  4.22M|#endif
 1927|  4.22M|    if (filters[i] <= BLOSC2_DEFINED_FILTERS_STOP) {
  ------------------
  |  Branch (1927:9): [True: 4.22M, False: 378]
  ------------------
 1928|  4.22M|      switch (filters[i]) {
 1929|  4.21M|        case BLOSC_SHUFFLE:
  ------------------
  |  Branch (1929:9): [True: 4.21M, False: 1.37k]
  ------------------
 1930|  4.21M|          blosc2_unshuffle(shuffle_size(context, i), bsize, _src, _dest);
 1931|  4.21M|          break;
 1932|    587|        case BLOSC_BITSHUFFLE:
  ------------------
  |  Branch (1932:9): [True: 587, False: 4.22M]
  ------------------
 1933|    587|          if (bitunshuffle(typesize, bsize, _src, _dest, bitshuffle_scratch(thread_context, bsize),
  ------------------
  |  Branch (1933:15): [True: 0, False: 587]
  ------------------
 1934|    587|                           context->src[BLOSC2_CHUNK_VERSION]) < 0) {
 1935|      0|            return BLOSC2_ERROR_FILTER_PIPELINE;
 1936|      0|          }
 1937|    587|          break;
 1938|    769|        case BLOSC_DELTA:
  ------------------
  |  Branch (1938:9): [True: 769, False: 4.22M]
  ------------------
 1939|    769|          if (_src != _dest) {
  ------------------
  |  Branch (1939:15): [True: 37, False: 732]
  ------------------
 1940|     37|            memcpy(_dest, _src, (size_t)bsize);
 1941|     37|          }
 1942|    769|          if (offset != 0 && !thread_context->serial) {
  ------------------
  |  Branch (1942:15): [True: 329, False: 440]
  |  Branch (1942:30): [True: 0, False: 329]
  ------------------
 1943|      0|            delta_wait_dref(context);
 1944|      0|          }
 1945|    769|          delta_decoder(offset == 0 ? _dest : dest, offset, bsize, typesize, _dest);
  ------------------
  |  Branch (1945:25): [True: 440, False: 329]
  ------------------
 1946|    769|          break;
 1947|     20|        default:
  ------------------
  |  Branch (1947:9): [True: 20, False: 4.22M]
  ------------------
 1948|     20|          BLOSC_TRACE_ERROR("Filter %d not handled during decompression.", filters[i]);
  ------------------
  |  |   93|     20|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     20|    do {                                            \
  |  |  |  |   98|     20|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     20|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     20|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1949|     20|          errcode = -1;
 1950|  4.22M|      }
 1951|  4.22M|    } else {
 1952|       |        // Look for the filters_meta in user filters and run it
 1953|  1.48k|        for (uint64_t j = 0; j < g_nfilters; ++j) {
  ------------------
  |  Branch (1953:30): [True: 1.42k, False: 56]
  ------------------
 1954|  1.42k|          if (g_filters[j].id == filters[i]) {
  ------------------
  |  Branch (1954:15): [True: 322, False: 1.10k]
  ------------------
 1955|    322|            if (load_acquire_ptr(&g_filters[j].backward) == NULL) {
  ------------------
  |  |  144|    322|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (1955:17): [True: 0, False: 322]
  ------------------
 1956|       |              // Dynamically load filter
 1957|      0|              if (fill_filter(&g_filters[j]) < 0) {
  ------------------
  |  Branch (1957:19): [True: 0, False: 0]
  ------------------
 1958|      0|                BLOSC_TRACE_ERROR("Could not load filter %d.", g_filters[j].id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1959|      0|                return BLOSC2_ERROR_FILTER_PIPELINE;
 1960|      0|              }
 1961|      0|            }
 1962|    322|            if (g_filters[j].backward != NULL) {
  ------------------
  |  Branch (1962:17): [True: 322, False: 0]
  ------------------
 1963|    322|              blosc2_dparams dparams;
 1964|    322|              blosc2_ctx_get_dparams(context, &dparams);
 1965|    322|              rc = g_filters[j].backward(_src, _dest, bsize, filters_meta[i], &dparams, g_filters[j].id);
 1966|    322|            } else {
 1967|      0|              BLOSC_TRACE_ERROR("Backward function is NULL");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1968|      0|              return BLOSC2_ERROR_FILTER_PIPELINE;
 1969|      0|            }
 1970|    322|            if (rc != BLOSC2_ERROR_SUCCESS) {
  ------------------
  |  Branch (1970:17): [True: 8, False: 314]
  ------------------
 1971|      8|              BLOSC_TRACE_ERROR("User-defined filter %d failed during decompression.", filters[i]);
  ------------------
  |  |   93|      8|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      8|    do {                                            \
  |  |  |  |   98|      8|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      8|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      8|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1972|      8|              return rc;
 1973|      8|            }
 1974|    314|            goto urfiltersuccess;
 1975|    322|          }
 1976|  1.42k|        }
 1977|     56|      BLOSC_TRACE_ERROR("User-defined filter %d not found during decompression.", filters[i]);
  ------------------
  |  |   93|     56|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     56|    do {                                            \
  |  |  |  |   98|     56|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     56|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 56, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     56|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1978|     56|      return BLOSC2_ERROR_FILTER_PIPELINE;
 1979|    314|      urfiltersuccess:;
 1980|    314|    }
 1981|       |
 1982|       |    // do_nothing() skipped the filters that leave the block as it is (TRUNC_PREC is not undone);
 1983|       |    // the output of this filter is the input of the next one
 1984|  4.22M|    _src = _dest;
 1985|  4.22M|    if (last_filter_index == i) {
  ------------------
  |  Branch (1985:9): [True: 4.22M, False: 1.19k]
  ------------------
 1986|  4.22M|      break;
 1987|  4.22M|    }
 1988|  4.22M|  }
 1989|       |
 1990|  4.66M|  if (context->postfilter == NULL && _src != dest + offset) {
  ------------------
  |  Branch (1990:7): [True: 4.21M, False: 447k]
  |  Branch (1990:38): [True: 80, False: 4.21M]
  ------------------
 1991|     80|    memcpy(dest + offset, _src, (unsigned int)bsize);
 1992|     80|  }
 1993|       |
 1994|       |  /* Postfilter function */
 1995|  4.66M|  if (context->postfilter != NULL) {
  ------------------
  |  Branch (1995:7): [True: 447k, False: 4.21M]
  ------------------
 1996|       |    // Create new postfilter parameters for this block (must be private for each thread)
 1997|   447k|    blosc2_postfilter_params postparams;
 1998|   447k|    memcpy(&postparams, context->postparams, sizeof(postparams));
 1999|   447k|    postparams.input = _src;
 2000|   447k|    postparams.output = dest + offset;
 2001|   447k|    postparams.size = bsize;
 2002|   447k|    postparams.typesize = typesize;
 2003|   447k|    postparams.offset = nblock * context->blocksize;
 2004|   447k|    postparams.nchunk = context->schunk != NULL ? context->schunk->current_nchunk : -1;
  ------------------
  |  Branch (2004:25): [True: 447k, False: 0]
  ------------------
 2005|   447k|    postparams.nblock = nblock;
 2006|   447k|    postparams.tid = thread_context->tid;
 2007|   447k|    postparams.ttmp = thread_context->tmp;
 2008|   447k|    postparams.ttmp_nbytes = thread_context->tmp_nbytes;
 2009|   447k|    postparams.ctx = context;
 2010|       |
 2011|   447k|    if (context->postfilter(&postparams) != 0) {
  ------------------
  |  Branch (2011:9): [True: 0, False: 447k]
  ------------------
 2012|      0|      BLOSC_TRACE_ERROR("Execution of postfilter function failed");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2013|      0|      return BLOSC2_ERROR_POSTFILTER;
 2014|      0|    }
 2015|   447k|  }
 2016|       |
 2017|  4.66M|  return errcode;
 2018|  4.66M|}
free_thread_context:
 2708|  2.56k|void free_thread_context(struct thread_context* thread_context) {
 2709|  2.56k|  destroy_thread_context(thread_context);
 2710|  2.56k|  my_free(thread_context);
 2711|  2.56k|}
blosc2_compress_ctx:
 3714|  1.75M|                        void* dest, int32_t destsize) {
 3715|  1.75M|  int error, cbytes;
 3716|       |
 3717|  1.75M|  if (context->do_compress != 1) {
  ------------------
  |  Branch (3717:7): [True: 0, False: 1.75M]
  ------------------
 3718|      0|    BLOSC_TRACE_ERROR("Context is not meant for compression.  Giving up.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3719|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 3720|      0|  }
 3721|       |
 3722|  1.75M|  error = initialize_context_compression(
 3723|  1.75M|          context, src, srcsize, dest, destsize,
 3724|  1.75M|          context->clevel, context->filters, context->filters_meta,
 3725|  1.75M|          context->typesize, context->compcode, context->blocksize,
 3726|  1.75M|          context->new_nthreads, context->nthreads, context->splitmode,
 3727|  1.75M|          context->tuner_id, context->tuner_params, context->schunk);
 3728|  1.75M|  if (error <= 0) {
  ------------------
  |  Branch (3728:7): [True: 0, False: 1.75M]
  ------------------
 3729|      0|    return error;
 3730|      0|  }
 3731|       |
 3732|  1.75M|  error = blosc1_format_check(context);
 3733|  1.75M|  if (error < 0) {
  ------------------
  |  Branch (3733:7): [True: 0, False: 1.75M]
  ------------------
 3734|      0|    return error;
 3735|      0|  }
 3736|       |
 3737|       |  /* Write the extended header, or the Blosc1 header if requested */
 3738|  1.75M|  error = write_compression_header(context, !context->blosc1_format);
 3739|  1.75M|  if (error < 0) {
  ------------------
  |  Branch (3739:7): [True: 0, False: 1.75M]
  ------------------
 3740|      0|    return error;
 3741|      0|  }
 3742|       |
 3743|  1.75M|  cbytes = blosc_compress_context(context);
 3744|  1.75M|  if (cbytes < 0) {
  ------------------
  |  Branch (3744:7): [True: 0, False: 1.75M]
  ------------------
 3745|      0|    return cbytes;
 3746|      0|  }
 3747|       |
 3748|  1.75M|  if (context->use_dict && context->dict_cdict == NULL) {
  ------------------
  |  Branch (3748:7): [True: 0, False: 1.75M]
  |  Branch (3748:28): [True: 0, False: 0]
  ------------------
 3749|       |    /* blosc_compress_context() overwrites context->destsize with the training-pass output
 3750|       |     * size.  Restore it so that the real compression pass has the correct output-buffer size. */
 3751|      0|    context->destsize = destsize;
 3752|       |
 3753|      0|    bool is_lz4 = (context->compcode == BLOSC_LZ4 || context->compcode == BLOSC_LZ4HC);
  ------------------
  |  Branch (3753:20): [True: 0, False: 0]
  |  Branch (3753:54): [True: 0, False: 0]
  ------------------
 3754|      0|    if (!is_lz4 && context->compcode != BLOSC_ZSTD) {
  ------------------
  |  Branch (3754:9): [True: 0, False: 0]
  |  Branch (3754:20): [True: 0, False: 0]
  ------------------
 3755|      0|      const char* compname;
 3756|      0|      compname = clibcode_to_clibname(context->compcode);
 3757|      0|      BLOSC_TRACE_ERROR("Codec %s does not support dicts.  Giving up.",
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3758|      0|                        compname);
 3759|      0|      return BLOSC2_ERROR_CODEC_DICT;
 3760|      0|    }
 3761|       |
 3762|       |    // Build the dictionary out of the filters outcome and compress with it.
 3763|       |    // For LZ4/LZ4HC the raw samples are used directly (no training algorithm).
 3764|       |    // For ZSTD, ZDICT_trainFromBuffer() is used.
 3765|      0|    int32_t dict_maxsize = BLOSC2_MAXDICTSIZE;
 3766|       |    // Do not make the dict more than 5% larger than uncompressed buffer
 3767|      0|    if (dict_maxsize > srcsize / 20) {
  ------------------
  |  Branch (3767:9): [True: 0, False: 0]
  ------------------
 3768|      0|      dict_maxsize = srcsize / 20;
 3769|      0|    }
 3770|      0|    void* samples_buffer = context->dest + context->header_overhead;
 3771|      0|    unsigned nblocks = (unsigned)context->nblocks;
 3772|      0|    int dont_split = (context->header_flags & 0x10) >> 4;
 3773|      0|    if (!dont_split) {
  ------------------
  |  Branch (3773:9): [True: 0, False: 0]
  ------------------
 3774|      0|      nblocks = nblocks * context->typesize;
 3775|      0|    }
 3776|      0|    if (nblocks < 8) {
  ------------------
  |  Branch (3776:9): [True: 0, False: 0]
  ------------------
 3777|      0|      nblocks = 8;
 3778|      0|    }
 3779|       |
 3780|      0|    unsigned sample_fraction = 16;
 3781|      0|    size_t sample_size = context->sourcesize / nblocks / sample_fraction;
 3782|       |
 3783|       |    // When the data is too small to produce useful dict samples,
 3784|       |    // fall back to plain compression without a dict.
 3785|      0|    if (dict_maxsize < BLOSC2_MINUSEFULDICT || sample_size == 0) {
  ------------------
  |  Branch (3785:9): [True: 0, False: 0]
  |  Branch (3785:48): [True: 0, False: 0]
  ------------------
 3786|      0|      BLOSC_TRACE_WARNING("Data too small for dict training (dict_maxsize=%d, sample_size=%zu)."
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3787|      0|                          "  Falling back to plain compression.", dict_maxsize, sample_size);
 3788|      0|      context->bstarts = (int32_t*)(context->dest + context->header_overhead);
 3789|      0|      context->output_bytes = context->header_overhead + (int32_t)sizeof(int32_t) * context->nblocks;
 3790|      0|      cbytes = blosc_compress_context_without_dict(context);
 3791|      0|    }
 3792|      0|    else if (is_lz4) {
  ------------------
  |  Branch (3792:14): [True: 0, False: 0]
  ------------------
 3793|       |      // LZ4/LZ4HC: use raw sample data directly as the dictionary (no training step).
 3794|      0|      int32_t dict_actual_size = (int32_t)(nblocks * sample_size);
 3795|      0|      if (dict_actual_size > dict_maxsize) {
  ------------------
  |  Branch (3795:11): [True: 0, False: 0]
  ------------------
 3796|      0|        dict_actual_size = dict_maxsize;
 3797|      0|      }
 3798|       |
 3799|       |      // Reset bstarts and embed dict in the output buffer.
 3800|      0|      context->bstarts = (int32_t*)(context->dest + context->header_overhead);
 3801|      0|      context->output_bytes = context->header_overhead + (int32_t)sizeof(int32_t) * context->nblocks;
 3802|       |      /* Move dict bytes; samples_buffer overlaps the dict (and its size) in dest,
 3803|       |         so this has to be a memmove, done before writing the size */
 3804|      0|      context->dict_buffer = context->dest + context->output_bytes + sizeof(int32_t);
 3805|      0|      memmove(context->dict_buffer, samples_buffer, (size_t)dict_actual_size);
 3806|       |      /* Write dict size */
 3807|      0|      _sw32(context->dest + context->output_bytes, dict_actual_size);
 3808|      0|      context->output_bytes += (int32_t)sizeof(int32_t);
 3809|       |      /* Build the stream used as cdict (pre-loaded with the dict bytes) */
 3810|      0|      if (context->compcode == BLOSC_LZ4HC) {
  ------------------
  |  Branch (3810:11): [True: 0, False: 0]
  ------------------
 3811|      0|        LZ4_streamHC_t* lz4hc_cdict = LZ4_createStreamHC();
 3812|      0|        LZ4_loadDictHC(lz4hc_cdict, (const char*)context->dict_buffer, dict_actual_size);
 3813|      0|        context->dict_cdict = lz4hc_cdict;
 3814|      0|      } else {
 3815|      0|        LZ4_stream_t* lz4_cdict = LZ4_createStream();
 3816|      0|        LZ4_loadDict(lz4_cdict, (const char*)context->dict_buffer, dict_actual_size);
 3817|      0|        context->dict_cdict = lz4_cdict;
 3818|      0|      }
 3819|      0|      context->output_bytes += dict_actual_size;
 3820|      0|      context->dict_size = dict_actual_size;
 3821|       |
 3822|       |      /* Compress with dict */
 3823|      0|      cbytes = blosc_compress_context(context);
 3824|       |
 3825|       |      // Invalidate the dictionary so the context can be reused for the next chunk
 3826|      0|      context->dict_buffer = NULL;
 3827|      0|      if (context->compcode == BLOSC_LZ4HC) {
  ------------------
  |  Branch (3827:11): [True: 0, False: 0]
  ------------------
 3828|      0|        LZ4_freeStreamHC((LZ4_streamHC_t*)context->dict_cdict);
 3829|      0|      } else {
 3830|      0|        LZ4_freeStream((LZ4_stream_t*)context->dict_cdict);
 3831|      0|      }
 3832|      0|      context->dict_cdict = NULL;
 3833|      0|    }
 3834|      0|#ifdef HAVE_ZSTD
 3835|      0|    else {
 3836|       |    // Populate the samples sizes for training the dictionary
 3837|      0|    size_t* samples_sizes = malloc(nblocks * sizeof(size_t));
 3838|      0|    BLOSC_ERROR_NULL(samples_sizes, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|      0|    do {                                            \
  |  |  105|      0|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3839|      0|    for (size_t i = 0; i < nblocks; i++) {
  ------------------
  |  Branch (3839:24): [True: 0, False: 0]
  ------------------
 3840|      0|      samples_sizes[i] = sample_size;
 3841|      0|    }
 3842|       |
 3843|       |    // Train from samples
 3844|      0|    void* dict_buffer = malloc(dict_maxsize);
 3845|      0|    if (dict_buffer == NULL) {
  ------------------
  |  Branch (3845:9): [True: 0, False: 0]
  ------------------
 3846|      0|      free(samples_sizes);
 3847|      0|      BLOSC_ERROR_NULL(dict_buffer, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|      0|    do {                                            \
  |  |  105|      0|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3848|      0|    }
 3849|      0|    int32_t dict_actual_size = (int32_t)ZDICT_trainFromBuffer(
 3850|      0|        dict_buffer, dict_maxsize,
 3851|      0|        samples_buffer, samples_sizes, nblocks);
 3852|       |
 3853|       |    // TODO: experiment with parameters of low-level fast cover algorithm
 3854|       |    // Note that this API is still unstable.  See: https://github.com/facebook/zstd/issues/1599
 3855|       |    // ZDICT_fastCover_params_t fast_cover_params;
 3856|       |    // memset(&fast_cover_params, 0, sizeof(fast_cover_params));
 3857|       |    // fast_cover_params.d = nblocks;
 3858|       |    // fast_cover_params.steps = 4;
 3859|       |    // fast_cover_params.zParams.compressionLevel = context->clevel;
 3860|       |    // size_t dict_actual_size = ZDICT_optimizeTrainFromBuffer_fastCover(
 3861|       |    //   dict_buffer, dict_maxsize, samples_buffer, samples_sizes, nblocks,
 3862|       |    //   &fast_cover_params);
 3863|       |
 3864|      0|    free(samples_sizes);
 3865|      0|    if (ZDICT_isError(dict_actual_size) != ZSTD_error_no_error) {
  ------------------
  |  Branch (3865:9): [True: 0, False: 0]
  ------------------
 3866|      0|      BLOSC_TRACE_WARNING("ZDICT_trainFromBuffer() failed: '%s'."
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3867|      0|                          "  Falling back to plain compression.",
 3868|      0|                          ZDICT_getErrorName(dict_actual_size));
 3869|      0|      free(dict_buffer);
 3870|      0|      context->bstarts = (int32_t*)(context->dest + context->header_overhead);
 3871|      0|      context->output_bytes = context->header_overhead + (int32_t)sizeof(int32_t) * context->nblocks;
 3872|      0|      cbytes = blosc_compress_context_without_dict(context);
 3873|      0|    }
 3874|      0|    else {
 3875|      0|    assert(dict_actual_size > 0);
 3876|       |
 3877|       |    // Update bytes counter and pointers to bstarts for the new compressed buffer
 3878|      0|    context->bstarts = (int32_t*)(context->dest + context->header_overhead);
 3879|      0|    context->output_bytes = context->header_overhead + (int32_t)sizeof(int32_t) * context->nblocks;
 3880|       |    /* Write the size of trained dict at the end of bstarts */
 3881|      0|    _sw32(context->dest + context->output_bytes, (int32_t)dict_actual_size);
 3882|      0|    context->output_bytes += sizeof(int32_t);
 3883|       |    /* Write the trained dict afterwards */
 3884|      0|    context->dict_buffer = context->dest + context->output_bytes;
 3885|      0|    memcpy(context->dict_buffer, dict_buffer, (unsigned int)dict_actual_size);
 3886|      0|    context->dict_cdict = ZSTD_createCDict(dict_buffer, dict_actual_size, 1);  // TODO: use get_accel()
 3887|      0|    free(dict_buffer);      // the dictionary is copied in the header now
 3888|      0|    context->output_bytes += (int32_t)dict_actual_size;
 3889|      0|    context->dict_size = dict_actual_size;
 3890|       |
 3891|       |    /* Compress with dict */
 3892|      0|    cbytes = blosc_compress_context(context);
 3893|       |
 3894|       |    // Invalidate the dictionary for compressing other chunks using the same context
 3895|      0|    context->dict_buffer = NULL;
 3896|      0|    ZSTD_freeCDict(context->dict_cdict);
 3897|      0|    context->dict_cdict = NULL;
 3898|      0|    }  // ZDICT_isError
 3899|      0|    }  // ZSTD else branch
 3900|      0|#endif  // HAVE_ZSTD
 3901|      0|  }
 3902|       |
 3903|  1.75M|  return cbytes;
 3904|  1.75M|}
build_filters:
 4287|  3.23M|                   const int32_t typesize, uint8_t* filters) {
 4288|       |
 4289|       |  /* Fill the end part of the filter pipeline */
 4290|  3.23M|  if ((doshuffle == BLOSC_SHUFFLE) && (typesize > 1))
  ------------------
  |  Branch (4290:7): [True: 0, False: 3.23M]
  |  Branch (4290:39): [True: 0, False: 0]
  ------------------
 4291|      0|    filters[BLOSC2_MAX_FILTERS - 1] = BLOSC_SHUFFLE;
 4292|  3.23M|  if (doshuffle == BLOSC_BITSHUFFLE)
  ------------------
  |  Branch (4292:7): [True: 0, False: 3.23M]
  ------------------
 4293|      0|    filters[BLOSC2_MAX_FILTERS - 1] = BLOSC_BITSHUFFLE;
 4294|  3.23M|  if (doshuffle == BLOSC_NOSHUFFLE)
  ------------------
  |  Branch (4294:7): [True: 0, False: 3.23M]
  ------------------
 4295|      0|    filters[BLOSC2_MAX_FILTERS - 1] = BLOSC_NOSHUFFLE;
 4296|  3.23M|  if (delta)
  ------------------
  |  Branch (4296:7): [True: 0, False: 3.23M]
  ------------------
 4297|      0|    filters[BLOSC2_MAX_FILTERS - 2] = BLOSC_DELTA;
 4298|  3.23M|}
blosc2_decompress_ctx:
 4548|  1.64M|                          void* dest, int32_t destsize) {
 4549|  1.64M|  int result;
 4550|       |
 4551|  1.64M|  if (context->do_compress != 0) {
  ------------------
  |  Branch (4551:7): [True: 0, False: 1.64M]
  ------------------
 4552|      0|    BLOSC_TRACE_ERROR("Context is not meant for decompression.  Giving up.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4553|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4554|      0|  }
 4555|       |
 4556|  1.64M|  result = blosc_run_decompression_with_context(context, src, srcsize, dest, destsize);
 4557|       |
 4558|       |  // Reset a possible block_maskout
 4559|  1.64M|  ctx_clear_maskout(context);
 4560|       |
 4561|  1.64M|  return result;
 4562|  1.64M|}
_blosc_getitem:
 4935|  2.90M|                   int start, int nitems, void* dest, int32_t destsize) {
 4936|  2.90M|  uint8_t* _src = (uint8_t*)(src);  /* current pos for source buffer */
 4937|  2.90M|  uint8_t* _dest = (uint8_t*)(dest);
 4938|  2.90M|  int32_t ntbytes = 0;              /* the number of uncompressed bytes */
 4939|  2.90M|  int32_t bsize, bsize2, leftoverblock;
 4940|  2.90M|  int32_t startb, stopb;
 4941|  2.90M|  int32_t stop;
 4942|  2.90M|  int32_t nitems_bytes;
 4943|  2.90M|  int64_t start64 = (int64_t)start;
 4944|  2.90M|  int64_t nitems64 = (int64_t)nitems;
 4945|  2.90M|  int64_t typesize64 = (int64_t)header->typesize;
 4946|  2.90M|  int64_t stop64;
 4947|  2.90M|  int64_t nitems_bytes64;
 4948|  2.90M|  int64_t start_bytes64;
 4949|  2.90M|  int64_t stop_bytes64;
 4950|  2.90M|  int j, rc;
 4951|       |
 4952|  2.90M|  if (nitems == 0) {
  ------------------
  |  Branch (4952:7): [True: 0, False: 2.90M]
  ------------------
 4953|       |    // We have nothing to do
 4954|      0|    return 0;
 4955|      0|  }
 4956|  2.90M|  if (nitems < 0) {
  ------------------
  |  Branch (4956:7): [True: 0, False: 2.90M]
  ------------------
 4957|      0|    BLOSC_TRACE_ERROR("`nitems` out of bounds.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4958|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4959|      0|  }
 4960|       |
 4961|  2.90M|  nitems_bytes64 = nitems64 * typesize64;
 4962|  2.90M|  if (nitems_bytes64 < 0 || nitems_bytes64 > INT32_MAX || nitems_bytes64 > destsize) {
  ------------------
  |  Branch (4962:7): [True: 0, False: 2.90M]
  |  Branch (4962:29): [True: 0, False: 2.90M]
  |  Branch (4962:59): [True: 10, False: 2.90M]
  ------------------
 4963|     10|    BLOSC_TRACE_ERROR("`nitems`*`typesize` out of dest bounds.");
  ------------------
  |  |   93|     10|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     10|    do {                                            \
  |  |  |  |   98|     10|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     10|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     10|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4964|     10|    return BLOSC2_ERROR_WRITE_BUFFER;
 4965|     10|  }
 4966|  2.90M|  nitems_bytes = (int32_t)nitems_bytes64;
 4967|       |
 4968|  2.90M|  int32_t* bstarts = (int32_t*)(_src + context->header_overhead);
 4969|       |
 4970|       |  /* Check region boundaries */
 4971|  2.90M|  start_bytes64 = start64 * typesize64;
 4972|  2.90M|  if ((start < 0) || (start_bytes64 < 0) || (start_bytes64 > header->nbytes)) {
  ------------------
  |  Branch (4972:7): [True: 0, False: 2.90M]
  |  Branch (4972:22): [True: 0, False: 2.90M]
  |  Branch (4972:45): [True: 0, False: 2.90M]
  ------------------
 4973|      0|    BLOSC_TRACE_ERROR("`start` out of bounds.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4974|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4975|      0|  }
 4976|       |
 4977|  2.90M|  stop64 = start64 + nitems64;
 4978|  2.90M|  if ((stop64 < 0) || (stop64 > INT32_MAX)) {
  ------------------
  |  Branch (4978:7): [True: 0, False: 2.90M]
  |  Branch (4978:23): [True: 0, False: 2.90M]
  ------------------
 4979|      0|    BLOSC_TRACE_ERROR("`start`+`nitems` out of bounds.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4980|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4981|      0|  }
 4982|  2.90M|  stop = (int32_t)stop64;
 4983|       |
 4984|  2.90M|  stop_bytes64 = stop64 * typesize64;
 4985|  2.90M|  if ((stop_bytes64 < 0) || (stop_bytes64 > header->nbytes)) {
  ------------------
  |  Branch (4985:7): [True: 0, False: 2.90M]
  |  Branch (4985:29): [True: 0, False: 2.90M]
  ------------------
 4986|      0|    BLOSC_TRACE_ERROR("`start`+`nitems` out of bounds.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4987|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4988|      0|  }
 4989|       |
 4990|  2.90M|  bool chunk_memcpyed = (header->flags & (uint8_t)BLOSC_MEMCPYED) != 0;
 4991|  2.90M|  if (!context->special_type && !chunk_memcpyed &&
  ------------------
  |  Branch (4991:7): [True: 2.89M, False: 10.2k]
  |  Branch (4991:33): [True: 2.87M, False: 21.4k]
  ------------------
 4992|  2.87M|      ((uint8_t *)(_src + srcsize) < (uint8_t *)(bstarts + context->nblocks))) {
  ------------------
  |  Branch (4992:7): [True: 0, False: 2.87M]
  ------------------
 4993|      0|    BLOSC_TRACE_ERROR("`bstarts` out of bounds.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4994|      0|    return BLOSC2_ERROR_READ_BUFFER;
 4995|      0|  }
 4996|       |
 4997|  2.90M|  bool memcpyed = header->flags & (uint8_t)BLOSC_MEMCPYED;
 4998|  2.90M|  if (context->special_type) {
  ------------------
  |  Branch (4998:7): [True: 10.2k, False: 2.89M]
  ------------------
 4999|       |    // Fake a runlen as if its a memcpyed chunk
 5000|  10.2k|    memcpyed = true;
 5001|  10.2k|  }
 5002|       |
 5003|  2.90M|  bool is_lazy = ((context->header_overhead == BLOSC_EXTENDED_HEADER_LENGTH) &&
  ------------------
  |  Branch (5003:19): [True: 2.90M, False: 28]
  ------------------
 5004|  2.90M|                  (context->blosc2_flags & 0x08u) && !context->special_type);
  ------------------
  |  Branch (5004:19): [True: 5, False: 2.90M]
  |  Branch (5004:54): [True: 0, False: 5]
  ------------------
 5005|  2.90M|  if (memcpyed && !is_lazy && !context->postfilter) {
  ------------------
  |  Branch (5005:7): [True: 31.7k, False: 2.87M]
  |  Branch (5005:19): [True: 31.7k, False: 0]
  |  Branch (5005:31): [True: 31.7k, False: 0]
  ------------------
 5006|       |    // Short-circuit for (non-lazy) memcpyed or special values
 5007|  31.7k|    ntbytes = nitems_bytes;
 5008|  31.7k|    switch (context->special_type) {
 5009|  10.1k|      case BLOSC2_SPECIAL_VALUE: {
  ------------------
  |  Branch (5009:7): [True: 10.1k, False: 21.6k]
  ------------------
 5010|       |        // The repeated value's width is cbytes minus the header, not the header
 5011|       |        // typesize byte (which is left unconstrained for special-value chunks).
 5012|       |        // Derive it the same way blosc_d() does so a crafted typesize cannot make
 5013|       |        // set_values() read past the end of the chunk.
 5014|  10.1k|        int32_t value_typesize = header->cbytes - context->header_overhead;
 5015|  10.1k|        rc = set_values(value_typesize, _src, _dest, ntbytes);
 5016|  10.1k|        if (rc < 0) {
  ------------------
  |  Branch (5016:13): [True: 1, False: 10.1k]
  ------------------
 5017|      1|          BLOSC_TRACE_ERROR("set_values failed");
  ------------------
  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5018|      1|          return BLOSC2_ERROR_DATA;
 5019|      1|        }
 5020|  10.1k|        break;
 5021|  10.1k|      }
 5022|  10.1k|      case BLOSC2_SPECIAL_NAN:
  ------------------
  |  Branch (5022:7): [True: 3, False: 31.7k]
  ------------------
 5023|      3|        rc = set_nans(context->typesize, _dest, ntbytes);
 5024|      3|        if (rc < 0) {
  ------------------
  |  Branch (5024:13): [True: 0, False: 3]
  ------------------
 5025|      0|          BLOSC_TRACE_ERROR("set_nans failed");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5026|      0|          return BLOSC2_ERROR_DATA;
 5027|      0|        }
 5028|      3|        break;
 5029|    129|      case BLOSC2_SPECIAL_ZERO:
  ------------------
  |  Branch (5029:7): [True: 129, False: 31.6k]
  ------------------
 5030|    129|        memset(_dest, 0, ntbytes);
 5031|    129|        break;
 5032|      2|      case BLOSC2_SPECIAL_UNINIT:
  ------------------
  |  Branch (5032:7): [True: 2, False: 31.7k]
  ------------------
 5033|       |        // We do nothing here
 5034|      2|        break;
 5035|  21.4k|      case BLOSC2_NO_SPECIAL:
  ------------------
  |  Branch (5035:7): [True: 21.4k, False: 10.2k]
  ------------------
 5036|  21.4k|        {
 5037|  21.4k|          int64_t src_offset64 = (int64_t)context->header_overhead + start_bytes64;
 5038|  21.4k|          int64_t src_stop64 = src_offset64 + nitems_bytes64;
 5039|  21.4k|          if ((src_offset64 < 0) || (src_stop64 < src_offset64) || (src_stop64 > srcsize)) {
  ------------------
  |  Branch (5039:15): [True: 0, False: 21.4k]
  |  Branch (5039:37): [True: 0, False: 21.4k]
  |  Branch (5039:68): [True: 0, False: 21.4k]
  ------------------
 5040|      0|            BLOSC_TRACE_ERROR("getitem memcpy source out of bounds.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5041|      0|            return BLOSC2_ERROR_READ_BUFFER;
 5042|      0|          }
 5043|  21.4k|          _src += (int32_t)src_offset64;
 5044|  21.4k|        }
 5045|      0|        memcpy(_dest, _src, ntbytes);
 5046|  21.4k|        break;
 5047|      0|      default:
  ------------------
  |  Branch (5047:7): [True: 0, False: 31.7k]
  ------------------
 5048|      0|        BLOSC_TRACE_ERROR("Unhandled special value case");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5049|      0|        BLOSC_ERROR(BLOSC2_ERROR_SCHUNK_SPECIAL);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5050|  31.7k|    }
 5051|  31.7k|    return ntbytes;
 5052|  31.7k|  }
 5053|       |
 5054|  2.87M|  if (filters_contain(context->filters, BLOSC_DELTA)) {
  ------------------
  |  Branch (5054:7): [True: 7, False: 2.87M]
  ------------------
 5055|      7|    uint8_t* full_chunk = malloc((size_t)header->nbytes);
 5056|      7|    if (full_chunk == NULL) {
  ------------------
  |  Branch (5056:9): [True: 0, False: 7]
  ------------------
 5057|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 5058|      0|    }
 5059|      7|    int dbytes = blosc2_decompress_ctx(context, src, srcsize, full_chunk, header->nbytes);
 5060|      7|    context->dest = NULL;
 5061|      7|    context->destsize = 0;
 5062|      7|    if (dbytes < 0 || dbytes != header->nbytes) {
  ------------------
  |  Branch (5062:9): [True: 0, False: 7]
  |  Branch (5062:23): [True: 0, False: 7]
  ------------------
 5063|      0|      free(full_chunk);
 5064|      0|      return dbytes < 0 ? dbytes : BLOSC2_ERROR_DATA;
  ------------------
  |  Branch (5064:14): [True: 0, False: 0]
  ------------------
 5065|      0|    }
 5066|      7|    memcpy(dest, full_chunk + start_bytes64, (size_t)nitems_bytes);
 5067|      7|    free(full_chunk);
 5068|      7|    return nitems_bytes;
 5069|      7|  }
 5070|       |
 5071|  2.87M|  struct thread_context* scontext = serial_context_get(context);
 5072|  2.87M|  BLOSC_ERROR_NULL(scontext, BLOSC2_ERROR_THREAD_CREATE);
  ------------------
  |  |  104|  2.87M|    do {                                            \
  |  |  105|  2.87M|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.87M]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  2.87M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.87M]
  |  |  ------------------
  ------------------
 5073|       |
 5074|  13.5M|  for (j = 0; j < context->nblocks; j++) {
  ------------------
  |  Branch (5074:15): [True: 11.1M, False: 2.45M]
  ------------------
 5075|  11.1M|    bsize = header->blocksize;
 5076|  11.1M|    leftoverblock = 0;
 5077|  11.1M|    if ((j == context->nblocks - 1) && (context->leftover > 0)) {
  ------------------
  |  Branch (5077:9): [True: 2.70M, False: 8.43M]
  |  Branch (5077:40): [True: 291k, False: 2.40M]
  ------------------
 5078|   291k|      bsize = context->leftover;
 5079|   291k|      leftoverblock = 1;
 5080|   291k|    }
 5081|       |
 5082|       |    /* Compute start & stop for each block */
 5083|  11.1M|    startb = start * header->typesize - j * header->blocksize;
 5084|  11.1M|    stopb = stop * header->typesize - j * header->blocksize;
 5085|  11.1M|    if (stopb <= 0) {
  ------------------
  |  Branch (5085:9): [True: 423k, False: 10.7M]
  ------------------
 5086|       |      // We can exit as soon as this block is beyond stop
 5087|   423k|      break;
 5088|   423k|    }
 5089|  10.7M|    if (startb >= header->blocksize) {
  ------------------
  |  Branch (5089:9): [True: 7.83M, False: 2.87M]
  ------------------
 5090|  7.83M|      continue;
 5091|  7.83M|    }
 5092|  2.87M|    if (startb < 0) {
  ------------------
  |  Branch (5092:9): [True: 59, False: 2.87M]
  ------------------
 5093|     59|      startb = 0;
 5094|     59|    }
 5095|  2.87M|    if (stopb > header->blocksize) {
  ------------------
  |  Branch (5095:9): [True: 59, False: 2.87M]
  ------------------
 5096|     59|      stopb = header->blocksize;
 5097|     59|    }
 5098|  2.87M|    bsize2 = stopb - startb;
 5099|       |
 5100|  2.87M|#if defined(HAVE_ZFP)
 5101|  2.87M|    if (context->compcode == BLOSC_CODEC_ZFP_FIXED_RATE) {
  ------------------
  |  Branch (5101:9): [True: 0, False: 2.87M]
  ------------------
 5102|       |      // The items in this block
 5103|      0|      scontext->zfp_cell_start = startb / context->typesize;
 5104|      0|      scontext->zfp_cell_nitems = bsize2 / context->typesize;
 5105|      0|    }
 5106|  2.87M|#endif /* HAVE_ZFP */
 5107|       |
 5108|       |    /* Do the actual data copy */
 5109|       |    // Regular decompression.  Put results in tmp2.
 5110|       |    // If the items are exactly this block, decompress it in destination and avoid a copy
 5111|  2.87M|    bool get_single_block = ((ntbytes == 0) && (startb == 0) && (bsize == nitems_bytes));
  ------------------
  |  Branch (5111:30): [True: 2.87M, False: 59]
  |  Branch (5111:48): [True: 1.19M, False: 1.68M]
  |  Branch (5111:65): [True: 46.8k, False: 1.14M]
  ------------------
 5112|  2.87M|    uint8_t* tmp2 = get_single_block ? dest : scontext->tmp2;
  ------------------
  |  Branch (5112:21): [True: 46.8k, False: 2.82M]
  ------------------
 5113|       |
 5114|       |    // If memcpyed we don't have a bstarts section (because it is not needed)
 5115|  2.87M|    int32_t src_offset = memcpyed ?
  ------------------
  |  Branch (5115:26): [True: 0, False: 2.87M]
  ------------------
 5116|  2.87M|      context->header_overhead + j * header->blocksize : sw32_(bstarts + j);
 5117|       |
 5118|  2.87M|    int32_t cbytes = blosc_d(scontext, bsize, leftoverblock, memcpyed,
 5119|  2.87M|                             src, srcsize, src_offset, j,
 5120|  2.87M|                             tmp2, 0, scontext->tmp, scontext->tmp3);
 5121|  2.87M|    if (cbytes < 0) {
  ------------------
  |  Branch (5121:9): [True: 0, False: 2.87M]
  ------------------
 5122|      0|      ntbytes = cbytes;
 5123|      0|      break;
 5124|      0|    }
 5125|  2.87M|    if (!get_single_block) {
  ------------------
  |  Branch (5125:9): [True: 2.82M, False: 46.8k]
  ------------------
 5126|       |      /* Copy to destination.  When ZFP decoded just the requested items (a single
 5127|       |         cell), they are at the start of tmp2, else the whole block was decoded. */
 5128|  2.82M|      bool zfp_cell = (scontext->zfp_cell_nitems > 0) && (cbytes == bsize2);
  ------------------
  |  Branch (5128:23): [True: 0, False: 2.82M]
  |  Branch (5128:58): [True: 0, False: 0]
  ------------------
 5129|  2.82M|      memcpy((uint8_t *) dest + ntbytes, tmp2 + (zfp_cell ? 0 : startb), (unsigned int) bsize2);
  ------------------
  |  Branch (5129:50): [True: 0, False: 2.82M]
  ------------------
 5130|  2.82M|    }
 5131|  2.87M|    ntbytes += bsize2;
 5132|  2.87M|  }
 5133|       |
 5134|  2.87M|  scontext->zfp_cell_nitems = 0;
 5135|  2.87M|  serial_context_put(scontext);
 5136|       |
 5137|  2.87M|  if (ntbytes >= 0 && ntbytes != nitems_bytes) {
  ------------------
  |  Branch (5137:7): [True: 2.87M, False: 0]
  |  Branch (5137:23): [True: 0, False: 2.87M]
  ------------------
 5138|       |    // A partial decode must not look like a success: callers that only test for
 5139|       |    // a negative return would silently keep hold of an incompletely filled dest.
 5140|      0|    BLOSC_TRACE_ERROR("Only %d bytes out of the %d requested could be decoded.",
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5141|      0|                      ntbytes, nitems_bytes);
 5142|      0|    return BLOSC2_ERROR_DATA;
 5143|      0|  }
 5144|       |
 5145|  2.87M|  return ntbytes;
 5146|  2.87M|}
blosc2_getitem:
 5148|  2.84M|int blosc2_getitem(const void* src, int32_t srcsize, int start, int nitems, void* dest, int32_t destsize) {
 5149|  2.84M|  blosc2_context context;
 5150|  2.84M|  int result;
 5151|       |
 5152|       |  /* Minimally populate the context */
 5153|  2.84M|  memset(&context, 0, sizeof(blosc2_context));
 5154|       |
 5155|  2.84M|  context.schunk = g_schunk;
 5156|  2.84M|  context.nthreads = 1;  // force a serial decompression; fixes #95
 5157|       |
 5158|       |  /* Call the actual getitem function */
 5159|  2.84M|  result = blosc2_getitem_ctx(&context, src, srcsize, start, nitems, dest, destsize);
 5160|       |
 5161|       |  /* Release resources */
 5162|  2.84M|  if (context.serial_context != NULL) {
  ------------------
  |  Branch (5162:7): [True: 1, False: 2.84M]
  ------------------
 5163|      1|    free_thread_context(context.serial_context);
 5164|      1|  }
 5165|  2.84M|  return result;
 5166|  2.84M|}
blosc2_getitem_ctx:
 5210|  2.84M|    int start, int nitems, void* dest, int32_t destsize) {
 5211|  2.84M|  blosc_header header;
 5212|  2.84M|  int result = getitem_read_header(src, srcsize, &header);
 5213|  2.84M|  if (result < 0) {
  ------------------
  |  Branch (5213:7): [True: 0, False: 2.84M]
  ------------------
 5214|      0|    return result;
 5215|      0|  }
 5216|       |
 5217|  2.84M|  return getitem_with_header(context, &header, src, srcsize, start, nitems, dest, destsize);
 5218|  2.84M|}
blosc2_getitem_bytes_ctx:
 5221|  57.3k|    int32_t start, int32_t nbytes, void* dest, int32_t destsize) {
 5222|  57.3k|  blosc_header header;
 5223|  57.3k|  int result = getitem_read_header(src, srcsize, &header);
 5224|  57.3k|  if (result < 0) {
  ------------------
  |  Branch (5224:7): [True: 0, False: 57.3k]
  ------------------
 5225|      0|    return result;
 5226|      0|  }
 5227|       |
 5228|  57.3k|  if (start < 0 || nbytes < 0) {
  ------------------
  |  Branch (5228:7): [True: 0, False: 57.3k]
  |  Branch (5228:20): [True: 0, False: 57.3k]
  ------------------
 5229|      0|    BLOSC_TRACE_ERROR("`start` and `nbytes` must not be negative.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5230|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 5231|      0|  }
 5232|       |
 5233|       |  /* The typesize a chunk records is 1 whenever the original one exceeded
 5234|       |     BLOSC_MAX_TYPESIZE, so for wide types this conversion is a no-op and the
 5235|       |     alignment check below is vacuous.  That is the whole point of this entry
 5236|       |     point: the caller never has to know whether the cap kicked in. */
 5237|  57.3k|  int32_t typesize = header.typesize;
 5238|  57.3k|  if ((start % typesize != 0) || (nbytes % typesize != 0)) {
  ------------------
  |  Branch (5238:7): [True: 0, False: 57.3k]
  |  Branch (5238:34): [True: 0, False: 57.3k]
  ------------------
 5239|      0|    BLOSC_TRACE_ERROR("`start` (%d) and `nbytes` (%d) must both be multiples of "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5240|      0|                      "the typesize stored in the chunk (%d).", start, nbytes, typesize);
 5241|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 5242|      0|  }
 5243|       |
 5244|  57.3k|  return getitem_with_header(context, &header, src, srcsize, start / typesize,
 5245|  57.3k|                             nbytes / typesize, dest, destsize);
 5246|  57.3k|}
blosc2_get_nthreads:
 6400|  5.92k|{
 6401|  5.92k|  int16_t nthreads;
 6402|  5.92k|  blosc2_init();
 6403|  5.92k|  blosc2_pthread_mutex_lock(&global_comp_mutex);
  ------------------
  |  |   92|  5.92k|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 6404|  5.92k|  nthreads = g_nthreads;
 6405|  5.92k|  blosc2_pthread_mutex_unlock(&global_comp_mutex);
  ------------------
  |  |   93|  5.92k|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6406|  5.92k|  return nthreads;
 6407|  5.92k|}
blosc2_set_nthreads:
 6409|  3.39k|int16_t blosc2_set_nthreads(int16_t nthreads) {
 6410|  3.39k|  int16_t ret;          /* the previous number of threads */
 6411|       |
 6412|       |  /* Check whether the library should be initialized */
 6413|  3.39k|  blosc2_init();
 6414|       |
 6415|  3.39k|  blosc2_pthread_mutex_lock(&global_comp_mutex);
  ------------------
  |  |   92|  3.39k|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 6416|  3.39k|  ret = g_nthreads;
 6417|  3.39k|  if (nthreads != ret) {
  ------------------
  |  Branch (6417:7): [True: 0, False: 3.39k]
  ------------------
 6418|      0|    int16_t old_new_nthreads = g_global_context->new_nthreads;
 6419|      0|    int16_t old_nthreads = g_global_context->nthreads;
 6420|      0|    g_nthreads = nthreads;
 6421|      0|    g_global_context->new_nthreads = nthreads;
 6422|      0|    int16_t ret2 = check_nthreads(g_global_context, true);
 6423|      0|    if (ret2 < 0) {
  ------------------
  |  Branch (6423:9): [True: 0, False: 0]
  ------------------
 6424|      0|      g_nthreads = ret;
 6425|      0|      g_global_context->new_nthreads = old_new_nthreads;
 6426|      0|      g_global_context->nthreads = old_nthreads;
 6427|      0|      check_nthreads(g_global_context, true);
 6428|      0|      blosc2_pthread_mutex_unlock(&global_comp_mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6429|      0|      return ret2;
 6430|      0|    }
 6431|      0|  }
 6432|  3.39k|  blosc2_pthread_mutex_unlock(&global_comp_mutex);
  ------------------
  |  |   93|  3.39k|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6433|       |
 6434|  3.39k|  return ret;
 6435|  3.39k|}
blosc2_cbuffer_sizes:
 6552|  23.0M|int blosc2_cbuffer_sizes(const void* cbuffer, int32_t* nbytes, int32_t* cbytes, int32_t* blocksize) {
 6553|  23.0M|  blosc_header header;
 6554|  23.0M|  int rc = read_chunk_header((uint8_t *) cbuffer, BLOSC_MIN_HEADER_LENGTH, false, &header);
 6555|  23.0M|  if (rc < 0) {
  ------------------
  |  Branch (6555:7): [True: 46, False: 23.0M]
  ------------------
 6556|       |    /* Return zeros if error reading header */
 6557|     46|    memset(&header, 0, sizeof(header));
 6558|     46|  }
 6559|       |
 6560|       |  /* Read the interesting values */
 6561|  23.0M|  if (nbytes != NULL)
  ------------------
  |  Branch (6561:7): [True: 17.5M, False: 5.56M]
  ------------------
 6562|  17.5M|    *nbytes = header.nbytes;
 6563|  23.0M|  if (cbytes != NULL)
  ------------------
  |  Branch (6563:7): [True: 21.0M, False: 2.08M]
  ------------------
 6564|  21.0M|    *cbytes = header.cbytes;
 6565|  23.0M|  if (blocksize != NULL)
  ------------------
  |  Branch (6565:7): [True: 4.54M, False: 18.5M]
  ------------------
 6566|  4.54M|    *blocksize = header.blocksize;
 6567|  23.0M|  return rc;
 6568|  23.0M|}
blosc2_init:
 6758|  76.0k|void blosc2_init(void) {
 6759|       |  /* Return if Blosc is already initialized */
 6760|  76.0k|  if (load_acquire_int(&g_initlib) == BLOSC_STATE_INITIALIZED) return;
  ------------------
  |  |  142|  76.0k|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
                if (load_acquire_int(&g_initlib) == BLOSC_STATE_INITIALIZED) return;
  ------------------
  |  |  104|  76.0k|#define BLOSC_STATE_INITIALIZED   1
  ------------------
  |  Branch (6760:7): [True: 72.6k, False: 3.39k]
  ------------------
 6761|       |
 6762|  3.39k|#if !defined(_WIN32)
 6763|       |  /* Before g_init_lock is taken: from now on a fork() waits for it */
 6764|  3.39k|  pthread_once(&atfork_once, register_atfork);
 6765|  3.39k|#endif
 6766|  3.39k|  static_lock(&g_init_lock);
  ------------------
  |  |  132|  3.39k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 6767|       |  /* Teardown drops this lock while joining prefetch workers.  Wait without
 6768|       |     holding it so the destroyer can finish; never reinitialize live globals. */
 6769|  3.39k|  while (g_initlib == BLOSC_STATE_TEARDOWN) {
  ------------------
  |  |  105|  3.39k|#define BLOSC_STATE_TEARDOWN      2
  ------------------
  |  Branch (6769:10): [True: 0, False: 3.39k]
  ------------------
 6770|       |#if defined(_WIN32)
 6771|       |    SleepConditionVariableSRW(&g_init_cv, &g_init_lock, INFINITE, 0);
 6772|       |#else
 6773|      0|    pthread_cond_wait(&g_init_cv, &g_init_lock);
 6774|      0|#endif
 6775|      0|  }
 6776|       |  /* Unless another thread initialized it meanwhile */
 6777|  3.39k|  if (g_initlib != BLOSC_STATE_INITIALIZED) {
  ------------------
  |  |  104|  3.39k|#define BLOSC_STATE_INITIALIZED   1
  ------------------
  |  Branch (6777:7): [True: 3.39k, False: 0]
  ------------------
 6778|  3.39k|    blosc2_init_locked();
 6779|  3.39k|  }
 6780|  3.39k|  static_unlock(&g_init_lock);
  ------------------
  |  |  133|  3.39k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6781|  3.39k|}
blosc2_tmp_malloc:
 6945|   678k|void *blosc2_tmp_malloc(size_t nbytes, size_t *capacity) {
 6946|   678k|  *capacity = nbytes;
 6947|   678k|#if !defined(_WIN32)
 6948|   678k|  tmp_cache_t *cache = nbytes >= BLOSC2_TMP_CACHE_MIN ? tmp_cache_get(false) : NULL;
  ------------------
  |  | 6812|   678k|#define BLOSC2_TMP_CACHE_MIN (64 * 1024)
  ------------------
  |  Branch (6948:24): [True: 3.24k, False: 675k]
  ------------------
 6949|   678k|  if (cache != NULL) {
  ------------------
  |  Branch (6949:7): [True: 3.24k, False: 675k]
  ------------------
 6950|       |    // The smallest buffer that fits, and not one far larger than needed
 6951|  3.24k|    int best = -1;
 6952|  16.2k|    for (int i = 0; i < BLOSC2_TMP_CACHE_SLOTS; ++i) {
  ------------------
  |  | 6811|  16.2k|#define BLOSC2_TMP_CACHE_SLOTS 4
  ------------------
  |  Branch (6952:21): [True: 12.9k, False: 3.24k]
  ------------------
 6953|  12.9k|      if (cache->ptr[i] != NULL && cache->size[i] >= nbytes && cache->size[i] / 2 <= nbytes &&
  ------------------
  |  Branch (6953:11): [True: 4.01k, False: 8.95k]
  |  Branch (6953:36): [True: 3.52k, False: 487]
  |  Branch (6953:64): [True: 3.52k, False: 0]
  ------------------
 6954|  3.52k|          (best < 0 || cache->size[i] < cache->size[best])) {
  ------------------
  |  Branch (6954:12): [True: 2.67k, False: 851]
  |  Branch (6954:24): [True: 0, False: 851]
  ------------------
 6955|  2.67k|        best = i;
 6956|  2.67k|      }
 6957|  12.9k|    }
 6958|  3.24k|    if (best >= 0) {
  ------------------
  |  Branch (6958:9): [True: 2.67k, False: 566]
  ------------------
 6959|  2.67k|      void *ptr = cache->ptr[best];
 6960|  2.67k|      *capacity = cache->size[best];
 6961|  2.67k|      cache->ptr[best] = NULL;
 6962|  2.67k|      cache->size[best] = 0;
 6963|  2.67k|      return ptr;
 6964|  2.67k|    }
 6965|  3.24k|  }
 6966|   675k|#endif
 6967|   675k|  return malloc(nbytes);
 6968|   678k|}
blosc2_tmp_free:
 6970|   799k|void blosc2_tmp_free(void *ptr, size_t capacity) {
 6971|   799k|  if (ptr == NULL) {
  ------------------
  |  Branch (6971:7): [True: 114k, False: 685k]
  ------------------
 6972|   114k|    return;
 6973|   114k|  }
 6974|   685k|#if !defined(_WIN32)
 6975|   685k|  tmp_cache_t *cache = NULL;
 6976|   685k|  if (capacity >= BLOSC2_TMP_CACHE_MIN && capacity <= BLOSC2_TMP_CACHE_MAX / 2) {
  ------------------
  |  | 6812|  1.37M|#define BLOSC2_TMP_CACHE_MIN (64 * 1024)
  ------------------
                if (capacity >= BLOSC2_TMP_CACHE_MIN && capacity <= BLOSC2_TMP_CACHE_MAX / 2) {
  ------------------
  |  | 6813|  3.24k|#define BLOSC2_TMP_CACHE_MAX (64 * 1024 * 1024)
  ------------------
  |  Branch (6976:7): [True: 3.24k, False: 682k]
  |  Branch (6976:43): [True: 3.22k, False: 16]
  ------------------
 6977|  3.22k|    cache = tmp_cache_get(true);
 6978|  3.22k|  }
 6979|   685k|  if (cache != NULL) {
  ------------------
  |  Branch (6979:7): [True: 3.22k, False: 682k]
  ------------------
 6980|       |    // Make room by dropping the smallest buffers (each one smaller than this)
 6981|  3.22k|    for (;;) {
 6982|  3.22k|      size_t total = capacity;
 6983|  3.22k|      int empty = -1;
 6984|  3.22k|      int smallest = -1;
 6985|  16.1k|      for (int i = 0; i < BLOSC2_TMP_CACHE_SLOTS; ++i) {
  ------------------
  |  | 6811|  16.1k|#define BLOSC2_TMP_CACHE_SLOTS 4
  ------------------
  |  Branch (6985:23): [True: 12.9k, False: 3.22k]
  ------------------
 6986|  12.9k|        if (cache->ptr[i] == NULL) {
  ------------------
  |  Branch (6986:13): [True: 11.2k, False: 1.63k]
  ------------------
 6987|  11.2k|          empty = i;
 6988|  11.2k|          continue;
 6989|  11.2k|        }
 6990|  1.63k|        total += cache->size[i];
 6991|  1.63k|        if (smallest < 0 || cache->size[i] < cache->size[smallest]) {
  ------------------
  |  Branch (6991:13): [True: 1.42k, False: 206]
  |  Branch (6991:29): [True: 0, False: 206]
  ------------------
 6992|  1.42k|          smallest = i;
 6993|  1.42k|        }
 6994|  1.63k|      }
 6995|  3.22k|      if (empty >= 0 && total <= BLOSC2_TMP_CACHE_MAX) {
  ------------------
  |  | 6813|  3.22k|#define BLOSC2_TMP_CACHE_MAX (64 * 1024 * 1024)
  ------------------
  |  Branch (6995:11): [True: 3.22k, False: 0]
  |  Branch (6995:25): [True: 3.22k, False: 0]
  ------------------
 6996|  3.22k|        cache->ptr[empty] = ptr;
 6997|  3.22k|        cache->size[empty] = capacity;
 6998|  3.22k|        return;
 6999|  3.22k|      }
 7000|      0|      if (smallest < 0 || cache->size[smallest] >= capacity) {
  ------------------
  |  Branch (7000:11): [True: 0, False: 0]
  |  Branch (7000:27): [True: 0, False: 0]
  ------------------
 7001|      0|        break;
 7002|      0|      }
 7003|      0|      free(cache->ptr[smallest]);
 7004|      0|      cache->ptr[smallest] = NULL;
 7005|      0|      cache->size[smallest] = 0;
 7006|      0|    }
 7007|  3.22k|  }
 7008|       |#else
 7009|       |  BLOSC_UNUSED_PARAM(capacity);
 7010|       |#endif
 7011|   682k|  free(ptr);
 7012|   682k|}
blosc2_tmp_cache_clear:
 7014|  6.78k|void blosc2_tmp_cache_clear(void) {
 7015|  6.78k|#if !defined(_WIN32)
 7016|  6.78k|  tmp_cache_t *cache = tmp_cache_get(false);
 7017|  6.78k|  if (cache != NULL) {
  ------------------
  |  Branch (7017:7): [True: 6.78k, False: 0]
  ------------------
 7018|  33.9k|    for (int i = 0; i < BLOSC2_TMP_CACHE_SLOTS; ++i) {
  ------------------
  |  | 6811|  33.9k|#define BLOSC2_TMP_CACHE_SLOTS 4
  ------------------
  |  Branch (7018:21): [True: 27.1k, False: 6.78k]
  ------------------
 7019|  27.1k|      free(cache->ptr[i]);
 7020|  27.1k|      cache->ptr[i] = NULL;
 7021|  27.1k|      cache->size[i] = 0;
 7022|  27.1k|    }
 7023|  6.78k|    if (cache->serial != NULL && !cache->serial_busy) {
  ------------------
  |  Branch (7023:9): [True: 2.41k, False: 4.37k]
  |  Branch (7023:34): [True: 2.41k, False: 0]
  ------------------
 7024|  2.41k|      free_thread_context(cache->serial);
 7025|       |      cache->serial = NULL;
 7026|  2.41k|    }
 7027|  6.78k|  }
 7028|  6.78k|#endif
 7029|  6.78k|}
blosc2_destroy:
 7067|  3.39k|void blosc2_destroy(void) {
 7068|       |  /* Return if Blosc is not initialized */
 7069|  3.39k|  if (load_acquire_int(&g_initlib) != BLOSC_STATE_INITIALIZED) return;
  ------------------
  |  |  142|  3.39k|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
                if (load_acquire_int(&g_initlib) != BLOSC_STATE_INITIALIZED) return;
  ------------------
  |  |  104|  3.39k|#define BLOSC_STATE_INITIALIZED   1
  ------------------
  |  Branch (7069:7): [True: 0, False: 3.39k]
  ------------------
 7070|       |
 7071|  3.39k|  static_lock(&g_init_lock);
  ------------------
  |  |  132|  3.39k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 7072|  3.39k|  if (g_initlib != BLOSC_STATE_INITIALIZED) {
  ------------------
  |  |  104|  3.39k|#define BLOSC_STATE_INITIALIZED   1
  ------------------
  |  Branch (7072:7): [True: 0, False: 3.39k]
  ------------------
 7073|      0|    static_unlock(&g_init_lock);
  ------------------
  |  |  133|      0|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 7074|      0|    return;
 7075|      0|  }
 7076|  3.39k|  store_release_int(&g_initlib, BLOSC_STATE_TEARDOWN);
  ------------------
  |  |  143|  3.39k|#define store_release_int(p, v) __atomic_store_n((p), (v), __ATOMIC_RELEASE)
  ------------------
 7077|  3.39k|  static_unlock(&g_init_lock);
  ------------------
  |  |  133|  3.39k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 7078|       |
 7079|       |  /* Not under g_init_lock: a fork() holds the read-ahead pool's lock while it
 7080|       |     waits for g_init_lock (prefetch.c registers its fork handlers later).
 7081|       |     New prefetch operations and threads are blocked by blosc2_is_initialized(). */
 7082|  3.39k|  prefetch_destroy();
 7083|       |
 7084|  3.39k|  static_lock(&g_init_lock);
  ------------------
  |  |  132|  3.39k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 7085|  3.39k|  blosc2_destroy_locked();
 7086|  3.39k|  store_release_int(&g_initlib, BLOSC_STATE_UNINITIALIZED);
  ------------------
  |  |  143|  3.39k|#define store_release_int(p, v) __atomic_store_n((p), (v), __ATOMIC_RELEASE)
  ------------------
 7087|       |#if defined(_WIN32)
 7088|       |  WakeAllConditionVariable(&g_init_cv);
 7089|       |#else
 7090|  3.39k|  pthread_cond_broadcast(&g_init_cv);
 7091|  3.39k|#endif
 7092|  3.39k|  static_unlock(&g_init_lock);
  ------------------
  |  |  133|  3.39k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 7093|  3.39k|}
blosc2_create_cctx:
 7099|  3.23M|blosc2_context* blosc2_create_cctx(blosc2_cparams cparams) {
 7100|  3.23M|  blosc2_context* context = (blosc2_context*)my_malloc(sizeof(blosc2_context));
 7101|  3.23M|  BLOSC_ERROR_NULL(context, NULL);
  ------------------
  |  |  104|  3.23M|    do {                                            \
  |  |  105|  3.23M|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 3.23M]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  3.23M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.23M]
  |  |  ------------------
  ------------------
 7102|       |
 7103|       |  /* Populate the context, using zeros as default values */
 7104|  3.23M|  memset(context, 0, sizeof(blosc2_context));
 7105|       |  /* Early, so that the cleanup at `failed` can always destroy it */
 7106|  3.23M|  blosc2_pthread_mutex_init(&context->nchunk_mutex, NULL);
  ------------------
  |  |   90|  3.23M|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 7107|  3.23M|  context->do_compress = 1;   /* meant for compression */
 7108|  3.23M|  context->use_dict = cparams.use_dict;
 7109|  3.23M|  if (cparams.instr_codec) {
  ------------------
  |  Branch (7109:7): [True: 0, False: 3.23M]
  ------------------
 7110|      0|    context->blosc2_flags = BLOSC2_INSTR_CODEC;
 7111|      0|  }
 7112|       |
 7113|  22.6M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (7113:19): [True: 19.4M, False: 3.23M]
  ------------------
 7114|  19.4M|    context->filters[i] = cparams.filters[i];
 7115|  19.4M|    context->filters_meta[i] = cparams.filters_meta[i];
 7116|       |
 7117|  19.4M|    if (context->filters[i] >= BLOSC_LAST_FILTER && context->filters[i] <= BLOSC2_DEFINED_FILTERS_STOP) {
  ------------------
  |  Branch (7117:9): [True: 76, False: 19.4M]
  |  Branch (7117:53): [True: 7, False: 69]
  ------------------
 7118|      7|      BLOSC_TRACE_ERROR("filter (%d) is not yet defined",
  ------------------
  |  |   93|      7|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      7|    do {                                            \
  |  |  |  |   98|      7|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      7|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      7|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7119|      7|                        context->filters[i]);
 7120|      7|      goto failed;
 7121|      7|    }
 7122|  19.4M|    if (context->filters[i] > BLOSC_LAST_REGISTERED_FILTER && context->filters[i] <= BLOSC2_GLOBAL_REGISTERED_FILTERS_STOP) {
  ------------------
  |  Branch (7122:9): [True: 58, False: 19.4M]
  |  Branch (7122:63): [True: 11, False: 47]
  ------------------
 7123|     11|      BLOSC_TRACE_ERROR("filter (%d) is not yet defined",
  ------------------
  |  |   93|     11|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     11|    do {                                            \
  |  |  |  |   98|     11|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     11|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     11|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7124|     11|                        context->filters[i]);
 7125|     11|      goto failed;
 7126|     11|    }
 7127|  19.4M|  }
 7128|       |
 7129|  3.23M|#if defined(HAVE_ZFP)
 7130|  3.23M|#include "blosc2/codecs-registry.h"
 7131|  3.23M|  if ((context->compcode >= BLOSC_CODEC_ZFP_FIXED_ACCURACY) && (context->compcode <= BLOSC_CODEC_ZFP_FIXED_RATE)) {
  ------------------
  |  Branch (7131:7): [True: 0, False: 3.23M]
  |  Branch (7131:64): [True: 0, False: 0]
  ------------------
 7132|      0|    for (int i = 0; i < BLOSC2_MAX_FILTERS; ++i) {
  ------------------
  |  Branch (7132:21): [True: 0, False: 0]
  ------------------
 7133|      0|      if ((context->filters[i] == BLOSC_SHUFFLE) || (context->filters[i] == BLOSC_BITSHUFFLE)) {
  ------------------
  |  Branch (7133:11): [True: 0, False: 0]
  |  Branch (7133:53): [True: 0, False: 0]
  ------------------
 7134|      0|        BLOSC_TRACE_ERROR("ZFP cannot be run in presence of SHUFFLE / BITSHUFFLE");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7135|      0|        goto failed;
 7136|      0|      }
 7137|      0|    }
 7138|      0|  }
 7139|  3.23M|#endif /* HAVE_ZFP */
 7140|       |
 7141|       |  /* Check for a BLOSC_SHUFFLE environment variable */
 7142|  3.23M|  int doshuffle = -1;
 7143|  3.23M|  char* envvar = getenv("BLOSC_SHUFFLE");
 7144|  3.23M|  if (envvar != NULL) {
  ------------------
  |  Branch (7144:7): [True: 0, False: 3.23M]
  ------------------
 7145|      0|    if (strcmp(envvar, "NOSHUFFLE") == 0) {
  ------------------
  |  Branch (7145:9): [True: 0, False: 0]
  ------------------
 7146|      0|      doshuffle = BLOSC_NOSHUFFLE;
 7147|      0|    }
 7148|      0|    else if (strcmp(envvar, "SHUFFLE") == 0) {
  ------------------
  |  Branch (7148:14): [True: 0, False: 0]
  ------------------
 7149|      0|      doshuffle = BLOSC_SHUFFLE;
 7150|      0|    }
 7151|      0|    else if (strcmp(envvar, "BITSHUFFLE") == 0) {
  ------------------
  |  Branch (7151:14): [True: 0, False: 0]
  ------------------
 7152|      0|      doshuffle = BLOSC_BITSHUFFLE;
 7153|      0|    }
 7154|      0|    else {
 7155|      0|      BLOSC_TRACE_WARNING("BLOSC_SHUFFLE environment variable '%s' not recognized\n", envvar);
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7156|      0|    }
 7157|      0|  }
 7158|       |  /* Check for a BLOSC_DELTA environment variable */
 7159|  3.23M|  int dodelta = BLOSC_NOFILTER;
 7160|  3.23M|  envvar = getenv("BLOSC_DELTA");
 7161|  3.23M|  if (envvar != NULL) {
  ------------------
  |  Branch (7161:7): [True: 0, False: 3.23M]
  ------------------
 7162|      0|    if (strcmp(envvar, "1") == 0) {
  ------------------
  |  Branch (7162:9): [True: 0, False: 0]
  ------------------
 7163|      0|      dodelta = BLOSC_DELTA;
 7164|      0|    } else if (strcmp(envvar, "0") == 0){
  ------------------
  |  Branch (7164:16): [True: 0, False: 0]
  ------------------
 7165|      0|      dodelta = BLOSC_NOFILTER;
 7166|      0|    }
 7167|      0|    else {
 7168|      0|      BLOSC_TRACE_WARNING("BLOSC_DELTA environment variable '%s' not recognized\n", envvar);
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7169|      0|    }
 7170|      0|  }
 7171|       |  /* Check for a BLOSC_TYPESIZE environment variable */
 7172|  3.23M|  context->typesize = cparams.typesize;
 7173|  3.23M|  envvar = getenv("BLOSC_TYPESIZE");
 7174|  3.23M|  if (envvar != NULL) {
  ------------------
  |  Branch (7174:7): [True: 0, False: 3.23M]
  ------------------
 7175|      0|    int32_t value;
 7176|      0|    errno = 0; /* To distinguish success/failure after call */
 7177|      0|    value = (int32_t) strtol(envvar, NULL, 10);
 7178|      0|    if ((errno != EINVAL) && (value > 0)) {
  ------------------
  |  Branch (7178:9): [True: 0, False: 0]
  |  Branch (7178:30): [True: 0, False: 0]
  ------------------
 7179|      0|      context->typesize = value;
 7180|      0|    }
 7181|      0|    else {
 7182|      0|      BLOSC_TRACE_WARNING("BLOSC_TYPESIZE environment variable '%s' not recognized\n", envvar);
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7183|      0|    }
 7184|      0|  }
 7185|  3.23M|  build_filters(doshuffle, dodelta, context->typesize, context->filters);
 7186|       |
 7187|  3.23M|  context->clevel = cparams.clevel;
 7188|       |  /* Check for a BLOSC_CLEVEL environment variable */
 7189|  3.23M|  envvar = getenv("BLOSC_CLEVEL");
 7190|  3.23M|  if (envvar != NULL) {
  ------------------
  |  Branch (7190:7): [True: 0, False: 3.23M]
  ------------------
 7191|      0|    int value;
 7192|      0|    errno = 0; /* To distinguish success/failure after call */
 7193|      0|    value = (int)strtol(envvar, NULL, 10);
 7194|      0|    if ((errno != EINVAL) && (value >= 0)) {
  ------------------
  |  Branch (7194:9): [True: 0, False: 0]
  |  Branch (7194:30): [True: 0, False: 0]
  ------------------
 7195|      0|      context->clevel = value;
 7196|      0|    }
 7197|      0|    else {
 7198|      0|      BLOSC_TRACE_WARNING("BLOSC_CLEVEL environment variable '%s' not recognized\n", envvar);
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7199|      0|    }
 7200|      0|  }
 7201|       |
 7202|  3.23M|  context->compcode = cparams.compcode;
 7203|       |  /* Check for a BLOSC_COMPRESSOR environment variable */
 7204|  3.23M|  envvar = getenv("BLOSC_COMPRESSOR");
 7205|  3.23M|  if (envvar != NULL) {
  ------------------
  |  Branch (7205:7): [True: 0, False: 3.23M]
  ------------------
 7206|      0|    int codec = blosc2_compname_to_compcode(envvar);
 7207|      0|    if (codec >= BLOSC_LAST_CODEC) {
  ------------------
  |  Branch (7207:9): [True: 0, False: 0]
  ------------------
 7208|      0|      BLOSC_TRACE_ERROR("User defined codecs cannot be set here. Use Blosc2 mechanism instead.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7209|      0|      goto failed;
 7210|      0|    }
 7211|      0|    context->compcode = codec;
 7212|      0|  }
 7213|  3.23M|  context->compcode_meta = cparams.compcode_meta;
 7214|       |
 7215|  3.23M|  context->blocksize = cparams.blocksize;
 7216|       |  /* Check for a BLOSC_BLOCKSIZE environment variable */
 7217|  3.23M|  envvar = getenv("BLOSC_BLOCKSIZE");
 7218|  3.23M|  if (envvar != NULL) {
  ------------------
  |  Branch (7218:7): [True: 0, False: 3.23M]
  ------------------
 7219|      0|    int32_t blocksize;
 7220|      0|    errno = 0; /* To distinguish success/failure after call */
 7221|      0|    blocksize = (int32_t) strtol(envvar, NULL, 10);
 7222|      0|    if ((errno != EINVAL) && (blocksize > 0)) {
  ------------------
  |  Branch (7222:9): [True: 0, False: 0]
  |  Branch (7222:30): [True: 0, False: 0]
  ------------------
 7223|      0|      context->blocksize = blocksize;
 7224|      0|    }
 7225|      0|    else {
 7226|      0|      BLOSC_TRACE_WARNING("BLOSC_BLOCKSIZE environment variable '%s' not recognized\n", envvar);
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7227|      0|    }
 7228|      0|  }
 7229|       |
 7230|  3.23M|  context->nthreads = cparams.nthreads;
 7231|       |  /* Check for a BLOSC_NTHREADS environment variable */
 7232|  3.23M|  envvar = getenv("BLOSC_NTHREADS");
 7233|  3.23M|  if (envvar != NULL) {
  ------------------
  |  Branch (7233:7): [True: 0, False: 3.23M]
  ------------------
 7234|      0|    errno = 0; /* To distinguish success/failure after call */
 7235|      0|    int16_t nthreads = (int16_t) strtol(envvar, NULL, 10);
 7236|      0|    if ((errno != EINVAL) && (nthreads > 0)) {
  ------------------
  |  Branch (7236:9): [True: 0, False: 0]
  |  Branch (7236:30): [True: 0, False: 0]
  ------------------
 7237|      0|      context->nthreads = nthreads;
 7238|      0|    }
 7239|      0|    else {
 7240|      0|      BLOSC_TRACE_WARNING("BLOSC_NTHREADS environment variable '%s' not recognized\n", envvar);
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7241|      0|    }
 7242|      0|  }
 7243|  3.23M|  context->new_nthreads = context->nthreads;
 7244|       |
 7245|  3.23M|  context->splitmode = cparams.splitmode;
 7246|       |  /* Check for a BLOSC_SPLITMODE environment variable */
 7247|  3.23M|  envvar = getenv("BLOSC_SPLITMODE");
 7248|  3.23M|  if (envvar != NULL) {
  ------------------
  |  Branch (7248:7): [True: 0, False: 3.23M]
  ------------------
 7249|      0|    int32_t splitmode = -1;
 7250|      0|    if (strcmp(envvar, "ALWAYS") == 0) {
  ------------------
  |  Branch (7250:9): [True: 0, False: 0]
  ------------------
 7251|      0|      splitmode = BLOSC_ALWAYS_SPLIT;
 7252|      0|    }
 7253|      0|    else if (strcmp(envvar, "NEVER") == 0) {
  ------------------
  |  Branch (7253:14): [True: 0, False: 0]
  ------------------
 7254|      0|      splitmode = BLOSC_NEVER_SPLIT;
 7255|      0|    }
 7256|      0|    else if (strcmp(envvar, "AUTO") == 0) {
  ------------------
  |  Branch (7256:14): [True: 0, False: 0]
  ------------------
 7257|      0|      splitmode = BLOSC_AUTO_SPLIT;
 7258|      0|    }
 7259|      0|    else if (strcmp(envvar, "FORWARD_COMPAT") == 0) {
  ------------------
  |  Branch (7259:14): [True: 0, False: 0]
  ------------------
 7260|      0|      splitmode = BLOSC_FORWARD_COMPAT_SPLIT;
 7261|      0|    }
 7262|      0|    else {
 7263|      0|      BLOSC_TRACE_WARNING("BLOSC_SPLITMODE environment variable '%s' not recognized\n", envvar);
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7264|      0|    }
 7265|      0|    if (splitmode >= 0) {
  ------------------
  |  Branch (7265:9): [True: 0, False: 0]
  ------------------
 7266|      0|      context->splitmode = splitmode;
 7267|      0|    }
 7268|      0|  }
 7269|       |
 7270|  3.23M|  context->threads_started = 0;
 7271|  3.23M|  context->schunk = cparams.schunk;
 7272|       |
 7273|  3.23M|  if (cparams.prefilter != NULL) {
  ------------------
  |  Branch (7273:7): [True: 0, False: 3.23M]
  ------------------
 7274|      0|    context->prefilter = cparams.prefilter;
 7275|      0|    context->preparams = (blosc2_prefilter_params*)my_malloc(sizeof(blosc2_prefilter_params));
 7276|      0|    if (context->preparams == NULL) {
  ------------------
  |  Branch (7276:9): [True: 0, False: 0]
  ------------------
 7277|      0|      goto failed;
 7278|      0|    }
 7279|      0|    memcpy(context->preparams, cparams.preparams, sizeof(blosc2_prefilter_params));
 7280|      0|  }
 7281|       |
 7282|  3.23M|  if (cparams.tuner_id <= 0) {
  ------------------
  |  Branch (7282:7): [True: 3.23M, False: 0]
  ------------------
 7283|  3.23M|    cparams.tuner_id = g_tuner;
 7284|  3.23M|  } else {
 7285|      0|    for (int i = 0; i < g_ntuners; ++i) {
  ------------------
  |  Branch (7285:21): [True: 0, False: 0]
  ------------------
 7286|      0|      if (g_tuners[i].id == cparams.tuner_id) {
  ------------------
  |  Branch (7286:11): [True: 0, False: 0]
  ------------------
 7287|      0|        if (load_acquire_ptr(&g_tuners[i].init) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (7287:13): [True: 0, False: 0]
  ------------------
 7288|      0|          if (fill_tuner(&g_tuners[i]) < 0) {
  ------------------
  |  Branch (7288:15): [True: 0, False: 0]
  ------------------
 7289|      0|            BLOSC_TRACE_ERROR("Could not load tuner %d.", g_tuners[i].id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7290|      0|            goto failed;
 7291|      0|          }
 7292|      0|        }
 7293|      0|        if (g_tuners[i].init(cparams.tuner_params, context, NULL) < 0) {
  ------------------
  |  Branch (7293:13): [True: 0, False: 0]
  ------------------
 7294|      0|          BLOSC_TRACE_ERROR("Error in user-defined tuner %d init function\n", cparams.tuner_id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7295|      0|          goto failed;
 7296|      0|        }
 7297|      0|        goto urtunersuccess;
 7298|      0|      }
 7299|      0|    }
 7300|      0|    BLOSC_TRACE_ERROR("User-defined tuner %d not found\n", cparams.tuner_id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7301|      0|    goto failed;
 7302|      0|  }
 7303|  3.23M|  urtunersuccess:;
 7304|       |
 7305|  3.23M|  context->tuner_id = cparams.tuner_id;
 7306|       |
 7307|  3.23M|  context->codec_params = cparams.codec_params;
 7308|  3.23M|  memcpy(context->filter_params, cparams.filter_params, BLOSC2_MAX_FILTERS * sizeof(void*));
 7309|       |
 7310|  3.23M|  return context;
 7311|       |
 7312|     18|failed:
 7313|     18|  my_free(context->preparams);
 7314|     18|  blosc2_pthread_mutex_destroy(&context->nchunk_mutex);
  ------------------
  |  |   91|     18|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 7315|     18|  my_free(context);
 7316|       |  return NULL;
 7317|  3.23M|}
blosc2_create_dctx:
 7320|  1.16M|blosc2_context* blosc2_create_dctx(blosc2_dparams dparams) {
 7321|  1.16M|  blosc2_context* context = (blosc2_context*)my_malloc(sizeof(blosc2_context));
 7322|  1.16M|  BLOSC_ERROR_NULL(context, NULL);
  ------------------
  |  |  104|  1.16M|    do {                                            \
  |  |  105|  1.16M|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.16M]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  1.16M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.16M]
  |  |  ------------------
  ------------------
 7323|       |
 7324|       |  /* Populate the context, using zeros as default values */
 7325|  1.16M|  memset(context, 0, sizeof(blosc2_context));
 7326|  1.16M|  context->do_compress = 0;   /* Meant for decompression */
 7327|       |
 7328|  1.16M|  context->nthreads = dparams.nthreads;
 7329|  1.16M|  char* envvar = getenv("BLOSC_NTHREADS");
 7330|  1.16M|  if (envvar != NULL) {
  ------------------
  |  Branch (7330:7): [True: 0, False: 1.16M]
  ------------------
 7331|      0|    errno = 0; /* To distinguish success/failure after call */
 7332|      0|    long nthreads = strtol(envvar, NULL, 10);
 7333|      0|    if ((errno != EINVAL) && (nthreads > 0)) {
  ------------------
  |  Branch (7333:9): [True: 0, False: 0]
  |  Branch (7333:30): [True: 0, False: 0]
  ------------------
 7334|      0|      context->nthreads = (int16_t) nthreads;
 7335|      0|    }
 7336|      0|  }
 7337|  1.16M|  context->new_nthreads = context->nthreads;
 7338|       |
 7339|  1.16M|  context->threads_started = 0;
 7340|  1.16M|  context->block_maskout = NULL;
 7341|  1.16M|  context->block_maskout_nitems = 0;
 7342|  1.16M|  blosc2_pthread_mutex_init(&context->nchunk_mutex, NULL);
  ------------------
  |  |   90|  1.16M|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 7343|  1.16M|  context->schunk = dparams.schunk;
 7344|       |
 7345|  1.16M|  if (dparams.postfilter != NULL) {
  ------------------
  |  Branch (7345:7): [True: 0, False: 1.16M]
  ------------------
 7346|      0|    context->postfilter = dparams.postfilter;
 7347|      0|    context->postparams = (blosc2_postfilter_params*)my_malloc(sizeof(blosc2_postfilter_params));
 7348|      0|    if (context->postparams == NULL) {
  ------------------
  |  Branch (7348:9): [True: 0, False: 0]
  ------------------
 7349|      0|      blosc2_pthread_mutex_destroy(&context->nchunk_mutex);
  ------------------
  |  |   91|      0|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 7350|      0|      my_free(context);
 7351|      0|      return NULL;
 7352|      0|    }
 7353|      0|    memcpy(context->postparams, dparams.postparams, sizeof(blosc2_postfilter_params));
 7354|      0|  }
 7355|       |
 7356|  1.16M|  return context;
 7357|  1.16M|}
blosc2_free_ctx:
 7360|  4.40M|void blosc2_free_ctx(blosc2_context* context) {
 7361|  4.40M|  if (load_acquire_int(&g_initlib) == BLOSC_STATE_INITIALIZED ||
  ------------------
  |  |  142|  4.40M|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
                if (load_acquire_int(&g_initlib) == BLOSC_STATE_INITIALIZED ||
  ------------------
  |  |  104|  8.80M|#define BLOSC_STATE_INITIALIZED   1
  ------------------
  |  Branch (7361:7): [True: 4.39M, False: 3.39k]
  ------------------
 7362|  3.39k|      context->thread_backend == BLOSC_BACKEND_PER_CONTEXT ||
  ------------------
  |  |   36|  4.40M|#define BLOSC_BACKEND_PER_CONTEXT 3   /* per-context threads; used on Windows */
  ------------------
  |  Branch (7362:7): [True: 0, False: 3.39k]
  ------------------
 7363|  4.39M|      context->thread_backend == BLOSC_BACKEND_CALLBACK) {
  ------------------
  |  |   35|  3.39k|#define BLOSC_BACKEND_CALLBACK 2
  ------------------
  |  Branch (7363:7): [True: 0, False: 3.39k]
  ------------------
 7364|  4.39M|    release_thread_backend(context);
 7365|  4.39M|  }
 7366|  4.40M|  if (context->serial_context != NULL) {
  ------------------
  |  Branch (7366:7): [True: 150, False: 4.40M]
  ------------------
 7367|    150|    free_thread_context(context->serial_context);
 7368|    150|  }
 7369|  4.40M|  blosc2_pthread_mutex_destroy(&context->nchunk_mutex);
  ------------------
  |  |   91|  4.40M|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 7370|  4.40M|  release_context_dict_buffer(context);
 7371|  4.40M|  if (context->dict_cdict != NULL) {
  ------------------
  |  Branch (7371:7): [True: 0, False: 4.40M]
  ------------------
 7372|      0|    if (context->compcode == BLOSC_LZ4) {
  ------------------
  |  Branch (7372:9): [True: 0, False: 0]
  ------------------
 7373|      0|      LZ4_freeStream((LZ4_stream_t*)context->dict_cdict);
 7374|      0|    } else if (context->compcode == BLOSC_LZ4HC) {
  ------------------
  |  Branch (7374:16): [True: 0, False: 0]
  ------------------
 7375|      0|      LZ4_freeStreamHC((LZ4_streamHC_t*)context->dict_cdict);
 7376|      0|    }
 7377|      0|#ifdef HAVE_ZSTD
 7378|      0|    else if (context->compcode == BLOSC_ZSTD) {
  ------------------
  |  Branch (7378:14): [True: 0, False: 0]
  ------------------
 7379|      0|      ZSTD_freeCDict(context->dict_cdict);
 7380|      0|    }
 7381|      0|#endif
 7382|      0|  }
 7383|  4.40M|  if (context->dict_ddict != NULL) {
  ------------------
  |  Branch (7383:7): [True: 8, False: 4.40M]
  ------------------
 7384|      8|#ifdef HAVE_ZSTD
 7385|      8|    ZSTD_freeDDict(context->dict_ddict);
 7386|      8|#endif
 7387|      8|  }
 7388|  4.40M|  if (context->tuner_params != NULL) {
  ------------------
  |  Branch (7388:7): [True: 0, False: 4.40M]
  ------------------
 7389|      0|    int rc;
 7390|      0|    if (context->tuner_id < BLOSC_LAST_TUNER && context->tuner_id == BLOSC_STUNE) {
  ------------------
  |  |   26|      0|#define BLOSC_STUNE 0
  ------------------
  |  Branch (7390:9): [True: 0, False: 0]
  |  Branch (7390:49): [True: 0, False: 0]
  ------------------
 7391|      0|      rc = blosc_stune_free(context);
 7392|      0|    } else {
 7393|      0|      for (int i = 0; i < g_ntuners; ++i) {
  ------------------
  |  Branch (7393:23): [True: 0, False: 0]
  ------------------
 7394|      0|        if (g_tuners[i].id == context->tuner_id) {
  ------------------
  |  Branch (7394:13): [True: 0, False: 0]
  ------------------
 7395|      0|          if (load_acquire_ptr(&g_tuners[i].init) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (7395:15): [True: 0, False: 0]
  ------------------
 7396|      0|            if (fill_tuner(&g_tuners[i]) < 0) {
  ------------------
  |  Branch (7396:17): [True: 0, False: 0]
  ------------------
 7397|      0|              BLOSC_TRACE_ERROR("Could not load tuner %d.", g_tuners[i].id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7398|      0|              return;
 7399|      0|            }
 7400|      0|          }
 7401|      0|          rc = g_tuners[i].free(context);
 7402|      0|          goto urtunersuccess;
 7403|      0|        }
 7404|      0|      }
 7405|      0|      BLOSC_TRACE_ERROR("User-defined tuner %d not found\n", context->tuner_id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7406|      0|      return;
 7407|      0|      urtunersuccess:;
 7408|      0|    }
 7409|      0|    if (rc < 0) {
  ------------------
  |  Branch (7409:9): [True: 0, False: 0]
  ------------------
 7410|      0|      BLOSC_TRACE_ERROR("Error in user-defined tuner free function\n");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7411|      0|      return;
 7412|      0|    }
 7413|      0|  }
 7414|       |  /* May be needed if codec_params ever contains nested objects
 7415|       |  if (context->codec_params != NULL) {
 7416|       |    int rc;
 7417|       |    for (int i = 0; i < g_ncodecs; ++i) {
 7418|       |      if (g_codecs[i].compcode == context->compcode) {
 7419|       |        if (g_codecs[i].free == NULL) {
 7420|       |          // Dynamically load codec plugin
 7421|       |          if (fill_codec(&g_codecs[i]) < 0) {
 7422|       |            BLOSC_TRACE_ERROR("Could not load codec %d.", g_codecs[i].compcode);
 7423|       |            return BLOSC2_ERROR_CODEC_SUPPORT;
 7424|       |          }
 7425|       |        }
 7426|       |        if (g_codecs[i].free == NULL){
 7427|       |          // no free func, codec_params is simple
 7428|       |          my_free(context->codec_params);
 7429|       |        }
 7430|       |        else{ // has free function for codec_params (e.g. openzl)
 7431|       |        rc = g_codecs[i].free(context->codec_params);
 7432|       |          goto urcodecsuccess;
 7433|       |        }
 7434|       |      }
 7435|       |    }
 7436|       |      BLOSC_TRACE_ERROR("User-defined compressor codec %d not found", context->compcode);
 7437|       |      return BLOSC2_ERROR_CODEC_SUPPORT;
 7438|       |    urcodecsuccess:;
 7439|       |    if (rc < 0) {
 7440|       |      BLOSC_TRACE_ERROR("Error in user-defined codec free function\n");
 7441|       |      return;
 7442|       |    }
 7443|       |  }
 7444|       |  */
 7445|  4.40M|  if (context->prefilter != NULL) {
  ------------------
  |  Branch (7445:7): [True: 0, False: 4.40M]
  ------------------
 7446|      0|    my_free(context->preparams);
 7447|      0|  }
 7448|  4.40M|  if (context->postfilter != NULL) {
  ------------------
  |  Branch (7448:7): [True: 0, False: 4.40M]
  ------------------
 7449|      0|    my_free(context->postparams);
 7450|      0|  }
 7451|       |
 7452|  4.40M|  if (context->block_maskout != NULL) {
  ------------------
  |  Branch (7452:7): [True: 0, False: 4.40M]
  ------------------
 7453|      0|    free(context->block_maskout);
 7454|      0|  }
 7455|  4.40M|  if (context->blocknbytes != NULL) {
  ------------------
  |  Branch (7455:7): [True: 113, False: 4.40M]
  ------------------
 7456|    113|    free(context->blocknbytes);
 7457|    113|  }
 7458|  4.40M|  if (context->blockoffsets != NULL) {
  ------------------
  |  Branch (7458:7): [True: 113, False: 4.40M]
  ------------------
 7459|    113|    free(context->blockoffsets);
 7460|    113|  }
 7461|  4.40M|  if (context->blockcbytes != NULL) {
  ------------------
  |  Branch (7461:7): [True: 113, False: 4.40M]
  ------------------
 7462|    113|    free(context->blockcbytes);
 7463|    113|  }
 7464|  4.40M|  my_free(context);
 7465|  4.40M|}
blosc2_ctx_get_dparams:
 7492|    412|int blosc2_ctx_get_dparams(blosc2_context *ctx, blosc2_dparams *dparams) {
 7493|    412|  dparams->nthreads = ctx->nthreads;
 7494|    412|  dparams->schunk = ctx->schunk;
 7495|    412|  dparams->postfilter = ctx->postfilter;
 7496|    412|  dparams->postparams = ctx->postparams;
 7497|    412|  dparams->typesize = ctx->typesize;
 7498|       |
 7499|    412|  return BLOSC2_ERROR_SUCCESS;
 7500|    412|}
blosc2_set_maskout:
 7513|   446k|int blosc2_set_maskout(blosc2_context *ctx, bool *maskout, int nblocks) {
 7514|       |  // Get rid of a possible mask here (also if the allocation below fails)
 7515|   446k|  ctx_clear_maskout(ctx);
 7516|       |
 7517|   446k|  bool *maskout_ = malloc(nblocks);
 7518|   446k|  BLOSC_ERROR_NULL(maskout_, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|   446k|    do {                                            \
  |  |  105|   446k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 446k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|   446k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 446k]
  |  |  ------------------
  ------------------
 7519|   446k|  memcpy(maskout_, maskout, nblocks);
 7520|   446k|  ctx->block_maskout = maskout_;
 7521|   446k|  ctx->block_maskout_nitems = nblocks;
 7522|       |
 7523|   446k|  return 0;
 7524|   446k|}
blosc2_chunk_zeros:
 7528|  2.07M|int blosc2_chunk_zeros(blosc2_cparams cparams, const int32_t nbytes, void* dest, int32_t destsize) {
 7529|  2.07M|  if (destsize < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (7529:7): [True: 0, False: 2.07M]
  ------------------
 7530|      0|    BLOSC_TRACE_ERROR("dest buffer is not long enough");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7531|      0|    return BLOSC2_ERROR_DATA;
 7532|      0|  }
 7533|       |
 7534|  2.07M|  if ((nbytes > 0) && (nbytes % cparams.typesize)) {
  ------------------
  |  Branch (7534:7): [True: 2.07M, False: 4.23k]
  |  Branch (7534:23): [True: 0, False: 2.07M]
  ------------------
 7535|      0|    BLOSC_TRACE_ERROR("nbytes must be a multiple of typesize");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7536|      0|    return BLOSC2_ERROR_DATA;
 7537|      0|  }
 7538|       |
 7539|  2.07M|  blosc_header header;
 7540|  2.07M|  blosc2_context* context = blosc2_create_cctx(cparams);
 7541|  2.07M|  if (context == NULL) {
  ------------------
  |  Branch (7541:7): [True: 0, False: 2.07M]
  ------------------
 7542|      0|    BLOSC_TRACE_ERROR("Error while creating the compression context");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7543|      0|    return BLOSC2_ERROR_NULL_POINTER;
 7544|      0|  }
 7545|       |
 7546|  2.07M|  int error = initialize_context_compression(
 7547|  2.07M|          context, NULL, nbytes, dest, destsize,
 7548|  2.07M|          context->clevel, context->filters, context->filters_meta,
 7549|  2.07M|          context->typesize, context->compcode, context->blocksize,
 7550|  2.07M|          context->new_nthreads, context->nthreads, context->splitmode,
 7551|  2.07M|          context->tuner_id, context->tuner_params, context->schunk);
 7552|  2.07M|  if (error <= 0) {
  ------------------
  |  Branch (7552:7): [True: 0, False: 2.07M]
  ------------------
 7553|      0|    blosc2_free_ctx(context);
 7554|      0|    return error;
 7555|      0|  }
 7556|       |
 7557|  2.07M|  memset(&header, 0, sizeof(header));
 7558|  2.07M|  header.version = BLOSC2_VERSION_FORMAT_STABLE;
 7559|  2.07M|  header.versionlz = BLOSC_BLOSCLZ_VERSION_FORMAT;
 7560|  2.07M|  header.flags = BLOSC_DOSHUFFLE | BLOSC_DOBITSHUFFLE;  // extended header
 7561|  2.07M|  header.typesize = context->typesize;
 7562|  2.07M|  header.nbytes = (int32_t)nbytes;
 7563|  2.07M|  header.blocksize = context->blocksize;
 7564|  2.07M|  header.cbytes = BLOSC_EXTENDED_HEADER_LENGTH;
 7565|  2.07M|  header.blosc2_flags = BLOSC2_SPECIAL_ZERO << 4;  // mark chunk as all zeros
 7566|  2.07M|  memcpy((uint8_t *)dest, &header, sizeof(header));
 7567|       |
 7568|  2.07M|  blosc2_free_ctx(context);
 7569|       |
 7570|  2.07M|  return BLOSC_EXTENDED_HEADER_LENGTH;
 7571|  2.07M|}
blosc2_chunk_repeatval:
 7669|  2.15k|                           void* dest, int32_t destsize, const void* repeatval) {
 7670|  2.15k|  if (destsize < BLOSC_EXTENDED_HEADER_LENGTH + cparams.typesize) {
  ------------------
  |  Branch (7670:7): [True: 0, False: 2.15k]
  ------------------
 7671|      0|    BLOSC_TRACE_ERROR("dest buffer is not long enough");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7672|      0|    return BLOSC2_ERROR_DATA;
 7673|      0|  }
 7674|       |
 7675|  2.15k|  if (nbytes % cparams.typesize) {
  ------------------
  |  Branch (7675:7): [True: 0, False: 2.15k]
  ------------------
 7676|      0|    BLOSC_TRACE_ERROR("nbytes must be a multiple of typesize");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7677|      0|    return BLOSC2_ERROR_DATA;
 7678|      0|  }
 7679|       |
 7680|  2.15k|  blosc_header header;
 7681|  2.15k|  blosc2_context* context = blosc2_create_cctx(cparams);
 7682|  2.15k|  if (context == NULL) {
  ------------------
  |  Branch (7682:7): [True: 0, False: 2.15k]
  ------------------
 7683|      0|    BLOSC_TRACE_ERROR("Error while creating the compression context");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7684|      0|    return BLOSC2_ERROR_NULL_POINTER;
 7685|      0|  }
 7686|       |
 7687|  2.15k|  int error = initialize_context_compression(
 7688|  2.15k|          context, NULL, nbytes, dest, destsize,
 7689|  2.15k|          context->clevel, context->filters, context->filters_meta,
 7690|  2.15k|          context->typesize, context->compcode, context->blocksize,
 7691|  2.15k|          context->new_nthreads, context->nthreads, context->splitmode,
 7692|  2.15k|          context->tuner_id, context->tuner_params, context->schunk);
 7693|  2.15k|  if (error <= 0) {
  ------------------
  |  Branch (7693:7): [True: 0, False: 2.15k]
  ------------------
 7694|      0|    blosc2_free_ctx(context);
 7695|      0|    return error;
 7696|      0|  }
 7697|       |
 7698|  2.15k|  memset(&header, 0, sizeof(header));
 7699|  2.15k|  header.version = BLOSC2_VERSION_FORMAT_STABLE;
 7700|  2.15k|  header.versionlz = BLOSC_BLOSCLZ_VERSION_FORMAT;
 7701|  2.15k|  header.flags = BLOSC_DOSHUFFLE | BLOSC_DOBITSHUFFLE;  // extended header
 7702|  2.15k|  header.typesize = context->typesize;
 7703|  2.15k|  header.nbytes = (int32_t)nbytes;
 7704|  2.15k|  header.blocksize = context->blocksize;
 7705|  2.15k|  header.cbytes = BLOSC_EXTENDED_HEADER_LENGTH + cparams.typesize;
 7706|  2.15k|  header.blosc2_flags = BLOSC2_SPECIAL_VALUE << 4;  // mark chunk as all repeated value
 7707|  2.15k|  memcpy((uint8_t *)dest, &header, sizeof(header));
 7708|  2.15k|  memcpy((uint8_t *)dest + sizeof(header), repeatval, cparams.typesize);
 7709|       |
 7710|  2.15k|  blosc2_free_ctx(context);
 7711|       |
 7712|  2.15k|  return BLOSC_EXTENDED_HEADER_LENGTH + cparams.typesize;
 7713|  2.15k|}
register_filter_private:
 7718|  16.9k|int register_filter_private(blosc2_filter *filter) {
 7719|  16.9k|    BLOSC_ERROR_NULL(filter, BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  104|  16.9k|    do {                                            \
  |  |  105|  16.9k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 16.9k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  16.9k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 16.9k]
  |  |  ------------------
  ------------------
 7720|  16.9k|    if (g_nfilters == UINT8_MAX) {
  ------------------
  |  Branch (7720:9): [True: 0, False: 16.9k]
  ------------------
 7721|      0|        BLOSC_TRACE_ERROR("Can not register more filters");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7722|      0|        return BLOSC2_ERROR_CODEC_SUPPORT;
 7723|      0|    }
 7724|  16.9k|    if (filter->id < BLOSC2_GLOBAL_REGISTERED_FILTERS_START) {
  ------------------
  |  Branch (7724:9): [True: 0, False: 16.9k]
  ------------------
 7725|      0|        BLOSC_TRACE_ERROR("The id must be greater or equal than %d", BLOSC2_GLOBAL_REGISTERED_FILTERS_START);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7726|      0|        return BLOSC2_ERROR_FAILURE;
 7727|      0|    }
 7728|       |    /* This condition can never be fulfilled
 7729|       |    if (filter->id > BLOSC2_USER_REGISTERED_FILTERS_STOP) {
 7730|       |        BLOSC_TRACE_ERROR("The id must be less than or equal to %d", BLOSC2_USER_REGISTERED_FILTERS_STOP);
 7731|       |        return BLOSC2_ERROR_FAILURE;
 7732|       |    }
 7733|       |    */
 7734|       |
 7735|  50.8k|    for (uint64_t i = 0; i < g_nfilters; ++i) {
  ------------------
  |  Branch (7735:26): [True: 33.9k, False: 16.9k]
  ------------------
 7736|  33.9k|      if (g_filters[i].id == filter->id) {
  ------------------
  |  Branch (7736:11): [True: 0, False: 33.9k]
  ------------------
 7737|      0|        if (strcmp(g_filters[i].name, filter->name) != 0) {
  ------------------
  |  Branch (7737:13): [True: 0, False: 0]
  ------------------
 7738|      0|          BLOSC_TRACE_ERROR("The filter (ID: %d) plugin is already registered with name: %s."
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7739|      0|                            "  Choose another one !", filter->id, g_filters[i].name);
 7740|      0|          return BLOSC2_ERROR_FAILURE;
 7741|      0|        }
 7742|      0|        else {
 7743|       |          // Already registered, so no more actions needed
 7744|      0|          return BLOSC2_ERROR_SUCCESS;
 7745|      0|        }
 7746|      0|      }
 7747|  33.9k|    }
 7748|       |
 7749|  16.9k|    blosc2_filter *filter_new = &g_filters[g_nfilters++];
 7750|  16.9k|    memcpy(filter_new, filter, sizeof(blosc2_filter));
 7751|       |
 7752|  16.9k|    return BLOSC2_ERROR_SUCCESS;
 7753|  16.9k|}
register_codec_private:
 7768|  30.5k|int register_codec_private(blosc2_codec *codec) {
 7769|  30.5k|    BLOSC_ERROR_NULL(codec, BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  104|  30.5k|    do {                                            \
  |  |  105|  30.5k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 30.5k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  30.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 30.5k]
  |  |  ------------------
  ------------------
 7770|  30.5k|    if (g_ncodecs == UINT8_MAX) {
  ------------------
  |  Branch (7770:9): [True: 0, False: 30.5k]
  ------------------
 7771|      0|      BLOSC_TRACE_ERROR("Can not register more codecs");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7772|      0|      return BLOSC2_ERROR_CODEC_SUPPORT;
 7773|      0|    }
 7774|  30.5k|    if (codec->compcode < BLOSC2_GLOBAL_REGISTERED_CODECS_START) {
  ------------------
  |  Branch (7774:9): [True: 0, False: 30.5k]
  ------------------
 7775|      0|      BLOSC_TRACE_ERROR("The id must be greater or equal than %d", BLOSC2_GLOBAL_REGISTERED_CODECS_START);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7776|      0|      return BLOSC2_ERROR_FAILURE;
 7777|      0|    }
 7778|       |    /* This condition can never be fulfilled
 7779|       |    if (codec->compcode > BLOSC2_USER_REGISTERED_CODECS_STOP) {
 7780|       |      BLOSC_TRACE_ERROR("The id must be less or equal to %d", BLOSC2_USER_REGISTERED_CODECS_STOP);
 7781|       |      return BLOSC2_ERROR_FAILURE;
 7782|       |    }
 7783|       |     */
 7784|       |
 7785|   152k|    for (int i = 0; i < g_ncodecs; ++i) {
  ------------------
  |  Branch (7785:21): [True: 122k, False: 30.5k]
  ------------------
 7786|   122k|      if (g_codecs[i].compcode == codec->compcode) {
  ------------------
  |  Branch (7786:11): [True: 0, False: 122k]
  ------------------
 7787|      0|        if (strcmp(g_codecs[i].compname, codec->compname) != 0) {
  ------------------
  |  Branch (7787:13): [True: 0, False: 0]
  ------------------
 7788|      0|          BLOSC_TRACE_ERROR("The codec (ID: %d) plugin is already registered with name: %s."
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7789|      0|                            "  Choose another one !", codec->compcode, codec->compname);
 7790|      0|          return BLOSC2_ERROR_CODEC_PARAM;
 7791|      0|        }
 7792|      0|        else {
 7793|       |          // Already registered, so no more actions needed
 7794|      0|          return BLOSC2_ERROR_SUCCESS;
 7795|      0|        }
 7796|      0|      }
 7797|   122k|    }
 7798|       |
 7799|  30.5k|    blosc2_codec *codec_new = &g_codecs[g_ncodecs++];
 7800|  30.5k|    memcpy(codec_new, codec, sizeof(blosc2_codec));
 7801|       |
 7802|  30.5k|    return BLOSC2_ERROR_SUCCESS;
 7803|  30.5k|}
register_tuner_private:
 7818|  3.39k|int register_tuner_private(blosc2_tuner *tuner) {
 7819|  3.39k|  BLOSC_ERROR_NULL(tuner, BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  104|  3.39k|    do {                                            \
  |  |  105|  3.39k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 3.39k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  3.39k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.39k]
  |  |  ------------------
  ------------------
 7820|  3.39k|  if (g_ntuners == UINT8_MAX) {
  ------------------
  |  Branch (7820:7): [True: 0, False: 3.39k]
  ------------------
 7821|      0|    BLOSC_TRACE_ERROR("Can not register more tuners");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7822|      0|    return BLOSC2_ERROR_CODEC_SUPPORT;
 7823|      0|  }
 7824|  3.39k|  if (tuner->id < BLOSC2_GLOBAL_REGISTERED_TUNER_START) {
  ------------------
  |  Branch (7824:7): [True: 0, False: 3.39k]
  ------------------
 7825|      0|    BLOSC_TRACE_ERROR("The id must be greater or equal than %d", BLOSC2_GLOBAL_REGISTERED_TUNER_START);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7826|      0|    return BLOSC2_ERROR_FAILURE;
 7827|      0|  }
 7828|       |
 7829|  3.39k|  for (int i = 0; i < g_ntuners; ++i) {
  ------------------
  |  Branch (7829:19): [True: 0, False: 3.39k]
  ------------------
 7830|      0|    if (g_tuners[i].id == tuner->id) {
  ------------------
  |  Branch (7830:9): [True: 0, False: 0]
  ------------------
 7831|      0|      if (strcmp(g_tuners[i].name, tuner->name) != 0) {
  ------------------
  |  Branch (7831:11): [True: 0, False: 0]
  ------------------
 7832|      0|        BLOSC_TRACE_ERROR("The tuner (ID: %d) plugin is already registered with name: %s."
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7833|      0|                          "  Choose another one !", tuner->id, g_tuners[i].name);
 7834|      0|        return BLOSC2_ERROR_FAILURE;
 7835|      0|      }
 7836|      0|      else {
 7837|       |        // Already registered, so no more actions needed
 7838|      0|        return BLOSC2_ERROR_SUCCESS;
 7839|      0|      }
 7840|      0|    }
 7841|      0|  }
 7842|       |
 7843|  3.39k|  blosc2_tuner *tuner_new = &g_tuners[g_ntuners++];
 7844|  3.39k|  memcpy(tuner_new, tuner, sizeof(blosc2_tuner));
 7845|       |
 7846|  3.39k|  return BLOSC2_ERROR_SUCCESS;
 7847|  3.39k|}
_blosc2_register_io_cb:
 7860|  6.78k|int _blosc2_register_io_cb(const blosc2_io_cb *io) {
 7861|       |
 7862|  10.1k|  for (uint64_t i = 0; i < g_nio; ++i) {
  ------------------
  |  Branch (7862:24): [True: 10.1k, False: 2]
  ------------------
 7863|  10.1k|    if (g_ios[i].id == io->id) {
  ------------------
  |  Branch (7863:9): [True: 6.78k, False: 3.39k]
  ------------------
 7864|  6.78k|      if (strcmp(g_ios[i].name, io->name) != 0) {
  ------------------
  |  Branch (7864:11): [True: 0, False: 6.78k]
  ------------------
 7865|      0|        BLOSC_TRACE_ERROR("The IO (ID: %d) plugin is already registered with name: %s."
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7866|      0|                          "  Choose another one !", io->id, g_ios[i].name);
 7867|      0|        return BLOSC2_ERROR_PLUGIN_IO;
 7868|      0|      }
 7869|  6.78k|      else {
 7870|       |        // Already registered, so no more actions needed
 7871|  6.78k|        return BLOSC2_ERROR_SUCCESS;
 7872|  6.78k|      }
 7873|  6.78k|    }
 7874|  10.1k|  }
 7875|       |
 7876|      2|  blosc2_io_cb *io_new = &g_ios[g_nio++];
 7877|      2|  memcpy(io_new, io, sizeof(blosc2_io_cb));
 7878|       |
 7879|      2|  return BLOSC2_ERROR_SUCCESS;
 7880|  6.78k|}
blosc2_get_io_cb:
 7897|  9.18M|blosc2_io_cb *blosc2_get_io_cb(uint8_t id) {
 7898|       |  // If g_initlib is not set by blosc2_init() this function will try to read
 7899|       |  // uninitialized memory. We should therefore always return NULL in that case
 7900|  9.18M|  if (load_acquire_int(&g_initlib) != BLOSC_STATE_INITIALIZED) {
  ------------------
  |  |  142|  9.18M|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
                if (load_acquire_int(&g_initlib) != BLOSC_STATE_INITIALIZED) {
  ------------------
  |  |  104|  9.18M|#define BLOSC_STATE_INITIALIZED   1
  ------------------
  |  Branch (7900:7): [True: 0, False: 9.18M]
  ------------------
 7901|      0|    return NULL;
 7902|      0|  }
 7903|  9.18M|  for (uint64_t i = 0; i < g_nio; ++i) {
  ------------------
  |  Branch (7903:24): [True: 9.18M, False: 0]
  ------------------
 7904|  9.18M|    if (g_ios[i].id == id) {
  ------------------
  |  Branch (7904:9): [True: 9.18M, False: 0]
  ------------------
 7905|  9.18M|      return &g_ios[i];
 7906|  9.18M|    }
 7907|  9.18M|  }
 7908|      0|  if (id == BLOSC2_IO_FILESYSTEM) {
  ------------------
  |  Branch (7908:7): [True: 0, False: 0]
  ------------------
 7909|      0|    if (_blosc2_register_io_cb(&BLOSC2_IO_CB_DEFAULTS) < 0) {
  ------------------
  |  Branch (7909:9): [True: 0, False: 0]
  ------------------
 7910|      0|      BLOSC_TRACE_ERROR("Error registering the default IO API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7911|      0|      return NULL;
 7912|      0|    }
 7913|      0|    return blosc2_get_io_cb(id);
 7914|      0|  }
 7915|      0|  else if (id == BLOSC2_IO_FILESYSTEM_MMAP) {
  ------------------
  |  Branch (7915:12): [True: 0, False: 0]
  ------------------
 7916|      0|    if (_blosc2_register_io_cb(&BLOSC2_IO_CB_MMAP) < 0) {
  ------------------
  |  Branch (7916:9): [True: 0, False: 0]
  ------------------
 7917|      0|      BLOSC_TRACE_ERROR("Error registering the mmap IO API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7918|      0|      return NULL;
 7919|      0|    }
 7920|      0|    return blosc2_get_io_cb(id);
 7921|      0|  }
 7922|      0|  return NULL;
 7923|      0|}
blosc2_unidim_to_multidim:
 7925|  18.1M|void blosc2_unidim_to_multidim(uint8_t ndim, int64_t *shape, int64_t i, int64_t *index) {
 7926|  18.1M|  if (ndim == 0) {
  ------------------
  |  Branch (7926:7): [True: 0, False: 18.1M]
  ------------------
 7927|      0|    return;
 7928|      0|  }
 7929|  18.1M|  assert(ndim <= B2ND_MAX_DIM);
 7930|  18.1M|  int64_t strides[B2ND_MAX_DIM];
 7931|       |
 7932|  18.1M|  strides[ndim - 1] = 1;
 7933|  97.9M|  for (int j = ndim - 2; j >= 0; --j) {
  ------------------
  |  Branch (7933:26): [True: 79.7M, False: 18.1M]
  ------------------
 7934|  79.7M|      strides[j] = shape[j + 1] * strides[j + 1];
 7935|  79.7M|  }
 7936|       |
 7937|  18.1M|  index[0] = i / strides[0];
 7938|  97.9M|  for (int j = 1; j < ndim; ++j) {
  ------------------
  |  Branch (7938:19): [True: 79.7M, False: 18.1M]
  ------------------
 7939|  79.7M|      index[j] = (i % strides[j - 1]) / strides[j];
 7940|  79.7M|  }
 7941|  18.1M|}
blosc2_multidim_to_unidim:
 7943|  1.96M|void blosc2_multidim_to_unidim(const int64_t *index, int8_t ndim, const int64_t *strides, int64_t *i) {
 7944|  1.96M|  *i = 0;
 7945|  10.7M|  for (int j = 0; j < ndim; ++j) {
  ------------------
  |  Branch (7945:19): [True: 8.79M, False: 1.96M]
  ------------------
 7946|  8.79M|    *i += index[j] * strides[j];
 7947|  8.79M|  }
 7948|  1.96M|}
blosc2_error_string:
 7995|  4.05k|const char *blosc2_error_string(int error_code) {
 7996|  4.05k|  switch (error_code) {
 7997|    543|    case BLOSC2_ERROR_FAILURE:
  ------------------
  |  Branch (7997:5): [True: 543, False: 3.51k]
  ------------------
 7998|    543|      return "Generic failure";
 7999|      0|    case BLOSC2_ERROR_STREAM:
  ------------------
  |  Branch (7999:5): [True: 0, False: 4.05k]
  ------------------
 8000|      0|      return "Bad stream";
 8001|      7|    case BLOSC2_ERROR_DATA:
  ------------------
  |  Branch (8001:5): [True: 7, False: 4.04k]
  ------------------
 8002|      7|      return "Invalid data";
 8003|      0|    case BLOSC2_ERROR_MEMORY_ALLOC:
  ------------------
  |  Branch (8003:5): [True: 0, False: 4.05k]
  ------------------
 8004|      0|      return "Memory alloc/realloc failure";
 8005|      0|    case BLOSC2_ERROR_READ_BUFFER:
  ------------------
  |  Branch (8005:5): [True: 0, False: 4.05k]
  ------------------
 8006|      0|      return "Not enough space to read";
 8007|      1|    case BLOSC2_ERROR_WRITE_BUFFER:
  ------------------
  |  Branch (8007:5): [True: 1, False: 4.05k]
  ------------------
 8008|      1|      return "Not enough space to write";
 8009|      0|    case BLOSC2_ERROR_CODEC_SUPPORT:
  ------------------
  |  Branch (8009:5): [True: 0, False: 4.05k]
  ------------------
 8010|      0|      return "Codec not supported";
 8011|      0|    case BLOSC2_ERROR_CODEC_PARAM:
  ------------------
  |  Branch (8011:5): [True: 0, False: 4.05k]
  ------------------
 8012|      0|      return "Invalid parameter supplied to codec";
 8013|      0|    case BLOSC2_ERROR_CODEC_DICT:
  ------------------
  |  Branch (8013:5): [True: 0, False: 4.05k]
  ------------------
 8014|      0|      return "Codec dictionary error";
 8015|      0|    case BLOSC2_ERROR_VERSION_SUPPORT:
  ------------------
  |  Branch (8015:5): [True: 0, False: 4.05k]
  ------------------
 8016|      0|      return "Version not supported";
 8017|      0|    case BLOSC2_ERROR_INVALID_HEADER:
  ------------------
  |  Branch (8017:5): [True: 0, False: 4.05k]
  ------------------
 8018|      0|      return "Invalid value in header";
 8019|  3.41k|    case BLOSC2_ERROR_INVALID_PARAM:
  ------------------
  |  Branch (8019:5): [True: 3.41k, False: 634]
  ------------------
 8020|  3.41k|      return "Invalid parameter supplied to function";
 8021|      0|    case BLOSC2_ERROR_FILE_READ:
  ------------------
  |  Branch (8021:5): [True: 0, False: 4.05k]
  ------------------
 8022|      0|      return "File read failure";
 8023|      0|    case BLOSC2_ERROR_FILE_WRITE:
  ------------------
  |  Branch (8023:5): [True: 0, False: 4.05k]
  ------------------
 8024|      0|      return "File write failure";
 8025|      0|    case BLOSC2_ERROR_FILE_OPEN:
  ------------------
  |  Branch (8025:5): [True: 0, False: 4.05k]
  ------------------
 8026|      0|      return "File open failure";
 8027|      0|    case BLOSC2_ERROR_NOT_FOUND:
  ------------------
  |  Branch (8027:5): [True: 0, False: 4.05k]
  ------------------
 8028|      0|      return "Not found";
 8029|      0|    case BLOSC2_ERROR_RUN_LENGTH:
  ------------------
  |  Branch (8029:5): [True: 0, False: 4.05k]
  ------------------
 8030|      0|      return "Bad run length encoding";
 8031|      0|    case BLOSC2_ERROR_FILTER_PIPELINE:
  ------------------
  |  Branch (8031:5): [True: 0, False: 4.05k]
  ------------------
 8032|      0|      return "Filter pipeline error";
 8033|      0|    case BLOSC2_ERROR_CHUNK_INSERT:
  ------------------
  |  Branch (8033:5): [True: 0, False: 4.05k]
  ------------------
 8034|      0|      return "Chunk insert failure";
 8035|      0|    case BLOSC2_ERROR_CHUNK_APPEND:
  ------------------
  |  Branch (8035:5): [True: 0, False: 4.05k]
  ------------------
 8036|      0|      return "Chunk append failure";
 8037|      0|    case BLOSC2_ERROR_CHUNK_UPDATE:
  ------------------
  |  Branch (8037:5): [True: 0, False: 4.05k]
  ------------------
 8038|      0|      return "Chunk update failure";
 8039|      0|    case BLOSC2_ERROR_2GB_LIMIT:
  ------------------
  |  Branch (8039:5): [True: 0, False: 4.05k]
  ------------------
 8040|      0|      return "Sizes larger than 2gb not supported";
 8041|      0|    case BLOSC2_ERROR_SCHUNK_COPY:
  ------------------
  |  Branch (8041:5): [True: 0, False: 4.05k]
  ------------------
 8042|      0|      return "Super-chunk copy failure";
 8043|      0|    case BLOSC2_ERROR_FRAME_TYPE:
  ------------------
  |  Branch (8043:5): [True: 0, False: 4.05k]
  ------------------
 8044|      0|      return "Wrong type for frame";
 8045|      0|    case BLOSC2_ERROR_FILE_TRUNCATE:
  ------------------
  |  Branch (8045:5): [True: 0, False: 4.05k]
  ------------------
 8046|      0|      return "File truncate failure";
 8047|      0|    case BLOSC2_ERROR_LOCK:
  ------------------
  |  Branch (8047:5): [True: 0, False: 4.05k]
  ------------------
 8048|      0|      return "Frame lock failure";
 8049|      0|    case BLOSC2_ERROR_THREAD_CREATE:
  ------------------
  |  Branch (8049:5): [True: 0, False: 4.05k]
  ------------------
 8050|      0|      return "Thread or thread context creation failure";
 8051|      0|    case BLOSC2_ERROR_POSTFILTER:
  ------------------
  |  Branch (8051:5): [True: 0, False: 4.05k]
  ------------------
 8052|      0|      return "Postfilter failure";
 8053|      0|    case BLOSC2_ERROR_FRAME_SPECIAL:
  ------------------
  |  Branch (8053:5): [True: 0, False: 4.05k]
  ------------------
 8054|      0|      return "Special frame failure";
 8055|      0|    case BLOSC2_ERROR_SCHUNK_SPECIAL:
  ------------------
  |  Branch (8055:5): [True: 0, False: 4.05k]
  ------------------
 8056|      0|      return "Special super-chunk failure";
 8057|      0|    case BLOSC2_ERROR_PLUGIN_IO:
  ------------------
  |  Branch (8057:5): [True: 0, False: 4.05k]
  ------------------
 8058|      0|      return "IO plugin error";
 8059|      0|    case BLOSC2_ERROR_FILE_REMOVE:
  ------------------
  |  Branch (8059:5): [True: 0, False: 4.05k]
  ------------------
 8060|      0|      return "Remove file failure";
 8061|      0|    case BLOSC2_ERROR_NULL_POINTER:
  ------------------
  |  Branch (8061:5): [True: 0, False: 4.05k]
  ------------------
 8062|      0|      return "Pointer is null";
 8063|     82|    case BLOSC2_ERROR_INVALID_INDEX:
  ------------------
  |  Branch (8063:5): [True: 82, False: 3.97k]
  ------------------
 8064|     82|      return "Invalid index";
 8065|      1|    case BLOSC2_ERROR_METALAYER_NOT_FOUND:
  ------------------
  |  Branch (8065:5): [True: 1, False: 4.05k]
  ------------------
 8066|      1|      return "Metalayer has not been found";
 8067|      0|    case BLOSC2_ERROR_MAX_BUFSIZE_EXCEEDED:
  ------------------
  |  Branch (8067:5): [True: 0, False: 4.05k]
  ------------------
 8068|      0|      return "Maximum buffersize exceeded";
 8069|      0|    case BLOSC2_ERROR_TUNER:
  ------------------
  |  Branch (8069:5): [True: 0, False: 4.05k]
  ------------------
 8070|      0|      return "Tuner failure";
 8071|      0|    default:
  ------------------
  |  Branch (8071:5): [True: 0, False: 4.05k]
  ------------------
 8072|      0|      return "Unknown error";
 8073|  4.05k|  }
 8074|  4.05k|}
blosc2.c:shuffle_size:
  791|  39.1M|static int32_t shuffle_size(const blosc2_context* context, int i) {
  792|  39.1M|  return context->filters_meta[i] == 0 ? context->typesize : context->filters_meta[i];
  ------------------
  |  Branch (792:10): [True: 39.1M, False: 648]
  ------------------
  793|  39.1M|}
blosc2.c:flags_to_filters:
  875|  23.0M|static void flags_to_filters(const uint8_t flags, uint8_t* filters) {
  876|       |  /* Initialize the filter pipeline */
  877|  23.0M|  memset(filters, 0, BLOSC2_MAX_FILTERS);
  878|       |  /* Fill the filter pipeline */
  879|  23.0M|  if (flags & BLOSC_DOSHUFFLE)
  ------------------
  |  Branch (879:7): [True: 23.0M, False: 1.43k]
  ------------------
  880|  23.0M|    filters[BLOSC2_MAX_FILTERS - 1] = BLOSC_SHUFFLE;
  881|  23.0M|  if (flags & BLOSC_DOBITSHUFFLE)
  ------------------
  |  Branch (881:7): [True: 23.0M, False: 649]
  ------------------
  882|  23.0M|    filters[BLOSC2_MAX_FILTERS - 1] = BLOSC_BITSHUFFLE;
  883|  23.0M|  if (flags & BLOSC_DODELTA)
  ------------------
  |  Branch (883:7): [True: 2.71M, False: 20.3M]
  ------------------
  884|  2.71M|    filters[BLOSC2_MAX_FILTERS - 2] = BLOSC_DELTA;
  885|  23.0M|}
blosc2.c:load_codec_locked:
 1155|      4|static int load_codec_locked(blosc2_codec *codec) {
 1156|      4|  char libpath[PATH_MAX];
 1157|      4|  void *lib = load_lib(codec->compname, libpath);
 1158|      4|  if(lib == NULL) {
  ------------------
  |  Branch (1158:6): [True: 4, False: 0]
  ------------------
 1159|      4|    BLOSC_TRACE_ERROR("Error while loading the library for codec `%s`", codec->compname);
  ------------------
  |  |   93|      4|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      4|    do {                                            \
  |  |  |  |   98|      4|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      4|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      4|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1160|      4|    return BLOSC2_ERROR_FAILURE;
 1161|      4|  }
 1162|       |
 1163|      0|  codec_info *info = dlsym(lib, "info");
 1164|      0|  if (info == NULL) {
  ------------------
  |  Branch (1164:7): [True: 0, False: 0]
  ------------------
 1165|      0|    BLOSC_TRACE_ERROR("`info` symbol cannot be loaded from plugin `%s`", codec->compname);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1166|      0|    dlclose(lib);
 1167|      0|    return BLOSC2_ERROR_FAILURE;
 1168|      0|  }
 1169|      0|  void *encoder = plugin_dlsym(lib, info->encoder);
 1170|      0|  void *decoder = plugin_dlsym(lib, info->decoder);
 1171|       |
 1172|      0|  if (encoder == NULL || decoder == NULL) {
  ------------------
  |  Branch (1172:7): [True: 0, False: 0]
  |  Branch (1172:26): [True: 0, False: 0]
  ------------------
 1173|      0|    BLOSC_TRACE_ERROR("encoder or decoder cannot be loaded from plugin `%s`", codec->compname);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1174|      0|    dlclose(lib);
 1175|      0|    return BLOSC2_ERROR_FAILURE;
 1176|      0|  }
 1177|      0|  codec->encoder = encoder;
 1178|      0|  store_release_ptr(&codec->decoder, decoder);
  ------------------
  |  |  145|      0|#define store_release_ptr(p, v) __atomic_store_n((p), (v), __ATOMIC_RELEASE)
  ------------------
 1179|       |
 1180|       |  /* If ever add .free function in future for codec params
 1181|       |  codecparams_info *info2 = dlsym(lib, "info2");
 1182|       |  if (info2 != NULL) {
 1183|       |    // New plugin (e.g. openzl) with free function for codec_params defined
 1184|       |    // will be used when destroying context in blosc2_free_ctx
 1185|       |      codec->free = dlsym(lib, info2->free);
 1186|       |  }
 1187|       |  else{
 1188|       |    codec->free = NULL;
 1189|       |  }
 1190|       |  */
 1191|       |
 1192|      0|  return BLOSC2_ERROR_SUCCESS;
 1193|      0|}
blosc2.c:_cycle_buffers_forward:
 1311|  7.60M|                                   const uint8_t *input) {
 1312|  7.60M|  uint8_t *prev_src = *src;
 1313|  7.60M|  *src = *dest;
 1314|  7.60M|  *dest = (prev_src == input) ? *tmp : prev_src;
  ------------------
  |  Branch (1314:11): [True: 6.90M, False: 696k]
  ------------------
 1315|  7.60M|}
blosc2.c:fused_shuffle_bytedelta_size:
  799|  6.36M|static int fused_shuffle_bytedelta_size(const blosc2_context *context, int i) {
  800|  6.36M|  if (i < 0 || i + 1 >= BLOSC2_MAX_FILTERS || context->filters[i] != BLOSC_SHUFFLE ||
  ------------------
  |  Branch (800:7): [True: 91, False: 6.36M]
  |  Branch (800:16): [True: 2.14M, False: 4.22M]
  |  Branch (800:47): [True: 4.22M, False: 316]
  ------------------
  801|  6.36M|      context->filters[i + 1] != BLOSC_FILTER_BYTEDELTA) {
  ------------------
  |  Branch (801:7): [True: 141, False: 175]
  ------------------
  802|  6.36M|    return 0;
  803|  6.36M|  }
  804|    133|  int delta_size = context->filters_meta[i + 1];
  805|    133|  if (delta_size == 0 && context->schunk != NULL) {
  ------------------
  |  Branch (805:7): [True: 1, False: 132]
  |  Branch (805:26): [True: 0, False: 1]
  ------------------
  806|      0|    delta_size = context->schunk->typesize;
  807|      0|  }
  808|    133|  int size = shuffle_size(context, i);
  809|    136|  return (size == 2 || size == 4 || size == 8) && size == delta_size &&
  ------------------
  |  Branch (809:11): [True: 16, False: 117]
  |  Branch (809:24): [True: 27, False: 90]
  |  Branch (809:37): [True: 51, False: 39]
  |  Branch (809:51): [True: 100, False: 36]
  ------------------
  810|    100|         shuffle_bytedelta_available() ? size : 0;
  ------------------
  |  Branch (810:10): [True: 100, False: 0]
  ------------------
  811|  6.36M|}
blosc2.c:bitshuffle_scratch:
 1322|    587|static uint8_t* bitshuffle_scratch(struct thread_context* thread_context, int32_t bsize) {
 1323|    587|  size_t offset = (size_t)(thread_context->tmp4 - thread_context->tmp);
 1324|    587|  size_t shift = (16 - ((uintptr_t)thread_context->tmp4 & 15)) & 15;
 1325|    587|  if (offset + shift + (size_t)bsize <= thread_context->tmp_nbytes) {
  ------------------
  |  Branch (1325:7): [True: 553, False: 34]
  ------------------
 1326|    553|    return thread_context->tmp4 + shift;
 1327|    553|  }
 1328|     34|  if (offset + (size_t)bsize <= thread_context->tmp_nbytes) {
  ------------------
  |  Branch (1328:7): [True: 34, False: 0]
  ------------------
 1329|     34|    return thread_context->tmp4;
 1330|     34|  }
 1331|      0|  return NULL;
 1332|     34|}
blosc2.c:destroy_thread_context:
 2689|  2.63k|static void destroy_thread_context(struct thread_context* thread_context) {
 2690|  2.63k|  my_free(thread_context->tmp);
 2691|  2.63k|  free(thread_context->blosclz_state);
 2692|  2.63k|#if defined(HAVE_ZSTD)
 2693|  2.63k|  if (thread_context->zstd_cctx != NULL) {
  ------------------
  |  Branch (2693:7): [True: 0, False: 2.63k]
  ------------------
 2694|      0|    ZSTD_freeCCtx(thread_context->zstd_cctx);
 2695|      0|  }
 2696|  2.63k|  if (thread_context->zstd_dctx != NULL) {
  ------------------
  |  Branch (2696:7): [True: 11, False: 2.62k]
  ------------------
 2697|     11|    ZSTD_freeDCtx(thread_context->zstd_dctx);
 2698|     11|  }
 2699|  2.63k|#endif
 2700|  2.63k|  if (thread_context->lz4_cstream != NULL) {
  ------------------
  |  Branch (2700:7): [True: 0, False: 2.63k]
  ------------------
 2701|      0|    LZ4_freeStream((LZ4_stream_t*)thread_context->lz4_cstream);
 2702|      0|  }
 2703|  2.63k|  if (thread_context->lz4hc_cstream != NULL) {
  ------------------
  |  Branch (2703:7): [True: 0, False: 2.63k]
  ------------------
 2704|      0|    LZ4_freeStreamHC((LZ4_streamHC_t*)thread_context->lz4hc_cstream);
 2705|      0|  }
 2706|  2.63k|}
blosc2.c:my_free:
  412|  4.88M|static void my_free(void* block) {
  413|       |#if defined(_WIN32)
  414|       |  _aligned_free(block);
  415|       |#else
  416|  4.88M|  free(block);
  417|  4.88M|#endif  /* _WIN32 */
  418|  4.88M|}
blosc2.c:initialize_context_compression:
 2879|  3.83M|        blosc2_schunk* schunk) {
 2880|       |
 2881|       |  /* The block size and the filters divide by the typesize */
 2882|  3.83M|  if (typesize <= 0) {
  ------------------
  |  Branch (2882:7): [True: 0, False: 3.83M]
  ------------------
 2883|      0|    BLOSC_TRACE_ERROR("The typesize must be positive, not %d.", typesize);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2884|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2885|      0|  }
 2886|       |
 2887|       |  /* Check typesize limits */
 2888|  3.83M|  if (typesize > BLOSC2_MAXTYPESIZE) {
  ------------------
  |  Branch (2888:7): [True: 0, False: 3.83M]
  ------------------
 2889|       |    // If typesize is too large for Blosc2, return an error
 2890|      0|    BLOSC_TRACE_ERROR("Typesize cannot exceed %d bytes.", BLOSC2_MAXTYPESIZE);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2891|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2892|      0|  }
 2893|       |  /* Now, cap typesize so that blosc2 split machinery can continue to work.  This has to be
 2894|       |     done before the tuner chooses the block size, which depends on the typesize: a buffer
 2895|       |     with a larger typesize is a plain stream of bytes and is blocked as one. */
 2896|  3.83M|  if (typesize > BLOSC_MAX_TYPESIZE) {
  ------------------
  |  Branch (2896:7): [True: 0, False: 3.83M]
  ------------------
 2897|       |    /* If typesize is too large, treat buffer as an 1-byte stream. */
 2898|      0|    typesize = 1;
 2899|      0|  }
 2900|       |
 2901|       |  /* Set parameters */
 2902|  3.83M|  context->do_compress = 1;
 2903|  3.83M|  context->src = (const uint8_t*)src;
 2904|  3.83M|  context->srcsize = srcsize;
 2905|  3.83M|  context->dest = (uint8_t*)dest;
 2906|  3.83M|  context->output_bytes = 0;
 2907|  3.83M|  context->destsize = destsize;
 2908|  3.83M|  context->sourcesize = srcsize;
 2909|  3.83M|  context->typesize = typesize;
 2910|  3.83M|  context->filter_flags = filters_to_flags(filters);
 2911|  26.8M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (2911:19): [True: 23.0M, False: 3.83M]
  ------------------
 2912|  23.0M|    context->filters[i] = filters[i];
 2913|  23.0M|    context->filters_meta[i] = filters_meta[i];
 2914|  23.0M|  }
 2915|  3.83M|  context->compcode = compressor;
 2916|  3.83M|  context->nthreads = nthreads;
 2917|  3.83M|  context->new_nthreads = new_nthreads;
 2918|  3.83M|  context->clevel = clevel;
 2919|  3.83M|  context->schunk = schunk;
 2920|  3.83M|  context->tuner_params = tuner_params;
 2921|  3.83M|  context->tuner_id = tuner_id;
 2922|  3.83M|  context->splitmode = splitmode;
 2923|  3.83M|  context->blosc2_flags2 = 0;
 2924|  3.83M|  if (context->blocknbytes != NULL) {
  ------------------
  |  Branch (2924:7): [True: 0, False: 3.83M]
  ------------------
 2925|      0|    free(context->blocknbytes);
 2926|      0|    context->blocknbytes = NULL;
 2927|      0|  }
 2928|  3.83M|  if (context->blockoffsets != NULL) {
  ------------------
  |  Branch (2928:7): [True: 0, False: 3.83M]
  ------------------
 2929|      0|    free(context->blockoffsets);
 2930|      0|    context->blockoffsets = NULL;
 2931|      0|  }
 2932|  3.83M|  if (context->blockcbytes != NULL) {
  ------------------
  |  Branch (2932:7): [True: 0, False: 3.83M]
  ------------------
 2933|      0|    free(context->blockcbytes);
 2934|      0|    context->blockcbytes = NULL;
 2935|      0|  }
 2936|  3.83M|  context->vlblock_sources = NULL;
 2937|  3.83M|  context->vlblock_dests = NULL;
 2938|       |  /* tuner some compression parameters */
 2939|  3.83M|  context->blocksize = (int32_t)blocksize;
 2940|  3.83M|  int rc = 0;
 2941|  3.83M|  if (context->tuner_params != NULL) {
  ------------------
  |  Branch (2941:7): [True: 0, False: 3.83M]
  ------------------
 2942|      0|    if (context->tuner_id < BLOSC_LAST_TUNER && context->tuner_id == BLOSC_STUNE) {
  ------------------
  |  |   26|      0|#define BLOSC_STUNE 0
  ------------------
  |  Branch (2942:9): [True: 0, False: 0]
  |  Branch (2942:49): [True: 0, False: 0]
  ------------------
 2943|      0|      if (blosc_stune_next_cparams(context) < 0) {
  ------------------
  |  Branch (2943:11): [True: 0, False: 0]
  ------------------
 2944|      0|        BLOSC_TRACE_ERROR("Error in stune next_cparams func\n");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2945|      0|        return BLOSC2_ERROR_TUNER;
 2946|      0|      }
 2947|      0|    } else {
 2948|      0|      for (int i = 0; i < g_ntuners; ++i) {
  ------------------
  |  Branch (2948:23): [True: 0, False: 0]
  ------------------
 2949|      0|        if (g_tuners[i].id == context->tuner_id) {
  ------------------
  |  Branch (2949:13): [True: 0, False: 0]
  ------------------
 2950|      0|          if (load_acquire_ptr(&g_tuners[i].init) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (2950:15): [True: 0, False: 0]
  ------------------
 2951|      0|            if (fill_tuner(&g_tuners[i]) < 0) {
  ------------------
  |  Branch (2951:17): [True: 0, False: 0]
  ------------------
 2952|      0|              BLOSC_TRACE_ERROR("Could not load tuner %d.", g_tuners[i].id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2953|      0|              return BLOSC2_ERROR_FAILURE;
 2954|      0|            }
 2955|      0|          }
 2956|      0|          if (g_tuners[i].next_cparams(context) < 0) {
  ------------------
  |  Branch (2956:15): [True: 0, False: 0]
  ------------------
 2957|      0|            BLOSC_TRACE_ERROR("Error in tuner %d next_cparams func\n", context->tuner_id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2958|      0|            return BLOSC2_ERROR_TUNER;
 2959|      0|          }
 2960|      0|          if (g_tuners[i].id == BLOSC_BTUNE && context->blocksize == 0) {
  ------------------
  |  Branch (2960:15): [True: 0, False: 0]
  |  Branch (2960:48): [True: 0, False: 0]
  ------------------
 2961|       |            // Call stune for initializing blocksize
 2962|      0|            if (blosc_stune_next_blocksize(context) < 0) {
  ------------------
  |  Branch (2962:17): [True: 0, False: 0]
  ------------------
 2963|      0|              BLOSC_TRACE_ERROR("Error in stune next_blocksize func\n");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2964|      0|              return BLOSC2_ERROR_TUNER;
 2965|      0|            }
 2966|      0|          }
 2967|      0|          goto urtunersuccess;
 2968|      0|        }
 2969|      0|      }
 2970|      0|      BLOSC_TRACE_ERROR("User-defined tuner %d not found\n", context->tuner_id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2971|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2972|      0|    }
 2973|  3.83M|  } else {
 2974|  3.83M|    if (context->tuner_id < BLOSC_LAST_TUNER && context->tuner_id == BLOSC_STUNE) {
  ------------------
  |  |   26|  3.83M|#define BLOSC_STUNE 0
  ------------------
  |  Branch (2974:9): [True: 3.83M, False: 0]
  |  Branch (2974:49): [True: 3.83M, False: 0]
  ------------------
 2975|  3.83M|      rc = blosc_stune_next_blocksize(context);
 2976|  3.83M|    } else {
 2977|      0|      for (int i = 0; i < g_ntuners; ++i) {
  ------------------
  |  Branch (2977:23): [True: 0, False: 0]
  ------------------
 2978|      0|        if (g_tuners[i].id == context->tuner_id) {
  ------------------
  |  Branch (2978:13): [True: 0, False: 0]
  ------------------
 2979|      0|          if (load_acquire_ptr(&g_tuners[i].init) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (2979:15): [True: 0, False: 0]
  ------------------
 2980|      0|            if (fill_tuner(&g_tuners[i]) < 0) {
  ------------------
  |  Branch (2980:17): [True: 0, False: 0]
  ------------------
 2981|      0|              BLOSC_TRACE_ERROR("Could not load tuner %d.", g_tuners[i].id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2982|      0|              return BLOSC2_ERROR_FAILURE;
 2983|      0|            }
 2984|      0|          }
 2985|      0|          rc = g_tuners[i].next_blocksize(context);
 2986|      0|          goto urtunersuccess;
 2987|      0|        }
 2988|      0|      }
 2989|      0|      BLOSC_TRACE_ERROR("User-defined tuner %d not found\n", context->tuner_id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2990|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2991|      0|    }
 2992|  3.83M|  }
 2993|  3.83M|  urtunersuccess:;
 2994|  3.83M|  if (rc < 0) {
  ------------------
  |  Branch (2994:7): [True: 0, False: 3.83M]
  ------------------
 2995|      0|    BLOSC_TRACE_ERROR("Error in tuner next_blocksize func\n");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2996|      0|    return BLOSC2_ERROR_TUNER;
 2997|      0|  }
 2998|       |  /* The header must record the block size that the tuner settled on (it rounds a requested
 2999|       |     one to a multiple of the typesize, for instance), not the one that was asked for: a reader
 3000|       |     splits the chunk into blocks of the size in the header.  Variable-length block chunks
 3001|       |     store something else there and set it themselves. */
 3002|  3.83M|  context->header_blocksize = context->blocksize;
 3003|       |
 3004|       |
 3005|       |  /* Check buffer size limits */
 3006|  3.83M|  if (srcsize > BLOSC2_MAX_BUFFERSIZE) {
  ------------------
  |  Branch (3006:7): [True: 0, False: 3.83M]
  ------------------
 3007|      0|    BLOSC_TRACE_ERROR("Input buffer size cannot exceed %d bytes.",
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3008|      0|                      BLOSC2_MAX_BUFFERSIZE);
 3009|      0|    return BLOSC2_ERROR_MAX_BUFSIZE_EXCEEDED;
 3010|      0|  }
 3011|       |
 3012|  3.83M|  if (destsize < BLOSC2_MAX_OVERHEAD) {
  ------------------
  |  Branch (3012:7): [True: 0, False: 3.83M]
  ------------------
 3013|      0|    BLOSC_TRACE_ERROR("Output buffer size should be larger than %d bytes.",
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3014|      0|                      BLOSC2_MAX_OVERHEAD);
 3015|      0|    return BLOSC2_ERROR_MAX_BUFSIZE_EXCEEDED;
 3016|      0|  }
 3017|       |
 3018|       |  /* Compression level */
 3019|  3.83M|  if (clevel < 0 || clevel > 9) {
  ------------------
  |  Branch (3019:7): [True: 0, False: 3.83M]
  |  Branch (3019:21): [True: 0, False: 3.83M]
  ------------------
 3020|       |    /* If clevel not in 0..9, print an error */
 3021|      0|    BLOSC_TRACE_ERROR("`clevel` parameter must be between 0 and 9!.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3022|      0|    return BLOSC2_ERROR_CODEC_PARAM;
 3023|      0|  }
 3024|       |
 3025|       |  /* Dictionary support is only available for ZSTD, LZ4, and LZ4HC.
 3026|       |   * Skip the check when src is NULL (special-value chunks): no compression
 3027|       |   * will actually happen, so codec compatibility is irrelevant. */
 3028|  3.83M|  if (src != NULL && context->use_dict && context->compcode != BLOSC_ZSTD &&
  ------------------
  |  Branch (3028:7): [True: 1.75M, False: 2.07M]
  |  Branch (3028:22): [True: 0, False: 1.75M]
  |  Branch (3028:43): [True: 0, False: 0]
  ------------------
 3029|      0|      context->compcode != BLOSC_LZ4 && context->compcode != BLOSC_LZ4HC) {
  ------------------
  |  Branch (3029:7): [True: 0, False: 0]
  |  Branch (3029:41): [True: 0, False: 0]
  ------------------
 3030|      0|    BLOSC_TRACE_ERROR("`use_dict` is only supported for ZSTD, LZ4, and LZ4HC codecs.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3031|      0|    return BLOSC2_ERROR_CODEC_PARAM;
 3032|      0|  }
 3033|       |
 3034|  3.83M|  blosc2_calculate_blocks(context);
 3035|       |
 3036|  3.83M|  return 1;
 3037|  3.83M|}
blosc2.c:filters_to_flags:
  852|  8.38M|static uint8_t filters_to_flags(const uint8_t* filters) {
  853|  8.38M|  uint8_t flags = 0;
  854|       |
  855|  58.6M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (855:19): [True: 50.2M, False: 8.38M]
  ------------------
  856|  50.2M|    switch (filters[i]) {
  857|  8.34M|      case BLOSC_SHUFFLE:
  ------------------
  |  Branch (857:7): [True: 8.34M, False: 41.9M]
  ------------------
  858|  8.34M|        flags |= BLOSC_DOSHUFFLE;
  859|  8.34M|        break;
  860|    411|      case BLOSC_BITSHUFFLE:
  ------------------
  |  Branch (860:7): [True: 411, False: 50.2M]
  ------------------
  861|    411|        flags |= BLOSC_DOBITSHUFFLE;
  862|    411|        break;
  863|    373|      case BLOSC_DELTA:
  ------------------
  |  Branch (863:7): [True: 373, False: 50.2M]
  ------------------
  864|    373|        flags |= BLOSC_DODELTA;
  865|    373|        break;
  866|  41.9M|      default :
  ------------------
  |  Branch (866:7): [True: 41.9M, False: 8.35M]
  ------------------
  867|  41.9M|        break;
  868|  50.2M|    }
  869|  50.2M|  }
  870|  8.38M|  return flags;
  871|  8.38M|}
blosc2.c:blosc2_calculate_blocks:
 1042|  8.38M|static inline void blosc2_calculate_blocks(blosc2_context* context) {
 1043|       |  /* Compute number of blocks in buffer */
 1044|  8.38M|  context->nblocks = context->sourcesize / context->blocksize;
 1045|  8.38M|  context->leftover = context->sourcesize % context->blocksize;
 1046|  8.38M|  context->nblocks = (context->leftover > 0) ?
  ------------------
  |  Branch (1046:22): [True: 730k, False: 7.65M]
  ------------------
 1047|  7.65M|                     (context->nblocks + 1) : context->nblocks;
 1048|  8.38M|}
blosc2.c:blosc1_format_check:
 3674|  1.75M|static int blosc1_format_check(const blosc2_context* context) {
 3675|  1.75M|  if (!context->blosc1_format) {
  ------------------
  |  Branch (3675:7): [True: 1.75M, False: 0]
  ------------------
 3676|  1.75M|    return BLOSC2_ERROR_SUCCESS;
 3677|  1.75M|  }
 3678|      0|  switch (context->compcode) {
 3679|      0|    case BLOSC_BLOSCLZ:
  ------------------
  |  Branch (3679:5): [True: 0, False: 0]
  ------------------
 3680|      0|    case BLOSC_LZ4:
  ------------------
  |  Branch (3680:5): [True: 0, False: 0]
  ------------------
 3681|      0|    case BLOSC_LZ4HC:
  ------------------
  |  Branch (3681:5): [True: 0, False: 0]
  ------------------
 3682|      0|    case BLOSC_ZLIB:
  ------------------
  |  Branch (3682:5): [True: 0, False: 0]
  ------------------
 3683|      0|    case BLOSC_ZSTD:
  ------------------
  |  Branch (3683:5): [True: 0, False: 0]
  ------------------
 3684|      0|      break;
 3685|      0|    default:
  ------------------
  |  Branch (3685:5): [True: 0, False: 0]
  ------------------
 3686|      0|      BLOSC_TRACE_ERROR("Codec %d cannot be used when writing Blosc1 chunks.", context->compcode);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3687|      0|      return BLOSC2_ERROR_CODEC_SUPPORT;
 3688|      0|  }
 3689|       |  /* The Blosc1 header only has flags for a shuffle or a bitshuffle, so the pipeline can have
 3690|       |     one of those and nothing else, in any of its slots. */
 3691|      0|  int nfilters = 0;
 3692|      0|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (3692:19): [True: 0, False: 0]
  ------------------
 3693|      0|    uint8_t filter = context->filters[i];
 3694|      0|    if (filter == BLOSC_NOFILTER) {
  ------------------
  |  Branch (3694:9): [True: 0, False: 0]
  ------------------
 3695|      0|      continue;
 3696|      0|    }
 3697|      0|    bool plain_shuffle = (filter == BLOSC_SHUFFLE || filter == BLOSC_BITSHUFFLE) &&
  ------------------
  |  Branch (3697:27): [True: 0, False: 0]
  |  Branch (3697:54): [True: 0, False: 0]
  ------------------
 3698|      0|                         context->filters_meta[i] == 0;
  ------------------
  |  Branch (3698:26): [True: 0, False: 0]
  ------------------
 3699|      0|    if (!plain_shuffle || ++nfilters > 1) {
  ------------------
  |  Branch (3699:9): [True: 0, False: 0]
  |  Branch (3699:27): [True: 0, False: 0]
  ------------------
 3700|      0|      BLOSC_TRACE_ERROR("Filter %d in slot %d cannot be used when writing Blosc1 chunks.", filter, i);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3701|      0|      return BLOSC2_ERROR_FILTER_PIPELINE;
 3702|      0|    }
 3703|      0|  }
 3704|      0|  if (context->use_dict || (context->blosc2_flags2 & BLOSC2_VL_BLOCKS)) {
  ------------------
  |  Branch (3704:7): [True: 0, False: 0]
  |  Branch (3704:28): [True: 0, False: 0]
  ------------------
 3705|      0|    BLOSC_TRACE_ERROR("Dictionaries and variable-length blocks cannot be used when writing Blosc1 chunks.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3706|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 3707|      0|  }
 3708|      0|  return BLOSC2_ERROR_SUCCESS;
 3709|      0|}
blosc2.c:write_compression_header:
 3444|  1.75M|static int write_compression_header(blosc2_context* context, bool extended_header) {
 3445|  1.75M|  blosc_header header;
 3446|  1.75M|  int dont_split;
 3447|  1.75M|  bool vlblocks = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0;
 3448|       |
 3449|  1.75M|  if (context->clevel == 0) {
  ------------------
  |  Branch (3449:7): [True: 26.3k, False: 1.73M]
  ------------------
 3450|       |    /* Compression level 0 means no compression — dicts serve no purpose here */
 3451|  26.3k|    context->use_dict = 0;
 3452|  26.3k|  }
 3453|       |
 3454|  1.75M|  int dict_training = context->use_dict && (context->dict_cdict == NULL);
  ------------------
  |  Branch (3454:23): [True: 0, False: 1.75M]
  |  Branch (3454:44): [True: 0, False: 0]
  ------------------
 3455|       |
 3456|  1.75M|  context->header_flags = 0;
 3457|       |
 3458|  1.75M|  if (!vlblocks && context->clevel == 0) {
  ------------------
  |  Branch (3458:7): [True: 1.75M, False: 0]
  |  Branch (3458:20): [True: 26.3k, False: 1.73M]
  ------------------
 3459|       |    /* Compression level 0 means buffer to be memcpy'ed */
 3460|  26.3k|    context->header_flags |= (uint8_t)BLOSC_MEMCPYED;
 3461|  26.3k|  }
 3462|  1.75M|  if (!vlblocks && context->sourcesize < BLOSC_MIN_BUFFERSIZE) {
  ------------------
  |  Branch (3462:7): [True: 1.75M, False: 0]
  |  Branch (3462:20): [True: 28.9k, False: 1.72M]
  ------------------
 3463|       |    /* Buffer is too small.  Try memcpy'ing. */
 3464|  28.9k|    context->header_flags |= (uint8_t)BLOSC_MEMCPYED;
 3465|  28.9k|  }
 3466|       |
 3467|  1.75M|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 3468|  1.75M|  if (extended_header) {
  ------------------
  |  Branch (3468:7): [True: 1.75M, False: 0]
  ------------------
 3469|       |    /* Indicate that we are building an extended header */
 3470|  1.75M|    context->header_overhead = BLOSC_EXTENDED_HEADER_LENGTH;
 3471|  1.75M|    context->header_flags |= (BLOSC_DOSHUFFLE | BLOSC_DOBITSHUFFLE);
 3472|       |    /* Store filter pipeline info at the end of the header */
 3473|  1.75M|    if (dict_training || memcpyed) {
  ------------------
  |  Branch (3473:9): [True: 0, False: 1.75M]
  |  Branch (3473:26): [True: 29.4k, False: 1.72M]
  ------------------
 3474|  29.4k|      context->bstarts = NULL;
 3475|  29.4k|      context->output_bytes = context->header_overhead;
 3476|  1.72M|    } else {
 3477|  1.72M|      context->bstarts = (int32_t*)(context->dest + context->header_overhead);
 3478|  1.72M|      context->output_bytes = context->header_overhead + (int32_t)sizeof(int32_t) * context->nblocks;
 3479|  1.72M|    }
 3480|  1.75M|  } else {
 3481|       |    // Regular header
 3482|      0|    context->header_overhead = BLOSC_MIN_HEADER_LENGTH;
 3483|      0|    if (memcpyed) {
  ------------------
  |  Branch (3483:9): [True: 0, False: 0]
  ------------------
 3484|      0|      context->bstarts = NULL;
 3485|      0|      context->output_bytes = context->header_overhead;
 3486|      0|    } else {
 3487|      0|      context->bstarts = (int32_t *) (context->dest + context->header_overhead);
 3488|      0|      context->output_bytes = context->header_overhead + (int32_t)sizeof(int32_t) * context->nblocks;
 3489|      0|    }
 3490|      0|  }
 3491|       |
 3492|       |  /* If the header + block starts don't fit in destsize, fall back to memcpy */
 3493|  1.75M|  if (!memcpyed && context->output_bytes > context->destsize) {
  ------------------
  |  Branch (3493:7): [True: 1.72M, False: 29.4k]
  |  Branch (3493:20): [True: 74, False: 1.72M]
  ------------------
 3494|     74|    context->header_flags |= (uint8_t)BLOSC_MEMCPYED;
 3495|     74|    memcpyed = true;
 3496|     74|    context->bstarts = NULL;
 3497|     74|    context->output_bytes = context->header_overhead;
 3498|     74|  }
 3499|       |
 3500|       |  // when memcpyed bit is set, there is no point in dealing with others
 3501|  1.75M|  if (!memcpyed) {
  ------------------
  |  Branch (3501:7): [True: 1.72M, False: 29.5k]
  ------------------
 3502|  1.72M|    if (context->filter_flags & BLOSC_DOSHUFFLE) {
  ------------------
  |  Branch (3502:9): [True: 1.72M, False: 0]
  ------------------
 3503|       |      /* Byte-shuffle is active */
 3504|  1.72M|      context->header_flags |= BLOSC_DOSHUFFLE;
 3505|  1.72M|    }
 3506|       |
 3507|  1.72M|    if (context->filter_flags & BLOSC_DOBITSHUFFLE) {
  ------------------
  |  Branch (3507:9): [True: 0, False: 1.72M]
  ------------------
 3508|       |      /* Bit-shuffle is active */
 3509|      0|      context->header_flags |= BLOSC_DOBITSHUFFLE;
 3510|      0|    }
 3511|       |
 3512|  1.72M|    if (context->filter_flags & BLOSC_DODELTA) {
  ------------------
  |  Branch (3512:9): [True: 0, False: 1.72M]
  ------------------
 3513|       |      /* Delta is active */
 3514|      0|      context->header_flags |= BLOSC_DODELTA;
 3515|      0|    }
 3516|       |
 3517|  1.72M|    dont_split = vlblocks || !split_block(context, context->typesize,
  ------------------
  |  Branch (3517:18): [True: 0, False: 1.72M]
  |  Branch (3517:30): [True: 1.23M, False: 488k]
  ------------------
 3518|  1.72M|                                          context->blocksize);
 3519|       |
 3520|       |    /* dont_split is in bit 4 */
 3521|  1.72M|    context->header_flags |= dont_split << 4;
 3522|       |    /* codec starts at bit 5 */
 3523|  1.72M|    uint8_t compformat = compcode_to_compformat(context->compcode);
 3524|  1.72M|    context->header_flags |= compformat << 5;
 3525|  1.72M|  }
 3526|       |
 3527|       |  // Create blosc header and store to dest
 3528|  1.75M|  blosc2_initialize_header_from_context(context, &header, extended_header);
 3529|       |
 3530|  1.75M|  memcpy(context->dest, &header, (extended_header) ?
  ------------------
  |  Branch (3530:34): [True: 1.75M, False: 0]
  ------------------
 3531|  1.75M|    BLOSC_EXTENDED_HEADER_LENGTH : BLOSC_MIN_HEADER_LENGTH);
 3532|       |
 3533|  1.75M|  return 1;
 3534|  1.75M|}
blosc2.c:compcode_to_compformat:
  536|  1.72M|static int compcode_to_compformat(int compcode) {
  537|  1.72M|  switch (compcode) {
  538|  1.72M|    case BLOSC_BLOSCLZ: return BLOSC_BLOSCLZ_FORMAT;
  ------------------
  |  Branch (538:5): [True: 1.72M, False: 0]
  ------------------
  539|      0|    case BLOSC_LZ4:     return BLOSC_LZ4_FORMAT;
  ------------------
  |  Branch (539:5): [True: 0, False: 1.72M]
  ------------------
  540|      0|    case BLOSC_LZ4HC:   return BLOSC_LZ4HC_FORMAT;
  ------------------
  |  Branch (540:5): [True: 0, False: 1.72M]
  ------------------
  541|       |
  542|      0|#if defined(HAVE_ZLIB)
  543|      0|    case BLOSC_ZLIB:    return BLOSC_ZLIB_FORMAT;
  ------------------
  |  Branch (543:5): [True: 0, False: 1.72M]
  ------------------
  544|      0|#endif /*  HAVE_ZLIB */
  545|       |
  546|      0|#if defined(HAVE_ZSTD)
  547|      0|    case BLOSC_ZSTD:    return BLOSC_ZSTD_FORMAT;
  ------------------
  |  Branch (547:5): [True: 0, False: 1.72M]
  ------------------
  548|      0|      break;
  549|      0|#endif /*  HAVE_ZSTD */
  550|      0|    default:
  ------------------
  |  Branch (550:5): [True: 0, False: 1.72M]
  ------------------
  551|      0|      return BLOSC_UDCODEC_FORMAT;
  552|  1.72M|  }
  553|      0|  BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      0|    do {                                            \
  |  |  112|      0|        int rc_ = (rc);                             \
  |  |  113|      0|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  114|      0|            char *error_msg = print_error(rc_);     \
  |  |  115|      0|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      0|            return rc_;                             \
  |  |  117|      0|        }                                           \
  |  |  118|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  554|      0|}
blosc2.c:blosc2_initialize_header_from_context:
 1256|  1.75M|static int blosc2_initialize_header_from_context(blosc2_context* context, blosc_header* header, bool extended_header) {
 1257|  1.75M|  int32_t header_blocksize = (int32_t)(context->header_blocksize > 0 ? context->header_blocksize : context->blocksize);
  ------------------
  |  Branch (1257:40): [True: 1.75M, False: 0]
  ------------------
 1258|  1.75M|  if ((context->blosc2_flags2 & BLOSC2_VL_BLOCKS) == 0 &&
  ------------------
  |  Branch (1258:7): [True: 1.75M, False: 0]
  ------------------
 1259|  1.75M|      context->sourcesize > 0 && header_blocksize > context->sourcesize) {
  ------------------
  |  Branch (1259:7): [True: 1.75M, False: 0]
  |  Branch (1259:34): [True: 0, False: 1.75M]
  ------------------
 1260|      0|    header_blocksize = (int32_t)context->sourcesize;
 1261|      0|  }
 1262|  1.75M|  memset(header, 0, sizeof(blosc_header));
 1263|       |
 1264|  1.75M|  header->version = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) ?
  ------------------
  |  Branch (1264:21): [True: 0, False: 1.75M]
  ------------------
 1265|      0|                    BLOSC2_VERSION_FORMAT_VL_BLOCKS :
 1266|  1.75M|                    BLOSC2_VERSION_FORMAT_STABLE;
 1267|  1.75M|  if (context->blosc1_format) {
  ------------------
  |  Branch (1267:7): [True: 0, False: 1.75M]
  ------------------
 1268|      0|    header->version = BLOSC1_VERSION_FORMAT;
 1269|      0|  }
 1270|  1.75M|  header->versionlz = compcode_to_compversion(context->compcode);
 1271|  1.75M|  header->flags = context->header_flags;
 1272|  1.75M|  header->typesize = (uint8_t)context->typesize;
 1273|  1.75M|  header->nbytes = (int32_t)context->sourcesize;
 1274|  1.75M|  header->blocksize = header_blocksize;
 1275|       |
 1276|  1.75M|  int little_endian = is_little_endian();
 1277|  1.75M|  if (!little_endian) {
  ------------------
  |  Branch (1277:7): [True: 0, False: 1.75M]
  ------------------
 1278|      0|    header->nbytes = bswap32_(header->nbytes);
 1279|      0|    header->blocksize = bswap32_(header->blocksize);
 1280|       |    // cbytes written after compression
 1281|      0|  }
 1282|       |
 1283|  1.75M|  if (extended_header) {
  ------------------
  |  Branch (1283:7): [True: 1.75M, False: 0]
  ------------------
 1284|       |    /* Store filter pipeline info at the end of the header */
 1285|  12.2M|    for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (1285:21): [True: 10.5M, False: 1.75M]
  ------------------
 1286|  10.5M|      header->filters[i] = context->filters[i];
 1287|  10.5M|      header->filters_meta[i] = context->filters_meta[i];
 1288|  10.5M|    }
 1289|  1.75M|    header->udcompcode = context->compcode;
 1290|  1.75M|    header->compcode_meta = context->compcode_meta;
 1291|  1.75M|    header->blosc2_flags2 = context->blosc2_flags2;
 1292|       |
 1293|  1.75M|    if (!little_endian) {
  ------------------
  |  Branch (1293:9): [True: 0, False: 1.75M]
  ------------------
 1294|      0|      header->blosc2_flags |= BLOSC2_BIGENDIAN;
 1295|      0|    }
 1296|  1.75M|    if (context->use_dict) {
  ------------------
  |  Branch (1296:9): [True: 0, False: 1.75M]
  ------------------
 1297|      0|      header->blosc2_flags |= BLOSC2_USEDICT;
 1298|      0|    }
 1299|  1.75M|    if (context->blosc2_flags & BLOSC2_INSTR_CODEC) {
  ------------------
  |  Branch (1299:9): [True: 0, False: 1.75M]
  ------------------
 1300|      0|      header->blosc2_flags |= BLOSC2_INSTR_CODEC;
 1301|      0|    }
 1302|  1.75M|  }
 1303|       |
 1304|  1.75M|  return 0;
 1305|  1.75M|}
blosc2.c:compcode_to_compversion:
  558|  1.75M|static int compcode_to_compversion(int compcode) {
  559|       |  /* Write compressor format */
  560|  1.75M|  switch (compcode) {
  561|  1.75M|    case BLOSC_BLOSCLZ:
  ------------------
  |  Branch (561:5): [True: 1.75M, False: 0]
  ------------------
  562|  1.75M|      return BLOSC_BLOSCLZ_VERSION_FORMAT;
  563|      0|    case BLOSC_LZ4:
  ------------------
  |  Branch (563:5): [True: 0, False: 1.75M]
  ------------------
  564|      0|      return BLOSC_LZ4_VERSION_FORMAT;
  565|      0|    case BLOSC_LZ4HC:
  ------------------
  |  Branch (565:5): [True: 0, False: 1.75M]
  ------------------
  566|      0|      return BLOSC_LZ4HC_VERSION_FORMAT;
  567|       |
  568|      0|#if defined(HAVE_ZLIB)
  569|      0|    case BLOSC_ZLIB:
  ------------------
  |  Branch (569:5): [True: 0, False: 1.75M]
  ------------------
  570|      0|      return BLOSC_ZLIB_VERSION_FORMAT;
  571|      0|      break;
  572|      0|#endif /*  HAVE_ZLIB */
  573|       |
  574|      0|#if defined(HAVE_ZSTD)
  575|      0|    case BLOSC_ZSTD:
  ------------------
  |  Branch (575:5): [True: 0, False: 1.75M]
  ------------------
  576|      0|      return BLOSC_ZSTD_VERSION_FORMAT;
  577|      0|      break;
  578|      0|#endif /*  HAVE_ZSTD */
  579|      0|    default:
  ------------------
  |  Branch (579:5): [True: 0, False: 1.75M]
  ------------------
  580|      0|      for (int i = 0; i < g_ncodecs; ++i) {
  ------------------
  |  Branch (580:23): [True: 0, False: 0]
  ------------------
  581|      0|        if (compcode == g_codecs[i].compcode) {
  ------------------
  |  Branch (581:13): [True: 0, False: 0]
  ------------------
  582|      0|          return g_codecs[i].version;
  583|      0|        }
  584|      0|      }
  585|  1.75M|  }
  586|      0|  return BLOSC2_ERROR_FAILURE;
  587|  1.75M|}
blosc2.c:blosc_compress_context:
 3537|  1.75M|static int blosc_compress_context(blosc2_context* context) {
 3538|  1.75M|  int ntbytes = 0;
 3539|  1.75M|  blosc_timestamp_t last = {0}, current;
 3540|  1.75M|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 3541|       |
 3542|  1.75M|  if (context->tuner_params != NULL) {
  ------------------
  |  Branch (3542:7): [True: 0, False: 1.75M]
  ------------------
 3543|      0|    blosc_set_timestamp(&last);
 3544|      0|  }
 3545|       |
 3546|  1.75M|  if (!memcpyed) {
  ------------------
  |  Branch (3546:7): [True: 1.72M, False: 29.5k]
  ------------------
 3547|       |    /* Do the actual compression */
 3548|  1.72M|    ntbytes = do_job(context);
 3549|  1.72M|    if (ntbytes < 0) {
  ------------------
  |  Branch (3549:9): [True: 0, False: 1.72M]
  ------------------
 3550|      0|      return ntbytes;
 3551|      0|    }
 3552|  1.72M|    if (ntbytes == 0) {
  ------------------
  |  Branch (3552:9): [True: 7.05k, False: 1.71M]
  ------------------
 3553|       |      // Try out with a memcpy later on (last chance for fitting src buffer in dest).
 3554|  7.05k|      context->header_flags |= (uint8_t)BLOSC_MEMCPYED;
 3555|  7.05k|      memcpyed = true;
 3556|  7.05k|    }
 3557|  1.72M|  }
 3558|       |
 3559|  1.75M|  int dont_split = (context->header_flags & 0x10) >> 4;
 3560|  1.75M|  int nstreams = context->nblocks;
 3561|  1.75M|  if (!dont_split) {
  ------------------
  |  Branch (3561:7): [True: 518k, False: 1.23M]
  ------------------
 3562|       |    // When splitting, the number of streams is computed differently
 3563|   518k|    if (context->leftover) {
  ------------------
  |  Branch (3563:9): [True: 0, False: 518k]
  ------------------
 3564|      0|      nstreams = (context->nblocks - 1) * context->typesize + 1;
 3565|      0|    }
 3566|   518k|    else {
 3567|   518k|      nstreams *= context->typesize;
 3568|   518k|    }
 3569|   518k|  }
 3570|       |
 3571|  1.75M|  if (memcpyed) {
  ------------------
  |  Branch (3571:7): [True: 36.5k, False: 1.71M]
  ------------------
 3572|  36.5k|    if (context->sourcesize + context->header_overhead > context->destsize) {
  ------------------
  |  Branch (3572:9): [True: 0, False: 36.5k]
  ------------------
 3573|       |      /* We are exceeding maximum output size */
 3574|      0|      ntbytes = 0;
 3575|      0|    }
 3576|  36.5k|    else {
 3577|  36.5k|      context->output_bytes = context->header_overhead;
 3578|  36.5k|      ntbytes = do_job(context);
 3579|  36.5k|      if (ntbytes < 0) {
  ------------------
  |  Branch (3579:11): [True: 0, False: 36.5k]
  ------------------
 3580|      0|        return ntbytes;
 3581|      0|      }
 3582|       |      // Success!  update the memcpy bit in header
 3583|  36.5k|      context->dest[BLOSC2_CHUNK_FLAGS] = context->header_flags;
 3584|  36.5k|      if (context->dict_cdict != NULL) {
  ------------------
  |  Branch (3584:11): [True: 0, False: 36.5k]
  ------------------
 3585|       |        // The copy overwrote the dictionary that this pass was going to use
 3586|      0|        context->dest[BLOSC2_CHUNK_BLOSC2_FLAGS] &= ~(uint8_t)BLOSC2_USEDICT;
 3587|      0|      }
 3588|       |      // and clear the memcpy bit in context (for next reuse)
 3589|  36.5k|      context->header_flags &= ~(uint8_t)BLOSC_MEMCPYED;
 3590|  36.5k|    }
 3591|  36.5k|  }
 3592|  1.71M|  else {
 3593|       |    // Check whether we have a run for the whole chunk
 3594|  1.71M|    int dict_training = context->use_dict && (context->dict_cdict == NULL);
  ------------------
  |  Branch (3594:25): [True: 0, False: 1.71M]
  |  Branch (3594:46): [True: 0, False: 0]
  ------------------
 3595|  1.71M|    int start_csizes = context->header_overhead + 4 * context->nblocks;
 3596|  1.71M|    if (!dict_training && ntbytes == (int)(start_csizes + nstreams * sizeof(int32_t))) {
  ------------------
  |  Branch (3596:9): [True: 1.71M, False: 0]
  |  Branch (3596:27): [True: 107k, False: 1.61M]
  ------------------
 3597|       |      // The streams are all zero runs (by construction).  Encode it...
 3598|   107k|      context->dest[BLOSC2_CHUNK_BLOSC2_FLAGS] |= BLOSC2_SPECIAL_ZERO << 4;
 3599|       |      // ...and assign the new chunk length
 3600|   107k|      ntbytes = context->header_overhead;
 3601|   107k|    }
 3602|  1.71M|  }
 3603|       |
 3604|       |  /* Set the number of compressed bytes in header */
 3605|  1.75M|  _sw32(context->dest + BLOSC2_CHUNK_CBYTES, ntbytes);
 3606|  1.75M|  if (context->blosc2_flags & BLOSC2_INSTR_CODEC) {
  ------------------
  |  Branch (3606:7): [True: 0, False: 1.75M]
  ------------------
 3607|      0|    dont_split = (context->header_flags & 0x10) >> 4;
 3608|      0|    int32_t blocksize = dont_split ? (int32_t)sizeof(blosc2_instr) : (int32_t)sizeof(blosc2_instr) * context->typesize;
  ------------------
  |  Branch (3608:25): [True: 0, False: 0]
  ------------------
 3609|      0|    _sw32(context->dest + BLOSC2_CHUNK_NBYTES, nstreams * (int32_t)sizeof(blosc2_instr));
 3610|      0|    _sw32(context->dest + BLOSC2_CHUNK_BLOCKSIZE, blocksize);
 3611|      0|  }
 3612|       |
 3613|       |  /* Set the number of bytes in dest buffer (might be useful for tuner) */
 3614|  1.75M|  context->destsize = ntbytes;
 3615|       |
 3616|  1.75M|  if (context->tuner_params != NULL) {
  ------------------
  |  Branch (3616:7): [True: 0, False: 1.75M]
  ------------------
 3617|      0|    blosc_set_timestamp(&current);
 3618|      0|    double ctime = blosc_elapsed_secs(last, current);
 3619|      0|    int rc;
 3620|      0|    if (context->tuner_id < BLOSC_LAST_TUNER && context->tuner_id == BLOSC_STUNE) {
  ------------------
  |  |   26|      0|#define BLOSC_STUNE 0
  ------------------
  |  Branch (3620:9): [True: 0, False: 0]
  |  Branch (3620:49): [True: 0, False: 0]
  ------------------
 3621|      0|      rc = blosc_stune_update(context, ctime);
 3622|      0|    } else {
 3623|      0|      for (int i = 0; i < g_ntuners; ++i) {
  ------------------
  |  Branch (3623:23): [True: 0, False: 0]
  ------------------
 3624|      0|        if (g_tuners[i].id == context->tuner_id) {
  ------------------
  |  Branch (3624:13): [True: 0, False: 0]
  ------------------
 3625|      0|          if (load_acquire_ptr(&g_tuners[i].init) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (3625:15): [True: 0, False: 0]
  ------------------
 3626|      0|            if (fill_tuner(&g_tuners[i]) < 0) {
  ------------------
  |  Branch (3626:17): [True: 0, False: 0]
  ------------------
 3627|      0|              BLOSC_TRACE_ERROR("Could not load tuner %d.", g_tuners[i].id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3628|      0|              return BLOSC2_ERROR_FAILURE;
 3629|      0|            }
 3630|      0|          }
 3631|      0|          rc = g_tuners[i].update(context, ctime);
 3632|      0|          goto urtunersuccess;
 3633|      0|        }
 3634|      0|      }
 3635|      0|      BLOSC_TRACE_ERROR("User-defined tuner %d not found\n", context->tuner_id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3636|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 3637|      0|      urtunersuccess:;
 3638|      0|    }
 3639|      0|    if (rc < 0) {
  ------------------
  |  Branch (3639:9): [True: 0, False: 0]
  ------------------
 3640|      0|      BLOSC_TRACE_ERROR("Error in tuner update func\n");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3641|      0|      return BLOSC2_ERROR_TUNER;
 3642|      0|    }
 3643|      0|  }
 3644|       |
 3645|  1.75M|  return ntbytes;
 3646|  1.75M|}
blosc2.c:clibcode_to_clibname:
  445|      1|static const char* clibcode_to_clibname(int clibcode) {
  446|      1|  if (clibcode == BLOSC_BLOSCLZ_LIB) return BLOSC_BLOSCLZ_LIBNAME;
  ------------------
  |  |  367|      0|#define BLOSC_BLOSCLZ_LIBNAME   "BloscLZ"
  ------------------
  |  Branch (446:7): [True: 0, False: 1]
  ------------------
  447|      1|  if (clibcode == BLOSC_LZ4_LIB) return BLOSC_LZ4_LIBNAME;
  ------------------
  |  |  368|      0|#define BLOSC_LZ4_LIBNAME       "LZ4"
  ------------------
  |  Branch (447:7): [True: 0, False: 1]
  ------------------
  448|      1|  if (clibcode == BLOSC_ZLIB_LIB) return BLOSC_ZLIB_LIBNAME;
  ------------------
  |  |  369|      0|#define BLOSC_ZLIB_LIBNAME      "Zlib"
  ------------------
  |  Branch (448:7): [True: 0, False: 1]
  ------------------
  449|      1|  if (clibcode == BLOSC_ZSTD_LIB) return BLOSC_ZSTD_LIBNAME;
  ------------------
  |  |  370|      0|#define BLOSC_ZSTD_LIBNAME      "Zstd"
  ------------------
  |  Branch (449:7): [True: 0, False: 1]
  ------------------
  450|     10|  for (int i = 0; i < g_ncodecs; ++i) {
  ------------------
  |  Branch (450:19): [True: 9, False: 1]
  ------------------
  451|      9|    if (clibcode == g_codecs[i].complib)
  ------------------
  |  Branch (451:9): [True: 0, False: 9]
  ------------------
  452|      0|      return g_codecs[i].compname;
  453|      9|  }
  454|      1|  return NULL;                  /* should never happen */
  455|      1|}
blosc2.c:blosc_run_decompression_with_context:
 4515|  1.64M|                                                void* dest, int32_t destsize) {
 4516|  1.64M|  blosc_header header;
 4517|  1.64M|  int32_t ntbytes;
 4518|  1.64M|  int rc;
 4519|       |
 4520|  1.64M|  rc = read_chunk_header(src, srcsize, true, &header);
 4521|  1.64M|  if (rc < 0) {
  ------------------
  |  Branch (4521:7): [True: 9, False: 1.64M]
  ------------------
 4522|      9|    return rc;
 4523|      9|  }
 4524|       |
 4525|  1.64M|  if (header.nbytes > destsize) {
  ------------------
  |  Branch (4525:7): [True: 0, False: 1.64M]
  ------------------
 4526|       |    // Not enough space for writing into the destination
 4527|      0|    return BLOSC2_ERROR_WRITE_BUFFER;
 4528|      0|  }
 4529|       |
 4530|  1.64M|  rc = initialize_context_decompression(context, &header, src, srcsize, dest, destsize);
 4531|  1.64M|  if (rc < 0) {
  ------------------
  |  Branch (4531:7): [True: 188, False: 1.64M]
  ------------------
 4532|    188|    return rc;
 4533|    188|  }
 4534|       |
 4535|       |  /* Do the actual decompression */
 4536|  1.64M|  ntbytes = do_job(context);
 4537|  1.64M|  if (ntbytes < 0) {
  ------------------
  |  Branch (4537:7): [True: 636, False: 1.64M]
  ------------------
 4538|    636|    return ntbytes;
 4539|    636|  }
 4540|       |
 4541|  1.64M|  assert(ntbytes <= (int32_t)destsize);
 4542|  1.64M|  return ntbytes;
 4543|  1.64M|}
blosc2.c:initialize_context_decompression:
 3206|  1.64M|                                            int32_t srcsize, void* dest, int32_t destsize) {
 3207|  1.64M|  int32_t bstarts_end;
 3208|  1.64M|  bool vlblocks;
 3209|       |
 3210|  1.64M|  context->do_compress = 0;
 3211|  1.64M|  context->src = (const uint8_t*)src;
 3212|  1.64M|  context->srcsize = srcsize;
 3213|  1.64M|  context->dest = (uint8_t*)dest;
 3214|  1.64M|  context->destsize = destsize;
 3215|  1.64M|  context->output_bytes = 0;
 3216|  1.64M|  context->vlblock_sources = NULL;
 3217|  1.64M|  context->vlblock_dests = NULL;
 3218|  1.64M|  if (context->blocknbytes != NULL) {
  ------------------
  |  Branch (3218:7): [True: 0, False: 1.64M]
  ------------------
 3219|      0|    free(context->blocknbytes);
 3220|      0|    context->blocknbytes = NULL;
 3221|      0|  }
 3222|  1.64M|  if (context->blockoffsets != NULL) {
  ------------------
  |  Branch (3222:7): [True: 0, False: 1.64M]
  ------------------
 3223|      0|    free(context->blockoffsets);
 3224|      0|    context->blockoffsets = NULL;
 3225|      0|  }
 3226|  1.64M|  if (context->blockcbytes != NULL) {
  ------------------
  |  Branch (3226:7): [True: 0, False: 1.64M]
  ------------------
 3227|      0|    free(context->blockcbytes);
 3228|      0|    context->blockcbytes = NULL;
 3229|      0|  }
 3230|       |
 3231|  1.64M|  int rc = blosc2_initialize_context_from_header(context, header);
 3232|  1.64M|  if (rc < 0) {
  ------------------
  |  Branch (3232:7): [True: 0, False: 1.64M]
  ------------------
 3233|      0|    return rc;
 3234|      0|  }
 3235|  1.64M|  clear_context_decompression_dict(context);
 3236|  1.64M|  vlblocks = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0;
 3237|  1.64M|  bool is_lazy = ((context->header_overhead == BLOSC_EXTENDED_HEADER_LENGTH) &&
  ------------------
  |  Branch (3237:19): [True: 1.64M, False: 242]
  ------------------
 3238|  1.64M|                  (context->blosc2_flags & 0x08u));
  ------------------
  |  Branch (3238:19): [True: 78, False: 1.64M]
  ------------------
 3239|       |
 3240|       |  /* Check that we have enough space to decompress */
 3241|  1.64M|  if (context->sourcesize > (int32_t)context->destsize) {
  ------------------
  |  Branch (3241:7): [True: 0, False: 1.64M]
  ------------------
 3242|      0|    return BLOSC2_ERROR_WRITE_BUFFER;
 3243|      0|  }
 3244|       |
 3245|  1.64M|  if (context->block_maskout != NULL) {
  ------------------
  |  Branch (3245:7): [True: 446k, False: 1.19M]
  ------------------
 3246|   446k|    if (context->block_maskout_nitems != context->nblocks) {
  ------------------
  |  Branch (3246:9): [True: 0, False: 446k]
  ------------------
 3247|      0|      BLOSC_TRACE_ERROR("The number of items in block_maskout (%d) must match the number"
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3248|      0|                        " of blocks in chunk (%d).",
 3249|      0|                        context->block_maskout_nitems, context->nblocks);
 3250|      0|      return BLOSC2_ERROR_DATA;
 3251|      0|    }
 3252|   446k|    if (filters_contain(context->filters, BLOSC_DELTA)) {
  ------------------
  |  Branch (3252:9): [True: 0, False: 446k]
  ------------------
 3253|      0|      bool any_needed = false;
 3254|      0|      for (int i = 0; i < context->block_maskout_nitems; ++i) {
  ------------------
  |  Branch (3254:23): [True: 0, False: 0]
  ------------------
 3255|      0|        if (!context->block_maskout[i]) {
  ------------------
  |  Branch (3255:13): [True: 0, False: 0]
  ------------------
 3256|      0|          any_needed = true;
 3257|      0|          break;
 3258|      0|        }
 3259|      0|      }
 3260|      0|      if (any_needed) {
  ------------------
  |  Branch (3260:11): [True: 0, False: 0]
  ------------------
 3261|       |        // Delta filter encodes subsequent blocks relative to block 0; block 0 must be unmasked.
 3262|      0|        context->block_maskout[0] = false;
 3263|      0|      }
 3264|      0|    }
 3265|   446k|  }
 3266|       |
 3267|  1.64M|  context->special_type = (header->blosc2_flags >> 4) & BLOSC2_SPECIAL_MASK;
 3268|  1.64M|  if (context->special_type > BLOSC2_SPECIAL_LASTID) {
  ------------------
  |  Branch (3268:7): [True: 1, False: 1.64M]
  ------------------
 3269|      1|    BLOSC_TRACE_ERROR("Unknown special values ID (%d) ",
  ------------------
  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3270|      1|                      context->special_type);
 3271|      1|    return BLOSC2_ERROR_DATA;
 3272|      1|  }
 3273|       |
 3274|  1.64M|  int memcpyed = (context->header_flags & (uint8_t) BLOSC_MEMCPYED);
 3275|  1.64M|  if (memcpyed && (header->cbytes != header->nbytes + context->header_overhead)) {
  ------------------
  |  Branch (3275:7): [True: 36.9k, False: 1.60M]
  |  Branch (3275:19): [True: 16, False: 36.9k]
  ------------------
 3276|     16|    BLOSC_TRACE_ERROR("Wrong header info for this memcpyed chunk");
  ------------------
  |  |   93|     16|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     16|    do {                                            \
  |  |  |  |   98|     16|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     16|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     16|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3277|     16|    return BLOSC2_ERROR_DATA;
 3278|     16|  }
 3279|       |
 3280|  1.64M|  if ((header->nbytes == 0) && (header->cbytes == context->header_overhead) &&
  ------------------
  |  Branch (3280:7): [True: 0, False: 1.64M]
  |  Branch (3280:32): [True: 0, False: 0]
  ------------------
 3281|      0|      !context->special_type) {
  ------------------
  |  Branch (3281:7): [True: 0, False: 0]
  ------------------
 3282|       |    // A compressed buffer with only a header can only contain a zero-length buffer
 3283|      0|    return 0;
 3284|      0|  }
 3285|       |
 3286|  1.64M|  context->bstarts = (int32_t *) (context->src + context->header_overhead);
 3287|  1.64M|  bstarts_end = context->header_overhead;
 3288|  1.64M|  if (!context->special_type && !memcpyed) {
  ------------------
  |  Branch (3288:7): [True: 1.62M, False: 21.0k]
  |  Branch (3288:33): [True: 1.58M, False: 36.9k]
  ------------------
 3289|  1.58M|    size_t bstarts_end_tmp;
 3290|  1.58M|    size_t bstarts_nbytes;
 3291|  1.58M|    if (context->nblocks < 0 ||
  ------------------
  |  Branch (3291:9): [True: 0, False: 1.58M]
  ------------------
 3292|  1.58M|        !blosc2_checked_mul_size((size_t)context->nblocks, sizeof(int32_t), &bstarts_nbytes) ||
  ------------------
  |  Branch (3292:9): [True: 0, False: 1.58M]
  ------------------
 3293|  1.58M|        !blosc2_checked_add_size((size_t)context->header_overhead, bstarts_nbytes, &bstarts_end_tmp) ||
  ------------------
  |  Branch (3293:9): [True: 0, False: 1.58M]
  ------------------
 3294|  1.58M|        bstarts_end_tmp > (size_t)INT32_MAX) {
  ------------------
  |  Branch (3294:9): [True: 2, False: 1.58M]
  ------------------
 3295|      2|      BLOSC_TRACE_ERROR("Invalid bstarts size in chunk header.");
  ------------------
  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3296|      2|      return BLOSC2_ERROR_INVALID_HEADER;
 3297|      2|    }
 3298|       |    /* If chunk is not special or a memcpyed, we do have a bstarts section */
 3299|  1.58M|    bstarts_end = (int32_t)bstarts_end_tmp;
 3300|  1.58M|  }
 3301|       |
 3302|  1.64M|  if (srcsize < bstarts_end) {
  ------------------
  |  Branch (3302:7): [True: 16, False: 1.64M]
  ------------------
 3303|     16|    BLOSC_TRACE_ERROR("`bstarts` exceeds length of source buffer.");
  ------------------
  |  |   93|     16|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     16|    do {                                            \
  |  |  |  |   98|     16|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     16|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     16|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3304|     16|    return BLOSC2_ERROR_READ_BUFFER;
 3305|     16|  }
 3306|       |
 3307|  1.64M|  if (vlblocks && is_lazy && !context->special_type && !memcpyed) {
  ------------------
  |  Branch (3307:7): [True: 116, False: 1.64M]
  |  Branch (3307:19): [True: 38, False: 78]
  |  Branch (3307:30): [True: 38, False: 0]
  |  Branch (3307:56): [True: 38, False: 0]
  ------------------
 3308|     38|    size_t block_csizes_nbytes;
 3309|     38|    size_t trailer_meta_nbytes;
 3310|     38|    size_t lazy_trailer_end;
 3311|     38|    if (context->srcsize < 0 || context->nblocks < 0 ||
  ------------------
  |  Branch (3311:9): [True: 0, False: 38]
  |  Branch (3311:33): [True: 0, False: 38]
  ------------------
 3312|     38|        !blosc2_checked_mul_size((size_t)context->nblocks, sizeof(int32_t), &block_csizes_nbytes) ||
  ------------------
  |  Branch (3312:9): [True: 0, False: 38]
  ------------------
 3313|     38|        !blosc2_checked_add_size(sizeof(int32_t) + sizeof(int64_t), block_csizes_nbytes, &trailer_meta_nbytes) ||
  ------------------
  |  Branch (3313:9): [True: 0, False: 38]
  ------------------
 3314|     38|        !blosc2_checked_add_size((size_t)bstarts_end, trailer_meta_nbytes, &lazy_trailer_end) ||
  ------------------
  |  Branch (3314:9): [True: 0, False: 38]
  ------------------
 3315|     38|        (size_t)context->srcsize < lazy_trailer_end) {
  ------------------
  |  Branch (3315:9): [True: 2, False: 36]
  ------------------
 3316|      2|      BLOSC_TRACE_ERROR("Lazy trailer exceeds source buffer.");
  ------------------
  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3317|      2|      return BLOSC2_ERROR_READ_BUFFER;
 3318|      2|    }
 3319|     38|  }
 3320|  1.64M|  srcsize -= bstarts_end;
 3321|       |
 3322|       |  /* Read optional dictionary if flag set.  A memcpyed chunk has none, even if the flag says so
 3323|       |     (older versions left it on chunks with a dictionary that did not compress) */
 3324|  1.64M|  if ((context->blosc2_flags & BLOSC2_USEDICT) && !memcpyed && !is_lazy) {
  ------------------
  |  Branch (3324:7): [True: 185, False: 1.64M]
  |  Branch (3324:51): [True: 185, False: 0]
  |  Branch (3324:64): [True: 179, False: 6]
  ------------------
 3325|    179|    context->use_dict = 1;
 3326|       |    // The dictionary section is after the bstarts block: [int32 size | raw bytes]
 3327|    179|    if (srcsize < (signed)sizeof(int32_t)) {
  ------------------
  |  Branch (3327:9): [True: 1, False: 178]
  ------------------
 3328|      1|      BLOSC_TRACE_ERROR("Not enough space to read size of dictionary.");
  ------------------
  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3329|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3330|      1|    }
 3331|    178|    srcsize -= sizeof(int32_t);
 3332|       |    // Read dictionary size
 3333|    178|    context->dict_size = sw32_(context->src + bstarts_end);
 3334|    178|    if (context->dict_size <= 0 || context->dict_size > BLOSC2_MAXDICTSIZE) {
  ------------------
  |  Branch (3334:9): [True: 20, False: 158]
  |  Branch (3334:36): [True: 13, False: 145]
  ------------------
 3335|     33|      BLOSC_TRACE_ERROR("Dictionary size is smaller than minimum or larger than maximum allowed.");
  ------------------
  |  |   93|     33|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     33|    do {                                            \
  |  |  |  |   98|     33|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     33|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 33, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     33|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3336|     33|      return BLOSC2_ERROR_CODEC_DICT;
 3337|     33|    }
 3338|    145|    if (srcsize < (int32_t)context->dict_size) {
  ------------------
  |  Branch (3338:9): [True: 3, False: 142]
  ------------------
 3339|      3|      BLOSC_TRACE_ERROR("Not enough space to read entire dictionary.");
  ------------------
  |  |   93|      3|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      3|    do {                                            \
  |  |  |  |   98|      3|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      3|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      3|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3340|      3|      return BLOSC2_ERROR_READ_BUFFER;
 3341|      3|    }
 3342|    142|    srcsize -= context->dict_size;
 3343|       |    // dict_buffer points directly into the source chunk — no copy needed
 3344|    142|    context->dict_buffer = (void*)(context->src + bstarts_end + sizeof(int32_t));
 3345|    142|    context->dict_buffer_owned = false;
 3346|    142|#if defined(HAVE_ZSTD)
 3347|       |    // context->compcode during decompression holds the format code (flags >> 5),
 3348|       |    // so compare against BLOSC_ZSTD_FORMAT (not BLOSC_ZSTD).
 3349|    142|    if (context->compcode == BLOSC_ZSTD_FORMAT) {
  ------------------
  |  Branch (3349:9): [True: 8, False: 134]
  ------------------
 3350|      8|      context->dict_ddict = ZSTD_createDDict(context->dict_buffer, context->dict_size);
 3351|      8|      if (context->dict_ddict == NULL) {
  ------------------
  |  Branch (3351:11): [True: 0, False: 8]
  ------------------
 3352|      0|        BLOSC_TRACE_ERROR("Cannot create ZSTD dictionary for chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3353|      0|        return BLOSC2_ERROR_CODEC_DICT;
 3354|      0|      }
 3355|      8|    }
 3356|    142|#endif   // HAVE_ZSTD
 3357|       |    // For LZ4/LZ4HC: dict_buffer and dict_size are sufficient; no digested object needed.
 3358|    142|  }
 3359|  1.64M|  else if ((context->blosc2_flags & BLOSC2_USEDICT) && !memcpyed && is_lazy) {
  ------------------
  |  Branch (3359:12): [True: 6, False: 1.64M]
  |  Branch (3359:56): [True: 6, False: 0]
  |  Branch (3359:69): [True: 6, False: 0]
  ------------------
 3360|      6|    rc = load_lazy_chunk_dict(context, header, bstarts_end);
 3361|      6|    if (rc < 0) {
  ------------------
  |  Branch (3361:9): [True: 6, False: 0]
  ------------------
 3362|      6|      return rc;
 3363|      6|    }
 3364|      6|  }
 3365|       |
 3366|  1.64M|  if (vlblocks && !context->special_type && !memcpyed) {
  ------------------
  |  Branch (3366:7): [True: 113, False: 1.64M]
  |  Branch (3366:19): [True: 113, False: 0]
  |  Branch (3366:45): [True: 113, False: 0]
  ------------------
 3367|    113|    context->blocknbytes = malloc((size_t)context->nblocks * sizeof(int32_t));
 3368|    113|    BLOSC_ERROR_NULL(context->blocknbytes, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|    113|    do {                                            \
  |  |  105|    113|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 113]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|    113|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 113]
  |  |  ------------------
  ------------------
 3369|    113|    context->blockoffsets = malloc((size_t)context->nblocks * sizeof(int32_t));
 3370|    113|    BLOSC_ERROR_NULL(context->blockoffsets, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|    113|    do {                                            \
  |  |  105|    113|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 113]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|    113|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 113]
  |  |  ------------------
  ------------------
 3371|    113|    context->blockcbytes = malloc((size_t)context->nblocks * sizeof(int32_t));
 3372|    113|    BLOSC_ERROR_NULL(context->blockcbytes, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|    113|    do {                                            \
  |  |  105|    113|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 113]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|    113|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 113]
  |  |  ------------------
  ------------------
 3373|       |
 3374|    113|    if (is_lazy) {
  ------------------
  |  Branch (3374:9): [True: 35, False: 78]
  ------------------
 3375|       |      // Lazy VL: block data is on disk, so blocknbytes is unknown at this point.
 3376|       |      // Populate blockcbytes from bstarts differences; blocksize gets max(blockcbytes)
 3377|       |      // as a safe upper bound so tmp buffers are large enough for the lazy block read.
 3378|     35|      int32_t max_csize = 0;
 3379|     42|      for (int32_t i = 0; i < context->nblocks; ++i) {
  ------------------
  |  Branch (3379:27): [True: 38, False: 4]
  ------------------
 3380|     38|        int32_t bstart = sw32_(context->bstarts + i);
 3381|     38|        int32_t next_bstart = (i + 1 < context->nblocks) ?
  ------------------
  |  Branch (3381:31): [True: 21, False: 17]
  ------------------
 3382|     21|            sw32_(context->bstarts + i + 1) : header->cbytes;
 3383|     38|        if (bstart < bstarts_end || next_bstart <= bstart ||
  ------------------
  |  Branch (3383:13): [True: 8, False: 30]
  |  Branch (3383:37): [True: 8, False: 22]
  ------------------
 3384|     31|            next_bstart > header->cbytes) {
  ------------------
  |  Branch (3384:13): [True: 15, False: 7]
  ------------------
 3385|     31|          BLOSC_TRACE_ERROR("Invalid VL-block offsets in lazy chunk.");
  ------------------
  |  |   93|     31|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     31|    do {                                            \
  |  |  |  |   98|     31|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     31|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 31, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     31|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3386|     31|          return BLOSC2_ERROR_INVALID_HEADER;
 3387|     31|        }
 3388|      7|        context->blocknbytes[i] = 0;   // unknown until block is read from disk
 3389|      7|        context->blockoffsets[i] = 0;  // unknown
 3390|      7|        context->blockcbytes[i] = next_bstart - bstart;
 3391|      7|        if (context->blockcbytes[i] > max_csize) {
  ------------------
  |  Branch (3391:13): [True: 7, False: 0]
  ------------------
 3392|      7|          max_csize = context->blockcbytes[i];
 3393|      7|        }
 3394|      7|      }
 3395|      4|      context->blocksize = max_csize;
 3396|      4|      context->leftover = 0;
 3397|      4|    }
 3398|     78|    else {
 3399|     78|      int32_t max_blocksize = 0;
 3400|     78|      int64_t total_nbytes = 0;
 3401|     78|      int32_t prev_bstart = 0;
 3402|     96|      for (int32_t i = 0; i < context->nblocks; ++i) {
  ------------------
  |  Branch (3402:27): [True: 78, False: 18]
  ------------------
 3403|     78|        int32_t bstart = sw32_(context->bstarts + i);
 3404|     78|        int32_t next_bstart = (i + 1 < context->nblocks) ?
  ------------------
  |  Branch (3404:31): [True: 9, False: 69]
  ------------------
 3405|     69|            sw32_(context->bstarts + i + 1) : header->cbytes;
 3406|     78|        if (bstart < bstarts_end || bstart <= prev_bstart || next_bstart <= bstart ||
  ------------------
  |  Branch (3406:13): [True: 3, False: 75]
  |  Branch (3406:37): [True: 0, False: 75]
  |  Branch (3406:62): [True: 26, False: 49]
  ------------------
 3407|     49|            next_bstart > header->cbytes || bstart > context->srcsize - (int32_t)sizeof(int32_t)) {
  ------------------
  |  Branch (3407:13): [True: 7, False: 42]
  |  Branch (3407:45): [True: 1, False: 41]
  ------------------
 3408|     37|          BLOSC_TRACE_ERROR("Invalid VL-block offsets in chunk.");
  ------------------
  |  |   93|     37|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     37|    do {                                            \
  |  |  |  |   98|     37|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     37|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 37, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     37|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3409|     37|          return BLOSC2_ERROR_INVALID_HEADER;
 3410|     37|        }
 3411|     41|        context->blocknbytes[i] = sw32_(context->src + bstart);
 3412|     41|        context->blockcbytes[i] = next_bstart - bstart;
 3413|     41|        if (context->blocknbytes[i] <= 0) {
  ------------------
  |  Branch (3413:13): [True: 11, False: 30]
  ------------------
 3414|     11|          BLOSC_TRACE_ERROR("Invalid VL-block uncompressed size in chunk.");
  ------------------
  |  |   93|     11|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     11|    do {                                            \
  |  |  |  |   98|     11|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     11|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     11|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3415|     11|          return BLOSC2_ERROR_INVALID_HEADER;
 3416|     11|        }
 3417|     30|        if (total_nbytes > INT32_MAX) {
  ------------------
  |  Branch (3417:13): [True: 0, False: 30]
  ------------------
 3418|      0|          BLOSC_TRACE_ERROR("Invalid VL-block cumulative size in chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3419|      0|          return BLOSC2_ERROR_INVALID_HEADER;
 3420|      0|        }
 3421|     30|        context->blockoffsets[i] = (int32_t)total_nbytes;
 3422|     30|        total_nbytes += context->blocknbytes[i];
 3423|     30|        if (total_nbytes > context->sourcesize) {
  ------------------
  |  Branch (3423:13): [True: 12, False: 18]
  ------------------
 3424|     12|          BLOSC_TRACE_ERROR("VL-block sizes exceed chunk nbytes.");
  ------------------
  |  |   93|     12|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     12|    do {                                            \
  |  |  |  |   98|     12|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     12|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     12|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3425|     12|          return BLOSC2_ERROR_INVALID_HEADER;
 3426|     12|        }
 3427|     18|        if (context->blocknbytes[i] > max_blocksize) {
  ------------------
  |  Branch (3427:13): [True: 18, False: 0]
  ------------------
 3428|     18|          max_blocksize = context->blocknbytes[i];
 3429|     18|        }
 3430|     18|        prev_bstart = bstart;
 3431|     18|      }
 3432|     18|      if (total_nbytes != context->sourcesize) {
  ------------------
  |  Branch (3432:11): [True: 17, False: 1]
  ------------------
 3433|     17|        BLOSC_TRACE_ERROR("VL-block sizes do not add up to chunk nbytes.");
  ------------------
  |  |   93|     17|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     17|    do {                                            \
  |  |  |  |   98|     17|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     17|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 17, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     17|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3434|     17|        return BLOSC2_ERROR_INVALID_HEADER;
 3435|     17|      }
 3436|      1|      context->blocksize = max_blocksize;
 3437|      1|      context->leftover = 0;
 3438|      1|    }
 3439|    113|  }
 3440|       |
 3441|  1.64M|  return 0;
 3442|  1.64M|}
blosc2.c:load_lazy_chunk_dict:
 3152|      6|static int load_lazy_chunk_dict(blosc2_context* context, blosc_header* header, int32_t bstarts_end) {
 3153|      6|  int32_t dict_offset = bstarts_end;
 3154|      6|  if (header->cbytes < dict_offset + (int32_t)sizeof(int32_t)) {
  ------------------
  |  Branch (3154:7): [True: 1, False: 5]
  ------------------
 3155|      1|    BLOSC_TRACE_ERROR("Lazy chunk dictionary header exceeds chunk length.");
  ------------------
  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3156|      1|    return BLOSC2_ERROR_INVALID_HEADER;
 3157|      1|  }
 3158|       |
 3159|      5|  uint8_t dict_size_buf[sizeof(int32_t)];
 3160|      5|  int rc = read_lazy_chunk_bytes(context, dict_offset, dict_size_buf, (int32_t)sizeof(dict_size_buf),
 3161|      5|                                 "Cannot open frame file for lazy chunk dictionary read.",
 3162|      5|                                 "Cannot read lazy chunk dictionary size from disk.");
 3163|      5|  if (rc < 0) {
  ------------------
  |  Branch (3163:7): [True: 5, False: 0]
  ------------------
 3164|      5|    return rc;
 3165|      5|  }
 3166|       |
 3167|      0|  context->dict_size = sw32_(dict_size_buf);
 3168|      0|  if (context->dict_size <= 0 || context->dict_size > BLOSC2_MAXDICTSIZE) {
  ------------------
  |  Branch (3168:7): [True: 0, False: 0]
  |  Branch (3168:34): [True: 0, False: 0]
  ------------------
 3169|      0|    BLOSC_TRACE_ERROR("Dictionary size is smaller than minimum or larger than maximum allowed.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3170|      0|    return BLOSC2_ERROR_CODEC_DICT;
 3171|      0|  }
 3172|      0|  if (header->cbytes < dict_offset + (int32_t)sizeof(int32_t) + context->dict_size) {
  ------------------
  |  Branch (3172:7): [True: 0, False: 0]
  ------------------
 3173|      0|    BLOSC_TRACE_ERROR("Lazy chunk dictionary exceeds chunk length.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3174|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 3175|      0|  }
 3176|       |
 3177|      0|  context->dict_buffer = malloc((size_t)context->dict_size);
 3178|      0|  BLOSC_ERROR_NULL(context->dict_buffer, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|      0|    do {                                            \
  |  |  105|      0|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3179|      0|  context->dict_buffer_owned = true;
 3180|      0|  rc = read_lazy_chunk_bytes(context, dict_offset + (int32_t)sizeof(int32_t),
 3181|      0|                             context->dict_buffer, context->dict_size,
 3182|      0|                             "Cannot open frame file for lazy chunk dictionary read.",
 3183|      0|                             "Cannot read lazy chunk dictionary from disk.");
 3184|      0|  if (rc < 0) {
  ------------------
  |  Branch (3184:7): [True: 0, False: 0]
  ------------------
 3185|      0|    release_context_dict_buffer(context);
 3186|      0|    return rc;
 3187|      0|  }
 3188|       |
 3189|      0|  context->use_dict = 1;
 3190|      0|#if defined(HAVE_ZSTD)
 3191|      0|  if (context->compcode == BLOSC_ZSTD_FORMAT) {
  ------------------
  |  Branch (3191:7): [True: 0, False: 0]
  ------------------
 3192|      0|    context->dict_ddict = ZSTD_createDDict(context->dict_buffer, context->dict_size);
 3193|      0|    if (context->dict_ddict == NULL) {
  ------------------
  |  Branch (3193:9): [True: 0, False: 0]
  ------------------
 3194|      0|      release_context_dict_buffer(context);
 3195|      0|      BLOSC_TRACE_ERROR("Cannot create ZSTD dictionary for lazy chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3196|      0|      return BLOSC2_ERROR_CODEC_DICT;
 3197|      0|    }
 3198|      0|  }
 3199|      0|#endif
 3200|       |
 3201|      0|  return 0;
 3202|      0|}
blosc2.c:do_job:
 2836|  3.40M|static int do_job(blosc2_context* context) {
 2837|  3.40M|  int32_t ntbytes;
 2838|       |
 2839|       |  /* Set sentinels */
 2840|  3.40M|  context->dref_not_init = 1;
 2841|       |
 2842|       |  /* Apply thread-count changes before deciding whether this operation actually
 2843|       |     needs a parallel backend.  POSIX defers backend startup for serial jobs.
 2844|       |     Windows keeps its existing per-context thread lifecycle and starts/rebinds
 2845|       |     the backend eagerly. */
 2846|       |#if defined(_WIN32)
 2847|       |  int rc = check_nthreads(context, true);
 2848|       |#else
 2849|  3.40M|  int rc = check_nthreads(context, false);
 2850|  3.40M|#endif
 2851|       |
 2852|       |  /* Run serially with one thread, with fewer than two full blocks of source
 2853|       |     data, or if thread configuration/backend setup fails. */
 2854|  3.40M|  if (context->nthreads == 1 || (context->sourcesize / context->blocksize) <= 1 || rc < 0) {
  ------------------
  |  Branch (2854:7): [True: 2.25M, False: 1.15M]
  |  Branch (2854:33): [True: 1.08M, False: 63.3k]
  |  Branch (2854:84): [True: 0, False: 63.3k]
  ------------------
 2855|  3.34M|    ntbytes = run_serial_job(context);
 2856|  3.34M|  }
 2857|  63.3k|  else {
 2858|  63.3k|    rc = check_nthreads(context, true);
 2859|  63.3k|    if (rc < 0) {
  ------------------
  |  Branch (2859:9): [True: 0, False: 63.3k]
  ------------------
 2860|       |      /* Backend startup failed; run serially and retry on the next parallel job. */
 2861|      0|      ntbytes = run_serial_job(context);
 2862|      0|    }
 2863|  63.3k|    else {
 2864|  63.3k|      ntbytes = parallel_blosc(context);
 2865|  63.3k|    }
 2866|  63.3k|  }
 2867|       |
 2868|  3.40M|  return ntbytes;
 2869|  3.40M|}
blosc2.c:run_serial_job:
 2824|  3.34M|static int run_serial_job(blosc2_context* context) {
 2825|  3.34M|  struct thread_context* thread_context = serial_context_get(context);
 2826|  3.34M|  if (thread_context == NULL) {
  ------------------
  |  Branch (2826:7): [True: 0, False: 3.34M]
  ------------------
 2827|      0|    return BLOSC2_ERROR_THREAD_CREATE;
 2828|      0|  }
 2829|  3.34M|  int ntbytes = serial_blosc(thread_context);
 2830|  3.34M|  serial_context_put(thread_context);
 2831|  3.34M|  return ntbytes;
 2832|  3.34M|}
blosc2.c:serial_blosc:
 2571|  3.34M|static int serial_blosc(struct thread_context* thread_context) {
 2572|  3.34M|  blosc2_context* context = thread_context->parent_context;
 2573|  3.34M|  bool vlblocks = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0;
 2574|  3.34M|  int32_t j, bsize, leftoverblock;
 2575|  3.34M|  int32_t cbytes;
 2576|  3.34M|  int32_t ntbytes = context->output_bytes;
 2577|  3.34M|  int32_t* bstarts = context->bstarts;
 2578|  3.34M|  uint8_t* tmp = thread_context->tmp;
 2579|  3.34M|  uint8_t* tmp2 = thread_context->tmp2;
 2580|  3.34M|  int dict_training = context->use_dict && (context->dict_cdict == NULL);
  ------------------
  |  Branch (2580:23): [True: 140, False: 3.34M]
  |  Branch (2580:44): [True: 140, False: 0]
  ------------------
 2581|  3.34M|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 2582|  3.34M|  if (!context->do_compress && context->special_type) {
  ------------------
  |  Branch (2582:7): [True: 1.64M, False: 1.70M]
  |  Branch (2582:32): [True: 21.0k, False: 1.62M]
  ------------------
 2583|       |    // Fake a runlen as if it was a memcpyed chunk
 2584|  21.0k|    memcpyed = true;
 2585|  21.0k|  }
 2586|       |
 2587|  16.8M|  for (j = 0; j < context->nblocks; j++) {
  ------------------
  |  Branch (2587:15): [True: 13.4M, False: 3.33M]
  ------------------
 2588|  13.4M|    if (context->do_compress && !memcpyed && !dict_training) {
  ------------------
  |  Branch (2588:9): [True: 7.49M, False: 5.98M]
  |  Branch (2588:33): [True: 6.80M, False: 690k]
  |  Branch (2588:46): [True: 6.80M, False: 0]
  ------------------
 2589|  6.80M|      _sw32(bstarts + j, ntbytes);
 2590|  6.80M|    }
 2591|  13.4M|    bsize = vlblocks ? context->blocknbytes[j] : context->blocksize;
  ------------------
  |  Branch (2591:13): [True: 5, False: 13.4M]
  ------------------
 2592|  13.4M|    leftoverblock = 0;
 2593|  13.4M|    if (!vlblocks && (j == context->nblocks - 1) && (context->leftover > 0)) {
  ------------------
  |  Branch (2593:9): [True: 13.4M, False: 5]
  |  Branch (2593:22): [True: 3.34M, False: 10.1M]
  |  Branch (2593:53): [True: 255k, False: 3.08M]
  ------------------
 2594|   255k|      bsize = context->leftover;
 2595|   255k|      leftoverblock = 1;
 2596|   255k|    }
 2597|  13.4M|    if (context->do_compress) {
  ------------------
  |  Branch (2597:9): [True: 7.49M, False: 5.98M]
  ------------------
 2598|  7.49M|      if (memcpyed && !context->prefilter) {
  ------------------
  |  Branch (2598:11): [True: 690k, False: 6.80M]
  |  Branch (2598:23): [True: 46.0k, False: 644k]
  ------------------
 2599|       |        /* We want to memcpy only */
 2600|  46.0k|        memcpy(context->dest + context->header_overhead + j * context->blocksize,
 2601|  46.0k|               context->src + j * context->blocksize, (unsigned int)bsize);
 2602|  46.0k|        cbytes = (int32_t)bsize;
 2603|  46.0k|      }
 2604|  7.45M|      else {
 2605|       |        /* Regular compression */
 2606|  7.45M|        cbytes = blosc_c(thread_context, bsize, leftoverblock, ntbytes,
 2607|  7.45M|                         context->destsize,
 2608|  7.45M|                         vlblocks ? context->vlblock_sources[j] : context->src,
  ------------------
  |  Branch (2608:26): [True: 0, False: 7.45M]
  ------------------
 2609|  7.45M|                         vlblocks ? 0 : j * context->blocksize,
  ------------------
  |  Branch (2609:26): [True: 0, False: 7.45M]
  ------------------
 2610|  7.45M|                         context->dest + ntbytes, tmp, tmp2);
 2611|  7.45M|        if (cbytes == 0) {
  ------------------
  |  Branch (2611:13): [True: 7.05k, False: 7.44M]
  ------------------
 2612|  7.05k|          ntbytes = 0;              /* incompressible data */
 2613|  7.05k|          break;
 2614|  7.05k|        }
 2615|  7.45M|      }
 2616|  7.49M|    }
 2617|  5.98M|    else {
 2618|       |      /* Regular decompression */
 2619|       |      // If memcpyed we don't have a bstarts section (because it is not needed)
 2620|  5.98M|      int32_t src_offset = memcpyed ?
  ------------------
  |  Branch (2620:28): [True: 2.89M, False: 3.09M]
  ------------------
 2621|  3.09M|          context->header_overhead + j * context->blocksize : sw32_(bstarts + j);
 2622|  5.98M|      uint8_t *dest_block = (vlblocks && context->vlblock_dests != NULL) ? context->vlblock_dests[j] : context->dest;
  ------------------
  |  Branch (2622:30): [True: 5, False: 5.98M]
  |  Branch (2622:42): [True: 0, False: 5]
  ------------------
 2623|  5.98M|      int32_t dest_offset = (vlblocks && context->vlblock_dests != NULL) ? 0 :
  ------------------
  |  Branch (2623:30): [True: 5, False: 5.98M]
  |  Branch (2623:42): [True: 0, False: 5]
  ------------------
 2624|  5.98M|                            (vlblocks ? context->blockoffsets[j] : j * context->blocksize);
  ------------------
  |  Branch (2624:30): [True: 5, False: 5.98M]
  ------------------
 2625|  5.98M|      cbytes = blosc_d(thread_context, bsize, leftoverblock, memcpyed,
 2626|  5.98M|                       context->src, context->srcsize, src_offset, j,
 2627|  5.98M|                       dest_block, dest_offset, tmp, tmp2);
 2628|  5.98M|    }
 2629|       |
 2630|  13.4M|    if (cbytes < 0) {
  ------------------
  |  Branch (2630:9): [True: 636, False: 13.4M]
  ------------------
 2631|    636|      ntbytes = cbytes;         /* error in blosc_c or blosc_d */
 2632|    636|      break;
 2633|    636|    }
 2634|  13.4M|    ntbytes += cbytes;
 2635|  13.4M|  }
 2636|       |
 2637|  3.34M|  return ntbytes;
 2638|  3.34M|}
blosc2.c:blosc_c:
 1579|  7.63M|                   uint8_t* tmp, uint8_t* tmp2) {
 1580|  7.63M|  blosc2_context* context = thread_context->parent_context;
 1581|  7.63M|  int dont_split = (context->header_flags & 0x10) >> 4;
 1582|  7.63M|  bool vlblocks = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0;
 1583|  7.63M|  int dict_training = context->use_dict && context->dict_cdict == NULL;
  ------------------
  |  Branch (1583:23): [True: 0, False: 7.63M]
  |  Branch (1583:44): [True: 0, False: 0]
  ------------------
 1584|  7.63M|  int32_t j, neblock, nstreams;
 1585|  7.63M|  int32_t cbytes;                   /* number of compressed bytes in split */
 1586|  7.63M|  int32_t ctbytes = 0;              /* number of compressed bytes in block */
 1587|  7.63M|  int32_t maxout;
 1588|  7.63M|  int32_t typesize = context->typesize;
 1589|  7.63M|  bool output_is_disposable = (context->preparams != NULL) ? context->preparams->output_is_disposable : false;
  ------------------
  |  Branch (1589:31): [True: 6.10M, False: 1.52M]
  ------------------
 1590|  7.63M|  const char* compname;
 1591|  7.63M|  int accel;
 1592|  7.63M|  const uint8_t* _src;
 1593|  7.63M|  uint8_t *_tmp = tmp, *_tmp2 = tmp2;
 1594|  7.63M|  int last_filter_index = last_filter(context, 'c');
 1595|  7.63M|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 1596|  7.63M|  bool instr_codec = context->blosc2_flags & BLOSC2_INSTR_CODEC;
 1597|  7.63M|  blosc_timestamp_t last, current;
 1598|  7.63M|  float filter_time = 0.f;
 1599|       |
 1600|  7.63M|  if (instr_codec) {
  ------------------
  |  Branch (1600:7): [True: 0, False: 7.63M]
  ------------------
 1601|      0|    blosc_set_timestamp(&last);
 1602|      0|  }
 1603|       |
 1604|       |  // See whether we have a run here
 1605|  7.63M|  if (last_filter_index >= 0 || context->prefilter != NULL) {
  ------------------
  |  Branch (1605:7): [True: 2.14M, False: 5.48M]
  |  Branch (1605:33): [True: 5.40M, False: 79.5k]
  ------------------
 1606|       |    /* Apply the filter pipeline just for the prefilter */
 1607|  7.54M|    if (memcpyed && context->prefilter != NULL) {
  ------------------
  |  Branch (1607:9): [True: 644k, False: 6.89M]
  |  Branch (1607:21): [True: 644k, False: 0]
  ------------------
 1608|       |      // We only need the prefilter output
 1609|   644k|      _src = pipeline_forward(thread_context, bsize, src, offset, dest, _tmp2);
 1610|   644k|      if (_src == NULL) {
  ------------------
  |  Branch (1610:11): [True: 0, False: 644k]
  ------------------
 1611|      0|        return BLOSC2_ERROR_FILTER_PIPELINE;
 1612|      0|      }
 1613|   644k|      return bsize;
 1614|   644k|    }
 1615|       |    /* Apply regular filter pipeline */
 1616|  6.89M|    _src = pipeline_forward(thread_context, bsize, src, offset, _tmp, _tmp2);
 1617|  6.89M|    if (_src == NULL) {
  ------------------
  |  Branch (1617:9): [True: 0, False: 6.89M]
  ------------------
 1618|      0|      return BLOSC2_ERROR_FILTER_PIPELINE;
 1619|      0|    }
 1620|  6.89M|  } else {
 1621|  90.2k|    _src = src + offset;
 1622|  90.2k|  }
 1623|       |
 1624|  6.98M|  if (instr_codec) {
  ------------------
  |  Branch (1624:7): [True: 0, False: 6.98M]
  ------------------
 1625|      0|    blosc_set_timestamp(&current);
 1626|      0|    filter_time = (float) blosc_elapsed_secs(last, current);
 1627|      0|    last = current;
 1628|      0|  }
 1629|       |
 1630|  6.98M|  assert(context->clevel > 0);
 1631|       |
 1632|       |  /* Calculate acceleration for different compressors */
 1633|  6.98M|  accel = get_accel(context);
 1634|       |
 1635|       |  /* The number of compressed data streams for this block */
 1636|  6.98M|  if (!dont_split && !leftoverblock && !dict_training) {
  ------------------
  |  Branch (1636:7): [True: 2.48M, False: 4.50M]
  |  Branch (1636:22): [True: 2.48M, False: 0]
  |  Branch (1636:40): [True: 2.48M, False: 0]
  ------------------
 1637|  2.48M|    nstreams = (int32_t)typesize;
 1638|  2.48M|  }
 1639|  4.50M|  else {
 1640|  4.50M|    nstreams = 1;
 1641|  4.50M|  }
 1642|  6.98M|  neblock = bsize / nstreams;
 1643|  13.9M|  for (j = 0; j < nstreams; j++) {
  ------------------
  |  Branch (1643:15): [True: 6.99M, False: 6.98M]
  ------------------
 1644|  6.99M|    if (instr_codec) {
  ------------------
  |  Branch (1644:9): [True: 0, False: 6.99M]
  ------------------
 1645|      0|      blosc_set_timestamp(&last);
 1646|      0|    }
 1647|  6.99M|    if (!dict_training) {
  ------------------
  |  Branch (1647:9): [True: 6.99M, False: 18.4E]
  ------------------
 1648|  6.99M|      dest += sizeof(int32_t);
 1649|  6.99M|      ntbytes += sizeof(int32_t);
 1650|  6.99M|      ctbytes += sizeof(int32_t);
 1651|       |
 1652|  6.99M|      if (!vlblocks && context->header_overhead == BLOSC_EXTENDED_HEADER_LENGTH && output_is_disposable) {
  ------------------
  |  Branch (1652:11): [True: 6.99M, False: 21]
  |  Branch (1652:24): [True: 6.99M, False: 18.4E]
  |  Branch (1652:84): [True: 0, False: 6.99M]
  ------------------
 1653|       |        // Simulate a run of 0s
 1654|      0|        memset(dest - 4, 0, sizeof(int32_t));
 1655|      0|        continue;
 1656|      0|      }
 1657|       |
 1658|  6.99M|      const uint8_t *ip = (uint8_t *) _src + j * neblock;
 1659|  6.99M|      const uint8_t *ipbound = (uint8_t *) _src + (j + 1) * neblock;
 1660|       |
 1661|  6.99M|      if (!vlblocks && context->header_overhead == BLOSC_EXTENDED_HEADER_LENGTH && get_run(ip, ipbound)) {
  ------------------
  |  Branch (1661:11): [True: 6.99M, False: 18]
  |  Branch (1661:24): [True: 6.99M, False: 5]
  |  Branch (1661:84): [True: 5.04M, False: 1.95M]
  ------------------
 1662|       |        // A run
 1663|  5.04M|        int32_t value = _src[j * neblock];
 1664|  5.04M|        if (ntbytes > destsize) {
  ------------------
  |  Branch (1664:13): [True: 579, False: 5.03M]
  ------------------
 1665|    579|          return 0;    /* Non-compressible data */
 1666|    579|        }
 1667|       |
 1668|  5.03M|        if (instr_codec) {
  ------------------
  |  Branch (1668:13): [True: 0, False: 5.03M]
  ------------------
 1669|      0|          blosc_set_timestamp(&current);
 1670|      0|          int32_t instr_size = sizeof(blosc2_instr);
 1671|      0|          ntbytes += instr_size;
 1672|      0|          ctbytes += instr_size;
 1673|      0|          if (ntbytes > destsize) {
  ------------------
  |  Branch (1673:15): [True: 0, False: 0]
  ------------------
 1674|      0|            return 0;    /* Non-compressible data */
 1675|      0|          }
 1676|      0|          _sw32(dest - 4, instr_size);
 1677|      0|          blosc2_instr *desti = (blosc2_instr *)dest;
 1678|      0|          memset(desti, 0, sizeof(blosc2_instr));
 1679|       |          // Special values have an overhead of about 1 int32
 1680|      0|          int32_t ssize = value == 0 ? sizeof(int32_t) : sizeof(int32_t) + 1;
  ------------------
  |  Branch (1680:27): [True: 0, False: 0]
  ------------------
 1681|      0|          desti->cratio = (float) neblock / (float) ssize;
 1682|      0|          float ctime = (float) blosc_elapsed_secs(last, current);
 1683|      0|          desti->cspeed = (float) neblock / ctime;
 1684|      0|          desti->filter_speed = (float) neblock / filter_time;
 1685|      0|          desti->flags[0] = 1;    // mark a runlen
 1686|      0|          dest += instr_size;
 1687|      0|          continue;
 1688|      0|        }
 1689|       |
 1690|       |        // Encode the repeated byte in the first (LSB) byte of the length of the split.
 1691|  5.03M|        _sw32(dest - 4, -value);    // write the value in two's complement
 1692|  5.03M|        if (value > 0) {
  ------------------
  |  Branch (1692:13): [True: 2.77k, False: 5.03M]
  ------------------
 1693|       |          // Mark encoding as a run-length (== 0 is always a 0's run)
 1694|  2.77k|          ntbytes += 1;
 1695|  2.77k|          ctbytes += 1;
 1696|  2.77k|          if (ntbytes > destsize) {
  ------------------
  |  Branch (1696:15): [True: 1, False: 2.77k]
  ------------------
 1697|      1|            return 0;    /* Non-compressible data */
 1698|      1|          }
 1699|       |          // Set MSB bit (sign) to 1 (not really necessary here, but for demonstration purposes)
 1700|       |          // dest[-1] |= 0x80;
 1701|  2.77k|          dest[0] = 0x1;   // set run-length bit (0) in token
 1702|  2.77k|          dest += 1;
 1703|  2.77k|        }
 1704|  5.03M|        continue;
 1705|  5.03M|      }
 1706|  6.99M|    }
 1707|       |
 1708|  1.95M|    maxout = neblock;
 1709|  1.95M|    if (ntbytes + maxout > destsize && !instr_codec) {
  ------------------
  |  Branch (1709:9): [True: 1.01M, False: 945k]
  |  Branch (1709:40): [True: 1.01M, False: 0]
  ------------------
 1710|       |      /* avoid buffer * overrun */
 1711|  1.01M|      maxout = destsize - ntbytes;
 1712|  1.01M|      if (maxout <= 0) {
  ------------------
  |  Branch (1712:11): [True: 480, False: 1.01M]
  ------------------
 1713|    480|        return 0;                  /* non-compressible block */
 1714|    480|      }
 1715|  1.01M|    }
 1716|  1.95M|    if (dict_training) {
  ------------------
  |  Branch (1716:9): [True: 0, False: 1.95M]
  ------------------
 1717|       |      // We are in the build dict state, so don't compress
 1718|       |      // TODO: copy only a percentage for sampling
 1719|      0|      memcpy(dest, _src + j * neblock, (unsigned int)neblock);
 1720|      0|      cbytes = (int32_t)neblock;
 1721|      0|    }
 1722|  1.95M|    else if (context->compcode == BLOSC_BLOSCLZ) {
  ------------------
  |  Branch (1722:14): [True: 1.95M, False: 23]
  ------------------
 1723|  1.95M|      if (thread_context->blosclz_state == NULL) {
  ------------------
  |  Branch (1723:11): [True: 1.55k, False: 1.95M]
  ------------------
 1724|  1.55k|        thread_context->blosclz_state = calloc(1, sizeof(blosclz_state));
 1725|  1.55k|      }
 1726|  1.95M|      cbytes = thread_context->blosclz_state != NULL ?
  ------------------
  |  Branch (1726:16): [True: 1.95M, False: 24]
  ------------------
 1727|  1.95M|               blosclz_compress_state(context->clevel, _src + j * neblock, (int)neblock,
 1728|  1.95M|                                      dest, maxout, thread_context->blosclz_state) :
 1729|  1.95M|               blosclz_compress(context->clevel, _src + j * neblock, (int)neblock,
 1730|     24|                                dest, maxout, context);
 1731|  1.95M|    }
 1732|     23|    else if (context->compcode == BLOSC_LZ4) {
  ------------------
  |  Branch (1732:14): [True: 0, False: 23]
  ------------------
 1733|      0|      cbytes = lz4_wrap_compress((char*)_src + j * neblock, (size_t)neblock,
 1734|      0|                                 (char*)dest, (size_t)maxout, accel,
 1735|      0|                                 thread_context);
 1736|      0|    }
 1737|     23|    else if (context->compcode == BLOSC_LZ4HC) {
  ------------------
  |  Branch (1737:14): [True: 0, False: 23]
  ------------------
 1738|      0|      cbytes = lz4hc_wrap_compress((char*)_src + j * neblock, (size_t)neblock,
 1739|      0|                                   (char*)dest, (size_t)maxout, context->clevel,
 1740|      0|                                   thread_context);
 1741|      0|    }
 1742|     23|  #if defined(HAVE_ZLIB)
 1743|     23|    else if (context->compcode == BLOSC_ZLIB) {
  ------------------
  |  Branch (1743:14): [True: 0, False: 23]
  ------------------
 1744|      0|      cbytes = zlib_wrap_compress((char*)_src + j * neblock, (size_t)neblock,
 1745|      0|                                  (char*)dest, (size_t)maxout, context->clevel);
 1746|      0|    }
 1747|     23|  #endif /* HAVE_ZLIB */
 1748|     23|  #if defined(HAVE_ZSTD)
 1749|     23|    else if (context->compcode == BLOSC_ZSTD) {
  ------------------
  |  Branch (1749:14): [True: 0, False: 23]
  ------------------
 1750|      0|      cbytes = zstd_wrap_compress(thread_context,
 1751|      0|                                  (char*)_src + j * neblock, (size_t)neblock,
 1752|      0|                                  (char*)dest, (size_t)maxout, context->clevel);
 1753|      0|    }
 1754|     23|  #endif /* HAVE_ZSTD */
 1755|     23|    else if (context->compcode > BLOSC2_DEFINED_CODECS_STOP) {
  ------------------
  |  Branch (1755:14): [True: 0, False: 23]
  ------------------
 1756|      0|      for (int i = 0; i < g_ncodecs; ++i) {
  ------------------
  |  Branch (1756:23): [True: 0, False: 0]
  ------------------
 1757|      0|        if (g_codecs[i].compcode == context->compcode) {
  ------------------
  |  Branch (1757:13): [True: 0, False: 0]
  ------------------
 1758|      0|          if (load_acquire_ptr(&g_codecs[i].decoder) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (1758:15): [True: 0, False: 0]
  ------------------
 1759|       |            // Dynamically load codec plugin
 1760|      0|            if (fill_codec(&g_codecs[i]) < 0) {
  ------------------
  |  Branch (1760:17): [True: 0, False: 0]
  ------------------
 1761|      0|              BLOSC_TRACE_ERROR("Could not load codec %d.", g_codecs[i].compcode);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1762|      0|              return BLOSC2_ERROR_CODEC_SUPPORT;
 1763|      0|            }
 1764|      0|          }
 1765|      0|          blosc2_cparams cparams;
 1766|      0|          blosc2_ctx_get_cparams(context, &cparams);
 1767|      0|          cbytes = g_codecs[i].encoder(_src + j * neblock,
 1768|      0|                                        neblock,
 1769|      0|                                        dest,
 1770|      0|                                        maxout,
 1771|      0|                                        context->compcode_meta,
 1772|      0|                                        &cparams,
 1773|      0|                                        context->src);
 1774|      0|          goto urcodecsuccess;
 1775|      0|        }
 1776|      0|      }
 1777|      0|      BLOSC_TRACE_ERROR("User-defined compressor codec %d not found during compression", context->compcode);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1778|      0|      return BLOSC2_ERROR_CODEC_SUPPORT;
 1779|      0|    urcodecsuccess:
 1780|      0|      ;
 1781|     23|    } else {
 1782|     23|      blosc2_compcode_to_compname(context->compcode, &compname);
 1783|     23|      BLOSC_TRACE_ERROR("Blosc has not been compiled with '%s' compression support."
  ------------------
  |  |   93|     23|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     23|    do {                                            \
  |  |  |  |   98|     23|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     23|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 23]
  |  |  |  |  ------------------
  |  |  |  |  100|     23|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|     23|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1784|     23|                        "Please use one having it.", compname);
 1785|     23|      return BLOSC2_ERROR_CODEC_SUPPORT;
 1786|     23|    }
 1787|       |
 1788|  1.95M|    if (cbytes > maxout) {
  ------------------
  |  Branch (1788:9): [True: 0, False: 1.95M]
  ------------------
 1789|       |      /* Buffer overrun caused by compression (should never happen) */
 1790|      0|      return BLOSC2_ERROR_WRITE_BUFFER;
 1791|      0|    }
 1792|  1.95M|    if (cbytes < 0) {
  ------------------
  |  Branch (1792:9): [True: 0, False: 1.95M]
  ------------------
 1793|       |      /* cbytes should never be negative */
 1794|      0|      return BLOSC2_ERROR_DATA;
 1795|      0|    }
 1796|  1.95M|    if (cbytes == 0) {
  ------------------
  |  Branch (1796:9): [True: 131k, False: 1.82M]
  ------------------
 1797|       |      // When cbytes is 0, the compressor has not been able to compress anything
 1798|   131k|      cbytes = neblock;
 1799|   131k|    }
 1800|       |
 1801|  1.95M|    if (instr_codec) {
  ------------------
  |  Branch (1801:9): [True: 0, False: 1.95M]
  ------------------
 1802|      0|      blosc_set_timestamp(&current);
 1803|      0|      int32_t instr_size = sizeof(blosc2_instr);
 1804|      0|      ntbytes += instr_size;
 1805|      0|      ctbytes += instr_size;
 1806|      0|      if (ntbytes > destsize) {
  ------------------
  |  Branch (1806:11): [True: 0, False: 0]
  ------------------
 1807|      0|        return 0;    /* Non-compressible data */
 1808|      0|      }
 1809|      0|      _sw32(dest - 4, vlblocks ? neblock : instr_size);
  ------------------
  |  Branch (1809:23): [True: 0, False: 0]
  ------------------
 1810|      0|      float ctime = (float)blosc_elapsed_secs(last, current);
 1811|      0|      blosc2_instr *desti = (blosc2_instr *)dest;
 1812|      0|      memset(desti, 0, sizeof(blosc2_instr));
 1813|       |      // cratio is computed having into account 1 additional int (csize)
 1814|      0|      desti->cratio = (float)neblock / (float)(cbytes + sizeof(int32_t));
 1815|      0|      desti->cspeed = (float)neblock / ctime;
 1816|      0|      desti->filter_speed = (float) neblock / filter_time;
 1817|      0|      dest += instr_size;
 1818|      0|      continue;
 1819|      0|    }
 1820|       |
 1821|  1.95M|    if (!dict_training) {
  ------------------
  |  Branch (1821:9): [True: 1.95M, False: 52]
  ------------------
 1822|  1.95M|      if (cbytes == neblock) {
  ------------------
  |  Branch (1822:11): [True: 131k, False: 1.82M]
  ------------------
 1823|       |        /* The compressor has been unable to compress data at all. */
 1824|       |        /* Before doing the copy, check that we are not running into a
 1825|       |           buffer overflow. */
 1826|   131k|        if ((ntbytes + neblock) > destsize) {
  ------------------
  |  Branch (1826:13): [True: 5.99k, False: 125k]
  ------------------
 1827|  5.99k|          return 0;    /* Non-compressible data */
 1828|  5.99k|        }
 1829|   125k|        memcpy(dest, _src + j * neblock, (unsigned int)neblock);
 1830|   125k|        cbytes = neblock;
 1831|   125k|      }
 1832|  1.95M|      _sw32(dest - 4, vlblocks ? neblock : cbytes);
  ------------------
  |  Branch (1832:23): [True: 0, False: 1.95M]
  ------------------
 1833|  1.95M|    }
 1834|  1.95M|    dest += cbytes;
 1835|  1.95M|    ntbytes += cbytes;
 1836|  1.95M|    ctbytes += cbytes;
 1837|  1.95M|  }  /* Closes j < nstreams */
 1838|       |
 1839|  6.98M|  return ctbytes;
 1840|  6.98M|}
blosc2.c:get_accel:
  777|  6.98M|static int get_accel(const blosc2_context* context) {
  778|  6.98M|  int clevel = context->clevel;
  779|       |
  780|  6.98M|  if (context->compcode == BLOSC_LZ4) {
  ------------------
  |  Branch (780:7): [True: 0, False: 6.98M]
  ------------------
  781|       |    /* This acceleration setting based on discussions held in:
  782|       |     * https://groups.google.com/forum/#!topic/lz4c/zosy90P8MQw
  783|       |     */
  784|      0|    return (10 - clevel);
  785|      0|  }
  786|  6.98M|  return 1;
  787|  6.98M|}
blosc2.c:get_run:
 1482|  6.99M|static bool get_run(const uint8_t* ip, const uint8_t* ip_bound) {
 1483|  6.99M|  uint8_t x = *ip;
 1484|  6.99M|  int64_t value, value2;
 1485|       |  /* Broadcast the value for every byte in a 64-bit register */
 1486|  6.99M|  memset(&value, x, 8);
 1487|  6.99M|#if defined(BLOSC_RUN_SSE2) || defined(BLOSC_RUN_NEON)
 1488|  6.99M|  if (ip_bound - ip >= 64) {
  ------------------
  |  Branch (1488:7): [True: 4.28M, False: 2.70M]
  ------------------
 1489|       |    /* Streams that are not runs mostly differ in their first bytes */
 1490|  4.28M|    memcpy(&value2, ip, 8);
 1491|  4.28M|    if (value != value2) {
  ------------------
  |  Branch (1491:9): [True: 1.29M, False: 2.99M]
  ------------------
 1492|  1.29M|      return false;
 1493|  1.29M|    }
 1494|  4.28M|  }
 1495|  5.70M|#endif
 1496|  5.70M|#if defined(BLOSCLZ_AVX2_ENABLED)
 1497|  5.70M|  if (ip_bound - ip >= 128 && blosc_cpu_has_avx2()) {
  ------------------
  |  Branch (1497:7): [True: 1.68M, False: 4.01M]
  |  Branch (1497:31): [True: 1.68M, False: 9]
  ------------------
 1498|  1.68M|    return blosc_get_run_avx2(ip, ip_bound);
 1499|  1.68M|  }
 1500|  4.01M|#endif
 1501|  4.01M|#if defined(BLOSC_RUN_SSE2)
 1502|  4.01M|  const __m128i vx = _mm_set1_epi8((char)x);
 1503|  5.27M|  while (ip_bound - ip >= 64) {
  ------------------
  |  Branch (1503:10): [True: 1.30M, False: 3.96M]
  ------------------
 1504|  1.30M|    const __m128i* p = (const __m128i*)ip;
 1505|  1.30M|    __m128i eq01 = _mm_and_si128(_mm_cmpeq_epi8(_mm_loadu_si128(p), vx),
 1506|  1.30M|                                 _mm_cmpeq_epi8(_mm_loadu_si128(p + 1), vx));
 1507|  1.30M|    __m128i eq23 = _mm_and_si128(_mm_cmpeq_epi8(_mm_loadu_si128(p + 2), vx),
 1508|  1.30M|                                 _mm_cmpeq_epi8(_mm_loadu_si128(p + 3), vx));
 1509|  1.30M|    if (_mm_movemask_epi8(_mm_and_si128(eq01, eq23)) != 0xFFFF) {
  ------------------
  |  Branch (1509:9): [True: 46.9k, False: 1.26M]
  ------------------
 1510|  46.9k|      return false;
 1511|  46.9k|    }
 1512|  1.26M|    ip += 64;
 1513|  1.26M|  }
 1514|       |#elif defined(BLOSC_RUN_NEON)
 1515|       |  if (x == 0) {
 1516|       |    while (ip_bound - ip >= 128) {
 1517|       |      uint8x16_t d01 = vorrq_u8(vld1q_u8(ip), vld1q_u8(ip + 16));
 1518|       |      uint8x16_t d23 = vorrq_u8(vld1q_u8(ip + 32), vld1q_u8(ip + 48));
 1519|       |      uint8x16_t d45 = vorrq_u8(vld1q_u8(ip + 64), vld1q_u8(ip + 80));
 1520|       |      uint8x16_t d67 = vorrq_u8(vld1q_u8(ip + 96), vld1q_u8(ip + 112));
 1521|       |      if (vmaxvq_u32(vreinterpretq_u32_u8(vorrq_u8(vorrq_u8(d01, d23),
 1522|       |                                                  vorrq_u8(d45, d67)))) != 0) {
 1523|       |        return false;
 1524|       |      }
 1525|       |      ip += 128;
 1526|       |    }
 1527|       |    if (ip_bound - ip >= 64) {
 1528|       |      uint8x16_t d01 = vorrq_u8(vld1q_u8(ip), vld1q_u8(ip + 16));
 1529|       |      uint8x16_t d23 = vorrq_u8(vld1q_u8(ip + 32), vld1q_u8(ip + 48));
 1530|       |      if (vmaxvq_u32(vreinterpretq_u32_u8(vorrq_u8(d01, d23))) != 0) {
 1531|       |        return false;
 1532|       |      }
 1533|       |      ip += 64;
 1534|       |    }
 1535|       |  }
 1536|       |  else {
 1537|       |    const uint8x16_t vx = vdupq_n_u8(x);
 1538|       |    while (ip_bound - ip >= 128) {
 1539|       |      uint8x16_t d01 = vorrq_u8(veorq_u8(vld1q_u8(ip), vx), veorq_u8(vld1q_u8(ip + 16), vx));
 1540|       |      uint8x16_t d23 = vorrq_u8(veorq_u8(vld1q_u8(ip + 32), vx), veorq_u8(vld1q_u8(ip + 48), vx));
 1541|       |      uint8x16_t d45 = vorrq_u8(veorq_u8(vld1q_u8(ip + 64), vx), veorq_u8(vld1q_u8(ip + 80), vx));
 1542|       |      uint8x16_t d67 = vorrq_u8(veorq_u8(vld1q_u8(ip + 96), vx), veorq_u8(vld1q_u8(ip + 112), vx));
 1543|       |      if (vmaxvq_u32(vreinterpretq_u32_u8(vorrq_u8(vorrq_u8(d01, d23),
 1544|       |                                                  vorrq_u8(d45, d67)))) != 0) {
 1545|       |        return false;
 1546|       |      }
 1547|       |      ip += 128;
 1548|       |    }
 1549|       |    if (ip_bound - ip >= 64) {
 1550|       |      uint8x16_t d01 = vorrq_u8(veorq_u8(vld1q_u8(ip), vx), veorq_u8(vld1q_u8(ip + 16), vx));
 1551|       |      uint8x16_t d23 = vorrq_u8(veorq_u8(vld1q_u8(ip + 32), vx), veorq_u8(vld1q_u8(ip + 48), vx));
 1552|       |      if (vmaxvq_u32(vreinterpretq_u32_u8(vorrq_u8(d01, d23))) != 0) {
 1553|       |        return false;
 1554|       |      }
 1555|       |      ip += 64;
 1556|       |    }
 1557|       |  }
 1558|       |#endif
 1559|  10.7M|  while (ip < (ip_bound - 8)) {
  ------------------
  |  Branch (1559:10): [True: 6.83M, False: 3.88M]
  ------------------
 1560|  6.83M|    memcpy(&value2, ip, 8);
 1561|  6.83M|    if (value != value2) {
  ------------------
  |  Branch (1561:9): [True: 87.0k, False: 6.75M]
  ------------------
 1562|       |      // Values differ.  We don't have a run.
 1563|  87.0k|      return false;
 1564|  87.0k|    }
 1565|  6.75M|    else {
 1566|  6.75M|      ip += 8;
 1567|  6.75M|    }
 1568|  6.83M|  }
 1569|       |  /* Look into the remainder */
 1570|  19.9M|  while ((ip < ip_bound) && (*ip == x)) ip++;
  ------------------
  |  Branch (1570:10): [True: 16.1M, False: 3.86M]
  |  Branch (1570:29): [True: 16.1M, False: 14.3k]
  ------------------
 1571|  3.88M|  return ip == ip_bound ? true : false;
  ------------------
  |  Branch (1571:10): [True: 3.86M, False: 14.2k]
  ------------------
 1572|  3.96M|}
blosc2.c:parallel_blosc:
 6254|  63.3k|static int parallel_blosc(blosc2_context* context) {
 6255|       |#if defined(_WIN32)
 6256|       |  /* Windows: per-context threads using WAIT_INIT/WAIT_FINISH barriers.
 6257|       |   * No job-group struct; workers read/write context fields directly. */
 6258|       |  context->job = NULL;
 6259|       |  context->thread_giveup_code = 1;
 6260|       |  context->thread_nblock = -1;
 6261|       |
 6262|       |  if (context->thread_backend == BLOSC_BACKEND_CALLBACK) {
 6263|       |    threads_callback(threads_callback_data, t_blosc_do_job,
 6264|       |                     context->nthreads, sizeof(struct thread_context), (void*) context->thread_contexts);
 6265|       |  }
 6266|       |  else {
 6267|       |    /* BLOSC_BACKEND_PER_CONTEXT: post job to sleeping workers and wait. */
 6268|       |    blosc2_pthread_mutex_lock(&context->jobs_mutex);
 6269|       |    context->active_workers = context->nthreads;
 6270|       |    context->job_seq++;
 6271|       |    blosc2_pthread_cond_broadcast(&context->jobs_ready);
 6272|       |    while (context->active_workers > 0) {
 6273|       |      blosc2_pthread_cond_wait(&context->jobs_done, &context->jobs_mutex);
 6274|       |    }
 6275|       |    blosc2_pthread_mutex_unlock(&context->jobs_mutex);
 6276|       |  }
 6277|       |
 6278|       |  if (context->thread_giveup_code <= 0) {
 6279|       |    return context->thread_giveup_code;
 6280|       |  }
 6281|       |  return (int)context->output_bytes;
 6282|       |
 6283|       |#else  /* !_WIN32 */
 6284|       |
 6285|  63.3k|  struct blosc_job_group job;
 6286|       |
 6287|  63.3k|  job_group_init(&job, context);
 6288|  63.3k|  context->job = &job;
 6289|       |
 6290|  63.3k|  if (context->thread_backend == BLOSC_BACKEND_CALLBACK) {
  ------------------
  |  |   35|  63.3k|#define BLOSC_BACKEND_CALLBACK 2
  ------------------
  |  Branch (6290:7): [True: 0, False: 63.3k]
  ------------------
 6291|      0|    job.active_workers = context->nthreads;
 6292|      0|    job.pending_workers = 0;
 6293|      0|    threads_callback(threads_callback_data, t_blosc_do_job,
 6294|      0|                     context->nthreads, sizeof(struct thread_context), (void*) context->thread_contexts);
 6295|      0|  }
 6296|  63.3k|  else {
 6297|  63.3k|    struct blosc_shared_pool *pool = context->thread_pool;
 6298|       |    /* More workers than blocks cannot add useful parallel work. */
 6299|  63.3k|    int32_t workers = context->nthreads < context->nblocks ? context->nthreads : context->nblocks;
  ------------------
  |  Branch (6299:23): [True: 0, False: 63.3k]
  ------------------
 6300|  63.3k|    if (workers > 0) {
  ------------------
  |  Branch (6300:9): [True: 63.3k, False: 0]
  ------------------
 6301|  63.3k|      struct thread_context *main_thcontext = serial_context_get(context);
 6302|  63.3k|      if (main_thcontext == NULL) {
  ------------------
  |  Branch (6302:11): [True: 0, False: 63.3k]
  ------------------
 6303|      0|        context->job = NULL;
 6304|      0|        job_group_destroy(&job);
 6305|      0|        return BLOSC2_ERROR_MEMORY_ALLOC;
 6306|      0|      }
 6307|  63.3k|      main_thcontext->tid = 0;
 6308|  63.3k|      int32_t pool_workers = workers - 1;
 6309|  63.3k|      main_thcontext->serial = (pool_workers == 0);
 6310|  63.3k|      job.active_workers = workers;
 6311|  63.3k|      job.pending_workers = pool_workers;
 6312|       |
 6313|  63.3k|      if (pool_workers > 0) {
  ------------------
  |  Branch (6313:11): [True: 63.3k, False: 0]
  ------------------
 6314|  63.3k|        int32_t expected_free = 0;
 6315|  63.3k|        if (__atomic_compare_exchange_n(&pool->fast_in_use, &expected_free, 1, false,
  ------------------
  |  Branch (6315:13): [True: 63.3k, False: 0]
  ------------------
 6316|  63.3k|                                        __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
 6317|  63.3k|          pool->fast_job = &job;
 6318|  63.3k|          pool->fast_workers = workers;
 6319|  63.3k|          __atomic_store_n(&pool->fast_remaining, pool_workers, __ATOMIC_SEQ_CST);
 6320|  63.3k|          if (__atomic_load_n(&pool->sleeping_workers, __ATOMIC_SEQ_CST) > 0 &&
  ------------------
  |  Branch (6320:15): [True: 30.4k, False: 32.9k]
  ------------------
 6321|  30.4k|              __atomic_load_n(&pool->fast_remaining, __ATOMIC_ACQUIRE) > 0) {
  ------------------
  |  Branch (6321:15): [True: 30.3k, False: 153]
  ------------------
 6322|  30.3k|            blosc2_pthread_mutex_lock(&pool->mutex);
  ------------------
  |  |   92|  30.3k|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 6323|  30.3k|            bool wake = __atomic_load_n(&pool->sleeping_workers, __ATOMIC_RELAXED) > 0 &&
  ------------------
  |  Branch (6323:25): [True: 30.3k, False: 0]
  ------------------
 6324|  30.3k|                        __atomic_load_n(&pool->fast_remaining, __ATOMIC_ACQUIRE) > 0;
  ------------------
  |  Branch (6324:25): [True: 28.4k, False: 1.83k]
  ------------------
 6325|  30.3k|            blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|  30.3k|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6326|  30.3k|            if (wake) {
  ------------------
  |  Branch (6326:17): [True: 28.4k, False: 1.83k]
  ------------------
 6327|  28.4k|              blosc2_pthread_cond_broadcast(&pool->work_cv);
  ------------------
  |  |  100|  28.4k|#define blosc2_pthread_cond_broadcast(a) pthread_cond_broadcast((a))
  ------------------
 6328|  28.4k|            }
 6329|  30.3k|          }
 6330|  63.3k|          t_blosc_do_job(main_thcontext);
 6331|  63.3k|          wait_job_completion(&job);
 6332|  63.3k|          pool->fast_job = NULL;
 6333|  63.3k|          __atomic_store_n(&pool->fast_in_use, 0, __ATOMIC_RELEASE);
 6334|  63.3k|        }
 6335|      0|        else {
 6336|      0|          struct blosc_job_queue_entry stack_entries[64];
 6337|      0|          struct blosc_job_queue_entry *entries = stack_entries;
 6338|      0|          if (pool_workers > 64) {
  ------------------
  |  Branch (6338:15): [True: 0, False: 0]
  ------------------
 6339|      0|            entries = (struct blosc_job_queue_entry *)my_malloc((size_t)pool_workers * sizeof(*entries));
 6340|      0|            if (entries == NULL) {
  ------------------
  |  Branch (6340:17): [True: 0, False: 0]
  ------------------
 6341|      0|              main_thcontext->serial = true;
 6342|      0|              serial_context_put(main_thcontext);
 6343|      0|              context->job = NULL;
 6344|      0|              job_group_destroy(&job);
 6345|      0|              return BLOSC2_ERROR_MEMORY_ALLOC;
 6346|      0|            }
 6347|      0|          }
 6348|      0|          for (int32_t tid = 0; tid < pool_workers; ++tid) {
  ------------------
  |  Branch (6348:33): [True: 0, False: 0]
  ------------------
 6349|      0|            entries[tid].job = &job;
 6350|      0|            entries[tid].logical_tid = tid + 1;
 6351|      0|            entries[tid].next = (tid + 1 < pool_workers) ? &entries[tid + 1] : NULL;
  ------------------
  |  Branch (6351:33): [True: 0, False: 0]
  ------------------
 6352|      0|          }
 6353|       |
 6354|      0|          blosc2_pthread_mutex_lock(&pool->mutex);
  ------------------
  |  |   92|      0|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 6355|      0|          if (pool->job_queue_tail != NULL) {
  ------------------
  |  Branch (6355:15): [True: 0, False: 0]
  ------------------
 6356|      0|            pool->job_queue_tail->next = &entries[0];
 6357|      0|          }
 6358|      0|          else {
 6359|      0|            pool->job_queue_head = &entries[0];
 6360|      0|          }
 6361|      0|          pool->job_queue_tail = &entries[pool_workers - 1];
 6362|      0|          __atomic_add_fetch(&pool->queued_jobs, pool_workers, __ATOMIC_SEQ_CST);
 6363|      0|          bool wake = __atomic_load_n(&pool->sleeping_workers, __ATOMIC_RELAXED) > 0;
 6364|      0|          blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6365|      0|          if (wake) {
  ------------------
  |  Branch (6365:15): [True: 0, False: 0]
  ------------------
 6366|      0|            blosc2_pthread_cond_broadcast(&pool->work_cv);
  ------------------
  |  |  100|      0|#define blosc2_pthread_cond_broadcast(a) pthread_cond_broadcast((a))
  ------------------
 6367|      0|          }
 6368|       |
 6369|      0|          t_blosc_do_job(main_thcontext);
 6370|      0|          wait_job_completion(&job);
 6371|      0|          if (entries != stack_entries) {
  ------------------
  |  Branch (6371:15): [True: 0, False: 0]
  ------------------
 6372|      0|            my_free(entries);
 6373|      0|          }
 6374|      0|        }
 6375|  63.3k|      }
 6376|      0|      else {
 6377|      0|        job.wait_state = 2;
 6378|      0|        job.completed = true;
 6379|      0|        t_blosc_do_job(main_thcontext);
 6380|      0|      }
 6381|  63.3k|      main_thcontext->serial = true;
 6382|  63.3k|      serial_context_put(main_thcontext);
 6383|  63.3k|    }
 6384|  63.3k|  }
 6385|       |
 6386|  63.3k|  context->job = NULL;
 6387|  63.3k|  context->output_bytes = (int32_t)job.output_bytes;
 6388|  63.3k|  context->thread_giveup_code = job.giveup_code;
 6389|  63.3k|  job_group_destroy(&job);
 6390|       |
 6391|  63.3k|  if (context->thread_giveup_code <= 0) {
  ------------------
  |  Branch (6391:7): [True: 0, False: 63.3k]
  ------------------
 6392|      0|    return context->thread_giveup_code;
 6393|      0|  }
 6394|  63.3k|  return (int)context->output_bytes;
 6395|       |
 6396|  63.3k|#endif  /* _WIN32 */
 6397|  63.3k|}
blosc2.c:job_group_init:
 5745|  63.3k|static void job_group_init(struct blosc_job_group *job, blosc2_context *context) {
 5746|  63.3k|  memset(job, 0, sizeof(*job));
 5747|  63.3k|  job->context = context;
 5748|  63.3k|  job->next_block = 0;
 5749|  63.3k|  job->output_bytes = context->output_bytes;
 5750|  63.3k|  job->giveup_code = 1;
 5751|  63.3k|  job->dref_not_init = 1;
 5752|  63.3k|  bool compress = context->do_compress != 0;
 5753|  63.3k|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 5754|  63.3k|  if (!compress && context->special_type) {
  ------------------
  |  Branch (5754:7): [True: 0, False: 63.3k]
  |  Branch (5754:20): [True: 0, False: 0]
  ------------------
 5755|      0|    memcpyed = true;
 5756|      0|  }
 5757|  63.3k|  job->static_schedule = (!compress || memcpyed) && context->block_maskout == NULL;
  ------------------
  |  Branch (5757:27): [True: 0, False: 63.3k]
  |  Branch (5757:40): [True: 0, False: 63.3k]
  |  Branch (5757:53): [True: 0, False: 0]
  ------------------
 5758|  63.3k|  job->has_delta_sync = !compress;
 5759|  63.3k|  blosc2_pthread_mutex_init(&job->mutex, NULL);
  ------------------
  |  |   90|  63.3k|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 5760|  63.3k|  if (job->has_delta_sync) {
  ------------------
  |  Branch (5760:7): [True: 0, False: 63.3k]
  ------------------
 5761|      0|    blosc2_pthread_mutex_init(&job->delta_mutex, NULL);
  ------------------
  |  |   90|      0|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 5762|      0|    blosc2_pthread_cond_init(&job->delta_cv, NULL);
  ------------------
  |  |   96|      0|#define blosc2_pthread_cond_init(a, b) pthread_cond_init((a), (b))
  ------------------
 5763|      0|  }
 5764|  63.3k|  blosc2_pthread_cond_init(&job->completion_cv, NULL);
  ------------------
  |  |   96|  63.3k|#define blosc2_pthread_cond_init(a, b) pthread_cond_init((a), (b))
  ------------------
 5765|  63.3k|}
blosc2.c:t_blosc_do_job:
 5564|   180k|static void t_blosc_do_job(void *ctxt) {
 5565|   180k|  struct thread_context* thcontext = (struct thread_context*)ctxt;
 5566|   180k|  blosc2_context* context = thcontext->parent_context;
 5567|   180k|  struct blosc_job_group* job = context->job;
 5568|   180k|  int32_t cbytes;
 5569|   180k|  int32_t tblocks;
 5570|   180k|  int32_t tblock;
 5571|   180k|  int32_t nblock_;
 5572|   180k|  int32_t bsize;
 5573|   180k|  int32_t leftoverblock;
 5574|   180k|  int32_t blocksize;
 5575|   180k|  int32_t ebsize;
 5576|   180k|  int32_t srcsize;
 5577|   180k|  bool compress = context->do_compress != 0;
 5578|   180k|  int32_t maxbytes;
 5579|   180k|  int32_t nblocks;
 5580|   180k|  int32_t leftover;
 5581|   180k|  int32_t leftover2;
 5582|   180k|  int32_t* bstarts;
 5583|   180k|  const uint8_t* src;
 5584|   180k|  uint8_t* dest;
 5585|   180k|  uint8_t* tmp;
 5586|   180k|  uint8_t* tmp2;
 5587|   180k|  uint8_t* tmp3;
 5588|       |
 5589|   180k|  blocksize = context->blocksize;
 5590|   180k|  ebsize = blocksize + context->typesize * (int32_t)sizeof(int32_t);
 5591|   180k|  maxbytes = context->destsize;
 5592|   180k|  nblocks = context->nblocks;
 5593|   180k|  leftover = context->leftover;
 5594|   180k|  bstarts = context->bstarts;
 5595|   180k|  src = context->src;
 5596|   180k|  srcsize = context->srcsize;
 5597|   180k|  dest = context->dest;
 5598|       |
 5599|   180k|  if (fit_thread_context(thcontext, context) < 0) {
  ------------------
  |  Branch (5599:7): [True: 0, False: 180k]
  ------------------
 5600|      0|    job_set_fatal_error(job, BLOSC2_ERROR_MEMORY_ALLOC);
 5601|      0|    if (!compress) {
  ------------------
  |  Branch (5601:9): [True: 0, False: 0]
  ------------------
 5602|      0|      delta_release_dref(context);
 5603|      0|    }
 5604|      0|    goto job_done;
 5605|      0|  }
 5606|       |
 5607|   180k|  tmp = thcontext->tmp;
 5608|   180k|  tmp2 = thcontext->tmp2;
 5609|   180k|  tmp3 = thcontext->tmp3;
 5610|       |
 5611|   180k|  bool vlblocks = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0;
 5612|   180k|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 5613|   180k|  if (!context->do_compress && context->special_type) {
  ------------------
  |  Branch (5613:7): [True: 0, False: 180k]
  |  Branch (5613:32): [True: 0, False: 0]
  ------------------
 5614|      0|    memcpyed = true;
 5615|      0|  }
 5616|       |
 5617|   180k|  if (job->static_schedule) {
  ------------------
  |  Branch (5617:7): [True: 0, False: 180k]
  ------------------
 5618|      0|    tblocks = nblocks / context->nthreads;
 5619|      0|    leftover2 = nblocks % context->nthreads;
 5620|      0|    tblocks = (leftover2 > 0) ? tblocks + 1 : tblocks;
  ------------------
  |  Branch (5620:15): [True: 0, False: 0]
  ------------------
 5621|      0|    nblock_ = thcontext->tid * tblocks;
 5622|      0|    tblock = nblock_ + tblocks;
 5623|      0|    if (tblock > nblocks) {
  ------------------
  |  Branch (5623:9): [True: 0, False: 0]
  ------------------
 5624|      0|      tblock = nblocks;
 5625|      0|    }
 5626|      0|  }
 5627|   180k|  else {
 5628|   180k|    nblock_ = claim_job_block(job);
 5629|   180k|    tblock = nblocks;
 5630|   180k|  }
 5631|       |
 5632|   180k|  leftoverblock = 0;
 5633|   362k|  while (nblock_ < tblock) {
  ------------------
  |  Branch (5633:10): [True: 181k, False: 180k]
  ------------------
 5634|   181k|    if (job->static_schedule &&
  ------------------
  |  Branch (5634:9): [True: 0, False: 181k]
  ------------------
 5635|      0|        __atomic_load_n(&job->giveup_code, __ATOMIC_RELAXED) <= 0) {
  ------------------
  |  Branch (5635:9): [True: 0, False: 0]
  ------------------
 5636|      0|      break;
 5637|      0|    }
 5638|       |
 5639|   181k|    bsize = vlblocks ? context->blocknbytes[nblock_] : blocksize;
  ------------------
  |  Branch (5639:13): [True: 0, False: 181k]
  ------------------
 5640|   181k|    leftoverblock = 0;
 5641|   181k|    if (!vlblocks && nblock_ == (nblocks - 1) && (leftover > 0)) {
  ------------------
  |  Branch (5641:9): [True: 181k, False: 74]
  |  Branch (5641:22): [True: 63.3k, False: 117k]
  |  Branch (5641:50): [True: 55.1k, False: 8.18k]
  ------------------
 5642|  55.1k|      bsize = leftover;
 5643|  55.1k|      leftoverblock = 1;
 5644|  55.1k|    }
 5645|   181k|    if (compress) {
  ------------------
  |  Branch (5645:9): [True: 181k, False: 18.4E]
  ------------------
 5646|   181k|      if (memcpyed) {
  ------------------
  |  Branch (5646:11): [True: 0, False: 181k]
  ------------------
 5647|      0|        if (!context->prefilter) {
  ------------------
  |  Branch (5647:13): [True: 0, False: 0]
  ------------------
 5648|      0|          memcpy(dest + context->header_overhead + nblock_ * blocksize,
 5649|      0|                 src + nblock_ * blocksize, (unsigned int) bsize);
 5650|      0|          cbytes = (int32_t)bsize;
 5651|      0|        }
 5652|      0|        else {
 5653|      0|          cbytes = blosc_c(thcontext, bsize, leftoverblock, 0,
 5654|      0|                           ebsize,
 5655|      0|                           vlblocks ? context->vlblock_sources[nblock_] : src,
  ------------------
  |  Branch (5655:28): [True: 0, False: 0]
  ------------------
 5656|      0|                           vlblocks ? 0 : nblock_ * blocksize,
  ------------------
  |  Branch (5656:28): [True: 0, False: 0]
  ------------------
 5657|      0|                           dest + context->header_overhead + nblock_ * blocksize,
 5658|      0|                           tmp, tmp3);
 5659|      0|        }
 5660|      0|      }
 5661|   181k|      else {
 5662|   181k|        cbytes = blosc_c(thcontext, bsize, leftoverblock, 0,
 5663|   181k|                         ebsize,
 5664|   181k|                         vlblocks ? context->vlblock_sources[nblock_] : src,
  ------------------
  |  Branch (5664:26): [True: 0, False: 181k]
  ------------------
 5665|   181k|                         vlblocks ? 0 : nblock_ * blocksize,
  ------------------
  |  Branch (5665:26): [True: 0, False: 181k]
  ------------------
 5666|   181k|                         tmp2, tmp, tmp3);
 5667|   181k|      }
 5668|   181k|    }
 5669|  18.4E|    else {
 5670|  18.4E|      if (context->special_type == BLOSC2_NO_SPECIAL && !memcpyed &&
  ------------------
  |  Branch (5670:11): [True: 0, False: 18.4E]
  |  Branch (5670:57): [True: 0, False: 0]
  ------------------
 5671|      0|          (srcsize < (int32_t)(context->header_overhead + (sizeof(int32_t) * nblocks)))) {
  ------------------
  |  Branch (5671:11): [True: 0, False: 0]
  ------------------
 5672|      0|        cbytes = -1;
 5673|      0|      }
 5674|  18.4E|      else {
 5675|  18.4E|        int32_t src_offset = memcpyed ?
  ------------------
  |  Branch (5675:30): [True: 0, False: 18.4E]
  ------------------
 5676|  18.4E|            context->header_overhead + nblock_ * blocksize : sw32_(bstarts + nblock_);
 5677|  18.4E|        uint8_t *dest_block = (vlblocks && context->vlblock_dests != NULL) ? context->vlblock_dests[nblock_] : dest;
  ------------------
  |  Branch (5677:32): [True: 0, False: 18.4E]
  |  Branch (5677:44): [True: 0, False: 0]
  ------------------
 5678|  18.4E|        int32_t dest_offset = (vlblocks && context->vlblock_dests != NULL) ? 0 :
  ------------------
  |  Branch (5678:32): [True: 0, False: 18.4E]
  |  Branch (5678:44): [True: 0, False: 0]
  ------------------
 5679|  18.4E|                              (vlblocks ? context->blockoffsets[nblock_] : nblock_ * blocksize);
  ------------------
  |  Branch (5679:32): [True: 0, False: 18.4E]
  ------------------
 5680|  18.4E|        cbytes = blosc_d(thcontext, bsize, leftoverblock, memcpyed,
 5681|  18.4E|                         src, srcsize, src_offset, nblock_,
 5682|  18.4E|                         dest_block, dest_offset, tmp, tmp2);
 5683|  18.4E|      }
 5684|  18.4E|      if (nblock_ == 0 || cbytes < 0) {
  ------------------
  |  Branch (5684:11): [True: 18.4E, False: 0]
  |  Branch (5684:27): [True: 0, False: 0]
  ------------------
 5685|      0|        delta_release_dref(context);
 5686|      0|      }
 5687|  18.4E|    }
 5688|       |
 5689|   181k|    if (cbytes < 0) {
  ------------------
  |  Branch (5689:9): [True: 0, False: 181k]
  ------------------
 5690|      0|      job_set_giveup(job, cbytes);
 5691|      0|      break;
 5692|      0|    }
 5693|       |
 5694|   181k|    if (__atomic_load_n(&job->giveup_code, __ATOMIC_RELAXED) <= 0) {
  ------------------
  |  Branch (5694:9): [True: 0, False: 181k]
  ------------------
 5695|      0|      break;
 5696|      0|    }
 5697|   181k|    if (compress && !memcpyed) {
  ------------------
  |  Branch (5697:9): [True: 181k, False: 18.4E]
  |  Branch (5697:21): [True: 181k, False: 18.4E]
  ------------------
 5698|   181k|      if (cbytes == 0) {
  ------------------
  |  Branch (5698:11): [True: 0, False: 181k]
  ------------------
 5699|      0|        job_set_giveup(job, 0);
 5700|      0|        break;
 5701|      0|      }
 5702|   181k|      int64_t ntdest64 = __atomic_fetch_add(&job->output_bytes, (int64_t)cbytes, __ATOMIC_RELAXED);
 5703|   181k|      if (ntdest64 + (int64_t)cbytes > (int64_t)maxbytes) {
  ------------------
  |  Branch (5703:11): [True: 0, False: 181k]
  ------------------
 5704|      0|        job_set_giveup(job, 0);
 5705|      0|        break;
 5706|      0|      }
 5707|   181k|      if (!(context->use_dict && context->dict_cdict == NULL)) {
  ------------------
  |  Branch (5707:13): [True: 0, False: 181k]
  |  Branch (5707:34): [True: 0, False: 0]
  ------------------
 5708|   181k|        _sw32(bstarts + nblock_, (int32_t)ntdest64);
 5709|   181k|      }
 5710|   181k|      memcpy(dest + ntdest64, tmp2, (size_t)cbytes);
 5711|   181k|    }
 5712|  18.4E|    else if (!job->static_schedule) {
  ------------------
  |  Branch (5712:14): [True: 0, False: 18.4E]
  ------------------
 5713|      0|      __atomic_fetch_add(&job->output_bytes, (int64_t)cbytes, __ATOMIC_RELAXED);
 5714|      0|    }
 5715|       |
 5716|   181k|    if (job->static_schedule) {
  ------------------
  |  Branch (5716:9): [True: 0, False: 181k]
  ------------------
 5717|      0|      nblock_++;
 5718|      0|    }
 5719|   181k|    else {
 5720|   181k|      nblock_ = claim_job_block(job);
 5721|   181k|    }
 5722|   181k|  }
 5723|       |
 5724|   181k|job_done:
 5725|   181k|  if (__atomic_sub_fetch(&job->active_workers, 1, __ATOMIC_ACQ_REL) == 0) {
  ------------------
  |  Branch (5725:7): [True: 63.3k, False: 118k]
  ------------------
 5726|  63.3k|    if (job->static_schedule &&
  ------------------
  |  Branch (5726:9): [True: 0, False: 63.3k]
  ------------------
 5727|      0|        __atomic_load_n(&job->giveup_code, __ATOMIC_ACQUIRE) > 0) {
  ------------------
  |  Branch (5727:9): [True: 0, False: 0]
  ------------------
 5728|      0|      int64_t total = context->sourcesize;
 5729|      0|      if (compress) {
  ------------------
  |  Branch (5729:11): [True: 0, False: 0]
  ------------------
 5730|      0|        total += context->header_overhead;
 5731|      0|      }
 5732|      0|      __atomic_store_n(&job->output_bytes, total, __ATOMIC_RELEASE);
 5733|      0|    }
 5734|  63.3k|    if (context->thread_backend == BLOSC_BACKEND_CALLBACK) {
  ------------------
  |  |   35|  63.3k|#define BLOSC_BACKEND_CALLBACK 2
  ------------------
  |  Branch (5734:9): [True: 0, False: 63.3k]
  ------------------
 5735|      0|      blosc2_pthread_mutex_lock(&job->mutex);
  ------------------
  |  |   92|      0|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5736|      0|      job->completed = true;
 5737|      0|      blosc2_pthread_cond_broadcast(&job->completion_cv);
  ------------------
  |  |  100|      0|#define blosc2_pthread_cond_broadcast(a) pthread_cond_broadcast((a))
  ------------------
 5738|      0|      blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5739|      0|    }
 5740|  63.3k|  }
 5741|   181k|}
blosc2.c:fit_thread_context:
 2764|  6.45M|static int fit_thread_context(struct thread_context* thread_context, blosc2_context* context) {
 2765|  6.45M|  int32_t ebsize = context->blocksize + context->typesize * (int32_t)sizeof(int32_t);
 2766|  6.45M|  if ((size_t)4 * ebsize <= thread_context->tmp_nbytes) {
  ------------------
  |  Branch (2766:7): [True: 5.97M, False: 478k]
  ------------------
 2767|  5.97M|    return 0;
 2768|  5.97M|  }
 2769|   478k|  my_free(thread_context->tmp);
 2770|   478k|  thread_context->tmp = my_malloc((size_t)4 * ebsize);
 2771|   478k|  if (thread_context->tmp == NULL) {
  ------------------
  |  Branch (2771:7): [True: 0, False: 478k]
  ------------------
 2772|      0|    thread_context->tmp_nbytes = 0;
 2773|      0|    thread_context->tmp_blocksize = 0;
 2774|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2775|      0|  }
 2776|   478k|  thread_context->tmp_nbytes = (size_t)4 * ebsize;
 2777|   478k|  thread_context->tmp2 = thread_context->tmp + ebsize;
 2778|   478k|  thread_context->tmp3 = thread_context->tmp2 + ebsize;
 2779|   478k|  thread_context->tmp4 = thread_context->tmp3 + ebsize;
 2780|   478k|  thread_context->tmp_blocksize = context->blocksize;
 2781|   478k|  return 0;
 2782|   478k|}
blosc2.c:claim_job_block:
 5555|   362k|static int32_t claim_job_block(struct blosc_job_group *job) {
 5556|   362k|  if (__atomic_load_n(&job->giveup_code, __ATOMIC_RELAXED) <= 0) {
  ------------------
  |  Branch (5556:7): [True: 0, False: 362k]
  ------------------
 5557|      0|    return INT32_MAX;
 5558|      0|  }
 5559|   362k|  int64_t n = __atomic_fetch_add(&job->next_block, 1, __ATOMIC_RELAXED);
 5560|   363k|  return n < INT32_MAX ? (int32_t)n : INT32_MAX;
  ------------------
  |  Branch (5560:10): [True: 363k, False: 18.4E]
  ------------------
 5561|   362k|}
blosc2.c:job_group_destroy:
 5767|  63.3k|static void job_group_destroy(struct blosc_job_group *job) {
 5768|  63.3k|  blosc2_pthread_mutex_destroy(&job->mutex);
  ------------------
  |  |   91|  63.3k|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 5769|  63.3k|  if (job->has_delta_sync) {
  ------------------
  |  Branch (5769:7): [True: 0, False: 63.3k]
  ------------------
 5770|      0|    blosc2_pthread_mutex_destroy(&job->delta_mutex);
  ------------------
  |  |   91|      0|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 5771|      0|    blosc2_pthread_cond_destroy(&job->delta_cv);
  ------------------
  |  |   97|      0|#define blosc2_pthread_cond_destroy(a) pthread_cond_destroy((a))
  ------------------
 5772|      0|  }
 5773|  63.3k|  blosc2_pthread_cond_destroy(&job->completion_cv);
  ------------------
  |  |   97|  63.3k|#define blosc2_pthread_cond_destroy(a) pthread_cond_destroy((a))
  ------------------
 5774|  63.3k|}
blosc2.c:wait_job_completion:
 5777|  63.3k|static void wait_job_completion(struct blosc_job_group *job) {
 5778|   302M|  for (int spin = 0; spin < 30000; spin++) {
  ------------------
  |  Branch (5778:22): [True: 302M, False: 889]
  ------------------
 5779|   302M|    if (__atomic_load_n(&job->wait_state, __ATOMIC_ACQUIRE) == 2) {
  ------------------
  |  Branch (5779:9): [True: 62.4k, False: 302M]
  ------------------
 5780|  62.4k|      return;
 5781|  62.4k|    }
 5782|   302M|    blosc_cpu_pause();
 5783|   302M|  }
 5784|    889|  blosc2_pthread_mutex_lock(&job->mutex);
  ------------------
  |  |   92|    889|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5785|    889|  int32_t expected = 0;
 5786|    889|  if (__atomic_compare_exchange_n(&job->wait_state, &expected, 1, false,
  ------------------
  |  Branch (5786:7): [True: 888, False: 1]
  ------------------
 5787|    889|                                  __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) {
 5788|  1.77k|    while (!job->completed) {
  ------------------
  |  Branch (5788:12): [True: 888, False: 888]
  ------------------
 5789|    888|      blosc2_pthread_cond_wait(&job->completion_cv, &job->mutex);
  ------------------
  |  |   98|    888|#define blosc2_pthread_cond_wait(a, b) pthread_cond_wait((a), (b))
  ------------------
 5790|    888|    }
 5791|    888|  }
 5792|    889|  blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|    889|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5793|    889|}
blosc2.c:blosc_cpu_pause:
  149|   396M|static inline void blosc_cpu_pause(void) {
  150|       |#if defined(__aarch64__) || defined(_M_ARM64)
  151|       |  __asm__ __volatile__("isb" ::: "memory");
  152|       |#elif defined(__x86_64__) || defined(__i386__)
  153|       |  __asm__ __volatile__("pause" ::: "memory");
  154|   396M|#endif
  155|   396M|}
blosc2.c:read_lazy_chunk_bytes:
 3064|      5|                                 const char* open_error, const char* read_error) {
 3065|      5|  int32_t chunk_cbytes;
 3066|      5|  if (context->src == NULL || context->srcsize < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (3066:7): [True: 0, False: 5]
  |  Branch (3066:31): [True: 0, False: 5]
  ------------------
 3067|      5|      offset < 0 || nbytes < 0 || context->nblocks <= 0 ||
  ------------------
  |  Branch (3067:7): [True: 0, False: 5]
  |  Branch (3067:21): [True: 0, False: 5]
  |  Branch (3067:35): [True: 0, False: 5]
  ------------------
 3068|      5|      blosc2_cbuffer_sizes(context->src, NULL, &chunk_cbytes, NULL) < 0 ||
  ------------------
  |  Branch (3068:7): [True: 0, False: 5]
  ------------------
 3069|      5|      offset > chunk_cbytes || nbytes > chunk_cbytes - offset) {
  ------------------
  |  Branch (3069:7): [True: 0, False: 5]
  |  Branch (3069:32): [True: 0, False: 5]
  ------------------
 3070|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 3071|      0|  }
 3072|      5|  int64_t trailer_end = BLOSC_EXTENDED_HEADER_LENGTH +
 3073|      5|      (int64_t)context->nblocks * sizeof(int32_t) + sizeof(int32_t) + sizeof(int64_t);
 3074|      5|  if (trailer_end > context->srcsize) return BLOSC2_ERROR_READ_BUFFER;
  ------------------
  |  Branch (3074:7): [True: 3, False: 2]
  ------------------
 3075|      2|  if (context->schunk == NULL || context->schunk->frame == NULL) {
  ------------------
  |  Branch (3075:7): [True: 2, False: 0]
  |  Branch (3075:34): [True: 0, False: 0]
  ------------------
 3076|      2|    BLOSC_TRACE_ERROR("Lazy chunk needs an associated super-chunk with a frame.");
  ------------------
  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3077|      2|    return BLOSC2_ERROR_INVALID_PARAM;
 3078|      2|  }
 3079|       |
 3080|      0|  blosc2_frame_s* frame = (blosc2_frame_s*)context->schunk->frame;
 3081|      0|  blosc2_io_cb* io_cb = blosc2_get_io_cb(context->schunk->storage->io->id);
 3082|      0|  if (io_cb == NULL) {
  ------------------
  |  Branch (3082:7): [True: 0, False: 0]
  ------------------
 3083|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3084|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 3085|      0|  }
 3086|       |
 3087|      0|  int32_t trailer_offset = BLOSC_EXTENDED_HEADER_LENGTH +
 3088|      0|                           context->nblocks * (int32_t)sizeof(int32_t);
 3089|      0|  int32_t nchunk_lazy;
 3090|      0|  int64_t chunk_offset;
 3091|      0|  memcpy(&nchunk_lazy, context->src + trailer_offset, sizeof(nchunk_lazy));
 3092|      0|  memcpy(&chunk_offset, context->src + trailer_offset + (int32_t)sizeof(int32_t), sizeof(chunk_offset));
 3093|      0|  if (nchunk_lazy < 0 || chunk_offset < 0 || frame->file_offset < 0 ||
  ------------------
  |  Branch (3093:7): [True: 0, False: 0]
  |  Branch (3093:26): [True: 0, False: 0]
  |  Branch (3093:46): [True: 0, False: 0]
  ------------------
 3094|      0|      (!frame->sframe && (chunk_offset < FRAME_HEADER_MINLEN ||
  ------------------
  |  |   49|      0|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|      0|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|      0|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|      0|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|      0|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|      0|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|      0|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|      0|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|      0|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|      0|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (3094:8): [True: 0, False: 0]
  |  Branch (3094:27): [True: 0, False: 0]
  ------------------
 3095|      0|       chunk_offset > frame->len || chunk_cbytes > frame->len - chunk_offset))) {
  ------------------
  |  Branch (3095:8): [True: 0, False: 0]
  |  Branch (3095:37): [True: 0, False: 0]
  ------------------
 3096|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 3097|      0|  }
 3098|       |
 3099|      0|  void* fp = NULL;
 3100|      0|  int64_t io_pos;
 3101|      0|  if (frame->sframe) {
  ------------------
  |  Branch (3101:7): [True: 0, False: 0]
  ------------------
 3102|      0|    fp = sframe_open_chunk(frame->urlpath, nchunk_lazy, "rb", context->schunk->storage->io);
 3103|      0|    io_pos = offset;
 3104|      0|  }
 3105|      0|  else {
 3106|      0|    if (chunk_offset < 0 || offset < 0) {
  ------------------
  |  Branch (3106:9): [True: 0, False: 0]
  |  Branch (3106:29): [True: 0, False: 0]
  ------------------
 3107|      0|      BLOSC_TRACE_ERROR("Lazy chunk offset cannot be negative.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3108|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 3109|      0|    }
 3110|      0|    fp = frame_reader_acquire(frame, context->schunk->storage->io);
 3111|      0|    if (!blosc2_checked_add_i64(frame->file_offset, chunk_offset, &io_pos)) {
  ------------------
  |  Branch (3111:9): [True: 0, False: 0]
  ------------------
 3112|      0|      BLOSC_TRACE_ERROR("Lazy chunk offset overflows file position.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3113|      0|      if (fp != NULL) {
  ------------------
  |  Branch (3113:11): [True: 0, False: 0]
  ------------------
 3114|      0|        frame_reader_release(frame, io_cb, fp);
 3115|      0|      }
 3116|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 3117|      0|    }
 3118|      0|    if (!blosc2_checked_add_i64(io_pos, offset, &io_pos)) {
  ------------------
  |  Branch (3118:9): [True: 0, False: 0]
  ------------------
 3119|      0|      BLOSC_TRACE_ERROR("Lazy block offset overflows file position.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3120|      0|      if (fp != NULL) {
  ------------------
  |  Branch (3120:11): [True: 0, False: 0]
  ------------------
 3121|      0|        frame_reader_release(frame, io_cb, fp);
 3122|      0|      }
 3123|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 3124|      0|    }
 3125|      0|  }
 3126|      0|  if (fp == NULL) {
  ------------------
  |  Branch (3126:7): [True: 0, False: 0]
  ------------------
 3127|      0|    BLOSC_TRACE_ERROR("%s", open_error);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3128|      0|    return BLOSC2_ERROR_FILE_OPEN;
 3129|      0|  }
 3130|      0|  if (!blosc2_checked_add_i64(io_pos, nbytes, NULL)) {
  ------------------
  |  Branch (3130:7): [True: 0, False: 0]
  ------------------
 3131|      0|    frame_reader_release(frame, io_cb, fp);
 3132|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 3133|      0|  }
 3134|       |
 3135|      0|  uint8_t* read_buffer = buffer;
 3136|      0|  int64_t rbytes = io_cb->read((void**)&read_buffer, 1, nbytes, io_pos, fp);
 3137|      0|  bool complete = rbytes == nbytes && read_buffer != NULL;
  ------------------
  |  Branch (3137:19): [True: 0, False: 0]
  |  Branch (3137:39): [True: 0, False: 0]
  ------------------
 3138|      0|  if (complete && read_buffer != buffer) {
  ------------------
  |  Branch (3138:7): [True: 0, False: 0]
  |  Branch (3138:19): [True: 0, False: 0]
  ------------------
 3139|       |    // An io that hands out its own memory (mmap) keeps owning it
 3140|      0|    memcpy(buffer, read_buffer, (size_t)nbytes);
 3141|      0|  }
 3142|      0|  frame_reader_release(frame, io_cb, fp);
 3143|      0|  if (!complete) {
  ------------------
  |  Branch (3143:7): [True: 0, False: 0]
  ------------------
 3144|      0|    BLOSC_TRACE_ERROR("%s", read_error);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3145|      0|    return BLOSC2_ERROR_FILE_READ;
 3146|      0|  }
 3147|       |
 3148|      0|  return 0;
 3149|      0|}
blosc2.c:serial_context_get:
 2796|  6.27M|static struct thread_context* serial_context_get(blosc2_context* context) {
 2797|  6.27M|  struct thread_context* thread_context = NULL;
 2798|  6.27M|  if (context->serial_context == NULL) {
  ------------------
  |  Branch (2798:7): [True: 6.27M, False: 3.93k]
  ------------------
 2799|  6.27M|    thread_context = serial_context_take_tls(context);
 2800|  6.27M|  }
 2801|  6.27M|  if (thread_context == NULL) {
  ------------------
  |  Branch (2801:7): [True: 4.08k, False: 6.27M]
  ------------------
 2802|  4.08k|    if (context->serial_context != NULL &&
  ------------------
  |  Branch (2802:9): [True: 3.93k, False: 151]
  ------------------
 2803|  3.93k|        context->serial_context->tmp_blocksize != context->blocksize) {
  ------------------
  |  Branch (2803:9): [True: 0, False: 3.93k]
  ------------------
 2804|      0|      free_thread_context(context->serial_context);
 2805|      0|      context->serial_context = NULL;
 2806|      0|    }
 2807|  4.08k|    if (context->serial_context == NULL) {
  ------------------
  |  Branch (2807:9): [True: 151, False: 3.93k]
  ------------------
 2808|    151|      context->serial_context = create_thread_context(context, 0);
 2809|    151|      if (context->serial_context == NULL) {
  ------------------
  |  Branch (2809:11): [True: 0, False: 151]
  ------------------
 2810|      0|        return NULL;
 2811|      0|      }
 2812|    151|    }
 2813|  3.93k|    else if (fit_thread_context(context->serial_context, context) < 0) {
  ------------------
  |  Branch (2813:14): [True: 0, False: 3.93k]
  ------------------
 2814|      0|      return NULL;
 2815|      0|    }
 2816|  4.08k|    thread_context = context->serial_context;
 2817|  4.08k|  }
 2818|  6.27M|  thread_context->parent_context = context;
 2819|  6.27M|  thread_context->tid = 0;
 2820|       |  thread_context->serial = true;
 2821|  6.27M|  return thread_context;
 2822|  6.27M|}
blosc2.c:serial_context_take_tls:
 6894|  6.27M|static struct thread_context* serial_context_take_tls(blosc2_context* context) {
 6895|  6.27M|#if !defined(_WIN32)
 6896|  6.27M|  int32_t ebsize = context->blocksize + context->typesize * (int32_t)sizeof(int32_t);
 6897|  6.27M|  if ((size_t)4 * ebsize > BLOSC2_SERIAL_TLS_MAX) {
  ------------------
  |  | 6817|  6.27M|#define BLOSC2_SERIAL_TLS_MAX (16 * 1024 * 1024)
  ------------------
  |  Branch (6897:7): [True: 151, False: 6.27M]
  ------------------
 6898|    151|    return NULL;
 6899|    151|  }
 6900|  6.27M|  tmp_cache_t *cache = tmp_cache_get(true);
 6901|  6.27M|  if (cache == NULL || cache->serial_busy) {
  ------------------
  |  Branch (6901:7): [True: 0, False: 6.27M]
  |  Branch (6901:24): [True: 0, False: 6.27M]
  ------------------
 6902|      0|    return NULL;
 6903|      0|  }
 6904|  6.27M|  if (cache->serial == NULL) {
  ------------------
  |  Branch (6904:7): [True: 2.41k, False: 6.27M]
  ------------------
 6905|  2.41k|    cache->serial = create_thread_context(context, 0);
 6906|  2.41k|    if (cache->serial == NULL) {
  ------------------
  |  Branch (6906:9): [True: 0, False: 2.41k]
  ------------------
 6907|      0|      return NULL;
 6908|      0|    }
 6909|  2.41k|  }
 6910|  6.27M|  else if (fit_thread_context(cache->serial, context) < 0) {
  ------------------
  |  Branch (6910:12): [True: 0, False: 6.27M]
  ------------------
 6911|      0|    return NULL;
 6912|      0|  }
 6913|  6.27M|  cache->serial_busy = true;
 6914|  6.27M|  return cache->serial;
 6915|       |#else
 6916|       |  BLOSC_UNUSED_PARAM(context);
 6917|       |  return NULL;
 6918|       |#endif
 6919|  6.27M|}
blosc2.c:create_thread_context:
 2676|  2.56k|create_thread_context(blosc2_context* context, int32_t tid) {
 2677|  2.56k|  struct thread_context* thread_context;
 2678|  2.56k|  thread_context = (struct thread_context*)my_malloc(sizeof(struct thread_context));
 2679|  2.56k|  BLOSC_ERROR_NULL(thread_context, NULL);
  ------------------
  |  |  104|  2.56k|    do {                                            \
  |  |  105|  2.56k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.56k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  2.56k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.56k]
  |  |  ------------------
  ------------------
 2680|  2.56k|  int rc = init_thread_context(thread_context, context, tid);
 2681|  2.56k|  if (rc < 0) {
  ------------------
  |  Branch (2681:7): [True: 0, False: 2.56k]
  ------------------
 2682|      0|    my_free(thread_context);
 2683|      0|    return NULL;
 2684|      0|  }
 2685|  2.56k|  return thread_context;
 2686|  2.56k|}
blosc2.c:init_thread_context:
 2644|  2.63k|{
 2645|  2.63k|  int32_t ebsize;
 2646|       |
 2647|  2.63k|  thread_context->parent_context = context;
 2648|  2.63k|  thread_context->owner_pool = NULL;
 2649|  2.63k|  thread_context->tid = tid;
 2650|  2.63k|  thread_context->serial = false;
 2651|  2.63k|  thread_context->blosclz_state = NULL;
 2652|       |
 2653|  2.63k|  int32_t blocksize = context != NULL ? context->blocksize : 0;
  ------------------
  |  Branch (2653:23): [True: 2.56k, False: 69]
  ------------------
 2654|  2.63k|  int32_t typesize = context != NULL ? context->typesize : 0;
  ------------------
  |  Branch (2654:22): [True: 2.56k, False: 69]
  ------------------
 2655|  2.63k|  ebsize = blocksize + typesize * (signed)sizeof(int32_t);
 2656|  2.63k|  thread_context->tmp_nbytes = (size_t)4 * ebsize;
 2657|  2.63k|  thread_context->tmp = my_malloc(thread_context->tmp_nbytes);
 2658|  2.63k|  BLOSC_ERROR_NULL(thread_context->tmp, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  2.63k|    do {                                            \
  |  |  105|  2.63k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.63k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  2.63k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.63k]
  |  |  ------------------
  ------------------
 2659|  2.63k|  thread_context->tmp2 = thread_context->tmp + ebsize;
 2660|  2.63k|  thread_context->tmp3 = thread_context->tmp2 + ebsize;
 2661|  2.63k|  thread_context->tmp4 = thread_context->tmp3 + ebsize;
 2662|  2.63k|  thread_context->tmp_blocksize = blocksize;
 2663|  2.63k|  thread_context->zfp_cell_nitems = 0;
 2664|  2.63k|  thread_context->zfp_cell_start = 0;
 2665|  2.63k|  #if defined(HAVE_ZSTD)
 2666|  2.63k|  thread_context->zstd_cctx = NULL;
 2667|  2.63k|  thread_context->zstd_dctx = NULL;
 2668|  2.63k|  #endif
 2669|  2.63k|  thread_context->lz4_cstream = NULL;
 2670|  2.63k|  thread_context->lz4hc_cstream = NULL;
 2671|       |
 2672|  2.63k|  return 0;
 2673|  2.63k|}
blosc2.c:blosc_d:
 2122|  8.85M|    int32_t nblock, uint8_t* dest, int32_t dest_offset, uint8_t* tmp, uint8_t* tmp2) {
 2123|  8.85M|  blosc2_context* context = thread_context->parent_context;
 2124|  8.85M|  uint8_t *tmp3 = thread_context->tmp4;
 2125|  8.85M|  bool vlblocks = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0;
 2126|  8.85M|  int32_t compformat = (context->header_flags & (uint8_t)0xe0) >> 5u;
 2127|  8.85M|  int dont_split = (context->header_flags & 0x10) >> 4;
 2128|  8.85M|  int32_t chunk_nbytes;
 2129|  8.85M|  int32_t chunk_cbytes;
 2130|  8.85M|  int nstreams;
 2131|  8.85M|  int32_t neblock;
 2132|  8.85M|  int32_t nbytes;                /* number of decompressed bytes in split */
 2133|  8.85M|  int32_t cbytes;                /* number of compressed bytes in split */
 2134|       |  // int32_t ctbytes = 0;           /* number of compressed bytes in block */
 2135|  8.85M|  int32_t ntbytes = 0;           /* number of uncompressed bytes in block */
 2136|  8.85M|  uint8_t* _dest;
 2137|  8.85M|  int32_t typesize = context->typesize;
 2138|  8.85M|  bool instr_codec = context->blosc2_flags & BLOSC2_INSTR_CODEC;
 2139|  8.85M|  const char* compname;
 2140|  8.85M|  int rc;
 2141|       |
 2142|  8.85M|  if (context->block_maskout != NULL && context->block_maskout[nblock]) {
  ------------------
  |  Branch (2142:7): [True: 1.70M, False: 7.15M]
  |  Branch (2142:41): [True: 1.22M, False: 477k]
  ------------------
 2143|       |    // Do not decompress, but act as if we successfully decompressed everything
 2144|  1.22M|    return bsize;
 2145|  1.22M|  }
 2146|       |
 2147|  7.63M|  rc = blosc2_cbuffer_sizes(src, &chunk_nbytes, &chunk_cbytes, NULL);
 2148|  7.63M|  if (rc < 0) {
  ------------------
  |  Branch (2148:7): [True: 0, False: 7.63M]
  ------------------
 2149|      0|    return rc;
 2150|      0|  }
 2151|  7.63M|  if (context->special_type == BLOSC2_SPECIAL_VALUE) {
  ------------------
  |  Branch (2151:7): [True: 83.9k, False: 7.54M]
  ------------------
 2152|       |    // We need the actual typesize in this case, but it cannot be encoded in the header, so derive it from cbytes
 2153|  83.9k|    typesize = chunk_cbytes - context->header_overhead;
 2154|  83.9k|  }
 2155|       |
 2156|       |  // In some situations (lazychunks) the context can arrive uninitialized
 2157|       |  // (but BITSHUFFLE needs it for accessing the format of the chunk)
 2158|  7.63M|  if (context->src == NULL) {
  ------------------
  |  Branch (2158:7): [True: 0, False: 7.63M]
  ------------------
 2159|      0|    context->src = src;
 2160|      0|  }
 2161|       |
 2162|       |  // Chunks with special values cannot be lazy
 2163|  7.63M|  bool is_lazy = ((context->header_overhead == BLOSC_EXTENDED_HEADER_LENGTH) &&
  ------------------
  |  Branch (2163:19): [True: 7.62M, False: 411]
  ------------------
 2164|  7.62M|          (context->blosc2_flags & 0x08u) && !context->special_type);
  ------------------
  |  Branch (2164:11): [True: 2.23M, False: 5.39M]
  |  Branch (2164:46): [True: 4, False: 2.23M]
  ------------------
 2165|  7.63M|  if (is_lazy) {
  ------------------
  |  Branch (2165:7): [True: 4, False: 7.63M]
  ------------------
 2166|       |    // The chunk is on disk, so just lazily load the block
 2167|      4|    if (context->schunk == NULL) {
  ------------------
  |  Branch (2167:9): [True: 4, False: 0]
  ------------------
 2168|      4|      BLOSC_TRACE_ERROR("Lazy chunk needs an associated super-chunk.");
  ------------------
  |  |   93|      4|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      4|    do {                                            \
  |  |  |  |   98|      4|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      4|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      4|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2169|      4|      return BLOSC2_ERROR_INVALID_PARAM;
 2170|      4|    }
 2171|      0|    if (context->schunk->frame == NULL) {
  ------------------
  |  Branch (2171:9): [True: 0, False: 0]
  ------------------
 2172|      0|      BLOSC_TRACE_ERROR("Lazy chunk needs an associated frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2173|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2174|      0|    }
 2175|      0|    blosc2_frame_s* frame = (blosc2_frame_s*)context->schunk->frame;
 2176|      0|    size_t bstarts_nbytes;
 2177|      0|    size_t trailer_offset;
 2178|      0|    size_t block_csizes_nbytes;
 2179|      0|    size_t trailer_meta_nbytes;
 2180|      0|    size_t lazy_trailer_end;
 2181|      0|    if (srcsize < 0 || context->nblocks < 0 ||
  ------------------
  |  Branch (2181:9): [True: 0, False: 0]
  |  Branch (2181:24): [True: 0, False: 0]
  ------------------
 2182|      0|        !blosc2_checked_mul_size((size_t)context->nblocks, sizeof(int32_t), &bstarts_nbytes) ||
  ------------------
  |  Branch (2182:9): [True: 0, False: 0]
  ------------------
 2183|      0|        !blosc2_checked_add_size((size_t)BLOSC_EXTENDED_HEADER_LENGTH, bstarts_nbytes, &trailer_offset) ||
  ------------------
  |  Branch (2183:9): [True: 0, False: 0]
  ------------------
 2184|      0|        !blosc2_checked_mul_size((size_t)context->nblocks, sizeof(int32_t), &block_csizes_nbytes) ||
  ------------------
  |  Branch (2184:9): [True: 0, False: 0]
  ------------------
 2185|      0|        !blosc2_checked_add_size(sizeof(int32_t) + sizeof(int64_t), block_csizes_nbytes, &trailer_meta_nbytes) ||
  ------------------
  |  Branch (2185:9): [True: 0, False: 0]
  ------------------
 2186|      0|        !blosc2_checked_add_size(trailer_offset, trailer_meta_nbytes, &lazy_trailer_end) ||
  ------------------
  |  Branch (2186:9): [True: 0, False: 0]
  ------------------
 2187|      0|        (size_t)srcsize < lazy_trailer_end) {
  ------------------
  |  Branch (2187:9): [True: 0, False: 0]
  ------------------
 2188|      0|      BLOSC_TRACE_ERROR("Lazy trailer exceeds source buffer.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2189|      0|      return BLOSC2_ERROR_READ_BUFFER;
 2190|      0|    }
 2191|      0|    int32_t nchunk;
 2192|      0|    int64_t chunk_offset;
 2193|       |    // The nchunk and the offset of the current chunk are in the trailer
 2194|      0|    memcpy(&nchunk, src + trailer_offset, sizeof(nchunk));
 2195|      0|    memcpy(&chunk_offset, src + trailer_offset + sizeof(int32_t), sizeof(chunk_offset));
 2196|       |    // Get the csize of the nblock
 2197|      0|    if (nblock < 0 || nblock >= context->nblocks) {
  ------------------
  |  Branch (2197:9): [True: 0, False: 0]
  |  Branch (2197:23): [True: 0, False: 0]
  ------------------
 2198|      0|      BLOSC_TRACE_ERROR("Invalid block index in lazy trailer.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2199|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 2200|      0|    }
 2201|      0|    int32_t *block_csizes = (int32_t *)(src + trailer_offset + sizeof(int32_t) + sizeof(int64_t));
 2202|      0|    int32_t block_csize = block_csizes[nblock];
 2203|      0|    int32_t max_lazy_block_csize = context->blocksize + context->typesize * (signed)sizeof(int32_t);
 2204|      0|    if (block_csize <= 0 || block_csize > max_lazy_block_csize) {
  ------------------
  |  Branch (2204:9): [True: 0, False: 0]
  |  Branch (2204:29): [True: 0, False: 0]
  ------------------
 2205|      0|      BLOSC_TRACE_ERROR("Invalid lazy block size in trailer.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2206|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 2207|      0|    }
 2208|      0|    if (vlblocks && block_csize <= (int32_t)sizeof(int32_t)) {
  ------------------
  |  Branch (2208:9): [True: 0, False: 0]
  |  Branch (2208:21): [True: 0, False: 0]
  ------------------
 2209|      0|      BLOSC_TRACE_ERROR("Lazy VL block compressed size is too small.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2210|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 2211|      0|    }
 2212|       |    // Read the lazy block on disk
 2213|      0|    void* fp = NULL;
 2214|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(context->schunk->storage->io->id);
 2215|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (2215:9): [True: 0, False: 0]
  ------------------
 2216|      0|      BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2217|      0|      return BLOSC2_ERROR_PLUGIN_IO;
 2218|      0|    }
 2219|       |
 2220|      0|    int64_t io_pos = 0;
 2221|      0|    if (frame->sframe) {
  ------------------
  |  Branch (2221:9): [True: 0, False: 0]
  ------------------
 2222|       |      // The chunk is not in the frame
 2223|      0|      fp = sframe_open_chunk(frame->urlpath, nchunk, "rb", context->schunk->storage->io);
 2224|      0|      BLOSC_ERROR_NULL(fp, BLOSC2_ERROR_FILE_OPEN);
  ------------------
  |  |  104|      0|    do {                                            \
  |  |  105|      0|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2225|       |      // The offset of the block is src_offset
 2226|      0|      if (src_offset < 0) {
  ------------------
  |  Branch (2226:11): [True: 0, False: 0]
  ------------------
 2227|      0|        frame_reader_release(frame, io_cb, fp);
 2228|      0|        BLOSC_TRACE_ERROR("Lazy block offset cannot be negative.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2229|      0|        return BLOSC2_ERROR_INVALID_HEADER;
 2230|      0|      }
 2231|      0|      io_pos = src_offset;
 2232|      0|    }
 2233|      0|    else {
 2234|      0|      fp = frame_reader_acquire(frame, context->schunk->storage->io);
 2235|      0|      BLOSC_ERROR_NULL(fp, BLOSC2_ERROR_FILE_OPEN);
  ------------------
  |  |  104|      0|    do {                                            \
  |  |  105|      0|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2236|       |      // The offset of the block is src_offset
 2237|      0|      if (src_offset < 0) {
  ------------------
  |  Branch (2237:11): [True: 0, False: 0]
  ------------------
 2238|      0|        frame_reader_release(frame, io_cb, fp);
 2239|      0|        BLOSC_TRACE_ERROR("Lazy block offset cannot be negative.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2240|      0|        return BLOSC2_ERROR_INVALID_HEADER;
 2241|      0|      }
 2242|      0|      if (chunk_offset < 0) {
  ------------------
  |  Branch (2242:11): [True: 0, False: 0]
  ------------------
 2243|      0|        frame_reader_release(frame, io_cb, fp);
 2244|      0|        BLOSC_TRACE_ERROR("Lazy chunk offset cannot be negative.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2245|      0|        return BLOSC2_ERROR_INVALID_HEADER;
 2246|      0|      }
 2247|      0|      if (!blosc2_checked_add_i64(frame->file_offset, chunk_offset, &io_pos)) {
  ------------------
  |  Branch (2247:11): [True: 0, False: 0]
  ------------------
 2248|      0|        frame_reader_release(frame, io_cb, fp);
 2249|      0|        BLOSC_TRACE_ERROR("Lazy chunk offset overflows file position.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2250|      0|        return BLOSC2_ERROR_INVALID_HEADER;
 2251|      0|      }
 2252|      0|      if (!blosc2_checked_add_i64(io_pos, src_offset, &io_pos)) {
  ------------------
  |  Branch (2252:11): [True: 0, False: 0]
  ------------------
 2253|      0|        frame_reader_release(frame, io_cb, fp);
 2254|      0|        BLOSC_TRACE_ERROR("Lazy block offset overflows file position.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2255|      0|        return BLOSC2_ERROR_INVALID_HEADER;
 2256|      0|      }
 2257|      0|    }
 2258|       |    // We can make use of tmp3 because it will be used after src is not needed anymore
 2259|      0|    int64_t rbytes = io_cb->read((void**)&tmp3, 1, block_csize, io_pos, fp);
 2260|      0|    frame_reader_release(frame, io_cb, fp);
 2261|      0|    if ((int32_t)rbytes != block_csize) {
  ------------------
  |  Branch (2261:9): [True: 0, False: 0]
  ------------------
 2262|      0|      BLOSC_TRACE_ERROR("Cannot read the (lazy) block out of the fileframe.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2263|      0|      return BLOSC2_ERROR_READ_BUFFER;
 2264|      0|    }
 2265|      0|    src = tmp3;
 2266|      0|    src_offset = 0;
 2267|      0|    srcsize = block_csize;
 2268|      0|  }
 2269|       |
 2270|       |  // If the chunk is memcpyed, we just have to copy the block to dest and return
 2271|  7.63M|  if (memcpyed) {
  ------------------
  |  Branch (2271:7): [True: 2.86M, False: 4.77M]
  ------------------
 2272|  2.86M|    int bsize_ = leftoverblock ? chunk_nbytes % context->blocksize : bsize;
  ------------------
  |  Branch (2272:18): [True: 43, False: 2.86M]
  ------------------
 2273|  2.86M|    if (!context->special_type) {
  ------------------
  |  Branch (2273:9): [True: 45.1k, False: 2.81M]
  ------------------
 2274|  45.1k|      if (chunk_nbytes + context->header_overhead != chunk_cbytes) {
  ------------------
  |  Branch (2274:11): [True: 0, False: 45.1k]
  ------------------
 2275|      0|        return BLOSC2_ERROR_WRITE_BUFFER;
 2276|      0|      }
 2277|  45.1k|      if (chunk_cbytes < context->header_overhead + (nblock * context->blocksize) + bsize_) {
  ------------------
  |  Branch (2277:11): [True: 0, False: 45.1k]
  ------------------
 2278|       |        /* Not enough input to copy block */
 2279|      0|        return BLOSC2_ERROR_READ_BUFFER;
 2280|      0|      }
 2281|  45.1k|    }
 2282|  2.86M|    if (!is_lazy) {
  ------------------
  |  Branch (2282:9): [True: 2.86M, False: 0]
  ------------------
 2283|  2.86M|      src += context->header_overhead + nblock * context->blocksize;
 2284|  2.86M|    }
 2285|  2.86M|    _dest = dest + dest_offset;
 2286|  2.86M|    if (context->postfilter != NULL) {
  ------------------
  |  Branch (2286:9): [True: 27.5k, False: 2.83M]
  ------------------
 2287|       |      // We are making use of a postfilter, so use a temp for destination
 2288|  27.5k|      _dest = tmp;
 2289|  27.5k|    }
 2290|  2.86M|    rc = 0;
 2291|  2.86M|    switch (context->special_type) {
 2292|  83.9k|      case BLOSC2_SPECIAL_VALUE:
  ------------------
  |  Branch (2292:7): [True: 83.9k, False: 2.77M]
  ------------------
 2293|       |        // All repeated values
 2294|  83.9k|        rc = set_values(typesize, context->src, _dest, bsize_);
 2295|  83.9k|        if (rc < 0) {
  ------------------
  |  Branch (2295:13): [True: 0, False: 83.9k]
  ------------------
 2296|      0|          BLOSC_TRACE_ERROR("set_values failed");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2297|      0|          return BLOSC2_ERROR_DATA;
 2298|      0|        }
 2299|  83.9k|        break;
 2300|  2.70M|      case BLOSC2_SPECIAL_NAN:
  ------------------
  |  Branch (2300:7): [True: 2.70M, False: 151k]
  ------------------
 2301|  2.70M|        rc = set_nans(context->typesize, _dest, bsize_);
 2302|  2.70M|        if (rc < 0) {
  ------------------
  |  Branch (2302:13): [True: 4, False: 2.70M]
  ------------------
 2303|      4|          BLOSC_TRACE_ERROR("set_nans failed");
  ------------------
  |  |   93|      4|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      4|    do {                                            \
  |  |  |  |   98|      4|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      4|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      4|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2304|      4|          return BLOSC2_ERROR_DATA;
 2305|      4|        }
 2306|  2.70M|        break;
 2307|  2.70M|      case BLOSC2_SPECIAL_ZERO:
  ------------------
  |  Branch (2307:7): [True: 22.1k, False: 2.83M]
  ------------------
 2308|  22.1k|        memset(_dest, 0, bsize_);
 2309|  22.1k|        break;
 2310|    262|      case BLOSC2_SPECIAL_UNINIT:
  ------------------
  |  Branch (2310:7): [True: 262, False: 2.85M]
  ------------------
 2311|       |        // We do nothing here
 2312|    262|        break;
 2313|  45.1k|      default:
  ------------------
  |  Branch (2313:7): [True: 45.1k, False: 2.81M]
  ------------------
 2314|  45.1k|        memcpy(_dest, src, bsize_);
 2315|  2.86M|    }
 2316|  2.86M|    if (context->postfilter != NULL) {
  ------------------
  |  Branch (2316:9): [True: 27.5k, False: 2.83M]
  ------------------
 2317|       |      // Create new postfilter parameters for this block (must be private for each thread)
 2318|  27.5k|      blosc2_postfilter_params postparams;
 2319|  27.5k|      memcpy(&postparams, context->postparams, sizeof(postparams));
 2320|  27.5k|      postparams.input = tmp;
 2321|  27.5k|      postparams.output = dest + dest_offset;
 2322|  27.5k|      postparams.size = bsize;
 2323|  27.5k|      postparams.typesize = typesize;
 2324|  27.5k|      postparams.offset = nblock * context->blocksize;
 2325|  27.5k|      postparams.nchunk = context->schunk != NULL ? context->schunk->current_nchunk : -1;
  ------------------
  |  Branch (2325:27): [True: 27.5k, False: 0]
  ------------------
 2326|  27.5k|      postparams.nblock = nblock;
 2327|  27.5k|      postparams.tid = thread_context->tid;
 2328|  27.5k|      postparams.ttmp = thread_context->tmp;
 2329|  27.5k|      postparams.ttmp_nbytes = thread_context->tmp_nbytes;
 2330|  27.5k|      postparams.ctx = context;
 2331|       |
 2332|       |      // Execute the postfilter (the processed block will be copied to dest)
 2333|  27.5k|      if (context->postfilter(&postparams) != 0) {
  ------------------
  |  Branch (2333:11): [True: 0, False: 27.5k]
  ------------------
 2334|      0|        BLOSC_TRACE_ERROR("Execution of postfilter function failed");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2335|      0|        return BLOSC2_ERROR_POSTFILTER;
 2336|      0|      }
 2337|  27.5k|    }
 2338|  2.86M|    thread_context->zfp_cell_nitems = 0;
 2339|       |
 2340|  2.86M|    return bsize_;
 2341|  2.86M|  }
 2342|       |
 2343|  4.77M|  if (!is_lazy && (src_offset <= 0 || src_offset >= srcsize)) {
  ------------------
  |  Branch (2343:7): [True: 4.77M, False: 0]
  |  Branch (2343:20): [True: 75, False: 4.76M]
  |  Branch (2343:39): [True: 92, False: 4.76M]
  ------------------
 2344|       |    /* Invalid block src offset encountered */
 2345|    167|    return BLOSC2_ERROR_DATA;
 2346|    167|  }
 2347|       |
 2348|  4.76M|  src += src_offset;
 2349|  4.76M|  if (vlblocks) {
  ------------------
  |  Branch (2349:7): [True: 1, False: 4.76M]
  ------------------
 2350|      1|    if (context->blockcbytes == NULL || nblock >= context->nblocks ||
  ------------------
  |  Branch (2350:9): [True: 0, False: 1]
  |  Branch (2350:41): [True: 0, False: 1]
  ------------------
 2351|      1|        context->blockcbytes[nblock] <= (int32_t)sizeof(int32_t) ||
  ------------------
  |  Branch (2351:9): [True: 1, False: 0]
  ------------------
 2352|      1|        src_offset > srcsize - context->blockcbytes[nblock]) {
  ------------------
  |  Branch (2352:9): [True: 0, False: 0]
  ------------------
 2353|      1|      return BLOSC2_ERROR_DATA;
 2354|      1|    }
 2355|      0|    srcsize = context->blockcbytes[nblock];
 2356|      0|  }
 2357|  4.76M|  else {
 2358|  4.76M|    srcsize -= src_offset;
 2359|  4.76M|  }
 2360|       |
 2361|  4.76M|  int last_filter_index = last_filter(context, 'd');
 2362|  4.76M|  if (instr_codec) {
  ------------------
  |  Branch (2362:7): [True: 80, False: 4.76M]
  ------------------
 2363|       |    // If instrumented, we don't want to run the filters
 2364|     80|    _dest = dest + dest_offset;
 2365|     80|  }
 2366|  4.76M|  else if (((last_filter_index >= 0) &&
  ------------------
  |  Branch (2366:13): [True: 4.22M, False: 549k]
  ------------------
 2367|  4.22M|       (next_filter(context, BLOSC2_MAX_FILTERS, 'd') != BLOSC_DELTA)) ||
  ------------------
  |  Branch (2367:8): [True: 4.22M, False: 305]
  ------------------
 2368|  4.66M|    context->postfilter != NULL) {
  ------------------
  |  Branch (2368:5): [True: 439k, False: 109k]
  ------------------
 2369|       |    // We are making use of some filter, so use a temp for destination
 2370|  4.66M|    _dest = tmp;
 2371|  4.66M|  }
 2372|   109k|  else {
 2373|       |    // If no filters, or only DELTA in pipeline
 2374|   109k|    _dest = dest + dest_offset;
 2375|   109k|  }
 2376|       |
 2377|       |  /* The number of compressed data streams for this block */
 2378|  4.76M|  if (vlblocks) {
  ------------------
  |  Branch (2378:7): [True: 0, False: 4.76M]
  ------------------
 2379|      0|    nstreams = 1;
 2380|      0|  }
 2381|  4.76M|  else if (!dont_split && !leftoverblock) {
  ------------------
  |  Branch (2381:12): [True: 483k, False: 4.28M]
  |  Branch (2381:27): [True: 483k, False: 1]
  ------------------
 2382|   483k|    nstreams = context->typesize;
 2383|   483k|  }
 2384|  4.28M|  else {
 2385|  4.28M|    nstreams = 1;
 2386|  4.28M|  }
 2387|       |
 2388|  4.76M|  neblock = bsize / nstreams;
 2389|  4.76M|  if (neblock == 0) {
  ------------------
  |  Branch (2389:7): [True: 1, False: 4.76M]
  ------------------
 2390|       |    /* Not enough space to output bytes */
 2391|      1|    BLOSC_ERROR(BLOSC2_ERROR_WRITE_BUFFER);
  ------------------
  |  |  111|      1|    do {                                            \
  |  |  112|      1|        int rc_ = (rc);                             \
  |  |  113|      1|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 1, False: 0]
  |  |  ------------------
  |  |  114|      1|            char *error_msg = print_error(rc_);     \
  |  |  115|      1|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      1|            return rc_;                             \
  |  |  117|      1|        }                                           \
  |  |  118|      1|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2392|      1|  }
 2393|       |  /* The splits must cover the whole block, or part of tmp is left unwritten */
 2394|  4.76M|  if (neblock * nstreams != bsize) {
  ------------------
  |  Branch (2394:7): [True: 7, False: 4.76M]
  ------------------
 2395|      7|    BLOSC_ERROR(BLOSC2_ERROR_DATA);
  ------------------
  |  |  111|      7|    do {                                            \
  |  |  112|      7|        int rc_ = (rc);                             \
  |  |  113|      7|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 7, False: 0]
  |  |  ------------------
  |  |  114|      7|            char *error_msg = print_error(rc_);     \
  |  |  115|      7|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      7|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      7|    do {                                            \
  |  |  |  |  |  |   98|      7|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      7|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 7, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      7|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      7|            return rc_;                             \
  |  |  117|      7|        }                                           \
  |  |  118|      7|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2396|      7|  }
 2397|  9.54M|  for (int j = 0; j < nstreams; j++) {
  ------------------
  |  Branch (2397:19): [True: 4.77M, False: 4.76M]
  ------------------
 2398|  4.77M|    if (vlblocks) {
  ------------------
  |  Branch (2398:9): [True: 0, False: 4.77M]
  ------------------
 2399|      0|      if (srcsize < (signed)sizeof(int32_t)) {
  ------------------
  |  Branch (2399:11): [True: 0, False: 0]
  ------------------
 2400|       |        /* Not enough input to read compressed bytes */
 2401|      0|        return BLOSC2_ERROR_READ_BUFFER;
 2402|      0|      }
 2403|      0|      neblock = sw32_(src);
 2404|      0|      if (neblock != bsize) {
  ------------------
  |  Branch (2404:11): [True: 0, False: 0]
  ------------------
 2405|      0|        return BLOSC2_ERROR_DATA;
 2406|      0|      }
 2407|      0|      src += sizeof(int32_t);
 2408|      0|      cbytes = srcsize - (int32_t)sizeof(int32_t);
 2409|      0|      srcsize = 0;
 2410|      0|    }
 2411|  4.77M|    else {
 2412|  4.77M|      if (srcsize < (signed)sizeof(int32_t)) {
  ------------------
  |  Branch (2412:11): [True: 0, False: 4.77M]
  ------------------
 2413|       |        /* Not enough input to read compressed size */
 2414|      0|        return BLOSC2_ERROR_READ_BUFFER;
 2415|      0|      }
 2416|  4.77M|      srcsize -= sizeof(int32_t);
 2417|  4.77M|      cbytes = sw32_(src);      /* amount of compressed bytes */
 2418|  4.77M|      if (cbytes > 0) {
  ------------------
  |  Branch (2418:11): [True: 4.73M, False: 45.0k]
  ------------------
 2419|  4.73M|        if (srcsize < cbytes) {
  ------------------
  |  Branch (2419:13): [True: 22, False: 4.72M]
  ------------------
 2420|       |          /* Not enough input to read compressed bytes */
 2421|     22|          return BLOSC2_ERROR_READ_BUFFER;
 2422|     22|        }
 2423|  4.72M|        srcsize -= cbytes;
 2424|  4.72M|      }
 2425|  4.77M|      src += sizeof(int32_t);
 2426|  4.77M|    }
 2427|       |    // ctbytes += (signed)sizeof(int32_t);
 2428|       |
 2429|       |    /* Uncompress */
 2430|  4.77M|    if (!vlblocks && cbytes == 0) {
  ------------------
  |  Branch (2430:9): [True: 4.77M, False: 0]
  |  Branch (2430:22): [True: 43.9k, False: 4.73M]
  ------------------
 2431|       |      // A run of 0's
 2432|  43.9k|      memset(_dest, 0, (unsigned int)neblock);
 2433|  43.9k|      nbytes = neblock;
 2434|  43.9k|    }
 2435|  4.73M|    else if (!vlblocks && cbytes < 0) {
  ------------------
  |  Branch (2435:14): [True: 4.73M, False: 0]
  |  Branch (2435:27): [True: 1.06k, False: 4.72M]
  ------------------
 2436|       |      // A negative number means some encoding depending on the token that comes next
 2437|  1.06k|      uint8_t token;
 2438|       |
 2439|  1.06k|      if (srcsize < (signed)sizeof(uint8_t)) {
  ------------------
  |  Branch (2439:11): [True: 1, False: 1.06k]
  ------------------
 2440|       |        // Not enough input to read token */
 2441|      1|        return BLOSC2_ERROR_READ_BUFFER;
 2442|      1|      }
 2443|  1.06k|      srcsize -= sizeof(uint8_t);
 2444|       |
 2445|  1.06k|      token = src[0];
 2446|  1.06k|      src += 1;
 2447|       |      // ctbytes += 1;
 2448|       |
 2449|  1.06k|      if (token & 0x1) {
  ------------------
  |  Branch (2449:11): [True: 1.06k, False: 6]
  ------------------
 2450|       |        // A run of bytes that are different than 0
 2451|  1.06k|        if (cbytes < -255) {
  ------------------
  |  Branch (2451:13): [True: 23, False: 1.03k]
  ------------------
 2452|       |          // Runs can only encode a byte
 2453|     23|          return BLOSC2_ERROR_RUN_LENGTH;
 2454|     23|        }
 2455|  1.03k|        uint8_t value = -cbytes;
 2456|  1.03k|        memset(_dest, value, (unsigned int)neblock);
 2457|  1.03k|      } else {
 2458|      6|        BLOSC_TRACE_ERROR("Invalid or unsupported compressed stream token value - %d", token);
  ------------------
  |  |   93|      6|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      6|    do {                                            \
  |  |  |  |   98|      6|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      6|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      6|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2459|      6|        return BLOSC2_ERROR_RUN_LENGTH;
 2460|      6|      }
 2461|  1.03k|      nbytes = neblock;
 2462|  1.03k|      cbytes = 0;  // everything is encoded in the cbytes token
 2463|  1.03k|    }
 2464|  4.72M|    else if (cbytes == neblock) {
  ------------------
  |  Branch (2464:14): [True: 126k, False: 4.60M]
  ------------------
 2465|   126k|      memcpy(_dest, src, (unsigned int)neblock);
 2466|   126k|      nbytes = (int32_t)neblock;
 2467|   126k|    }
 2468|  4.60M|    else {
 2469|  4.60M|      if (compformat == BLOSC_BLOSCLZ_FORMAT) {
  ------------------
  |  Branch (2469:11): [True: 4.60M, False: 317]
  ------------------
 2470|  4.60M|        nbytes = blosclz_decompress(src, cbytes, _dest, (int)neblock);
 2471|  4.60M|      }
 2472|    317|      else if (compformat == BLOSC_LZ4_FORMAT) {
  ------------------
  |  Branch (2472:16): [True: 203, False: 114]
  ------------------
 2473|    203|        nbytes = lz4_wrap_decompress((char*)src, (size_t)cbytes,
 2474|    203|                                     (char*)_dest, (size_t)neblock,
 2475|    203|                                     thread_context);
 2476|    203|      }
 2477|    114|  #if defined(HAVE_ZLIB)
 2478|    114|      else if (compformat == BLOSC_ZLIB_FORMAT) {
  ------------------
  |  Branch (2478:16): [True: 5, False: 109]
  ------------------
 2479|      5|        nbytes = zlib_wrap_decompress((char*)src, (size_t)cbytes,
 2480|      5|                                      (char*)_dest, (size_t)neblock);
 2481|      5|      }
 2482|    109|  #endif /*  HAVE_ZLIB */
 2483|    109|  #if defined(HAVE_ZSTD)
 2484|    109|      else if (compformat == BLOSC_ZSTD_FORMAT) {
  ------------------
  |  Branch (2484:16): [True: 11, False: 98]
  ------------------
 2485|     11|        nbytes = zstd_wrap_decompress(thread_context,
 2486|     11|                                      (char*)src, (size_t)cbytes,
 2487|     11|                                      (char*)_dest, (size_t)neblock);
 2488|     11|      }
 2489|     98|  #endif /*  HAVE_ZSTD */
 2490|     98|      else if (compformat == BLOSC_UDCODEC_FORMAT) {
  ------------------
  |  Branch (2490:16): [True: 97, False: 1]
  ------------------
 2491|     97|        bool getcell = false;
 2492|       |
 2493|     97|#if defined(HAVE_ZFP)
 2494|     97|        if ((context->compcode == BLOSC_CODEC_ZFP_FIXED_RATE) &&
  ------------------
  |  Branch (2494:13): [True: 1, False: 96]
  ------------------
 2495|      1|            (thread_context->zfp_cell_nitems > 0)) {
  ------------------
  |  Branch (2495:13): [True: 0, False: 1]
  ------------------
 2496|      0|          nbytes = zfp_getcell(thread_context, src, cbytes, _dest, neblock);
 2497|      0|          if (nbytes < 0) {
  ------------------
  |  Branch (2497:15): [True: 0, False: 0]
  ------------------
 2498|      0|            return BLOSC2_ERROR_DATA;
 2499|      0|          }
 2500|      0|          if (nbytes == thread_context->zfp_cell_nitems * typesize) {
  ------------------
  |  Branch (2500:15): [True: 0, False: 0]
  ------------------
 2501|      0|            getcell = true;
 2502|      0|          }
 2503|      0|        }
 2504|     97|#endif /* HAVE_ZFP */
 2505|     97|        if (!getcell) {
  ------------------
  |  Branch (2505:13): [True: 97, False: 0]
  ------------------
 2506|     97|          thread_context->zfp_cell_nitems = 0;
 2507|    151|          for (int i = 0; i < g_ncodecs; ++i) {
  ------------------
  |  Branch (2507:27): [True: 148, False: 3]
  ------------------
 2508|    148|            if (g_codecs[i].compcode == context->compcode) {
  ------------------
  |  Branch (2508:17): [True: 94, False: 54]
  ------------------
 2509|     94|              if (load_acquire_ptr(&g_codecs[i].decoder) == NULL) {
  ------------------
  |  |  144|     94|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (2509:19): [True: 4, False: 90]
  ------------------
 2510|       |                // Dynamically load codec plugin
 2511|      4|                if (fill_codec(&g_codecs[i]) < 0) {
  ------------------
  |  Branch (2511:21): [True: 4, False: 0]
  ------------------
 2512|      4|                  BLOSC_TRACE_ERROR("Could not load codec %d.", g_codecs[i].compcode);
  ------------------
  |  |   93|      4|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      4|    do {                                            \
  |  |  |  |   98|      4|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      4|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      4|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2513|      4|                  return BLOSC2_ERROR_CODEC_SUPPORT;
 2514|      4|                }
 2515|      4|              }
 2516|     90|              blosc2_dparams dparams;
 2517|     90|              blosc2_ctx_get_dparams(context, &dparams);
 2518|     90|              nbytes = g_codecs[i].decoder(src,
 2519|     90|                                           cbytes,
 2520|     90|                                           _dest,
 2521|     90|                                           neblock,
 2522|     90|                                           context->compcode_meta,
 2523|     90|                                           &dparams,
 2524|     90|                                           context->src);
 2525|     90|              goto urcodecsuccess;
 2526|     94|            }
 2527|    148|          }
 2528|      3|          BLOSC_TRACE_ERROR("User-defined compressor codec %d not found during decompression", context->compcode);
  ------------------
  |  |   93|      3|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      3|    do {                                            \
  |  |  |  |   98|      3|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      3|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      3|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2529|      3|          return BLOSC2_ERROR_CODEC_SUPPORT;
 2530|     97|        }
 2531|     90|      urcodecsuccess:
 2532|     90|        ;
 2533|     90|      }
 2534|      1|      else {
 2535|      1|        compname = clibcode_to_clibname(compformat);
 2536|      1|        BLOSC_TRACE_ERROR(
  ------------------
  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2537|      1|                "Blosc has not been compiled with decompression "
 2538|      1|                "support for '%s' format.  "
 2539|      1|                "Please recompile for adding this support.", compname);
 2540|      1|        return BLOSC2_ERROR_CODEC_SUPPORT;
 2541|      1|      }
 2542|       |
 2543|       |      /* Check that decompressed bytes number is correct */
 2544|  4.60M|      if ((nbytes != neblock) && (thread_context->zfp_cell_nitems == 0)) {
  ------------------
  |  Branch (2544:11): [True: 320, False: 4.60M]
  |  Branch (2544:34): [True: 320, False: 0]
  ------------------
 2545|    320|        return BLOSC2_ERROR_DATA;
 2546|    320|      }
 2547|       |
 2548|  4.60M|    }
 2549|  4.77M|    src += cbytes;
 2550|       |    // ctbytes += cbytes;
 2551|  4.77M|    _dest += nbytes;
 2552|  4.77M|    ntbytes += nbytes;
 2553|  4.77M|  } /* Closes j < nstreams */
 2554|       |
 2555|  4.76M|  if (!instr_codec) {
  ------------------
  |  Branch (2555:7): [True: 4.76M, False: 57]
  ------------------
 2556|  4.76M|    if (last_filter_index >= 0 || context->postfilter != NULL) {
  ------------------
  |  Branch (2556:9): [True: 4.22M, False: 549k]
  |  Branch (2556:35): [True: 439k, False: 109k]
  ------------------
 2557|       |      /* Apply regular filter pipeline */
 2558|  4.66M|      int errcode = pipeline_backward(thread_context, bsize, dest, dest_offset, tmp, tmp2, tmp3,
 2559|  4.66M|                                      last_filter_index, nblock);
 2560|  4.66M|      if (errcode < 0)
  ------------------
  |  Branch (2560:11): [True: 72, False: 4.66M]
  ------------------
 2561|     72|        return errcode;
 2562|  4.66M|    }
 2563|  4.76M|  }
 2564|       |
 2565|       |  /* Return the number of uncompressed bytes */
 2566|  4.76M|  return (int)ntbytes;
 2567|  4.76M|}
blosc2.c:lz4_wrap_decompress:
  659|    203|                               struct thread_context* thread_context) {
  660|    203|  int nbytes;
  661|    203|  blosc2_context* context = thread_context->parent_context;
  662|    203|  if (context->use_dict && context->dict_buffer != NULL && context->dict_size > 0) {
  ------------------
  |  Branch (662:7): [True: 109, False: 94]
  |  Branch (662:28): [True: 109, False: 0]
  |  Branch (662:60): [True: 109, False: 0]
  ------------------
  663|    109|    nbytes = LZ4_decompress_safe_usingDict(input, output,
  664|    109|                                           (int)compressed_length, (int)maxout,
  665|    109|                                           (const char*)context->dict_buffer,
  666|    109|                                           (int)context->dict_size);
  667|    109|  } else {
  668|     94|    nbytes = LZ4_decompress_safe(input, output, (int)compressed_length, (int)maxout);
  669|     94|  }
  670|    203|  if (nbytes != (int)maxout) {
  ------------------
  |  Branch (670:7): [True: 202, False: 1]
  ------------------
  671|    202|    return 0;
  672|    202|  }
  673|      1|  return (int)maxout;
  674|    203|}
blosc2.c:zlib_wrap_decompress:
  698|      5|                                char* output, size_t maxout) {
  699|      5|  int status;
  700|      5|#if defined(HAVE_ZLIB_NG) && ! defined(ZLIB_COMPAT)
  701|      5|  size_t ul = maxout;
  702|      5|  status = zng_uncompress(
  703|      5|      (uint8_t*)output, &ul, (uint8_t*)input, compressed_length);
  704|       |#else
  705|       |  uLongf ul = (uLongf)maxout;
  706|       |  status = uncompress(
  707|       |      (Bytef*)output, &ul, (Bytef*)input, (uLong)compressed_length);
  708|       |#endif
  709|      5|  if (status != Z_OK) {
  ------------------
  |  |  180|      5|#define Z_OK            0
  ------------------
  |  Branch (709:7): [True: 5, False: 0]
  ------------------
  710|      5|    return 0;
  711|      5|  }
  712|      0|  return (int)ul;
  713|      5|}
blosc2.c:zstd_wrap_decompress:
  750|     11|                                char* output, size_t maxout) {
  751|     11|  size_t code;
  752|     11|  blosc2_context* context = thread_context->parent_context;
  753|       |
  754|     11|  if (thread_context->zstd_dctx == NULL) {
  ------------------
  |  Branch (754:7): [True: 11, False: 0]
  ------------------
  755|     11|    thread_context->zstd_dctx = ZSTD_createDCtx();
  756|     11|  }
  757|       |
  758|     11|  if (context->use_dict) {
  ------------------
  |  Branch (758:7): [True: 7, False: 4]
  ------------------
  759|      7|    assert(context->dict_ddict != NULL);
  760|      7|    code = ZSTD_decompress_usingDDict(
  761|      7|            thread_context->zstd_dctx, (void*)output, maxout, (void*)input,
  762|      7|            compressed_length, context->dict_ddict);
  763|      7|  } else {
  764|      4|    code = ZSTD_decompressDCtx(thread_context->zstd_dctx,
  765|      4|        (void*)output, maxout, (void*)input, compressed_length);
  766|      4|  }
  767|     11|  if (ZSTD_isError(code) != ZSTD_error_no_error) {
  ------------------
  |  Branch (767:7): [True: 11, False: 0]
  ------------------
  768|     11|    BLOSC_TRACE_ERROR("Error in ZSTD decompression: '%s'.  Giving up.",
  ------------------
  |  |   93|     11|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     11|    do {                                            \
  |  |  |  |   98|     11|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     11|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     11|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  769|     11|                      ZDICT_getErrorName(code));
  770|     11|    return 0;
  771|     11|  }
  772|      0|  return (int)code;
  773|     11|}
blosc2.c:set_values:
 2053|  94.0k|static int32_t set_values(int32_t typesize, const uint8_t* src, uint8_t* dest, int32_t destsize) {
 2054|       |#if defined(BLOSC_STRICT_ALIGN)
 2055|       |  if (destsize % typesize != 0) {
 2056|       |    BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
 2057|       |  }
 2058|       |  int32_t nitems = destsize / typesize;
 2059|       |  if (nitems == 0) {
 2060|       |    return 0;
 2061|       |  }
 2062|       |  for (int i = 0; i < nitems; i++) {
 2063|       |    memcpy(dest + i * typesize, src + BLOSC_EXTENDED_HEADER_LENGTH, typesize);
 2064|       |  }
 2065|       |#else
 2066|  94.0k|  if (destsize % typesize != 0) {
  ------------------
  |  Branch (2066:7): [True: 1, False: 94.0k]
  ------------------
 2067|      1|    BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      1|    do {                                            \
  |  |  112|      1|        int rc_ = (rc);                             \
  |  |  113|      1|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 1, False: 0]
  |  |  ------------------
  |  |  114|      1|            char *error_msg = print_error(rc_);     \
  |  |  115|      1|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      1|            return rc_;                             \
  |  |  117|      1|        }                                           \
  |  |  118|      1|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2068|      1|  }
 2069|  94.0k|  int32_t nitems = destsize / typesize;
 2070|  94.0k|  if (nitems == 0) {
  ------------------
  |  Branch (2070:7): [True: 0, False: 94.0k]
  ------------------
 2071|      0|    return 0;
 2072|      0|  }
 2073|       |
 2074|  94.0k|  switch (typesize) {
 2075|  72.0k|    case 8: {
  ------------------
  |  Branch (2075:5): [True: 72.0k, False: 22.0k]
  ------------------
 2076|  72.0k|      int64_t val8 = ((int64_t*)(src + BLOSC_EXTENDED_HEADER_LENGTH))[0];
 2077|  72.0k|      int64_t* dest8 = (int64_t*)dest;
 2078|  16.5M|      for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (2078:23): [True: 16.5M, False: 72.0k]
  ------------------
 2079|  16.5M|        dest8[i] = val8;
 2080|  16.5M|      }
 2081|  72.0k|      break;
 2082|      0|    }
 2083|  3.77k|    case 4: {
  ------------------
  |  Branch (2083:5): [True: 3.77k, False: 90.3k]
  ------------------
 2084|  3.77k|      int32_t val4 = ((int32_t*)(src + BLOSC_EXTENDED_HEADER_LENGTH))[0];
 2085|  3.77k|      int32_t* dest4 = (int32_t*)dest;
 2086|  3.70G|      for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (2086:23): [True: 3.70G, False: 3.77k]
  ------------------
 2087|  3.70G|        dest4[i] = val4;
 2088|  3.70G|      }
 2089|  3.77k|      break;
 2090|      0|    }
 2091|    310|    case 2: {
  ------------------
  |  Branch (2091:5): [True: 310, False: 93.7k]
  ------------------
 2092|    310|      int16_t val2 = ((int16_t*)(src + BLOSC_EXTENDED_HEADER_LENGTH))[0];
 2093|    310|      int16_t* dest2 = (int16_t*)dest;
 2094|  88.7k|      for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (2094:23): [True: 88.4k, False: 310]
  ------------------
 2095|  88.4k|        dest2[i] = val2;
 2096|  88.4k|      }
 2097|    310|      break;
 2098|      0|    }
 2099|  12.8k|    case 1: {
  ------------------
  |  Branch (2099:5): [True: 12.8k, False: 81.2k]
  ------------------
 2100|  12.8k|      int8_t val1 = ((int8_t*)(src + BLOSC_EXTENDED_HEADER_LENGTH))[0];
 2101|  12.8k|      int8_t* dest1 = (int8_t*)dest;
 2102|   401M|      for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (2102:23): [True: 401M, False: 12.8k]
  ------------------
 2103|   401M|        dest1[i] = val1;
 2104|   401M|      }
 2105|  12.8k|      break;
 2106|      0|    }
 2107|  5.20k|    default:
  ------------------
  |  Branch (2107:5): [True: 5.20k, False: 88.8k]
  ------------------
 2108|  5.36M|      for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (2108:23): [True: 5.35M, False: 5.20k]
  ------------------
 2109|  5.35M|        memcpy(dest + i * typesize, src + BLOSC_EXTENDED_HEADER_LENGTH, typesize);
 2110|  5.35M|      }
 2111|  94.0k|  }
 2112|  94.0k|#endif
 2113|       |
 2114|  94.0k|  return nitems;
 2115|  94.0k|}
blosc2.c:set_nans:
 2021|  2.70M|static int32_t set_nans(int32_t typesize, uint8_t* dest, int32_t destsize) {
 2022|  2.70M|  if (destsize % typesize != 0) {
  ------------------
  |  Branch (2022:7): [True: 2, False: 2.70M]
  ------------------
 2023|      2|    BLOSC_TRACE_ERROR("destsize can only be a multiple of typesize");
  ------------------
  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2024|      2|    BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      2|    do {                                            \
  |  |  112|      2|        int rc_ = (rc);                             \
  |  |  113|      2|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 2, False: 0]
  |  |  ------------------
  |  |  114|      2|            char *error_msg = print_error(rc_);     \
  |  |  115|      2|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      2|            return rc_;                             \
  |  |  117|      2|        }                                           \
  |  |  118|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2025|      2|  }
 2026|  2.70M|  int32_t nitems = destsize / typesize;
 2027|  2.70M|  if (nitems == 0) {
  ------------------
  |  Branch (2027:7): [True: 0, False: 2.70M]
  ------------------
 2028|      0|    return 0;
 2029|      0|  }
 2030|       |
 2031|  2.70M|  if (typesize == 4) {
  ------------------
  |  Branch (2031:7): [True: 2.23M, False: 477k]
  ------------------
 2032|  2.23M|    float* dest_ = (float*)dest;
 2033|  2.23M|    float val = nanf("");
 2034|  1.54G|    for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (2034:21): [True: 1.54G, False: 2.23M]
  ------------------
 2035|  1.54G|      dest_[i] = val;
 2036|  1.54G|    }
 2037|  2.23M|    return nitems;
 2038|  2.23M|  }
 2039|   477k|  else if (typesize == 8) {
  ------------------
  |  Branch (2039:12): [True: 477k, False: 2]
  ------------------
 2040|   477k|    double* dest_ = (double*)dest;
 2041|   477k|    double val = nan("");
 2042|   295M|    for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (2042:21): [True: 295M, False: 477k]
  ------------------
 2043|   295M|      dest_[i] = val;
 2044|   295M|    }
 2045|   477k|    return nitems;
 2046|   477k|  }
 2047|       |
 2048|      2|  BLOSC_TRACE_ERROR("Unsupported typesize for NaN");
  ------------------
  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2049|      2|  return BLOSC2_ERROR_DATA;
 2050|  2.70M|}
blosc2.c:getitem_read_header:
 5177|  2.90M|static int getitem_read_header(const void* src, int32_t srcsize, blosc_header* header) {
 5178|  2.90M|  int result = read_chunk_header((uint8_t *) src, srcsize, true, header);
 5179|  2.90M|  if (result < 0) {
  ------------------
  |  Branch (5179:7): [True: 0, False: 2.90M]
  ------------------
 5180|      0|    return result;
 5181|      0|  }
 5182|  2.90M|  if (header->blosc2_flags2 & BLOSC2_VL_BLOCKS) {
  ------------------
  |  Branch (5182:7): [True: 0, False: 2.90M]
  ------------------
 5183|      0|    BLOSC_TRACE_ERROR("getitem is not supported for VL-block chunks.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5184|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 5185|      0|  }
 5186|  2.90M|  return 0;
 5187|  2.90M|}
blosc2.c:getitem_with_header:
 5193|  2.90M|                               int start, int nitems, void* dest, int32_t destsize) {
 5194|       |  /* Minimally populate the context */
 5195|  2.90M|  context->src = src;
 5196|  2.90M|  context->srcsize = srcsize;
 5197|  2.90M|  context->dest = dest;
 5198|  2.90M|  context->destsize = destsize;
 5199|       |
 5200|  2.90M|  int result = blosc2_initialize_context_from_header(context, header);
 5201|  2.90M|  if (result < 0) {
  ------------------
  |  Branch (5201:7): [True: 0, False: 2.90M]
  ------------------
 5202|      0|    return result;
 5203|      0|  }
 5204|       |
 5205|       |  /* Call the actual getitem function */
 5206|  2.90M|  return _blosc_getitem(context, header, src, srcsize, start, nitems, dest, destsize);
 5207|  2.90M|}
blosc2.c:blosc2_initialize_context_from_header:
 1050|  4.54M|static int blosc2_initialize_context_from_header(blosc2_context* context, blosc_header* header) {
 1051|  4.54M|  context->header_flags = header->flags;
 1052|  4.54M|  context->typesize = header->typesize;
 1053|  4.54M|  context->sourcesize = header->nbytes;
 1054|  4.54M|  context->header_blocksize = header->blocksize;
 1055|  4.54M|  context->blocksize = header->blocksize;
 1056|  4.54M|  context->blosc2_flags2 = header->blosc2_flags2;
 1057|  4.54M|  context->blosc2_flags = header->blosc2_flags;
 1058|  4.54M|  context->compcode = header->flags >> 5;
 1059|  4.54M|  if (context->compcode == BLOSC_UDCODEC_FORMAT) {
  ------------------
  |  Branch (1059:7): [True: 128, False: 4.54M]
  ------------------
 1060|    128|    context->compcode = header->udcompcode;
 1061|    128|  }
 1062|  4.54M|  if (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) {
  ------------------
  |  Branch (1062:7): [True: 124, False: 4.54M]
  ------------------
 1063|    124|    context->nblocks = header->blocksize;
 1064|    124|    context->leftover = 0;
 1065|    124|    context->blocksize = 0;
 1066|    124|  }
 1067|  4.54M|  else {
 1068|  4.54M|    blosc2_calculate_blocks(context);
 1069|  4.54M|  }
 1070|       |
 1071|  4.54M|  bool is_lazy = false;
 1072|  4.54M|  if ((context->header_flags & BLOSC_DOSHUFFLE) &&
  ------------------
  |  Branch (1072:7): [True: 4.54M, False: 256]
  ------------------
 1073|  4.54M|      (context->header_flags & BLOSC_DOBITSHUFFLE)) {
  ------------------
  |  Branch (1073:7): [True: 4.54M, False: 23]
  ------------------
 1074|       |    /* Extended header */
 1075|  4.54M|    context->header_overhead = BLOSC_EXTENDED_HEADER_LENGTH;
 1076|       |
 1077|  4.54M|    memcpy(context->filters, header->filters, BLOSC2_MAX_FILTERS);
 1078|  4.54M|    memcpy(context->filters_meta, header->filters_meta, BLOSC2_MAX_FILTERS);
 1079|  4.54M|    context->compcode_meta = header->compcode_meta;
 1080|       |
 1081|  4.54M|    context->filter_flags = filters_to_flags(header->filters);
 1082|  4.54M|    context->special_type = (header->blosc2_flags >> 4) & BLOSC2_SPECIAL_MASK;
 1083|       |
 1084|       |    // Chunks with special values cannot be lazy (as in blosc_d()), and their
 1085|       |    // value is read from the buffer, so the cbytes check below must apply
 1086|  4.54M|    is_lazy = (context->blosc2_flags & 0x08u) && !context->special_type;
  ------------------
  |  Branch (1086:15): [True: 83, False: 4.54M]
  |  Branch (1086:50): [True: 42, False: 41]
  ------------------
 1087|  4.54M|  }
 1088|    279|  else {
 1089|    279|    context->header_overhead = BLOSC_MIN_HEADER_LENGTH;
 1090|    279|    context->filter_flags = get_filter_flags(context->header_flags, context->typesize);
 1091|    279|    flags_to_filters(context->header_flags, context->filters);
 1092|    279|  }
 1093|       |
 1094|       |  // Some checks for malformed headers
 1095|  4.54M|  if (!is_lazy && header->cbytes > context->srcsize) {
  ------------------
  |  Branch (1095:7): [True: 4.54M, False: 42]
  |  Branch (1095:19): [True: 0, False: 4.54M]
  ------------------
 1096|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 1097|      0|  }
 1098|       |
 1099|  4.54M|  return 0;
 1100|  4.54M|}
blosc2.c:get_filter_flags:
  890|    279|                                const int32_t typesize) {
  891|    279|  uint8_t flags = 0;
  892|       |
  893|    279|  if ((header_flags & BLOSC_DOSHUFFLE) && (typesize > 1)) {
  ------------------
  |  Branch (893:7): [True: 23, False: 256]
  |  Branch (893:43): [True: 12, False: 11]
  ------------------
  894|     12|    flags |= BLOSC_DOSHUFFLE;
  895|     12|  }
  896|    279|  if (header_flags & BLOSC_DOBITSHUFFLE) {
  ------------------
  |  Branch (896:7): [True: 157, False: 122]
  ------------------
  897|    157|    flags |= BLOSC_DOBITSHUFFLE;
  898|    157|  }
  899|    279|  if (header_flags & BLOSC_DODELTA) {
  ------------------
  |  Branch (899:7): [True: 248, False: 31]
  ------------------
  900|    248|    flags |= BLOSC_DODELTA;
  901|    248|  }
  902|    279|  if (header_flags & BLOSC_MEMCPYED) {
  ------------------
  |  Branch (902:7): [True: 102, False: 177]
  ------------------
  903|    102|    flags |= BLOSC_MEMCPYED;
  904|    102|  }
  905|    279|  return flags;
  906|    279|}
blosc2.c:clear_context_decompression_dict:
 3049|  1.64M|static void clear_context_decompression_dict(blosc2_context* context) {
 3050|  1.64M|  context->use_dict = 0;
 3051|  1.64M|  release_context_dict_buffer(context);
 3052|  1.64M|#if defined(HAVE_ZSTD)
 3053|  1.64M|  if (context->dict_ddict != NULL) {
  ------------------
  |  Branch (3053:7): [True: 0, False: 1.64M]
  ------------------
 3054|      0|    ZSTD_freeDDict(context->dict_ddict);
 3055|      0|    context->dict_ddict = NULL;
 3056|      0|  }
 3057|       |#else
 3058|       |  context->dict_ddict = NULL;
 3059|       |#endif
 3060|  1.64M|}
blosc2.c:check_nthreads:
 2714|  3.46M|static int check_nthreads(blosc2_context* context, bool start_backend) {
 2715|  3.46M|  if (context->new_nthreads != context->nthreads && context->new_nthreads <= 0) {
  ------------------
  |  Branch (2715:7): [True: 7, False: 3.46M]
  |  Branch (2715:53): [True: 7, False: 0]
  ------------------
 2716|      7|    BLOSC_TRACE_ERROR("nthreads must be >= 1 and <= %d", INT16_MAX);
  ------------------
  |  |   93|      7|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      7|    do {                                            \
  |  |  |  |   98|      7|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      7|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      7|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 2716|      0|    BLOSC_TRACE_ERROR("nthreads must be >= 1 and <= %d", INT16_MAX);
  |  |  |  |  ------------------
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2717|      7|    return BLOSC2_ERROR_INVALID_PARAM;
 2718|      7|  }
 2719|  3.46M|  if (context->nthreads <= 0) {
  ------------------
  |  Branch (2719:7): [True: 0, False: 3.46M]
  ------------------
 2720|      0|    BLOSC_TRACE_ERROR("nthreads must be >= 1 and <= %d", INT16_MAX);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 2720|      0|    BLOSC_TRACE_ERROR("nthreads must be >= 1 and <= %d", INT16_MAX);
  |  |  |  |  ------------------
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2721|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2722|      0|  }
 2723|       |
 2724|       |  /* Detect a pool that was torn down by blosc2_destroy() while this context
 2725|       |   * was still alive, or that belongs to the parent of a forked process.  The
 2726|       |   * epoch mismatch tells us the pool pointer is dangling or has no threads;
 2727|       |   * clear it so the re-attach logic below creates a fresh one. */
 2728|  3.46M|  if (context->thread_backend == BLOSC_BACKEND_SHARED_POOL &&
  ------------------
  |  |   34|  6.93M|#define BLOSC_BACKEND_SHARED_POOL 1
  ------------------
  |  Branch (2728:7): [True: 0, False: 3.46M]
  ------------------
 2729|      0|      context->pool_epoch != load_acquire_int(&g_destroy_count)) {
  ------------------
  |  |  142|      0|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (2729:7): [True: 0, False: 0]
  ------------------
 2730|      0|    context->thread_pool = NULL;
 2731|      0|    context->threads_started = 0;
 2732|      0|    context->thread_backend = BLOSC_BACKEND_SERIAL;
  ------------------
  |  |   33|      0|#define BLOSC_BACKEND_SERIAL 0
  ------------------
 2733|      0|  }
 2734|       |
 2735|  3.46M|  if (context->new_nthreads != context->nthreads) {
  ------------------
  |  Branch (2735:7): [True: 0, False: 3.46M]
  ------------------
 2736|      0|    release_thread_backend(context);
 2737|      0|    context->nthreads = context->new_nthreads;
 2738|      0|  }
 2739|  3.46M|  if (start_backend && context->nthreads > 1 && context->threads_started == 0) {
  ------------------
  |  Branch (2739:7): [True: 63.3k, False: 3.40M]
  |  Branch (2739:24): [True: 63.3k, False: 0]
  |  Branch (2739:49): [True: 63.3k, False: 0]
  ------------------
 2740|  63.3k|    int rc;
 2741|  63.3k|    if (threads_callback) {
  ------------------
  |  Branch (2741:9): [True: 0, False: 63.3k]
  ------------------
 2742|      0|      rc = init_callback_threads(context);
 2743|      0|    }
 2744|  63.3k|    else {
 2745|       |#if defined(_WIN32)
 2746|       |      rc = init_threadpool(context);
 2747|       |#else
 2748|  63.3k|      rc = attach_shared_pool(context);
 2749|  63.3k|#endif
 2750|  63.3k|    }
 2751|  63.3k|    if (rc < 0) {
  ------------------
  |  Branch (2751:9): [True: 0, False: 63.3k]
  ------------------
 2752|      0|      return rc;
 2753|      0|    }
 2754|  63.3k|  }
 2755|  3.46M|  if (context->nthreads <= 1) {
  ------------------
  |  Branch (2755:7): [True: 2.25M, False: 1.21M]
  ------------------
 2756|  2.25M|    context->thread_backend = BLOSC_BACKEND_SERIAL;
  ------------------
  |  |   33|  2.25M|#define BLOSC_BACKEND_SERIAL 0
  ------------------
 2757|  2.25M|  }
 2758|       |
 2759|  3.46M|  return context->nthreads;
 2760|  3.46M|}
blosc2.c:attach_shared_pool:
 6032|  63.3k|static int attach_shared_pool(blosc2_context *context) {
 6033|  63.3k|  struct blosc_shared_pool *pool;
 6034|       |
 6035|  63.3k|  blosc2_init();
 6036|  63.3k|  static_lock(&pool_registry_mutex);
  ------------------
  |  |  132|  63.3k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 6037|  63.3k|  pool = find_shared_pool_locked(context->nthreads);
 6038|  63.3k|  if (pool == NULL) {
  ------------------
  |  Branch (6038:7): [True: 23, False: 63.3k]
  ------------------
 6039|     23|    int rc = create_shared_pool(context->nthreads, &pool);
 6040|     23|    if (rc < 0) {
  ------------------
  |  Branch (6040:9): [True: 0, False: 23]
  ------------------
 6041|      0|      static_unlock(&pool_registry_mutex);
  ------------------
  |  |  133|      0|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6042|      0|      return rc;
 6043|      0|    }
 6044|     23|    pool->next = shared_pools;
 6045|     23|    shared_pools = pool;
 6046|     23|  }
 6047|  63.3k|  pool->context_refs++;
 6048|  63.3k|  context->thread_pool = pool;
 6049|  63.3k|  context->thread_backend = BLOSC_BACKEND_SHARED_POOL;
  ------------------
  |  |   34|  63.3k|#define BLOSC_BACKEND_SHARED_POOL 1
  ------------------
 6050|  63.3k|  context->threads_started = context->nthreads;
 6051|  63.3k|  context->pool_epoch = load_acquire_int(&g_destroy_count);
  ------------------
  |  |  142|  63.3k|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
 6052|  63.3k|  static_unlock(&pool_registry_mutex);
  ------------------
  |  |  133|  63.3k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6053|  63.3k|  return 0;
 6054|  63.3k|}
blosc2.c:find_shared_pool_locked:
 5882|  63.3k|static struct blosc_shared_pool* find_shared_pool_locked(int16_t nthreads) {
 5883|  63.3k|  struct blosc_shared_pool *pool = shared_pools;
 5884|  63.3k|  while (pool != NULL) {
  ------------------
  |  Branch (5884:10): [True: 63.3k, False: 23]
  ------------------
 5885|  63.3k|    if (pool->nthreads == nthreads) {
  ------------------
  |  Branch (5885:9): [True: 63.3k, False: 0]
  ------------------
 5886|  63.3k|      return pool;
 5887|  63.3k|    }
 5888|      0|    pool = pool->next;
 5889|      0|  }
 5890|     23|  return NULL;
 5891|  63.3k|}
blosc2.c:create_shared_pool:
 5893|     23|static int create_shared_pool(int16_t nthreads, struct blosc_shared_pool **pool_out) {
 5894|     23|  int rc = 0;
 5895|     23|  int rc2;
 5896|     23|  int32_t contexts_init = 0;    // per-thread contexts successfully initialized
 5897|     23|  int32_t threads_started = 0;  // worker threads successfully created
 5898|     23|#if !defined(_WIN32)
 5899|     23|  bool attr_inited = false;
 5900|     23|#endif
 5901|     23|  int32_t num_workers = nthreads > 1 ? nthreads - 1 : 1;
  ------------------
  |  Branch (5901:25): [True: 23, False: 0]
  ------------------
 5902|     23|  struct blosc_shared_pool *pool = (struct blosc_shared_pool *)my_malloc(sizeof(*pool));
 5903|     23|  BLOSC_ERROR_NULL(pool, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|     23|    do {                                            \
  |  |  105|     23|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 23]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|     23|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 23]
  |  |  ------------------
  ------------------
 5904|     23|  memset(pool, 0, sizeof(*pool));
 5905|     23|  pool->nthreads = nthreads;
 5906|     23|  pool->num_workers = num_workers;
 5907|     23|  blosc2_pthread_mutex_init(&pool->mutex, NULL);
  ------------------
  |  |   90|     23|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 5908|     23|  blosc2_pthread_cond_init(&pool->work_cv, NULL);
  ------------------
  |  |   96|     23|#define blosc2_pthread_cond_init(a, b) pthread_cond_init((a), (b))
  ------------------
 5909|     23|  pool->threads = (blosc2_pthread_t*)my_malloc((size_t)num_workers * sizeof(blosc2_pthread_t));
 5910|     23|  if (pool->threads == NULL) { rc = BLOSC2_ERROR_MEMORY_ALLOC; goto error; }
  ------------------
  |  Branch (5910:7): [True: 0, False: 23]
  ------------------
 5911|     23|  pool->thread_contexts = (struct thread_context*)my_malloc((size_t)num_workers * sizeof(struct thread_context));
 5912|     23|  if (pool->thread_contexts == NULL) { rc = BLOSC2_ERROR_MEMORY_ALLOC; goto error; }
  ------------------
  |  Branch (5912:7): [True: 0, False: 23]
  ------------------
 5913|     23|  memset(pool->thread_contexts, 0, (size_t)num_workers * sizeof(struct thread_context));
 5914|     23|#if !defined(_WIN32)
 5915|     23|  pthread_attr_init(&pool->ct_attr);
 5916|     23|  pthread_attr_setdetachstate(&pool->ct_attr, PTHREAD_CREATE_JOINABLE);
 5917|     23|  attr_inited = true;
 5918|     23|#endif
 5919|     92|  for (int32_t tid = 0; tid < num_workers; ++tid) {
  ------------------
  |  Branch (5919:25): [True: 69, False: 23]
  ------------------
 5920|     69|    rc = init_thread_context(pool->thread_contexts + tid, NULL, tid);
 5921|     69|    if (rc < 0) {
  ------------------
  |  Branch (5921:9): [True: 0, False: 69]
  ------------------
 5922|      0|      goto error;
 5923|      0|    }
 5924|     69|    contexts_init++;
 5925|     69|    pool->thread_contexts[tid].owner_pool = pool;
 5926|     69|#if !defined(_WIN32)
 5927|     69|    rc2 = blosc2_pthread_create(&pool->threads[tid], &pool->ct_attr, shared_pool_worker,
  ------------------
  |  |  103|     69|#define blosc2_pthread_create(a, b, c, d) pthread_create((a), (b), (c), (d))
  ------------------
 5928|     69|                                (void*)(pool->thread_contexts + tid));
 5929|       |#else
 5930|       |    rc2 = blosc2_pthread_create(&pool->threads[tid], NULL, shared_pool_worker,
 5931|       |                                (void*)(pool->thread_contexts + tid));
 5932|       |#endif
 5933|     69|    if (rc2) {
  ------------------
  |  Branch (5933:9): [True: 0, False: 69]
  ------------------
 5934|      0|      BLOSC_TRACE_ERROR("Return code from blosc2_pthread_create() is %d.\n\tError detail: %s\n", rc2, strerror(rc2));
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5935|      0|      rc = BLOSC2_ERROR_THREAD_CREATE;
 5936|      0|      goto error;
 5937|      0|    }
 5938|     69|    threads_started++;
 5939|     69|  }
 5940|     23|  *pool_out = pool;
 5941|     23|  return 0;
 5942|       |
 5943|      0|error:
 5944|       |  // A worker frees its own thread context when it exits (see shared_pool_worker),
 5945|       |  // so signal shutdown and join the ones already started before freeing anything.
 5946|      0|  if (threads_started > 0) {
  ------------------
  |  Branch (5946:7): [True: 0, False: 0]
  ------------------
 5947|      0|    blosc2_pthread_mutex_lock(&pool->mutex);
  ------------------
  |  |   92|      0|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5948|      0|    __atomic_store_n(&pool->shutdown, 1, __ATOMIC_RELEASE);
 5949|      0|    blosc2_pthread_cond_broadcast(&pool->work_cv);
  ------------------
  |  |  100|      0|#define blosc2_pthread_cond_broadcast(a) pthread_cond_broadcast((a))
  ------------------
 5950|      0|    blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5951|      0|    for (int32_t t = 0; t < threads_started; ++t) {
  ------------------
  |  Branch (5951:25): [True: 0, False: 0]
  ------------------
 5952|      0|      void *status;
 5953|      0|      blosc2_pthread_join(pool->threads[t], &status);
  ------------------
  |  |  104|      0|#define blosc2_pthread_join(a, b) pthread_join((a), (b))
  ------------------
 5954|      0|    }
 5955|      0|  }
 5956|       |  // Contexts that were initialized but never got a running worker have no owner
 5957|       |  // to free them; tear those down here (the started ones did it themselves).
 5958|      0|  for (int32_t t = threads_started; t < contexts_init; ++t) {
  ------------------
  |  Branch (5958:37): [True: 0, False: 0]
  ------------------
 5959|      0|    destroy_thread_context(pool->thread_contexts + t);
 5960|      0|  }
 5961|      0|#if !defined(_WIN32)
 5962|      0|  if (attr_inited) {
  ------------------
  |  Branch (5962:7): [True: 0, False: 0]
  ------------------
 5963|      0|    pthread_attr_destroy(&pool->ct_attr);
 5964|      0|  }
 5965|      0|#endif
 5966|      0|  if (pool->thread_contexts != NULL) {
  ------------------
  |  Branch (5966:7): [True: 0, False: 0]
  ------------------
 5967|      0|    my_free(pool->thread_contexts);
 5968|      0|  }
 5969|      0|  if (pool->threads != NULL) {
  ------------------
  |  Branch (5969:7): [True: 0, False: 0]
  ------------------
 5970|      0|    my_free(pool->threads);
 5971|      0|  }
 5972|      0|  blosc2_pthread_cond_destroy(&pool->work_cv);
  ------------------
  |  |   97|      0|#define blosc2_pthread_cond_destroy(a) pthread_cond_destroy((a))
  ------------------
 5973|      0|  blosc2_pthread_mutex_destroy(&pool->mutex);
  ------------------
  |  |   91|      0|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 5974|      0|  my_free(pool);
 5975|      0|  return rc;
 5976|     23|}
blosc2.c:shared_pool_worker:
 5795|     69|static void* shared_pool_worker(void* arg) {
 5796|     69|  struct thread_context* thcontext = (struct thread_context*)arg;
 5797|     69|  struct blosc_shared_pool* pool = thcontext->owner_pool;
 5798|       |
 5799|   118k|  while (1) {
  ------------------
  |  Branch (5799:10): [True: 118k, Folded]
  ------------------
 5800|   118k|    struct blosc_job_group* job = NULL;
 5801|   118k|    int32_t logical_tid = 0;
 5802|       |
 5803|   104M|    for (int spin = 0; spin < 12000; spin++) {
  ------------------
  |  Branch (5803:24): [True: 104M, False: 617]
  ------------------
 5804|   104M|      int32_t rem = __atomic_load_n(&pool->fast_remaining, __ATOMIC_ACQUIRE);
 5805|   104M|      if (rem > 0) {
  ------------------
  |  Branch (5805:11): [True: 174k, False: 104M]
  ------------------
 5806|   174k|        if (__atomic_compare_exchange_n(&pool->fast_remaining, &rem, rem - 1, false,
  ------------------
  |  Branch (5806:13): [True: 118k, False: 56.0k]
  ------------------
 5807|   174k|                                        __ATOMIC_ACQ_REL, __ATOMIC_RELAXED)) {
 5808|   118k|          job = pool->fast_job;
 5809|   118k|          logical_tid = pool->fast_workers - rem;
 5810|   118k|          break;
 5811|   118k|        }
 5812|  56.0k|        continue;
 5813|   174k|      }
 5814|   104M|      if (__atomic_load_n(&pool->queued_jobs, __ATOMIC_ACQUIRE) > 0 ||
  ------------------
  |  Branch (5814:11): [True: 18.4E, False: 104M]
  ------------------
 5815|   104M|          __atomic_load_n(&pool->shutdown, __ATOMIC_ACQUIRE) != 0) {
  ------------------
  |  Branch (5815:11): [True: 18.4E, False: 104M]
  ------------------
 5816|      0|        break;
 5817|      0|      }
 5818|   104M|#if !defined(_WIN32)
 5819|   104M|      blosc_cpu_pause();
 5820|   104M|#endif
 5821|   104M|    }
 5822|       |
 5823|   118k|    if (job == NULL) {
  ------------------
  |  Branch (5823:9): [True: 277, False: 118k]
  ------------------
 5824|    277|      blosc2_pthread_mutex_lock(&pool->mutex);
  ------------------
  |  |   92|    277|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5825|  32.9k|      while (!__atomic_load_n(&pool->shutdown, __ATOMIC_RELAXED) &&
  ------------------
  |  Branch (5825:14): [True: 32.8k, False: 69]
  ------------------
 5826|  32.8k|             pool->job_queue_head == NULL) {
  ------------------
  |  Branch (5826:14): [True: 32.8k, False: 0]
  ------------------
 5827|  32.8k|        int32_t rem = __atomic_load_n(&pool->fast_remaining, __ATOMIC_ACQUIRE);
 5828|  32.8k|        if (rem > 0 &&
  ------------------
  |  Branch (5828:13): [True: 210, False: 32.6k]
  ------------------
 5829|    210|            __atomic_compare_exchange_n(&pool->fast_remaining, &rem, rem - 1, false,
  ------------------
  |  Branch (5829:13): [True: 208, False: 2]
  ------------------
 5830|    210|                                        __ATOMIC_ACQ_REL, __ATOMIC_RELAXED)) {
 5831|    208|          job = pool->fast_job;
 5832|    208|          logical_tid = pool->fast_workers - rem;
 5833|    208|          break;
 5834|    208|        }
 5835|  32.6k|        __atomic_fetch_add(&pool->sleeping_workers, 1, __ATOMIC_SEQ_CST);
 5836|  32.6k|        if (__atomic_load_n(&pool->fast_remaining, __ATOMIC_SEQ_CST) == 0 &&
  ------------------
  |  Branch (5836:13): [True: 32.6k, False: 1]
  ------------------
 5837|  32.6k|            !__atomic_load_n(&pool->shutdown, __ATOMIC_RELAXED) &&
  ------------------
  |  Branch (5837:13): [True: 32.6k, False: 0]
  ------------------
 5838|  32.6k|            pool->job_queue_head == NULL) {
  ------------------
  |  Branch (5838:13): [True: 32.6k, False: 0]
  ------------------
 5839|  32.6k|          blosc2_pthread_cond_wait(&pool->work_cv, &pool->mutex);
  ------------------
  |  |   98|  32.6k|#define blosc2_pthread_cond_wait(a, b) pthread_cond_wait((a), (b))
  ------------------
 5840|  32.6k|        }
 5841|  32.6k|        __atomic_fetch_sub(&pool->sleeping_workers, 1, __ATOMIC_RELAXED);
 5842|  32.6k|      }
 5843|    277|      if (job == NULL) {
  ------------------
  |  Branch (5843:11): [True: 69, False: 208]
  ------------------
 5844|     69|        if (__atomic_load_n(&pool->shutdown, __ATOMIC_RELAXED)) {
  ------------------
  |  Branch (5844:13): [True: 69, False: 0]
  ------------------
 5845|     69|          blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|     69|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5846|     69|          break;
 5847|     69|        }
 5848|      0|        struct blosc_job_queue_entry* entry = pool->job_queue_head;
 5849|      0|        job = entry->job;
 5850|      0|        logical_tid = entry->logical_tid;
 5851|      0|        pool->job_queue_head = entry->next;
 5852|      0|        if (pool->job_queue_head == NULL) {
  ------------------
  |  Branch (5852:13): [True: 0, False: 0]
  ------------------
 5853|      0|          pool->job_queue_tail = NULL;
 5854|      0|        }
 5855|      0|        __atomic_sub_fetch(&pool->queued_jobs, 1, __ATOMIC_RELEASE);
 5856|      0|      }
 5857|    208|      blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|    208|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5858|    208|    }
 5859|       |
 5860|   118k|    thcontext->parent_context = job->context;
 5861|   118k|    thcontext->tid = logical_tid;
 5862|   118k|    t_blosc_do_job(thcontext);
 5863|   118k|    thcontext->parent_context = NULL;
 5864|       |
 5865|       |    /* Signal job completion only on the last worker.
 5866|       |     * If wait_state was 0 (main spinning), do NOT touch job after exchange. */
 5867|   118k|    if (__atomic_sub_fetch(&job->pending_workers, 1, __ATOMIC_ACQ_REL) == 0) {
  ------------------
  |  Branch (5867:9): [True: 63.3k, False: 55.1k]
  ------------------
 5868|  63.3k|      int32_t prev = __atomic_exchange_n(&job->wait_state, 2, __ATOMIC_ACQ_REL);
 5869|  63.3k|      if (prev == 1) {
  ------------------
  |  Branch (5869:11): [True: 888, False: 62.4k]
  ------------------
 5870|    888|        blosc2_pthread_mutex_lock(&job->mutex);
  ------------------
  |  |   92|    888|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5871|    888|        job->completed = true;
 5872|    888|        blosc2_pthread_cond_signal(&job->completion_cv);
  ------------------
  |  |   99|    888|#define blosc2_pthread_cond_signal(a) pthread_cond_signal((a))
  ------------------
 5873|    888|        blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|    888|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5874|    888|      }
 5875|  63.3k|    }
 5876|   118k|  }
 5877|       |
 5878|     69|  destroy_thread_context(thcontext);
 5879|       |  return NULL;
 5880|     69|}
blosc2.c:register_atfork:
  311|      1|static void register_atfork(void) {
  312|      1|  if (pthread_atfork(atfork_prepare, atfork_parent, atfork_child) != 0) {
  ------------------
  |  Branch (312:7): [True: 0, False: 1]
  ------------------
  313|       |    BLOSC_TRACE_WARNING("pthread_atfork() failed: a fork()ed child may hang or crash with more than one thread");
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  314|      0|  }
  315|      1|}
blosc2.c:blosc2_init_locked:
 6696|  3.39k|static void blosc2_init_locked(void) {
 6697|  3.39k|  BLOSC2_IO_CB_DEFAULTS.id = BLOSC2_IO_FILESYSTEM;
 6698|  3.39k|  BLOSC2_IO_CB_DEFAULTS.name = "filesystem";
 6699|  3.39k|  BLOSC2_IO_CB_DEFAULTS.is_allocation_necessary = true;
 6700|  3.39k|  BLOSC2_IO_CB_DEFAULTS.open = (blosc2_open_cb) blosc2_stdio_open;
 6701|  3.39k|  BLOSC2_IO_CB_DEFAULTS.close = (blosc2_close_cb) blosc2_stdio_close;
 6702|  3.39k|  BLOSC2_IO_CB_DEFAULTS.size = (blosc2_size_cb) blosc2_stdio_size;
 6703|  3.39k|  BLOSC2_IO_CB_DEFAULTS.write = (blosc2_write_cb) blosc2_stdio_write;
 6704|  3.39k|  BLOSC2_IO_CB_DEFAULTS.read = (blosc2_read_cb) blosc2_stdio_read;
 6705|  3.39k|  BLOSC2_IO_CB_DEFAULTS.truncate = (blosc2_truncate_cb) blosc2_stdio_truncate;
 6706|  3.39k|  BLOSC2_IO_CB_DEFAULTS.destroy = (blosc2_destroy_cb) blosc2_stdio_destroy;
 6707|       |
 6708|  3.39k|  _blosc2_register_io_cb(&BLOSC2_IO_CB_DEFAULTS);
 6709|       |
 6710|  3.39k|  BLOSC2_IO_CB_MMAP.id = BLOSC2_IO_FILESYSTEM_MMAP;
 6711|  3.39k|  BLOSC2_IO_CB_MMAP.name = "filesystem_mmap";
 6712|  3.39k|  BLOSC2_IO_CB_MMAP.is_allocation_necessary = false;
 6713|  3.39k|  BLOSC2_IO_CB_MMAP.open = (blosc2_open_cb) blosc2_stdio_mmap_open;
 6714|  3.39k|  BLOSC2_IO_CB_MMAP.close = (blosc2_close_cb) blosc2_stdio_mmap_close;
 6715|  3.39k|  BLOSC2_IO_CB_MMAP.read = (blosc2_read_cb) blosc2_stdio_mmap_read;
 6716|  3.39k|  BLOSC2_IO_CB_MMAP.size = (blosc2_size_cb) blosc2_stdio_mmap_size;
 6717|  3.39k|  BLOSC2_IO_CB_MMAP.write = (blosc2_write_cb) blosc2_stdio_mmap_write;
 6718|  3.39k|  BLOSC2_IO_CB_MMAP.truncate = (blosc2_truncate_cb) blosc2_stdio_mmap_truncate;
 6719|  3.39k|  BLOSC2_IO_CB_MMAP.destroy = (blosc2_destroy_cb) blosc2_stdio_mmap_destroy;
 6720|       |
 6721|  3.39k|  _blosc2_register_io_cb(&BLOSC2_IO_CB_MMAP);
 6722|       |
 6723|       |  // BLOSC_PREFETCH=<nthreads> turns read-ahead on without touching the sources (see blosc2_set_prefetch())
 6724|  3.39k|  const char *prefetch_env = getenv("BLOSC_PREFETCH");
 6725|  3.39k|  if (prefetch_env != NULL && prefetch_env[0] != '\0') {
  ------------------
  |  Branch (6725:7): [True: 0, False: 3.39k]
  |  Branch (6725:31): [True: 0, False: 0]
  ------------------
 6726|      0|    long nthreads = strtol(prefetch_env, NULL, 10);
 6727|      0|    if (nthreads > 0 && nthreads <= BLOSC2_PREFETCH_MAX_NTHREADS) {
  ------------------
  |  |  786|      0|#define BLOSC2_PREFETCH_MAX_NTHREADS 256
  ------------------
  |  Branch (6727:9): [True: 0, False: 0]
  |  Branch (6727:25): [True: 0, False: 0]
  ------------------
 6728|      0|      blosc2_set_prefetch((int) nthreads, 0, 0);
 6729|      0|    }
 6730|      0|  }
 6731|       |  // BLOSC_PREFETCH_POPULATE: of which memory-mapped frames read-ahead populates the mapping: of all (1), of none (0),
 6732|       |  // or, if unset or empty, of those on GPFS
 6733|  3.39k|  const char *populate_env = getenv("BLOSC_PREFETCH_POPULATE");
 6734|  3.39k|  prefetch_set_populate(populate_env != NULL && populate_env[0] != '\0' ? strtol(populate_env, NULL, 10) != 0 : -1);
  ------------------
  |  Branch (6734:25): [True: 0, False: 3.39k]
  |  Branch (6734:49): [True: 0, False: 0]
  ------------------
 6735|       |
 6736|  3.39k|  g_ncodecs = 0;
 6737|  3.39k|  g_nfilters = 0;
 6738|  3.39k|  g_ntuners = 0;
 6739|       |
 6740|  3.39k|#if defined(HAVE_PLUGINS)
 6741|  3.39k|  #include "blosc2/blosc2-common.h"
 6742|  3.39k|  #include "blosc2/blosc2-stdio.h"
 6743|  3.39k|  register_codecs();
 6744|  3.39k|  register_filters();
 6745|  3.39k|  register_tuners();
 6746|  3.39k|#endif
 6747|  3.39k|  blosc2_pthread_mutex_init(&global_comp_mutex, NULL);
  ------------------
  |  |   90|  3.39k|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 6748|       |  /* Create a global context */
 6749|  3.39k|  g_global_context = (blosc2_context*)my_malloc(sizeof(blosc2_context));
 6750|  3.39k|  memset(g_global_context, 0, sizeof(blosc2_context));
 6751|  3.39k|  g_global_context->nthreads = g_nthreads;
 6752|  3.39k|  g_global_context->new_nthreads = g_nthreads;
 6753|  3.39k|  blosc2_pthread_mutex_init(&g_global_context->nchunk_mutex, NULL);
  ------------------
  |  |   90|  3.39k|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 6754|  3.39k|  store_release_int(&g_initlib, BLOSC_STATE_INITIALIZED);
  ------------------
  |  |  143|  3.39k|#define store_release_int(p, v) __atomic_store_n((p), (v), __ATOMIC_RELEASE)
  ------------------
 6755|  3.39k|}
blosc2.c:blosc2_free_resources_locked:
 6784|  3.39k|static int blosc2_free_resources_locked(void) {
 6785|       |  /* The calling thread's temporaries (other threads free theirs at exit) */
 6786|  3.39k|  blosc2_tmp_cache_clear();
 6787|  3.39k|  int rc = release_thread_backend(g_global_context);
 6788|       |  /* The thread pools that no context uses (kept for reuse) */
 6789|  3.39k|  static_lock(&pool_registry_mutex);
  ------------------
  |  |  132|  3.39k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 6790|  3.39k|  struct blosc_shared_pool *unused = unlink_unused_pools_locked(0);
 6791|  3.39k|  static_unlock(&pool_registry_mutex);
  ------------------
  |  |  133|  3.39k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6792|  3.39k|  destroy_shared_pools(unused);
 6793|  3.39k|  return rc;
 6794|  3.39k|}
blosc2.c:unlink_unused_pools_locked:
 6013|  66.7k|static struct blosc_shared_pool *unlink_unused_pools_locked(int keep) {
 6014|  66.7k|  struct blosc_shared_pool *unused = NULL;
 6015|  66.7k|  struct blosc_shared_pool **prev = &shared_pools;
 6016|   130k|  while (*prev != NULL) {
  ------------------
  |  Branch (6016:10): [True: 63.4k, False: 66.7k]
  ------------------
 6017|  63.4k|    struct blosc_shared_pool *pool = *prev;
 6018|  63.4k|    if (pool->context_refs == 0) {
  ------------------
  |  Branch (6018:9): [True: 63.4k, False: 0]
  ------------------
 6019|  63.4k|      if (keep == 0) {
  ------------------
  |  Branch (6019:11): [True: 23, False: 63.3k]
  ------------------
 6020|     23|        *prev = pool->next;
 6021|     23|        pool->next = unused;
 6022|     23|        unused = pool;
 6023|     23|        continue;
 6024|     23|      }
 6025|  63.3k|      keep--;
 6026|  63.3k|    }
 6027|  63.3k|    prev = &pool->next;
 6028|  63.3k|  }
 6029|  66.7k|  return unused;
 6030|  66.7k|}
blosc2.c:destroy_shared_pools:
 6000|  70.1k|static void destroy_shared_pools(struct blosc_shared_pool *pool) {
 6001|  70.1k|  while (pool != NULL) {
  ------------------
  |  Branch (6001:10): [True: 23, False: 70.1k]
  ------------------
 6002|     23|    struct blosc_shared_pool *next = pool->next;
 6003|     23|    destroy_shared_pool(pool);
 6004|     23|    pool = next;
 6005|     23|  }
 6006|  70.1k|}
blosc2.c:destroy_shared_pool:
 5978|     23|static void destroy_shared_pool(struct blosc_shared_pool *pool) {
 5979|     23|  void *status;
 5980|       |
 5981|     23|  blosc2_pthread_mutex_lock(&pool->mutex);
  ------------------
  |  |   92|     23|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5982|     23|  __atomic_store_n(&pool->shutdown, 1, __ATOMIC_RELEASE);
 5983|     23|  blosc2_pthread_cond_broadcast(&pool->work_cv);
  ------------------
  |  |  100|     23|#define blosc2_pthread_cond_broadcast(a) pthread_cond_broadcast((a))
  ------------------
 5984|     23|  blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|     23|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5985|       |
 5986|     92|  for (int32_t t = 0; t < pool->num_workers; ++t) {
  ------------------
  |  Branch (5986:23): [True: 69, False: 23]
  ------------------
 5987|     69|    blosc2_pthread_join(pool->threads[t], &status);
  ------------------
  |  |  104|     69|#define blosc2_pthread_join(a, b) pthread_join((a), (b))
  ------------------
 5988|     69|  }
 5989|     23|#if !defined(_WIN32)
 5990|     23|  pthread_attr_destroy(&pool->ct_attr);
 5991|     23|#endif
 5992|     23|  my_free(pool->threads);
 5993|     23|  my_free(pool->thread_contexts);
 5994|     23|  blosc2_pthread_cond_destroy(&pool->work_cv);
  ------------------
  |  |   97|     23|#define blosc2_pthread_cond_destroy(a) pthread_cond_destroy((a))
  ------------------
 5995|     23|  blosc2_pthread_mutex_destroy(&pool->mutex);
  ------------------
  |  |   91|     23|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 5996|     23|  my_free(pool);
 5997|     23|}
blosc2.c:serial_context_put:
 6921|  6.27M|static void serial_context_put(struct thread_context* thread_context) {
 6922|  6.27M|#if !defined(_WIN32)
 6923|  6.27M|  tmp_cache_t *cache = tmp_cache_get(false);
 6924|  6.27M|  if (cache != NULL && cache->serial == thread_context) {
  ------------------
  |  Branch (6924:7): [True: 6.27M, False: 0]
  |  Branch (6924:24): [True: 6.27M, False: 4.08k]
  ------------------
 6925|  6.27M|    blosc2_context* context = thread_context->parent_context;
 6926|  6.27M|    if (context->serial_context == NULL &&
  ------------------
  |  Branch (6926:9): [True: 6.27M, False: 0]
  ------------------
 6927|  6.27M|        thread_context_nbytes(thread_context) > BLOSC2_SERIAL_TLS_MAX) {
  ------------------
  |  | 6817|  6.27M|#define BLOSC2_SERIAL_TLS_MAX (16 * 1024 * 1024)
  ------------------
  |  Branch (6927:9): [True: 0, False: 6.27M]
  ------------------
 6928|       |      /* Grown too large to keep per thread (e.g. ZSTD compression state for
 6929|       |         large blocks at high levels): the context that needed it keeps it, as
 6930|       |         if it had always been its own, and the thread starts a new one */
 6931|      0|      thread_context->tmp_blocksize = context->blocksize;
 6932|      0|      context->serial_context = thread_context;
 6933|      0|      cache->serial = NULL;
 6934|      0|    }
 6935|  6.27M|    else {
 6936|  6.27M|      thread_context->parent_context = NULL;
 6937|  6.27M|    }
 6938|  6.27M|    cache->serial_busy = false;
 6939|  6.27M|  }
 6940|       |#else
 6941|       |  BLOSC_UNUSED_PARAM(thread_context);
 6942|       |#endif
 6943|  6.27M|}
blosc2.c:thread_context_nbytes:
 6867|  6.27M|static size_t thread_context_nbytes(const struct thread_context* thread_context) {
 6868|  6.27M|  size_t nbytes = thread_context->tmp_nbytes +
 6869|  6.27M|                  (thread_context->blosclz_state != NULL ? sizeof(blosclz_state) : 0);
  ------------------
  |  Branch (6869:20): [True: 6.26M, False: 5.85k]
  ------------------
 6870|  6.27M|#if defined(HAVE_ZSTD)
 6871|  6.27M|  if (thread_context->zstd_cctx != NULL) {
  ------------------
  |  Branch (6871:7): [True: 0, False: 6.27M]
  ------------------
 6872|      0|    nbytes += ZSTD_sizeof_CCtx(thread_context->zstd_cctx);
 6873|      0|  }
 6874|  6.27M|  if (thread_context->zstd_dctx != NULL) {
  ------------------
  |  Branch (6874:7): [True: 10, False: 6.27M]
  ------------------
 6875|     10|    nbytes += ZSTD_sizeof_DCtx(thread_context->zstd_dctx);
 6876|     10|  }
 6877|  6.27M|#endif
 6878|  6.27M|  if (thread_context->lz4_cstream != NULL) {
  ------------------
  |  Branch (6878:7): [True: 0, False: 6.27M]
  ------------------
 6879|      0|    nbytes += sizeof(LZ4_stream_t);
 6880|      0|  }
 6881|  6.27M|  if (thread_context->lz4hc_cstream != NULL) {
  ------------------
  |  Branch (6881:7): [True: 0, False: 6.27M]
  ------------------
 6882|      0|    nbytes += sizeof(LZ4_streamHC_t);
 6883|      0|  }
 6884|  6.27M|  return nbytes;
 6885|  6.27M|}
blosc2.c:tmp_cache_get:
 6848|  12.5M|static tmp_cache_t *tmp_cache_get(bool create) {
 6849|  12.5M|  pthread_once(&tmp_cache_once, tmp_cache_init);
 6850|  12.5M|  if (!tmp_cache_ready) {
  ------------------
  |  Branch (6850:7): [True: 0, False: 12.5M]
  ------------------
 6851|      0|    return NULL;
 6852|      0|  }
 6853|  12.5M|  tmp_cache_t *cache = pthread_getspecific(tmp_cache_key);
 6854|  12.5M|  if (cache == NULL && create) {
  ------------------
  |  Branch (6854:7): [True: 1, False: 12.5M]
  |  Branch (6854:24): [True: 1, False: 0]
  ------------------
 6855|      1|    cache = calloc(1, sizeof(tmp_cache_t));
 6856|      1|    if (cache != NULL && pthread_setspecific(tmp_cache_key, cache) != 0) {
  ------------------
  |  Branch (6856:9): [True: 1, False: 0]
  |  Branch (6856:26): [True: 0, False: 1]
  ------------------
 6857|      0|      free(cache);
 6858|       |      cache = NULL;
 6859|      0|    }
 6860|      1|  }
 6861|  12.5M|  return cache;
 6862|  12.5M|}
blosc2.c:tmp_cache_init:
 6844|      1|static void tmp_cache_init(void) {
 6845|      1|  tmp_cache_ready = pthread_key_create(&tmp_cache_key, tmp_cache_release) == 0;
 6846|      1|}
blosc2.c:blosc2_destroy_locked:
 7045|  3.39k|static void blosc2_destroy_locked(void) {
 7046|  3.39k|  blosc2_free_resources_locked();
 7047|  3.39k|  blosc2_free_ctx(g_global_context);
 7048|  3.39k|  blosc2_tmp_cache_clear();
 7049|       |
 7050|       |  /* Atomically invalidate outstanding context pointers and detach the registry.
 7051|       |   * A release either finishes its refcount update before this, or observes the
 7052|       |   * new epoch without dereferencing its stale pool.  Join outside the lock. */
 7053|  3.39k|  static_lock(&pool_registry_mutex);
  ------------------
  |  |  132|  3.39k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 7054|  3.39k|  store_release_int(&g_destroy_count, load_acquire_int(&g_destroy_count) + 1);
  ------------------
  |  |  143|  3.39k|#define store_release_int(p, v) __atomic_store_n((p), (v), __ATOMIC_RELEASE)
  ------------------
 7055|  3.39k|  struct blosc_shared_pool *pools = shared_pools;
 7056|  3.39k|  shared_pools = NULL;
 7057|  3.39k|  static_unlock(&pool_registry_mutex);
  ------------------
  |  |  133|  3.39k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 7058|  3.39k|  destroy_shared_pools(pools);
 7059|       |
 7060|  3.39k|  blosc2_pthread_mutex_destroy(&global_comp_mutex);
  ------------------
  |  |   91|  3.39k|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 7061|  3.39k|}
blosc2.c:my_malloc:
  383|  4.88M|static uint8_t* my_malloc(size_t size) {
  384|  4.88M|  void* block = NULL;
  385|  4.88M|  int res = 0;
  386|       |  /* Keep aligned allocations valid under Valgrind and POSIX wrappers. */
  387|  4.88M|  if (size == 0) {
  ------------------
  |  Branch (387:7): [True: 69, False: 4.88M]
  ------------------
  388|     69|    size = 1;
  389|     69|  }
  390|       |
  391|       |/* Do an alignment to 32 bytes because AVX2 is supported */
  392|       |#if defined(_WIN32)
  393|       |  /* A (void *) cast needed for avoiding a warning with MINGW :-/ */
  394|       |  block = (void *)_aligned_malloc(size, 32);
  395|       |#elif _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
  396|       |  /* Platform does have an implementation of posix_memalign */
  397|  4.88M|  res = posix_memalign(&block, 32, size);
  398|       |#else
  399|       |  block = malloc(size);
  400|       |#endif  /* _WIN32 */
  401|       |
  402|  4.88M|  if (block == NULL || res != 0) {
  ------------------
  |  Branch (402:7): [True: 0, False: 4.88M]
  |  Branch (402:24): [True: 0, False: 4.88M]
  ------------------
  403|      0|    BLOSC_TRACE_ERROR("Error allocating memory!");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  404|      0|    return NULL;
  405|      0|  }
  406|       |
  407|  4.88M|  return (uint8_t*)block;
  408|  4.88M|}
blosc2.c:release_thread_backend:
 6178|  4.40M|static int release_thread_backend(blosc2_context *context) {
 6179|  4.40M|  if (context->thread_backend == BLOSC_BACKEND_CALLBACK && context->threads_started > 0) {
  ------------------
  |  |   35|  8.80M|#define BLOSC_BACKEND_CALLBACK 2
  ------------------
  |  Branch (6179:7): [True: 0, False: 4.40M]
  |  Branch (6179:60): [True: 0, False: 0]
  ------------------
 6180|      0|    for (int32_t t = 0; t < context->threads_started; t++) {
  ------------------
  |  Branch (6180:25): [True: 0, False: 0]
  ------------------
 6181|      0|      destroy_thread_context(context->thread_contexts + t);
 6182|      0|    }
 6183|      0|    my_free(context->thread_contexts);
 6184|      0|    context->thread_contexts = NULL;
 6185|      0|    blosc2_pthread_mutex_destroy(&context->count_mutex);
  ------------------
  |  |   91|      0|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 6186|      0|    blosc2_pthread_mutex_destroy(&context->delta_mutex);
  ------------------
  |  |   91|      0|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 6187|      0|    blosc2_pthread_cond_destroy(&context->delta_cv);
  ------------------
  |  |   97|      0|#define blosc2_pthread_cond_destroy(a) pthread_cond_destroy((a))
  ------------------
 6188|      0|  }
 6189|       |#if defined(_WIN32)
 6190|       |  else if (context->thread_backend == BLOSC_BACKEND_PER_CONTEXT && context->threads_started > 0) {
 6191|       |    /* Signal all workers to exit. */
 6192|       |    blosc2_pthread_mutex_lock(&context->jobs_mutex);
 6193|       |    context->end_threads = 1;
 6194|       |    blosc2_pthread_cond_broadcast(&context->jobs_ready);
 6195|       |    blosc2_pthread_mutex_unlock(&context->jobs_mutex);
 6196|       |
 6197|       |    for (int32_t t = 0; t < context->threads_started; t++) {
 6198|       |      blosc2_pthread_join(context->threads[t], NULL);
 6199|       |    }
 6200|       |    my_free(context->threads);
 6201|       |    context->threads = NULL;
 6202|       |    blosc2_pthread_cond_destroy(&context->jobs_done);
 6203|       |    blosc2_pthread_cond_destroy(&context->jobs_ready);
 6204|       |    blosc2_pthread_mutex_destroy(&context->jobs_mutex);
 6205|       |    blosc2_pthread_cond_destroy(&context->delta_cv);
 6206|       |    blosc2_pthread_mutex_destroy(&context->delta_mutex);
 6207|       |    blosc2_pthread_mutex_destroy(&context->count_mutex);
 6208|       |  }
 6209|       |#endif  /* _WIN32 */
 6210|  4.40M|  else if (context->thread_backend == BLOSC_BACKEND_SHARED_POOL && context->thread_pool != NULL) {
  ------------------
  |  |   34|  8.80M|#define BLOSC_BACKEND_SHARED_POOL 1
  ------------------
  |  Branch (6210:12): [True: 63.3k, False: 4.33M]
  |  Branch (6210:68): [True: 63.3k, False: 0]
  ------------------
 6211|  63.3k|    struct blosc_shared_pool *pool = context->thread_pool;
 6212|       |
 6213|  63.3k|    static_lock(&pool_registry_mutex);
  ------------------
  |  |  132|  63.3k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 6214|  63.3k|    if (context->pool_epoch != load_acquire_int(&g_destroy_count)) {
  ------------------
  |  |  142|  63.3k|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (6214:9): [True: 0, False: 63.3k]
  ------------------
 6215|       |      /* Check under the process-lifetime registry lock: destruction cannot
 6216|       |       * invalidate the pool between this check and the refcount update. */
 6217|      0|      static_unlock(&pool_registry_mutex);
  ------------------
  |  |  133|      0|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6218|      0|      context->thread_pool = NULL;
 6219|      0|      context->threads_started = 0;
 6220|      0|      context->thread_backend = BLOSC_BACKEND_SERIAL;
  ------------------
  |  |   33|      0|#define BLOSC_BACKEND_SERIAL 0
  ------------------
 6221|      0|      return 0;
 6222|      0|    }
 6223|       |
 6224|       |    /* A pool that no context uses any more stays registered for the next
 6225|       |     * contexts with the same nthreads: contexts that live for one call
 6226|       |     * (python-blosc2's compress2()/decompress2(), BLOSC_NOLOCK) would otherwise
 6227|       |     * start and join all of its threads every time.  The most recently
 6228|       |     * released unused pools are kept, the others destroyed (the pool moves to
 6229|       |     * the front of the registry); blosc2_free_resources() destroys all. */
 6230|  63.3k|    struct blosc_shared_pool *unused = NULL;
 6231|  63.3k|    pool->context_refs--;
 6232|  63.3k|    if (pool->context_refs == 0) {
  ------------------
  |  Branch (6232:9): [True: 63.3k, False: 0]
  ------------------
 6233|  63.3k|      struct blosc_shared_pool **prev = &shared_pools;
 6234|  63.3k|      while (*prev != NULL && *prev != pool) {
  ------------------
  |  Branch (6234:14): [True: 63.3k, False: 0]
  |  Branch (6234:31): [True: 0, False: 63.3k]
  ------------------
 6235|      0|        prev = &(*prev)->next;
 6236|      0|      }
 6237|  63.3k|      if (*prev == pool) {
  ------------------
  |  Branch (6237:11): [True: 63.3k, False: 0]
  ------------------
 6238|  63.3k|        *prev = pool->next;
 6239|  63.3k|        pool->next = shared_pools;
 6240|  63.3k|        shared_pools = pool;
 6241|  63.3k|      }
 6242|  63.3k|      unused = unlink_unused_pools_locked(BLOSC2_UNUSED_POOLS_MAX);
  ------------------
  |  |  197|  63.3k|#define BLOSC2_UNUSED_POOLS_MAX 2
  ------------------
 6243|  63.3k|    }
 6244|  63.3k|    static_unlock(&pool_registry_mutex);
  ------------------
  |  |  133|  63.3k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6245|  63.3k|    destroy_shared_pools(unused);
 6246|  63.3k|    context->thread_pool = NULL;
 6247|  63.3k|  }
 6248|       |
 6249|  4.40M|  context->threads_started = 0;
 6250|  4.40M|  context->thread_backend = BLOSC_BACKEND_SERIAL;
  ------------------
  |  |   33|  4.40M|#define BLOSC_BACKEND_SERIAL 0
  ------------------
 6251|  4.40M|  return 0;
 6252|  4.40M|}
blosc2.c:release_context_dict_buffer:
 3039|  6.04M|static void release_context_dict_buffer(blosc2_context* context) {
 3040|  6.04M|  if (context->dict_buffer_owned && context->dict_buffer != NULL) {
  ------------------
  |  Branch (3040:7): [True: 0, False: 6.04M]
  |  Branch (3040:37): [True: 0, False: 0]
  ------------------
 3041|      0|    free(context->dict_buffer);
 3042|      0|  }
 3043|  6.04M|  context->dict_buffer = NULL;
 3044|       |  context->dict_buffer_owned = false;
 3045|  6.04M|  context->dict_size = 0;
 3046|  6.04M|}

blosclz_compress_state:
 2108|  1.95M|                           void* output, int maxout, blosclz_state* state) {
 2109|  1.95M|#if defined(BLOSCLZ_AVX2_ENABLED) && !defined(__AVX2__)
 2110|  1.95M|  if (blosc_cpu_has_avx2()) {
  ------------------
  |  Branch (2110:7): [True: 1.95M, False: 38]
  ------------------
 2111|  1.95M|    return blosclz_compress_state_avx2(clevel, input, length, output, maxout, state);
 2112|  1.95M|  }
 2113|     38|#endif
 2114|     38|  if (state->tagged) {
  ------------------
  |  Branch (2114:7): [True: 0, False: 38]
  ------------------
 2115|      0|    return compress_impl(clevel, input, length, output, maxout, state->htab, state, 1);
 2116|      0|  }
 2117|     38|  return compress_impl(clevel, input, length, output, maxout, state->htab, state, 0);
 2118|     38|}
blosclz_decompress:
 2120|  4.60M|int blosclz_decompress(const void* input, int length, void* output, int maxout) {
 2121|  4.60M|#if defined(BLOSCLZ_AVX2_ENABLED) && !defined(__AVX2__)
 2122|  4.60M|  if (blosc_cpu_has_avx2()) {
  ------------------
  |  Branch (2122:7): [True: 4.60M, False: 0]
  ------------------
 2123|  4.60M|    return blosclz_decompress_avx2(input, length, output, maxout);
 2124|  4.60M|  }
 2125|      0|#endif
 2126|      0|  return blosclz_decompress_impl(input, length, output, maxout);
 2127|  4.60M|}
blosclz_compress_state_avx2:
 1266|  1.95M|                                void* output, int maxout, blosclz_state* state) {
 1267|  1.95M|  if (state->tagged) {
  ------------------
  |  Branch (1267:7): [True: 1.92M, False: 26.8k]
  ------------------
 1268|  1.92M|    return compress_impl(clevel, input, length, output, maxout, state->htab, state, 1);
 1269|  1.92M|  }
 1270|  26.8k|  return compress_impl(clevel, input, length, output, maxout, state->htab, state, 0);
 1271|  1.95M|}
blosc_get_run_avx2:
 1274|  1.68M|bool blosc_get_run_avx2(const uint8_t* ip, const uint8_t* ip_bound) {
 1275|  1.68M|  uint8_t x = *ip;
 1276|       |  /* Broadcast the reference byte across all 32 lanes */
 1277|  1.68M|  const __m256i vx = _mm256_set1_epi8((char)x);
 1278|  16.6M|  while (ip_bound - ip >= 128) {
  ------------------
  |  Branch (1278:10): [True: 15.4M, False: 1.19M]
  ------------------
 1279|  15.4M|    const __m256i* p = (const __m256i*)ip;
 1280|  15.4M|    __m256i eq01 = _mm256_and_si256(_mm256_cmpeq_epi8(_mm256_loadu_si256(p), vx),
 1281|  15.4M|                                    _mm256_cmpeq_epi8(_mm256_loadu_si256(p + 1), vx));
 1282|  15.4M|    __m256i eq23 = _mm256_and_si256(_mm256_cmpeq_epi8(_mm256_loadu_si256(p + 2), vx),
 1283|  15.4M|                                    _mm256_cmpeq_epi8(_mm256_loadu_si256(p + 3), vx));
 1284|  15.4M|    if ((uint32_t)_mm256_movemask_epi8(_mm256_and_si256(eq01, eq23)) != 0xFFFFFFFFU) {
  ------------------
  |  Branch (1284:9): [True: 492k, False: 14.9M]
  ------------------
 1285|   492k|      return false;
 1286|   492k|    }
 1287|  14.9M|    ip += 128;
 1288|  14.9M|  }
 1289|       |  /* Check remaining 32-byte vectors and scalar tail */
 1290|  2.73M|  while (ip_bound - ip >= 32) {
  ------------------
  |  Branch (1290:10): [True: 1.55M, False: 1.17M]
  ------------------
 1291|  1.55M|    if ((uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(_mm256_loadu_si256((const __m256i*)ip), vx)) != 0xFFFFFFFFU) {
  ------------------
  |  Branch (1291:9): [True: 21.0k, False: 1.53M]
  ------------------
 1292|  21.0k|      return false;
 1293|  21.0k|    }
 1294|  1.53M|    ip += 32;
 1295|  1.53M|  }
 1296|  16.2M|  while (ip < ip_bound) {
  ------------------
  |  Branch (1296:10): [True: 15.1M, False: 1.17M]
  ------------------
 1297|  15.1M|    if (*ip != x) {
  ------------------
  |  Branch (1297:9): [True: 2.22k, False: 15.1M]
  ------------------
 1298|  2.22k|      return false;
 1299|  2.22k|    }
 1300|  15.1M|    ip++;
 1301|  15.1M|  }
 1302|  1.17M|  return true;
 1303|  1.17M|}
blosclz_decompress_avx2:
 2089|  4.60M|int blosclz_decompress_avx2(const void* input, int length, void* output, int maxout) {
 2090|  4.60M|  return blosclz_decompress_impl(input, length, output, maxout);
 2091|  4.60M|}
blosclz-avx2.c:compress_impl:
  978|  1.95M|                                        int maxout, uint32_t htab[], blosclz_state* state, const int tagged) {
  979|       |  /* input and output buffer cannot be less than 16 and 66 bytes or we can get into trouble */
  980|  1.95M|  if (length < 16 || maxout < 66) {
  ------------------
  |  Branch (980:7): [True: 34.8k, False: 1.92M]
  |  Branch (980:22): [True: 73.0k, False: 1.84M]
  ------------------
  981|   107k|    return 0;
  982|   107k|  }
  983|       |
  984|  1.84M|  uint8_t* ibase = (uint8_t*)input;
  985|       |
  986|       |  /* Keep match coverage and boundary positioning consistent across levels.
  987|       |   * A shift of 4 truncates matches further and can disrupt periodic byte deltas,
  988|       |   * reducing both compression ratio and speed on floating-point ramps. */
  989|  1.84M|  const unsigned ipshift = 3;
  990|       |  /* Use a uniform 6-byte minimum match (len >= 4) paired with 6-byte hashing.
  991|       |   * Matching hash width to minlen eliminates short-match rejection thrashing
  992|       |   * on low-cardinality shuffled streams and keeps clevel cratio monotonic. */
  993|  1.84M|  const unsigned minlen = 4;
  994|       |
  995|       |  /* Keep at least an 8 KB (2048-entry) hash table at low levels so periodic
  996|       |   * shuffled byte streams (periods > 256 B) do not collapse, growing to 64 KB
  997|       |   * at level 7. */
  998|  1.84M|  static const uint8_t hashlog_[10] = {0, HASH_LOG - 3, HASH_LOG - 3, HASH_LOG - 3, HASH_LOG - 3,
  ------------------
  |  |   74|  1.84M|#define HASH_LOG (14U)
  ------------------
                static const uint8_t hashlog_[10] = {0, HASH_LOG - 3, HASH_LOG - 3, HASH_LOG - 3, HASH_LOG - 3,
  ------------------
  |  |   74|  1.84M|#define HASH_LOG (14U)
  ------------------
                static const uint8_t hashlog_[10] = {0, HASH_LOG - 3, HASH_LOG - 3, HASH_LOG - 3, HASH_LOG - 3,
  ------------------
  |  |   74|  1.84M|#define HASH_LOG (14U)
  ------------------
                static const uint8_t hashlog_[10] = {0, HASH_LOG - 3, HASH_LOG - 3, HASH_LOG - 3, HASH_LOG - 3,
  ------------------
  |  |   74|  1.84M|#define HASH_LOG (14U)
  ------------------
  999|  1.84M|                                       HASH_LOG - 2, HASH_LOG - 1, HASH_LOG, HASH_LOG, HASH_LOG};
  ------------------
  |  |   74|  1.84M|#define HASH_LOG (14U)
  ------------------
                                                     HASH_LOG - 2, HASH_LOG - 1, HASH_LOG, HASH_LOG, HASH_LOG};
  ------------------
  |  |   74|  1.84M|#define HASH_LOG (14U)
  ------------------
                                                     HASH_LOG - 2, HASH_LOG - 1, HASH_LOG, HASH_LOG, HASH_LOG};
  ------------------
  |  |   74|  1.84M|#define HASH_LOG (14U)
  ------------------
                                                     HASH_LOG - 2, HASH_LOG - 1, HASH_LOG, HASH_LOG, HASH_LOG};
  ------------------
  |  |   74|  1.84M|#define HASH_LOG (14U)
  ------------------
                                                     HASH_LOG - 2, HASH_LOG - 1, HASH_LOG, HASH_LOG, HASH_LOG};
  ------------------
  |  |   74|  1.84M|#define HASH_LOG (14U)
  ------------------
 1000|  1.84M|  uint8_t hashlog = hashlog_[clevel];
 1001|       |
 1002|       |  /* Miss skip acceleration:
 1003|       |   * - clevel 1..3 (fast): capped exponential ramp (misses += step up to max_step)
 1004|       |   *   so random spans inside mixed-entropy blocks (e.g. BITSHUFFLE LSB planes)
 1005|       |   *   are crossed quickly.
 1006|       |   * - clevel 4..9 (balanced/high-ratio): gentle linear ramp (misses++, max_step=0)
 1007|       |   *   preserving full compression ratio while backward match extension recovers
 1008|       |   *   any overshot prefix. */
 1009|  1.84M|  static const uint8_t skip_shift_[10] = {0, 4, 5, 5, 6, 6, 6, 6, 6, 6};
 1010|  1.84M|  static const uint16_t max_step_[10] = {0, 256, 256, 128, 0, 0, 0, 0, 0, 0};
 1011|  1.84M|  const unsigned skip_shift = skip_shift_[clevel];
 1012|  1.84M|  const unsigned max_step = max_step_[clevel];
 1013|       |
 1014|       |  /* Discard probes with small compression ratios (too expensive). */
 1015|  1.84M|  static const double cratio_[10] = {0, 1.3, 1.25, 1.2, 1.2, 1.2, 1.2, 1.15, 1.1, 1.0};
 1016|  1.84M|  const double min_cratio = cratio_[clevel];
 1017|       |
 1018|       |  /* Bounded head + tail entropy probing (up to 2 KB at head, plus 1 KB at tail
 1019|       |   * only if the head falls short).  Capping the probe avoids compressing half
 1020|       |   * of every stream twice at high levels, while checking the tail preserves
 1021|       |   * BITSHUFFLE blocks whose compressible MSB planes sit at the end.
 1022|       |   * Cap the probe table at 2048 entries (8 KB) so it fits in L1 cache and
 1023|       |   * keeps untagged resets cheap. */
 1024|  1.84M|  int head_len = length < 2048 ? length : 2048;
  ------------------
  |  Branch (1024:18): [True: 670k, False: 1.17M]
  ------------------
 1025|  1.84M|  uint8_t probe_hashlog = hashlog > 11 ? 11 : hashlog;
  ------------------
  |  Branch (1025:27): [True: 1.45M, False: 390k]
  ------------------
 1026|  1.84M|  uint32_t base = htab_reset(htab, probe_hashlog, state, head_len, tagged);
 1027|  1.84M|  double cratio = get_cratio(ibase, head_len, (int)minlen, (int)ipshift, htab, probe_hashlog, base, tagged);
 1028|  1.84M|  if (cratio < min_cratio && length > 4096) {
  ------------------
  |  Branch (1028:7): [True: 59.2k, False: 1.78M]
  |  Branch (1028:30): [True: 37.7k, False: 21.5k]
  ------------------
 1029|  37.7k|    int tail_len = 1024;
 1030|  37.7k|    base = htab_reset(htab, probe_hashlog, state, tail_len, tagged);
 1031|  37.7k|    double tail_cratio = get_cratio(ibase + (length - tail_len), tail_len, (int)minlen, (int)ipshift,
 1032|  37.7k|                                    htab, probe_hashlog, base, tagged);
 1033|  37.7k|    if (tail_cratio > cratio) {
  ------------------
  |  Branch (1033:9): [True: 37.6k, False: 107]
  ------------------
 1034|  37.6k|      cratio = tail_cratio;
 1035|  37.6k|    }
 1036|  37.7k|  }
 1037|  1.84M|  if (state != NULL) {
  ------------------
  |  Branch (1037:7): [True: 1.84M, False: 18.4E]
  ------------------
 1038|       |    /* Tagged lookups skip clearing the >= 8 KB table between compressible streams. */
 1039|  1.84M|    state->tagged = hashlog >= 11 && cratio >= min_cratio;
  ------------------
  |  Branch (1039:21): [True: 1.84M, False: 58]
  |  Branch (1039:38): [True: 1.82M, False: 21.8k]
  ------------------
 1040|  1.84M|  }
 1041|  1.84M|  if (cratio < min_cratio) {
  ------------------
  |  Branch (1041:7): [True: 21.8k, False: 1.82M]
  ------------------
 1042|  21.8k|    goto out;
 1043|  21.8k|  }
 1044|       |
 1045|  1.82M|  uint8_t* ip = ibase + 4;
 1046|  1.82M|  uint8_t* lit_start = ibase;
 1047|  1.82M|  uint8_t* ip_bound = ibase + length - 1;
 1048|  1.82M|  uint8_t* ip_limit = ibase + length - 12;
 1049|  1.82M|  uint8_t* op = (uint8_t*)output;
 1050|  1.82M|  const uint8_t* op_limit = op + maxout;
 1051|  1.82M|  bool after_match = false;
 1052|       |
 1053|       |  /* Initialize the hash table for the full pass */
 1054|  1.82M|  base = htab_reset(htab, hashlog, state, length, tagged);
 1055|       |
 1056|       |  /* main loop */
 1057|  88.8M|  while (BLOSCLZ_LIKELY(ip < ip_limit)) {
  ------------------
  |  |   51|  88.8M|#define BLOSCLZ_LIKELY(c)    (c)
  |  |  ------------------
  |  |  |  Branch (51:30): [True: 87.0M, False: 1.80M]
  |  |  ------------------
  ------------------
 1058|  87.0M|    const uint8_t* ref;
 1059|  87.0M|    unsigned distance;
 1060|  87.0M|    uint8_t* anchor;
 1061|  87.0M|    unsigned len;
 1062|       |
 1063|       |    /* Immediately after a match (no pending literals), try the position
 1064|       |     * following the previous occurrence of the prefix at ip - 1. Hoisted out
 1065|       |     * of the miss loop so steady-state literal scans do not test after_match. */
 1066|  87.0M|    if (after_match) {
  ------------------
  |  Branch (1066:9): [True: 85.2M, False: 1.81M]
  ------------------
 1067|  85.2M|      after_match = false;
 1068|  85.2M|      anchor = ip;
 1069|  85.2M|      uint32_t hval = blosclz_hash6(ip, hashlog);
 1070|  85.2M|      uint32_t prevhash = blosclz_hash6(ip - 1, hashlog);
 1071|  85.2M|      const uint8_t *candidate = ibase + HTAB_GET(htab[prevhash], base) + 1;
  ------------------
  |  |  845|  85.2M|#define HTAB_GET(entry, base) (tagged ? blosclz_htab_get_tagged((entry), (base)) : (entry))
  |  |  ------------------
  |  |  |  Branch (845:32): [True: 85.0M, False: 249k]
  |  |  ------------------
  ------------------
 1072|  85.2M|      htab[prevhash] = (uint32_t)(ip - 1 - ibase) + base;
 1073|  85.2M|      const uint8_t *preferred = NULL;
 1074|  85.2M|      if (candidate < ip && ip - candidate < MAX_FARDISTANCE &&
  ------------------
  |  |   64|   170M|#define MAX_FARDISTANCE (65535 + MAX_DISTANCE - 1)
  |  |  ------------------
  |  |  |  |   63|  85.1M|#define MAX_DISTANCE 8191
  |  |  ------------------
  ------------------
  |  Branch (1074:11): [True: 85.1M, False: 112k]
  |  Branch (1074:29): [True: 85.1M, False: 18.4E]
  ------------------
 1075|  85.1M|          memcmp(candidate, ip, 8) == 0) {
  ------------------
  |  Branch (1075:11): [True: 21.0M, False: 64.0M]
  ------------------
 1076|  21.0M|        preferred = candidate;
 1077|  21.0M|      }
 1078|  85.2M|      ref = preferred ? preferred : ibase + HTAB_GET(htab[hval], base);
  ------------------
  |  |  845|   149M|#define HTAB_GET(entry, base) (tagged ? blosclz_htab_get_tagged((entry), (base)) : (entry))
  |  |  ------------------
  |  |  |  Branch (845:32): [True: 64.0M, False: 71.9k]
  |  |  ------------------
  ------------------
  |  Branch (1078:13): [True: 21.0M, False: 64.1M]
  ------------------
 1079|  85.2M|      distance = (unsigned int)(anchor - ref);
 1080|  85.2M|      htab[hval] = (uint32_t)(anchor - ibase) + base;
 1081|  85.2M|      if (distance != 0 && distance < MAX_FARDISTANCE) {
  ------------------
  |  |   64|  85.2M|#define MAX_FARDISTANCE (65535 + MAX_DISTANCE - 1)
  |  |  ------------------
  |  |  |  |   63|  85.2M|#define MAX_DISTANCE 8191
  |  |  ------------------
  ------------------
  |  Branch (1081:11): [True: 85.2M, False: 53.6k]
  |  Branch (1081:28): [True: 85.2M, False: 18.4E]
  ------------------
 1082|       |        /* The preferred candidate already matched all eight bytes. */
 1083|  85.2M|        uint64_t diff = preferred ? 0 : blosclz_readu64(anchor) ^ blosclz_readu64(ref);
  ------------------
  |  Branch (1083:25): [True: 21.0M, False: 64.1M]
  ------------------
 1084|  85.2M|        if ((diff & BLOSCLZ_PREFIX6_MASK) == 0) {
  ------------------
  |  |   82|  85.2M|#define BLOSCLZ_PREFIX6_MASK 0x0000FFFFFFFFFFFFULL
  ------------------
  |  Branch (1084:13): [True: 41.4M, False: 43.7M]
  ------------------
 1085|  41.4M|          distance--;
 1086|  41.4M|          if (BLOSCLZ_UNLIKELY(!distance)) {
  ------------------
  |  |   52|  41.4M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 3.42M, False: 38.0M]
  |  |  ------------------
  ------------------
 1087|  3.42M|            ip = get_run_fast(anchor + 4, ip_bound, ref + 4);
 1088|  3.42M|          }
 1089|  38.0M|#if !BLOSCLZ_BIG_ENDIAN && defined(BLOSCLZ_HAVE_CTZ64)
 1090|  38.0M|          else if (diff != 0) {
  ------------------
  |  Branch (1090:20): [True: 10.6M, False: 27.3M]
  ------------------
 1091|  10.6M|            ip = anchor + (blosclz_ctz64(diff) >> 3) + 1;
 1092|  10.6M|          }
 1093|  27.3M|          else {
 1094|  27.3M|            ip = get_match_fast(anchor + 8, ip_bound, ref + 8);
 1095|  27.3M|          }
 1096|       |#else
 1097|       |          else {
 1098|       |            ip = get_match_fast(anchor + 6, ip_bound, ref + 6);
 1099|       |          }
 1100|       |#endif
 1101|  41.4M|          ip -= ipshift;
 1102|  41.4M|          len = (unsigned)(ip - anchor);
 1103|  41.4M|          if (len >= minlen && !(len <= 5 && distance >= MAX_DISTANCE)) {
  ------------------
  |  |   63|  12.3M|#define MAX_DISTANCE 8191
  ------------------
  |  Branch (1103:15): [True: 41.4M, False: 18.4E]
  |  Branch (1103:34): [True: 12.3M, False: 29.0M]
  |  Branch (1103:46): [True: 11.9k, False: 12.3M]
  ------------------
 1104|  41.4M|            goto emit_match;
 1105|  41.4M|          }
 1106|  41.4M|        }
 1107|  85.2M|      }
 1108|  43.8M|      ip = anchor + 1;
 1109|  43.8M|    }
 1110|       |
 1111|  45.6M|    {
 1112|  45.6M|      unsigned misses = 1U << skip_shift;
 1113|       |      /* Keep at least 4 leading literals so output[0] is always a literal token. */
 1114|  45.6M|      const uint8_t *back_limit = (lit_start > ibase) ? lit_start : (ibase + 4);
  ------------------
  |  Branch (1114:35): [True: 43.8M, False: 1.73M]
  ------------------
 1115|       |
 1116|       |      /* Tight match-finding loop: defer literal copies until a match is found. */
 1117|   781M|      for (;;) {
 1118|   781M|        if (BLOSCLZ_UNLIKELY(ip >= ip_limit)) {
  ------------------
  |  |   52|   781M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 15.6k, False: 781M]
  |  |  ------------------
  ------------------
 1119|  15.6k|          goto tail;
 1120|  15.6k|        }
 1121|   781M|        anchor = ip;
 1122|       |
 1123|       |        /* find potential match */
 1124|   781M|        uint32_t hval = blosclz_hash6(ip, hashlog);
 1125|   781M|        ref = ibase + HTAB_GET(htab[hval], base);
  ------------------
  |  |  845|   781M|#define HTAB_GET(entry, base) (tagged ? blosclz_htab_get_tagged((entry), (base)) : (entry))
  |  |  ------------------
  |  |  |  Branch (845:32): [True: 780M, False: 694k]
  |  |  ------------------
  ------------------
 1126|       |
 1127|       |        /* calculate distance to the match */
 1128|   781M|        distance = (unsigned int)(anchor - ref);
 1129|       |
 1130|       |        /* update hash table */
 1131|   781M|        htab[hval] = (uint32_t)(anchor - ibase) + base;
 1132|       |
 1133|   781M|        if (distance != 0 && distance < MAX_FARDISTANCE) {
  ------------------
  |  |   64|   781M|#define MAX_FARDISTANCE (65535 + MAX_DISTANCE - 1)
  |  |  ------------------
  |  |  |  |   63|   781M|#define MAX_DISTANCE 8191
  |  |  ------------------
  ------------------
  |  Branch (1133:13): [True: 781M, False: 18.4E]
  |  Branch (1133:30): [True: 781M, False: 18.4E]
  ------------------
 1134|       |          /* Verify all 6 bytes (minlen == 4) in one 64-bit XOR before match scan */
 1135|   781M|          uint64_t diff = blosclz_readu64(anchor) ^ blosclz_readu64(ref);
 1136|   781M|          if ((diff & BLOSCLZ_PREFIX6_MASK) == 0) {
  ------------------
  |  |   82|   781M|#define BLOSCLZ_PREFIX6_MASK 0x0000FFFFFFFFFFFFULL
  ------------------
  |  Branch (1136:15): [True: 45.8M, False: 735M]
  ------------------
 1137|  45.8M|            uint8_t *orig_anchor = anchor;
 1138|       |            /* Recover bytes skipped when a larger step lands inside a match. */
 1139|  45.8M|            if (BLOSCLZ_UNLIKELY(anchor > back_limit && ref > ibase && anchor[-1] == ref[-1])) {
  ------------------
  |  |   52|   182M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:31): [True: 45.3M, False: 508k]
  |  |  |  Branch (52:31): [True: 45.2M, False: 103k]
  |  |  |  Branch (52:31): [True: 7.82M, False: 37.3M]
  |  |  ------------------
  ------------------
 1140|  11.6M|              do {
 1141|  11.6M|                anchor--;
 1142|  11.6M|                ref--;
 1143|  11.6M|              } while (anchor > back_limit && ref > ibase && anchor[-1] == ref[-1]);
  ------------------
  |  Branch (1143:24): [True: 9.24M, False: 2.41M]
  |  Branch (1143:47): [True: 9.22M, False: 17.2k]
  |  Branch (1143:62): [True: 3.83M, False: 5.39M]
  ------------------
 1144|  7.82M|              distance--;
 1145|  7.82M|              if (BLOSCLZ_UNLIKELY(!distance)) {
  ------------------
  |  |   52|  7.82M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 368k, False: 7.45M]
  |  |  ------------------
  ------------------
 1146|   368k|                ip = get_run_fast(anchor + 4, ip_bound, ref + 4);
 1147|  7.45M|              } else {
 1148|  7.45M|                ip = get_match_fast(anchor + 6, ip_bound, ref + 6);
 1149|  7.45M|              }
 1150|  37.9M|            } else {
 1151|       |              /* distance is biased */
 1152|  37.9M|              distance--;
 1153|       |
 1154|       |              /* get runs or matches; zero distance means a run */
 1155|  37.9M|              if (BLOSCLZ_UNLIKELY(!distance)) {
  ------------------
  |  |   52|  37.9M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 12.1M, False: 25.8M]
  |  |  ------------------
  ------------------
 1156|  12.1M|                ip = get_run_fast(anchor + 4, ip_bound, ref + 4);
 1157|  12.1M|              }
 1158|  25.8M|#if !BLOSCLZ_BIG_ENDIAN && defined(BLOSCLZ_HAVE_CTZ64)
 1159|  25.8M|              else if (diff != 0) {
  ------------------
  |  Branch (1159:24): [True: 12.1M, False: 13.6M]
  ------------------
 1160|  12.1M|                ip = anchor + (blosclz_ctz64(diff) >> 3) + 1;
 1161|  12.1M|              }
 1162|  13.6M|              else {
 1163|  13.6M|                ip = get_match_fast(anchor + 8, ip_bound, ref + 8);
 1164|  13.6M|              }
 1165|       |#else
 1166|       |              else {
 1167|       |                ip = get_match_fast(anchor + 6, ip_bound, ref + 6);
 1168|       |              }
 1169|       |#endif
 1170|  37.9M|            }
 1171|       |
 1172|       |            /* length is biased, '1' means a match of 3 bytes */
 1173|  45.8M|            ip -= ipshift;
 1174|  45.8M|            len = (unsigned)(ip - anchor);
 1175|       |
 1176|  45.8M|            if (len >= minlen && !(len <= 5 && distance >= MAX_DISTANCE)) {
  ------------------
  |  |   63|  23.0M|#define MAX_DISTANCE 8191
  ------------------
  |  Branch (1176:17): [True: 45.7M, False: 81.1k]
  |  Branch (1176:36): [True: 23.0M, False: 22.7M]
  |  Branch (1176:48): [True: 18.5k, False: 22.9M]
  ------------------
 1177|  45.7M|              break;
 1178|  45.7M|            }
 1179|  92.0k|            ip = orig_anchor + 1;
 1180|  92.0k|            continue;
 1181|  45.8M|          }
 1182|   781M|        }
 1183|       |
 1184|   735M|        unsigned step = misses >> skip_shift;
 1185|   735M|        if (max_step != 0) {
  ------------------
  |  Branch (1185:13): [True: 1.34M, False: 733M]
  ------------------
 1186|  1.34M|          if (step >= max_step) {
  ------------------
  |  Branch (1186:15): [True: 148, False: 1.34M]
  ------------------
 1187|    148|            step = max_step;
 1188|  1.34M|          } else {
 1189|  1.34M|            misses += step;
 1190|  1.34M|          }
 1191|   733M|        } else {
 1192|   733M|          misses++;
 1193|   733M|        }
 1194|   735M|        ip = anchor + step;
 1195|   735M|      }
 1196|  45.6M|    }
 1197|       |
 1198|  87.0M|emit_match:
 1199|       |    /* Emit pending literals in bulk */
 1200|  87.0M|    {
 1201|  87.0M|      size_t lit_len = (size_t)(anchor - lit_start);
 1202|  87.0M|      if (lit_len > 0) {
  ------------------
  |  Branch (1202:11): [True: 43.6M, False: 43.3M]
  ------------------
 1203|  43.6M|        op = emit_literals(op, op_limit, lit_start, lit_len);
 1204|  43.6M|        if (BLOSCLZ_UNLIKELY(op == NULL)) {
  ------------------
  |  |   52|  43.6M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 242, False: 43.6M]
  |  |  ------------------
  ------------------
 1205|    242|          goto out;
 1206|    242|        }
 1207|  43.6M|      }
 1208|  87.0M|    }
 1209|       |
 1210|       |    /* encode the match */
 1211|  87.0M|    if (distance < MAX_DISTANCE) {
  ------------------
  |  |   63|  87.0M|#define MAX_DISTANCE 8191
  ------------------
  |  Branch (1211:9): [True: 86.8M, False: 255k]
  ------------------
 1212|  86.8M|      if (len < 7) {
  ------------------
  |  Branch (1212:11): [True: 42.6M, False: 44.1M]
  ------------------
 1213|  42.6M|        MATCH_SHORT(op, op_limit, len, distance)
  ------------------
  |  |  788|  42.6M|#define MATCH_SHORT(op, op_limit, len, distance) {        \
  |  |  789|  42.6M|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 2))            \
  |  |  ------------------
  |  |  |  |   52|  42.6M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (52:30): [True: 139, False: 42.6M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  790|  42.6M|    goto out;                                             \
  |  |  791|  42.6M|  *(op)++ = (uint8_t)(((len) << 5U) + ((distance) >> 8U));\
  |  |  792|  42.6M|  *(op)++ = (uint8_t)(((distance) & 255U));               \
  |  |  793|  42.6M|}
  ------------------
 1214|  44.1M|      } else {
 1215|   132M|        MATCH_LONG(op, op_limit, len, distance)
  ------------------
  |  |  795|  44.1M|#define MATCH_LONG(op, op_limit, len, distance) {       \
  |  |  796|  44.1M|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 1))          \
  |  |  ------------------
  |  |  |  |   52|  44.1M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (52:30): [True: 47, False: 44.1M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  797|  44.1M|    goto out;                                           \
  |  |  798|  44.1M|  *(op)++ = (uint8_t)((7U << 5U) + ((distance) >> 8U)); \
  |  |  799|  84.0M|  for ((len) -= 7; (len) >= 255; (len) -= 255) {        \
  |  |  ------------------
  |  |  |  Branch (799:20): [True: 39.8M, False: 44.1M]
  |  |  ------------------
  |  |  800|  39.8M|    if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 1))        \
  |  |  ------------------
  |  |  |  |   52|  39.8M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (52:30): [True: 0, False: 39.8M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  801|  39.8M|      goto out;                                         \
  |  |  802|  39.8M|    *(op)++ = 255;                                      \
  |  |  803|  39.8M|  }                                                     \
  |  |  804|  44.1M|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 2))          \
  |  |  ------------------
  |  |  |  |   52|  44.1M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (52:30): [True: 111, False: 44.1M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  805|  44.1M|    goto out;                                           \
  |  |  806|  44.1M|  *(op)++ = (uint8_t)(len);                             \
  |  |  807|  44.1M|  *(op)++ = (uint8_t)(((distance) & 255U));             \
  |  |  808|  44.1M|}
  ------------------
 1216|   132M|      }
 1217|  86.8M|    } else {
 1218|       |      /* far away, but not yet in the another galaxy... */
 1219|   255k|      distance -= MAX_DISTANCE;
  ------------------
  |  |   63|   255k|#define MAX_DISTANCE 8191
  ------------------
 1220|   255k|      if (len < 7) {
  ------------------
  |  Branch (1220:11): [True: 27.1k, False: 228k]
  ------------------
 1221|  27.1k|        MATCH_SHORT_FAR(op, op_limit, len, distance)
  ------------------
  |  |  810|  27.1k|#define MATCH_SHORT_FAR(op, op_limit, len, distance) {      \
  |  |  811|  27.1k|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 4))              \
  |  |  ------------------
  |  |  |  |   52|  27.1k|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (52:30): [True: 0, False: 27.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  812|  27.1k|    goto out;                                               \
  |  |  813|  27.1k|  *(op)++ = (uint8_t)(((len) << 5U) + 31);                  \
  |  |  814|  27.1k|  *(op)++ = 255;                                            \
  |  |  815|  27.1k|  *(op)++ = (uint8_t)((distance) >> 8U);                    \
  |  |  816|  27.1k|  *(op)++ = (uint8_t)((distance) & 255U);                   \
  |  |  817|  27.1k|}
  ------------------
 1222|   228k|      } else {
 1223|   684k|        MATCH_LONG_FAR(op, op_limit, len, distance)
  ------------------
  |  |  819|   228k|#define MATCH_LONG_FAR(op, op_limit, len, distance) {       \
  |  |  820|   228k|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 1))              \
  |  |  ------------------
  |  |  |  |   52|   228k|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (52:30): [True: 0, False: 228k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  821|   228k|    goto out;                                               \
  |  |  822|   228k|  *(op)++ = (7U << 5U) + 31;                                \
  |  |  823|   554k|  for ((len) -= 7; (len) >= 255; (len) -= 255) {            \
  |  |  ------------------
  |  |  |  Branch (823:20): [True: 326k, False: 228k]
  |  |  ------------------
  |  |  824|   326k|    if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 1))            \
  |  |  ------------------
  |  |  |  |   52|   326k|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (52:30): [True: 0, False: 326k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  825|   326k|      goto out;                                             \
  |  |  826|   326k|    *(op)++ = 255;                                          \
  |  |  827|   326k|  }                                                         \
  |  |  828|   228k|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 4))              \
  |  |  ------------------
  |  |  |  |   52|   228k|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (52:30): [True: 0, False: 228k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  829|   228k|    goto out;                                               \
  |  |  830|   228k|  *(op)++ = (uint8_t)(len);                                 \
  |  |  831|   228k|  *(op)++ = 255;                                            \
  |  |  832|   228k|  *(op)++ = (uint8_t)((distance) >> 8U);                    \
  |  |  833|   228k|  *(op)++ = (uint8_t)((distance) & 255U);                   \
  |  |  834|   228k|}
  ------------------
 1224|   684k|      }
 1225|   255k|    }
 1226|       |
 1227|       |    /* Advance past the biased match length.  Update the boundary hashes on
 1228|       |     * the next iteration, preserving the old ip-1 entry for the extra candidate. */
 1229|  87.0M|    ip += 2;
 1230|  87.0M|    lit_start = ip;
 1231|  87.0M|    after_match = true;
 1232|  87.0M|  }
 1233|       |
 1234|  1.82M|tail:
 1235|       |  /* Emit left-over bytes as literals */
 1236|  1.82M|  {
 1237|  1.82M|    size_t lit_len = (size_t)(ip_bound - lit_start + 1);
 1238|  1.82M|    if (lit_len > 0) {
  ------------------
  |  Branch (1238:9): [True: 1.82M, False: 18.4E]
  ------------------
 1239|  1.82M|      op = emit_literals(op, op_limit, lit_start, lit_len);
 1240|  1.82M|      if (BLOSCLZ_UNLIKELY(op == NULL)) {
  ------------------
  |  |   52|  1.82M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 827, False: 1.82M]
  |  |  ------------------
  ------------------
 1241|    827|        goto out;
 1242|    827|      }
 1243|  1.82M|    }
 1244|  1.82M|  }
 1245|       |
 1246|       |  /* marker for blosclz */
 1247|  1.82M|  *(uint8_t*)output |= (1U << 5U);
 1248|       |
 1249|  1.82M|  return (int)(op - (uint8_t*)output);
 1250|       |
 1251|  23.2k|out:
 1252|  23.2k|  return 0;
 1253|  1.82M|}
blosclz-avx2.c:htab_reset:
  959|  3.71M|                                          const int tagged) {
  960|  3.71M|  if (!tagged) {
  ------------------
  |  Branch (960:7): [True: 43.7k, False: 3.66M]
  ------------------
  961|  43.7k|    memset(htab, 0, (1U << hashlog) * sizeof(uint32_t));
  962|       |    /* untagged entries (< span) must look stale to the next tagged pass */
  963|  43.7k|    if (state != NULL && state->base < (uint32_t)span) {
  ------------------
  |  Branch (963:9): [True: 43.7k, False: 1]
  |  Branch (963:26): [True: 2.17k, False: 41.5k]
  ------------------
  964|  2.17k|      state->base = (uint32_t)span;
  965|  2.17k|    }
  966|  43.7k|    return 0;
  967|  43.7k|  }
  968|  3.66M|  if (state->base > UINT32_MAX - (uint32_t)span) {
  ------------------
  |  Branch (968:7): [True: 0, False: 3.66M]
  ------------------
  969|      0|    memset(state->htab, 0, sizeof(state->htab));
  970|      0|    state->base = 0;
  971|      0|  }
  972|  3.66M|  uint32_t base = state->base;
  973|  3.66M|  state->base += (uint32_t)span;
  974|  3.66M|  return base;
  975|  3.71M|}
blosclz-avx2.c:get_cratio:
  849|  1.88M|                                        uint8_t hashlog, uint32_t base, const int tagged) {
  850|  1.88M|  if (maxlen < 16) {
  ------------------
  |  Branch (850:7): [True: 0, False: 1.88M]
  ------------------
  851|      0|    return 0.0;
  852|      0|  }
  853|  1.88M|  uint8_t* ip = ibase + 4;
  854|  1.88M|  int32_t oc = 5;
  855|  1.88M|  uint8_t copy = 4;
  856|  1.88M|  const uint16_t hashlen = (1U << hashlog);
  857|  1.88M|  uint16_t limit = (maxlen > hashlen) ? hashlen : (uint16_t)maxlen;
  ------------------
  |  Branch (857:20): [True: 0, False: 1.88M]
  ------------------
  858|  1.88M|  uint8_t* ip_end = ibase + limit;
  859|  1.88M|  uint8_t* ip_bound = ip_end - 1;
  860|  1.88M|  uint8_t* ip_limit = ip_end - 12;
  861|       |
  862|       |  /* main loop */
  863|   403M|  while (BLOSCLZ_LIKELY(ip < ip_limit)) {
  ------------------
  |  |   51|   403M|#define BLOSCLZ_LIKELY(c)    (c)
  |  |  ------------------
  |  |  |  Branch (51:30): [True: 403M, False: 527k]
  |  |  ------------------
  ------------------
  864|   403M|    uint8_t* anchor = ip;    /* comparison starting-point */
  865|       |
  866|       |    /* find potential match */
  867|   403M|    uint32_t hval = blosclz_hash6(ip, hashlog);
  868|   403M|    const uint8_t* ref = ibase + HTAB_GET(htab[hval], base);
  ------------------
  |  |  845|   403M|#define HTAB_GET(entry, base) (tagged ? blosclz_htab_get_tagged((entry), (base)) : (entry))
  |  |  ------------------
  |  |  |  Branch (845:32): [True: 401M, False: 2.20M]
  |  |  ------------------
  ------------------
  869|       |
  870|       |    /* calculate distance to the match */
  871|   403M|    unsigned distance = (unsigned int)(anchor - ref);
  872|       |
  873|       |    /* update hash table */
  874|   403M|    htab[hval] = (uint32_t)(anchor - ibase) + base;
  875|       |
  876|   403M|    if (distance == 0 || distance >= MAX_FARDISTANCE) {
  ------------------
  |  |   64|   403M|#define MAX_FARDISTANCE (65535 + MAX_DISTANCE - 1)
  |  |  ------------------
  |  |  |  |   63|   403M|#define MAX_DISTANCE 8191
  |  |  ------------------
  ------------------
  |  Branch (876:9): [True: 70.2k, False: 403M]
  |  Branch (876:26): [True: 18.4E, False: 403M]
  ------------------
  877|      0|      LITERAL2(ip, anchor, copy)
  ------------------
  |  |  778|      0|#define LITERAL2(ip, anchor, copy) {                    \
  |  |  779|      0|  oc++; (anchor)++;                                     \
  |  |  780|      0|  (ip) = (anchor);                                      \
  |  |  781|      0|  (copy)++;                                             \
  |  |  782|      0|  if (BLOSCLZ_UNLIKELY((copy) == MAX_COPY)) {           \
  |  |  ------------------
  |  |  |  |   52|      0|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (52:30): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  783|      0|    (copy) = 0;                                         \
  |  |  784|      0|    oc++;                                               \
  |  |  785|      0|  }                                                     \
  |  |  786|      0|}
  ------------------
  878|      0|      continue;
  879|      0|    }
  880|       |
  881|       |    /* Check the full 6-byte prefix (matching minlen == 4) in one 64-bit op */
  882|   403M|    uint64_t a64 = blosclz_readu64(anchor);
  883|   403M|    uint64_t b64 = blosclz_readu64(ref);
  884|   403M|    uint64_t diff = a64 ^ b64;
  885|   403M|    if ((diff & BLOSCLZ_PREFIX6_MASK) != 0) {
  ------------------
  |  |   82|   403M|#define BLOSCLZ_PREFIX6_MASK 0x0000FFFFFFFFFFFFULL
  ------------------
  |  Branch (885:9): [True: 390M, False: 12.4M]
  ------------------
  886|   390M|      LITERAL2(ip, anchor, copy)
  ------------------
  |  |  778|   390M|#define LITERAL2(ip, anchor, copy) {                    \
  |  |  779|   390M|  oc++; (anchor)++;                                     \
  |  |  780|   390M|  (ip) = (anchor);                                      \
  |  |  781|   390M|  (copy)++;                                             \
  |  |  782|   390M|  if (BLOSCLZ_UNLIKELY((copy) == MAX_COPY)) {           \
  |  |  ------------------
  |  |  |  |   52|   390M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (52:30): [True: 9.45M, False: 381M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  783|  9.45M|    (copy) = 0;                                         \
  |  |  784|  9.45M|    oc++;                                               \
  |  |  785|  9.45M|  }                                                     \
  |  |  786|   390M|}
  ------------------
  887|   390M|      continue;
  888|   390M|    }
  889|       |
  890|       |    /* distance is biased */
  891|  12.4M|    distance--;
  892|       |
  893|       |    /* get runs or matches; zero distance means a run */
  894|  12.4M|    if (BLOSCLZ_UNLIKELY(!distance)) {
  ------------------
  |  |   52|  12.4M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 2.07M, False: 10.3M]
  |  |  ------------------
  ------------------
  895|  2.07M|      ip = get_run_fast(anchor + 4, ip_bound, ref + 4);
  896|  2.07M|    }
  897|  10.3M|#if !BLOSCLZ_BIG_ENDIAN && defined(BLOSCLZ_HAVE_CTZ64)
  898|  10.3M|    else if (diff != 0) {
  ------------------
  |  Branch (898:14): [True: 4.06M, False: 6.26M]
  ------------------
  899|  4.06M|      ip = anchor + (blosclz_ctz64(diff) >> 3) + 1;
  900|  4.06M|    }
  901|  6.26M|    else {
  902|  6.26M|      ip = get_match_fast(anchor + 8, ip_bound, ref + 8);
  903|  6.26M|    }
  904|       |#else
  905|       |    else {
  906|       |      ip = get_match_fast(anchor + 6, ip_bound, ref + 6);
  907|       |    }
  908|       |#endif
  909|       |
  910|  12.4M|    ip -= ipshift;
  911|  12.4M|    int len = (int)(ip - anchor);
  912|  12.4M|    if (len < minlen) {
  ------------------
  |  Branch (912:9): [True: 0, False: 12.4M]
  ------------------
  913|      0|      LITERAL2(ip, anchor, copy)
  ------------------
  |  |  778|      0|#define LITERAL2(ip, anchor, copy) {                    \
  |  |  779|      0|  oc++; (anchor)++;                                     \
  |  |  780|      0|  (ip) = (anchor);                                      \
  |  |  781|      0|  (copy)++;                                             \
  |  |  782|      0|  if (BLOSCLZ_UNLIKELY((copy) == MAX_COPY)) {           \
  |  |  ------------------
  |  |  |  |   52|      0|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (52:30): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  783|      0|    (copy) = 0;                                         \
  |  |  784|      0|    oc++;                                               \
  |  |  785|      0|  }                                                     \
  |  |  786|      0|}
  ------------------
  914|      0|      continue;
  915|      0|    }
  916|       |
  917|       |    /* if we haven't copied anything, adjust the output counter */
  918|  12.4M|    if (!copy)
  ------------------
  |  Branch (918:9): [True: 2.57M, False: 9.83M]
  ------------------
  919|  2.57M|      oc--;
  920|       |    /* reset literal counter */
  921|  12.4M|    copy = 0;
  922|       |
  923|       |    /* encode the match */
  924|  12.5M|    if (distance < MAX_DISTANCE) {
  ------------------
  |  |   63|  12.4M|#define MAX_DISTANCE 8191
  ------------------
  |  Branch (924:9): [True: 12.5M, False: 18.4E]
  ------------------
  925|  12.5M|      if (len >= 7) {
  ------------------
  |  Branch (925:11): [True: 6.67M, False: 5.86M]
  ------------------
  926|  6.67M|        oc += ((len - 7) / 255) + 1;
  927|  6.67M|      }
  928|  12.5M|      oc += 2;
  929|  12.5M|    }
  930|  18.4E|    else {
  931|       |      /* far away, but not yet in the another galaxy... */
  932|  18.4E|      if (len >= 7) {
  ------------------
  |  Branch (932:11): [True: 0, False: 18.4E]
  ------------------
  933|      0|        oc += ((len - 7) / 255) + 1;
  934|      0|      }
  935|  18.4E|      oc += 4;
  936|  18.4E|    }
  937|       |
  938|       |    /* update the hash at match boundary (guard 8-byte read against window end) */
  939|  12.4M|    if (ip + 8 <= ip_end) {
  ------------------
  |  Branch (939:9): [True: 11.8M, False: 555k]
  ------------------
  940|  11.8M|      hval = blosclz_hash6(ip, hashlog);
  941|  11.8M|      htab[hval] = (uint32_t)(ip - ibase) + base;
  942|  11.8M|    }
  943|  12.4M|    ip += 2;
  944|       |    /* assuming literal copy */
  945|  12.4M|    oc++;
  946|       |    /* Stop probing early once a 256-byte prefix already confirms compressibility
  947|       |     * well above the highest level threshold (1.5x at clevel 1). */
  948|  12.4M|    if (ip - ibase >= 256 && (ip - ibase) * 5 >= (ptrdiff_t)oc * 8) {
  ------------------
  |  Branch (948:9): [True: 8.85M, False: 3.55M]
  |  Branch (948:30): [True: 1.35M, False: 7.49M]
  ------------------
  949|  1.35M|      break;
  950|  1.35M|    }
  951|  12.4M|  }
  952|       |
  953|  1.88M|  double ic = (double)(ip - ibase);
  954|  1.88M|  return ic / (double)oc;
  955|  1.88M|}
blosclz-avx2.c:blosclz_hash6:
  100|  1.35G|BLOSCLZ_ALWAYS_INLINE uint32_t blosclz_hash6(const uint8_t *p, uint8_t hashlog) {
  101|  1.35G|  uint64_t s = blosclz_readu64(p) & BLOSCLZ_PREFIX6_MASK;
  ------------------
  |  |   82|  1.35G|#define BLOSCLZ_PREFIX6_MASK 0x0000FFFFFFFFFFFFULL
  ------------------
  102|  1.35G|  return (uint32_t)((s * 11400714819323198485ULL) >> (64U - hashlog));
  103|  1.35G|}
blosclz-avx2.c:blosclz_htab_get_tagged:
  841|  1.32G|BLOSCLZ_ALWAYS_INLINE uint32_t blosclz_htab_get_tagged(uint32_t entry, uint32_t base) {
  842|  1.32G|  uint32_t valid = 0U - (uint32_t)(entry >= base);
  843|  1.32G|  return (entry - base) & valid;
  844|  1.32G|}
blosclz-avx2.c:blosclz_readu64:
   91|  3.83G|BLOSCLZ_ALWAYS_INLINE uint64_t blosclz_readu64(const uint8_t *p) {
   92|  3.83G|  uint64_t v;
   93|  3.83G|  memcpy(&v, p, sizeof(v));
   94|  3.83G|  return v;
   95|  3.83G|}
blosclz-avx2.c:get_run_fast:
  731|  17.9M|BLOSCLZ_ALWAYS_INLINE uint8_t* get_run_fast(uint8_t* ip, const uint8_t* ip_bound, const uint8_t* ref) {
  732|  17.9M|#if defined(__AVX2__)
  733|  17.9M|  return get_run_32(ip, ip_bound, ref);
  734|       |#elif defined(__SSE2__)
  735|       |  return get_run_16(ip, ip_bound, ref);
  736|       |#elif defined(__aarch64__) || defined(_M_ARM64)
  737|       |  return get_run_neon(ip, ip_bound, ref);
  738|       |#else
  739|       |  return get_run(ip, ip_bound, ref);
  740|       |#endif
  741|  17.9M|}
blosclz-avx2.c:get_run_32:
  146|  17.9M|BLOSCLZ_ALWAYS_INLINE uint8_t *get_run_32(uint8_t *ip, const uint8_t *ip_bound, const uint8_t *ref) {
  147|  17.9M|  uint8_t x = ip[-1];
  148|       |  /* Most runs in shuffled floating-point streams are short; check 8 bytes in a
  149|       |   * GPR before broadcasting into YMM registers and loading 128 bytes. */
  150|  18.0M|  if (ip_bound - ip >= 8) {
  ------------------
  |  Branch (150:7): [True: 18.0M, False: 18.4E]
  ------------------
  151|  18.0M|    uint64_t val = (uint64_t)x * 0x0101010101010101ULL;
  152|  18.0M|    uint64_t r = blosclz_readu64(ref);
  153|  18.0M|    uint64_t diff = val ^ r;
  154|  18.0M|    if (diff) {
  ------------------
  |  Branch (154:9): [True: 12.7M, False: 5.29M]
  ------------------
  155|  12.7M|#if defined(BLOSCLZ_HAVE_CTZ64)
  156|  12.7M|      return ip + (blosclz_ctz64(diff) >> 3);
  157|       |#else
  158|       |      while (*ref++ == x) ip++;
  159|       |      return ip;
  160|       |#endif
  161|  12.7M|    }
  162|  5.29M|    ip += 8;
  163|  5.29M|    ref += 8;
  164|  5.29M|  }
  165|       |  /* Broadcast the run byte across all 32 lanes once outside the loop */
  166|  5.29M|  const __m256i value = _mm256_set1_epi8((char)x);
  167|       |  /* Scan long runs in 128-byte (4x32B) groups with a single reduction */
  168|  21.4M|  while (ip_bound - ip >= 128) {
  ------------------
  |  Branch (168:10): [True: 19.8M, False: 1.62M]
  ------------------
  169|  19.8M|    __m256i cmp0 = _mm256_cmpeq_epi8(value, _mm256_loadu_si256((const __m256i *)ref));
  170|  19.8M|    __m256i cmp1 = _mm256_cmpeq_epi8(value, _mm256_loadu_si256((const __m256i *)(ref + 32)));
  171|  19.8M|    __m256i cmp2 = _mm256_cmpeq_epi8(value, _mm256_loadu_si256((const __m256i *)(ref + 64)));
  172|  19.8M|    __m256i cmp3 = _mm256_cmpeq_epi8(value, _mm256_loadu_si256((const __m256i *)(ref + 96)));
  173|  19.8M|    __m256i eq01 = _mm256_and_si256(cmp0, cmp1);
  174|  19.8M|    __m256i eq23 = _mm256_and_si256(cmp2, cmp3);
  175|  19.8M|    if ((uint32_t)_mm256_movemask_epi8(_mm256_and_si256(eq01, eq23)) != 0xFFFFFFFFU) {
  ------------------
  |  Branch (175:9): [True: 3.67M, False: 16.1M]
  ------------------
  176|       |      /* Pinpoint the first differing byte directly from the compare vectors */
  177|  3.67M|      if ((uint32_t)_mm256_movemask_epi8(eq01) != 0xFFFFFFFFU) {
  ------------------
  |  Branch (177:11): [True: 2.69M, False: 974k]
  ------------------
  178|  2.69M|        uint32_t m0 = (uint32_t)_mm256_movemask_epi8(cmp0);
  179|  2.69M|        if (m0 != 0xFFFFFFFFU) {
  ------------------
  |  Branch (179:13): [True: 1.78M, False: 907k]
  ------------------
  180|  1.78M|#if defined(BLOSCLZ_HAVE_CTZ32)
  181|  1.78M|          return ip + blosclz_ctz32(~m0);
  182|       |#else
  183|       |          while (*ref++ == x) ip++;
  184|       |          return ip;
  185|       |#endif
  186|  1.78M|        }
  187|   907k|        uint32_t m1 = (uint32_t)_mm256_movemask_epi8(cmp1);
  188|   907k|#if defined(BLOSCLZ_HAVE_CTZ32)
  189|   907k|        return ip + 32 + blosclz_ctz32(~m1);
  190|       |#else
  191|       |        ip += 32;
  192|       |        ref += 32;
  193|       |        while (*ref++ == x) ip++;
  194|       |        return ip;
  195|       |#endif
  196|  2.69M|      }
  197|   974k|      uint32_t m2 = (uint32_t)_mm256_movemask_epi8(cmp2);
  198|   974k|      if (m2 != 0xFFFFFFFFU) {
  ------------------
  |  Branch (198:11): [True: 528k, False: 445k]
  ------------------
  199|   528k|#if defined(BLOSCLZ_HAVE_CTZ32)
  200|   528k|        return ip + 64 + blosclz_ctz32(~m2);
  201|       |#else
  202|       |        ip += 64;
  203|       |        ref += 64;
  204|       |        while (*ref++ == x) ip++;
  205|       |        return ip;
  206|       |#endif
  207|   528k|      }
  208|   445k|      uint32_t m3 = (uint32_t)_mm256_movemask_epi8(cmp3);
  209|   445k|#if defined(BLOSCLZ_HAVE_CTZ32)
  210|   445k|      return ip + 96 + blosclz_ctz32(~m3);
  211|       |#else
  212|       |      ip += 96;
  213|       |      ref += 96;
  214|       |      while (*ref++ == x) ip++;
  215|       |      return ip;
  216|       |#endif
  217|   974k|    }
  218|  16.1M|    ip += 128;
  219|  16.1M|    ref += 128;
  220|  16.1M|  }
  221|       |  /* Narrow 32-byte and 16-byte vector tails */
  222|  3.07M|  while (ip_bound - ip >= 32) {
  ------------------
  |  Branch (222:10): [True: 1.84M, False: 1.22M]
  ------------------
  223|  1.84M|    __m256i cmp = _mm256_cmpeq_epi8(value, _mm256_loadu_si256((const __m256i *)ref));
  224|  1.84M|    uint32_t mask = (uint32_t)_mm256_movemask_epi8(cmp);
  225|  1.84M|    if (mask != 0xFFFFFFFFU) {
  ------------------
  |  Branch (225:9): [True: 391k, False: 1.45M]
  ------------------
  226|   391k|#if defined(BLOSCLZ_HAVE_CTZ32)
  227|   391k|      return ip + blosclz_ctz32(~mask);
  228|       |#else
  229|       |      while (*ref++ == x) ip++;
  230|       |      return ip;
  231|       |#endif
  232|   391k|    }
  233|  1.45M|    ip += 32;
  234|  1.45M|    ref += 32;
  235|  1.45M|  }
  236|  1.22M|  if (ip_bound - ip >= 16) {
  ------------------
  |  Branch (236:7): [True: 583k, False: 645k]
  ------------------
  237|   583k|    __m128i cmp = _mm_cmpeq_epi8(_mm256_castsi256_si128(value),
  238|   583k|                                 _mm_loadu_si128((const __m128i *)ref));
  239|   583k|    uint32_t mask = (uint32_t)_mm_movemask_epi8(cmp);
  240|   583k|    if (mask != 0xFFFFU) {
  ------------------
  |  Branch (240:9): [True: 10.2k, False: 573k]
  ------------------
  241|  10.2k|#if defined(BLOSCLZ_HAVE_CTZ32)
  242|  10.2k|      return ip + blosclz_ctz32(~mask);
  243|       |#else
  244|       |      while (*ref++ == x) ip++;
  245|       |      return ip;
  246|       |#endif
  247|  10.2k|    }
  248|   573k|    ip += 16;
  249|   573k|    ref += 16;
  250|   573k|  }
  251|       |  /* Keep the original run byte: ref trails ip by one byte, so ip[-1] has
  252|       |   * not necessarily been checked when a vector iteration ends. */
  253|  10.6M|  while ((ip < ip_bound) && (*ref++ == x)) ip++;
  ------------------
  |  Branch (253:10): [True: 9.46M, False: 1.20M]
  |  Branch (253:29): [True: 9.44M, False: 17.1k]
  ------------------
  254|  1.21M|  return ip;
  255|  1.22M|}
blosclz-avx2.c:blosclz_ctz32:
  108|  26.5M|static inline unsigned blosclz_ctz32(uint32_t v) {
  109|  26.5M|  return (unsigned)__builtin_ctz(v);
  110|  26.5M|}
blosclz-avx2.c:blosclz_ctz64:
  113|  70.9M|static inline unsigned blosclz_ctz64(uint64_t v) {
  114|  70.9M|  return (unsigned)__builtin_ctzll(v);
  115|  70.9M|}
blosclz-avx2.c:get_match_fast:
  743|  54.9M|BLOSCLZ_ALWAYS_INLINE uint8_t* get_match_fast(uint8_t* ip, const uint8_t* ip_bound, const uint8_t* ref) {
  744|  54.9M|#if defined(__AVX2__)
  745|  54.9M|  return get_match_32(ip, ip_bound, ref);
  746|       |#elif defined(__SSE2__)
  747|       |  return get_match_16(ip, ip_bound, ref);
  748|       |#elif defined(__aarch64__) || defined(_M_ARM64)
  749|       |  return get_match_neon(ip, ip_bound, ref);
  750|       |#else
  751|       |  return get_match(ip, ip_bound, ref);
  752|       |#endif
  753|  54.9M|}
blosclz-avx2.c:get_match_32:
  257|  54.9M|BLOSCLZ_ALWAYS_INLINE uint8_t *get_match_32(uint8_t *ip, const uint8_t *ip_bound, const uint8_t *ref) {
  258|       |  /* Most matches in floating-point byte deltas are short. Avoid wide vector
  259|       |   * comparisons for these; a little-endian 64-bit scan locates a mismatch
  260|       |   * without a byte-at-a-time loop. */
  261|  54.9M|  if (ip_bound - ip >= 8) {
  ------------------
  |  Branch (261:7): [True: 54.8M, False: 66.5k]
  ------------------
  262|  54.8M|    uint64_t a, b;
  263|  54.8M|    memcpy(&a, ip, sizeof(a));
  264|  54.8M|    memcpy(&b, ref, sizeof(b));
  265|  54.8M|    uint64_t diff = a ^ b;
  266|  54.8M|    if (diff) {
  ------------------
  |  Branch (266:9): [True: 31.4M, False: 23.4M]
  ------------------
  267|  31.4M|#if defined(BLOSCLZ_HAVE_CTZ64)
  268|  31.4M|      return ip + (blosclz_ctz64(diff) >> 3) + 1;
  269|       |#else
  270|       |      while (*ref++ == *ip++) {}
  271|       |      return ip;
  272|       |#endif
  273|  31.4M|    }
  274|  23.4M|    ip += 8;
  275|  23.4M|    ref += 8;
  276|  23.4M|  }
  277|       |  /* Scan long matches in 128-byte (4x32B) groups with a single reduction */
  278|  96.6M|  while (ip_bound - ip >= 128) {
  ------------------
  |  Branch (278:10): [True: 94.7M, False: 1.94M]
  ------------------
  279|  94.7M|    __m256i cmp0 = _mm256_cmpeq_epi8(_mm256_loadu_si256((const __m256i *)ip),
  280|  94.7M|                                     _mm256_loadu_si256((const __m256i *)ref));
  281|  94.7M|    __m256i cmp1 = _mm256_cmpeq_epi8(_mm256_loadu_si256((const __m256i *)(ip + 32)),
  282|  94.7M|                                     _mm256_loadu_si256((const __m256i *)(ref + 32)));
  283|  94.7M|    __m256i cmp2 = _mm256_cmpeq_epi8(_mm256_loadu_si256((const __m256i *)(ip + 64)),
  284|  94.7M|                                     _mm256_loadu_si256((const __m256i *)(ref + 64)));
  285|  94.7M|    __m256i cmp3 = _mm256_cmpeq_epi8(_mm256_loadu_si256((const __m256i *)(ip + 96)),
  286|  94.7M|                                     _mm256_loadu_si256((const __m256i *)(ref + 96)));
  287|  94.7M|    __m256i eq01 = _mm256_and_si256(cmp0, cmp1);
  288|  94.7M|    __m256i eq23 = _mm256_and_si256(cmp2, cmp3);
  289|  94.7M|    if ((uint32_t)_mm256_movemask_epi8(_mm256_and_si256(eq01, eq23)) != 0xFFFFFFFFU) {
  ------------------
  |  Branch (289:9): [True: 21.5M, False: 73.1M]
  ------------------
  290|       |      /* Pinpoint the first mismatch (+1 matches the scalar post-increment contract) */
  291|  21.5M|      if ((uint32_t)_mm256_movemask_epi8(eq01) != 0xFFFFFFFFU) {
  ------------------
  |  Branch (291:11): [True: 18.1M, False: 3.36M]
  ------------------
  292|  18.1M|        uint32_t m0 = (uint32_t)_mm256_movemask_epi8(cmp0);
  293|  18.1M|        if (m0 != 0xFFFFFFFFU) {
  ------------------
  |  Branch (293:13): [True: 14.8M, False: 3.33M]
  ------------------
  294|  14.8M|#if defined(BLOSCLZ_HAVE_CTZ32)
  295|  14.8M|          return ip + blosclz_ctz32(~m0) + 1;
  296|       |#else
  297|       |          while (*ref++ == *ip++) {}
  298|       |          return ip;
  299|       |#endif
  300|  14.8M|        }
  301|  3.33M|        uint32_t m1 = (uint32_t)_mm256_movemask_epi8(cmp1);
  302|  3.33M|#if defined(BLOSCLZ_HAVE_CTZ32)
  303|  3.33M|        return ip + 32 + blosclz_ctz32(~m1) + 1;
  304|       |#else
  305|       |        ip += 32;
  306|       |        ref += 32;
  307|       |        while (*ref++ == *ip++) {}
  308|       |        return ip;
  309|       |#endif
  310|  18.1M|      }
  311|  3.36M|      uint32_t m2 = (uint32_t)_mm256_movemask_epi8(cmp2);
  312|  3.36M|      if (m2 != 0xFFFFFFFFU) {
  ------------------
  |  Branch (312:11): [True: 1.89M, False: 1.47M]
  ------------------
  313|  1.89M|#if defined(BLOSCLZ_HAVE_CTZ32)
  314|  1.89M|        return ip + 64 + blosclz_ctz32(~m2) + 1;
  315|       |#else
  316|       |        ip += 64;
  317|       |        ref += 64;
  318|       |        while (*ref++ == *ip++) {}
  319|       |        return ip;
  320|       |#endif
  321|  1.89M|      }
  322|  1.47M|      uint32_t m3 = (uint32_t)_mm256_movemask_epi8(cmp3);
  323|  1.47M|#if defined(BLOSCLZ_HAVE_CTZ32)
  324|  1.47M|      return ip + 96 + blosclz_ctz32(~m3) + 1;
  325|       |#else
  326|       |      ip += 96;
  327|       |      ref += 96;
  328|       |      while (*ref++ == *ip++) {}
  329|       |      return ip;
  330|       |#endif
  331|  3.36M|    }
  332|  73.1M|    ip += 128;
  333|  73.1M|    ref += 128;
  334|  73.1M|  }
  335|       |  /* Narrow 32-byte, 16-byte, and scalar tails */
  336|  3.78M|  while (ip_bound - ip >= 32) {
  ------------------
  |  Branch (336:10): [True: 2.65M, False: 1.12M]
  ------------------
  337|  2.65M|    __m256i cmp = _mm256_cmpeq_epi8(_mm256_loadu_si256((const __m256i *)ip),
  338|  2.65M|                                    _mm256_loadu_si256((const __m256i *)ref));
  339|  2.65M|    uint32_t mask = (uint32_t)_mm256_movemask_epi8(cmp);
  340|  2.65M|    if (mask != 0xFFFFFFFFU) {
  ------------------
  |  Branch (340:9): [True: 817k, False: 1.84M]
  ------------------
  341|   817k|#if defined(BLOSCLZ_HAVE_CTZ32)
  342|   817k|      return ip + blosclz_ctz32(~mask) + 1;
  343|       |#else
  344|       |      while (*ref++ == *ip++) {}
  345|       |      return ip;
  346|       |#endif
  347|   817k|    }
  348|  1.84M|    ip += 32;
  349|  1.84M|    ref += 32;
  350|  1.84M|  }
  351|  1.12M|  if (ip_bound - ip >= 16) {
  ------------------
  |  Branch (351:7): [True: 560k, False: 566k]
  ------------------
  352|   560k|    __m128i cmp = _mm_cmpeq_epi8(_mm_loadu_si128((const __m128i *)ip),
  353|   560k|                                 _mm_loadu_si128((const __m128i *)ref));
  354|   560k|    uint32_t mask = (uint32_t)_mm_movemask_epi8(cmp);
  355|   560k|    if (mask != 0xFFFFU) {
  ------------------
  |  Branch (355:9): [True: 96.0k, False: 464k]
  ------------------
  356|  96.0k|#if defined(BLOSCLZ_HAVE_CTZ32)
  357|  96.0k|      return ip + blosclz_ctz32(~mask) + 1;
  358|       |#else
  359|       |      while (*ref++ == *ip++) {}
  360|       |      return ip;
  361|       |#endif
  362|  96.0k|    }
  363|   464k|    ip += 16;
  364|   464k|    ref += 16;
  365|   464k|  }
  366|  10.6M|  while ((ip < ip_bound) && (*ref++ == *ip++)) {}
  ------------------
  |  Branch (366:10): [True: 9.73M, False: 868k]
  |  Branch (366:29): [True: 9.57M, False: 162k]
  ------------------
  367|  1.03M|  return ip;
  368|  1.12M|}
blosclz-avx2.c:emit_literals:
  756|  45.5M|                                             const uint8_t* lit_start, size_t lit_len) {
  757|  71.0M|  while (lit_len >= MAX_COPY) {
  ------------------
  |  |   62|  71.0M|#define MAX_COPY 32U
  ------------------
  |  Branch (757:10): [True: 25.5M, False: 45.5M]
  ------------------
  758|  25.5M|    if (BLOSCLZ_UNLIKELY((size_t)(op_limit - op) < MAX_COPY + 1)) {
  ------------------
  |  |   52|  25.5M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 455, False: 25.5M]
  |  |  ------------------
  ------------------
  759|    455|      return NULL;
  760|    455|    }
  761|  25.5M|    *op++ = MAX_COPY - 1;
  ------------------
  |  |   62|  25.5M|#define MAX_COPY 32U
  ------------------
  762|  25.5M|    memcpy(op, lit_start, MAX_COPY);
  ------------------
  |  |   62|  25.5M|#define MAX_COPY 32U
  ------------------
  763|  25.5M|    op += MAX_COPY;
  ------------------
  |  |   62|  25.5M|#define MAX_COPY 32U
  ------------------
  764|  25.5M|    lit_start += MAX_COPY;
  ------------------
  |  |   62|  25.5M|#define MAX_COPY 32U
  ------------------
  765|  25.5M|    lit_len -= MAX_COPY;
  ------------------
  |  |   62|  25.5M|#define MAX_COPY 32U
  ------------------
  766|  25.5M|  }
  767|  45.5M|  if (lit_len > 0) {
  ------------------
  |  Branch (767:7): [True: 45.2M, False: 291k]
  ------------------
  768|  45.2M|    if (BLOSCLZ_UNLIKELY((size_t)(op_limit - op) < lit_len + 1)) {
  ------------------
  |  |   52|  45.2M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 614, False: 45.2M]
  |  |  ------------------
  ------------------
  769|    614|      return NULL;
  770|    614|    }
  771|  45.2M|    *op++ = (uint8_t)(lit_len - 1);
  772|  45.2M|    memcpy(op, lit_start, lit_len);
  773|  45.2M|    op += lit_len;
  774|  45.2M|  }
  775|  45.5M|  return op;
  776|  45.5M|}
blosclz-avx2.c:blosclz_decompress_impl:
 1949|  4.60M|static inline int blosclz_decompress_impl(const void* input, int length, void* output, int maxout) {
 1950|  4.60M|  const uint8_t* ip = (const uint8_t*)input;
 1951|  4.60M|  const uint8_t* ip_limit = ip + length;
 1952|  4.60M|  uint8_t* op = (uint8_t*)output;
 1953|  4.60M|  uint32_t ctrl;
 1954|  4.60M|  uint8_t* op_limit = op + maxout;
 1955|  4.60M|  if (BLOSCLZ_UNLIKELY(length == 0)) {
  ------------------
  |  |   52|  4.60M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 0, False: 4.60M]
  |  |  ------------------
  ------------------
 1956|      0|    return 0;
 1957|      0|  }
 1958|  4.60M|  ctrl = (*ip++) & 31U;
 1959|       |
 1960|   517M|  while (1) {
  ------------------
  |  Branch (1960:10): [True: 517M, Folded]
  ------------------
 1961|   517M|    if (ctrl >= 32) {
  ------------------
  |  Branch (1961:9): [True: 281M, False: 236M]
  ------------------
 1962|       |      // match
 1963|   281M|      int32_t len = (int32_t)(ctrl >> 5U) - 1 ;
 1964|   281M|      int32_t ofs = (int32_t)(ctrl & 31U) << 8U;
 1965|   281M|      uint8_t code;
 1966|   281M|      const uint8_t* ref;
 1967|       |
 1968|   281M|      if (len == 7 - 1) {
  ------------------
  |  Branch (1968:11): [True: 143M, False: 138M]
  ------------------
 1969|   143M|#ifdef BLOSCLZ_WIDE_DECODE
 1970|       |        /* Long runs encode their lengths as consecutive 255-byte extensions.
 1971|       |         * Consume eight together, keeping an offset byte in reserve. */
 1972|   152M|        while (ip_limit - ip >= 9) {
  ------------------
  |  Branch (1972:16): [True: 149M, False: 3.88M]
  ------------------
 1973|   149M|          uint64_t extensions;
 1974|   149M|          memcpy(&extensions, ip, sizeof(extensions));
 1975|   149M|          if (extensions != UINT64_MAX) {
  ------------------
  |  Branch (1975:15): [True: 139M, False: 9.34M]
  ------------------
 1976|   139M|            break;
 1977|   139M|          }
 1978|  9.34M|          if (BLOSCLZ_UNLIKELY(len > maxout - 8 * 255)) {
  ------------------
  |  |   52|  9.34M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 1, False: 9.34M]
  |  |  ------------------
  ------------------
 1979|      1|            return 0;
 1980|      1|          }
 1981|  9.34M|          len += 8 * 255;
 1982|  9.34M|          ip += 8;
 1983|  9.34M|        }
 1984|   143M|#endif
 1985|   174M|        do {
 1986|   174M|          if (BLOSCLZ_UNLIKELY(ip + 1 >= ip_limit)) {
  ------------------
  |  |   52|   174M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 1, False: 174M]
  |  |  ------------------
  ------------------
 1987|      1|            return 0;
 1988|      1|          }
 1989|   174M|          code = *ip++;
 1990|       |          /* Guard before the addition so that `len` can never wrap past
 1991|       |             INT32_MAX.  The subsequent `len += 3` adds at most 3 more,
 1992|       |             so capping at maxout here is safe and sufficient. */
 1993|   174M|          if (BLOSCLZ_UNLIKELY(len > maxout - code)) {
  ------------------
  |  |   52|   174M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 1, False: 174M]
  |  |  ------------------
  ------------------
 1994|      1|            return 0;
 1995|      1|          }
 1996|   174M|          len += code;
 1997|   174M|        } while (code == 255);
  ------------------
  |  Branch (1997:18): [True: 30.7M, False: 143M]
  ------------------
 1998|   143M|      }
 1999|   138M|      else {
 2000|   138M|        if (BLOSCLZ_UNLIKELY(ip + 1 >= ip_limit)) {
  ------------------
  |  |   52|   138M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 1, False: 138M]
  |  |  ------------------
  ------------------
 2001|      1|          return 0;
 2002|      1|        }
 2003|   138M|      }
 2004|   281M|      code = *ip++;
 2005|   281M|      len += 3;
 2006|   281M|      ofs += code;
 2007|       |
 2008|       |      /* match from 16-bit distance: ofs == (31 << 8) && code == 255 iff ofs + code == MAX_DISTANCE */
 2009|   281M|      if (BLOSCLZ_UNLIKELY(ofs == MAX_DISTANCE)) {
  ------------------
  |  |   52|   281M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 799k, False: 280M]
  |  |  ------------------
  ------------------
 2010|   799k|        if (ip + 1 >= ip_limit) {
  ------------------
  |  Branch (2010:13): [True: 1, False: 799k]
  ------------------
 2011|      1|          return 0;
 2012|      1|        }
 2013|   799k|        ofs = (*ip++) << 8U;
 2014|   799k|        ofs += *ip++;
 2015|   799k|        ofs += MAX_DISTANCE;
  ------------------
  |  |   63|   799k|#define MAX_DISTANCE 8191
  ------------------
 2016|   799k|      }
 2017|   281M|      ref = op - ofs;
 2018|       |
 2019|   281M|      if (BLOSCLZ_UNLIKELY(len > op_limit - op)) {
  ------------------
  |  |   52|   281M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 1, False: 281M]
  |  |  ------------------
  ------------------
 2020|      1|        return 0;
 2021|      1|      }
 2022|       |
 2023|   281M|      if (BLOSCLZ_UNLIKELY(ref <= (uint8_t*)output)) {
  ------------------
  |  |   52|   281M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 1, False: 281M]
  |  |  ------------------
  ------------------
 2024|      1|        return 0;
 2025|      1|      }
 2026|       |
 2027|   281M|      if (BLOSCLZ_UNLIKELY(ip >= ip_limit)) break;
  ------------------
  |  |   52|   281M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 2, False: 281M]
  |  |  ------------------
  ------------------
 2028|   281M|      ctrl = *ip++;
 2029|       |
 2030|   281M|      ref--;
 2031|   281M|#if defined(__aarch64__) || defined(_M_ARM64) || defined(__AVX2__) || defined(__SSSE3__)
 2032|   281M|      if (len <= 32 && op_limit - op >= 32) {
  ------------------
  |  Branch (2032:11): [True: 244M, False: 37.4M]
  |  Branch (2032:24): [True: 242M, False: 2.16M]
  ------------------
 2033|   242M|        blosclz_copy_short_match(op, ref, len);
 2034|   242M|        op += len;
 2035|   242M|        continue;
 2036|   242M|      }
 2037|  39.6M|#endif
 2038|  39.6M|#if defined(__AVX2__)
 2039|  39.6M|      op = blosclz_copy_match_avx2(op, ref, len, op_limit);
 2040|       |#elif defined(__SSE2__) || defined(__x86_64__) || defined(_M_X64)
 2041|       |      op = blosclz_copy_match_sse2(op, ref, len, op_limit);
 2042|       |#elif defined(__aarch64__) || defined(_M_ARM64)
 2043|       |      op = blosclz_copy_match_neon(op, ref, len, op_limit);
 2044|       |#else
 2045|       |      if (ref == op - 1) {
 2046|       |        /* optimized copy for a run */
 2047|       |        memset(op, *ref, len);
 2048|       |        op += len;
 2049|       |      }
 2050|       |      else if ((op - ref >= 8) && (op_limit - op - len >= 8)) {
 2051|       |        // copy with an overlap not larger than 8
 2052|       |        wild_copy(op, ref, op + len);
 2053|       |        op += len;
 2054|       |      }
 2055|       |      else {
 2056|       |        op = copy_match(op, ref, (unsigned) len);
 2057|       |      }
 2058|       |#endif
 2059|  39.6M|    }
 2060|   236M|    else {
 2061|       |      // literal
 2062|   236M|      ctrl++;
 2063|   236M|#ifdef BLOSCLZ_WIDE_DECODE
 2064|       |      /* All literal lengths fit in one fixed-size copy when both buffers have room. */
 2065|   236M|      if (op_limit - op >= 32 && ip_limit - ip >= 32) {
  ------------------
  |  Branch (2065:11): [True: 231M, False: 4.90M]
  |  Branch (2065:34): [True: 225M, False: 5.29M]
  ------------------
 2066|   225M|        memcpy(op, ip, 32);
 2067|   225M|      }
 2068|  10.1M|      else
 2069|  10.1M|#endif
 2070|  10.1M|      {
 2071|  10.1M|        if (BLOSCLZ_UNLIKELY(ctrl > op_limit - op || ctrl > ip_limit - ip)) {
  ------------------
  |  |   52|  20.3M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:31): [True: 2, False: 10.1M]
  |  |  |  Branch (52:31): [True: 1, False: 10.1M]
  |  |  ------------------
  ------------------
 2072|      3|          return 0;
 2073|      3|        }
 2074|  10.1M|        memcpy(op, ip, ctrl);
 2075|  10.1M|      }
 2076|   236M|      op += ctrl; ip += ctrl;
 2077|       |
 2078|   236M|      if (BLOSCLZ_UNLIKELY(ip >= ip_limit)) break;
  ------------------
  |  |   52|   236M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (52:30): [True: 4.60M, False: 231M]
  |  |  ------------------
  ------------------
 2079|   231M|      ctrl = *ip++;
 2080|   231M|    }
 2081|   517M|  }
 2082|       |
 2083|  4.60M|  return (int)(op - (uint8_t*)output);
 2084|  4.60M|}
blosclz-avx2.c:blosclz_copy_short_match:
 1308|   242M|BLOSCLZ_ALWAYS_INLINE void blosclz_copy_short_match(uint8_t *op, const uint8_t *ref, int32_t len) {
 1309|   242M|  ptrdiff_t dist = op - ref;
 1310|       |  /* Row d repeats the first d bytes. Row zero is the identity for distances
 1311|       |   * of at least 16, where each vector load already contains the next 16 bytes. */
 1312|   242M|  static const uint8_t repeat[16][16] = {
 1313|   242M|    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
 1314|   242M|    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
 1315|   242M|    {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},
 1316|   242M|    {0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0},
 1317|   242M|    {0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3},
 1318|   242M|    {0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0},
 1319|   242M|    {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3},
 1320|   242M|    {0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1},
 1321|   242M|    {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7},
 1322|   242M|    {0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6},
 1323|   242M|    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5},
 1324|   242M|    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4},
 1325|   242M|    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3},
 1326|   242M|    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 1, 2},
 1327|   242M|    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 1},
 1328|   242M|    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0},
 1329|   242M|  };
 1330|       |
 1331|       |  /* Compute the repeat-table row branchlessly (row 0 is identity for dist >= 16)
 1332|       |   * so GCC does not emit a mispredicting branch on dist < 16. */
 1333|   242M|  size_t row = (size_t)dist & ((size_t)0 - (size_t)(dist < 16));
 1334|       |#if defined(__aarch64__) || defined(_M_ARM64)
 1335|       |  uint8x16_t index = vld1q_u8(repeat[row]);
 1336|       |  vst1q_u8(op, vqtbl1q_u8(vld1q_u8(ref), index));
 1337|       |  if (len > 16) {
 1338|       |    vst1q_u8(op + 16, vqtbl1q_u8(vld1q_u8(ref + 16), index));
 1339|       |  }
 1340|       |#else
 1341|   242M|  __m128i index = _mm_loadu_si128((const __m128i *)repeat[row]);
 1342|   242M|  _mm_storeu_si128((__m128i *)op, _mm_shuffle_epi8(_mm_loadu_si128((const __m128i *)ref), index));
 1343|   242M|  if (len > 16) {
  ------------------
  |  Branch (1343:7): [True: 29.6M, False: 212M]
  ------------------
 1344|  29.6M|    _mm_storeu_si128((__m128i *)(op + 16), _mm_shuffle_epi8(_mm_loadu_si128((const __m128i *)(ref + 16)), index));
 1345|  29.6M|  }
 1346|   242M|#endif
 1347|   242M|}
blosclz-avx2.c:blosclz_copy_match_avx2:
 1356|  39.6M|    uint8_t *op, const uint8_t *ref, int32_t len, uint8_t *op_limit) {
 1357|  39.6M|  ptrdiff_t dist = op - ref;
 1358|  39.6M|  uint8_t *end = op + len;
 1359|       |
 1360|  39.6M|  if (dist >= 32) {
  ------------------
  |  Branch (1360:7): [True: 22.0M, False: 17.5M]
  ------------------
 1361|       |    /* Short match overcopies when output slack permits (subsequent tokens overwrite excess). */
 1362|  22.0M|    if (len <= 16 && op_limit - op >= 16) {
  ------------------
  |  Branch (1362:9): [True: 1.35M, False: 20.6M]
  |  Branch (1362:22): [True: 1.17M, False: 179k]
  ------------------
 1363|  1.17M|      _mm_storeu_si128((__m128i *)op, _mm_loadu_si128((const __m128i *)ref));
 1364|  1.17M|      return end;
 1365|  1.17M|    }
 1366|  20.8M|    if (len <= 32 && op_limit - op >= 32) {
  ------------------
  |  Branch (1366:9): [True: 395k, False: 20.4M]
  |  Branch (1366:22): [True: 0, False: 395k]
  ------------------
 1367|      0|      _mm256_storeu_si256((__m256i *)op, _mm256_loadu_si256((const __m256i *)ref));
 1368|      0|      return end;
 1369|      0|    }
 1370|  20.8M|    if (len <= 64 && op_limit - op >= 64) {
  ------------------
  |  Branch (1370:9): [True: 10.5M, False: 10.2M]
  |  Branch (1370:22): [True: 10.0M, False: 535k]
  ------------------
 1371|  10.0M|      _mm256_storeu_si256((__m256i *)op, _mm256_loadu_si256((const __m256i *)ref));
 1372|  10.0M|      _mm256_storeu_si256((__m256i *)(op + 32), _mm256_loadu_si256((const __m256i *)(ref + 32)));
 1373|  10.0M|      return end;
 1374|  10.0M|    }
 1375|  10.8M|    if (len >= 32) {
  ------------------
  |  Branch (1375:9): [True: 10.4M, False: 395k]
  ------------------
 1376|  10.4M|      uint8_t *cur = op;
 1377|  10.4M|      const uint8_t *src = ref;
 1378|  10.4M|      if (dist >= 128) {
  ------------------
  |  Branch (1378:11): [True: 8.96M, False: 1.44M]
  ------------------
 1379|       |        /* Non-overlapping 128B blocks: batch 4x32B loads before stores in 256B/128B steps. */
 1380|  35.7M|        while (cur + 256 <= end) {
  ------------------
  |  Branch (1380:16): [True: 26.7M, False: 8.96M]
  ------------------
 1381|  26.7M|          __m256i v0 = _mm256_loadu_si256((const __m256i *)src);
 1382|  26.7M|          __m256i v1 = _mm256_loadu_si256((const __m256i *)(src + 32));
 1383|  26.7M|          __m256i v2 = _mm256_loadu_si256((const __m256i *)(src + 64));
 1384|  26.7M|          __m256i v3 = _mm256_loadu_si256((const __m256i *)(src + 96));
 1385|  26.7M|          _mm256_storeu_si256((__m256i *)cur, v0);
 1386|  26.7M|          _mm256_storeu_si256((__m256i *)(cur + 32), v1);
 1387|  26.7M|          _mm256_storeu_si256((__m256i *)(cur + 64), v2);
 1388|  26.7M|          _mm256_storeu_si256((__m256i *)(cur + 96), v3);
 1389|  26.7M|          __m256i v4 = _mm256_loadu_si256((const __m256i *)(src + 128));
 1390|  26.7M|          __m256i v5 = _mm256_loadu_si256((const __m256i *)(src + 160));
 1391|  26.7M|          __m256i v6 = _mm256_loadu_si256((const __m256i *)(src + 192));
 1392|  26.7M|          __m256i v7 = _mm256_loadu_si256((const __m256i *)(src + 224));
 1393|  26.7M|          _mm256_storeu_si256((__m256i *)(cur + 128), v4);
 1394|  26.7M|          _mm256_storeu_si256((__m256i *)(cur + 160), v5);
 1395|  26.7M|          _mm256_storeu_si256((__m256i *)(cur + 192), v6);
 1396|  26.7M|          _mm256_storeu_si256((__m256i *)(cur + 224), v7);
 1397|  26.7M|          cur += 256;
 1398|  26.7M|          src += 256;
 1399|  26.7M|        }
 1400|  8.96M|        if (cur + 128 <= end) {
  ------------------
  |  Branch (1400:13): [True: 3.55M, False: 5.40M]
  ------------------
 1401|  3.55M|          __m256i v0 = _mm256_loadu_si256((const __m256i *)src);
 1402|  3.55M|          __m256i v1 = _mm256_loadu_si256((const __m256i *)(src + 32));
 1403|  3.55M|          __m256i v2 = _mm256_loadu_si256((const __m256i *)(src + 64));
 1404|  3.55M|          __m256i v3 = _mm256_loadu_si256((const __m256i *)(src + 96));
 1405|  3.55M|          _mm256_storeu_si256((__m256i *)cur, v0);
 1406|  3.55M|          _mm256_storeu_si256((__m256i *)(cur + 32), v1);
 1407|  3.55M|          _mm256_storeu_si256((__m256i *)(cur + 64), v2);
 1408|  3.55M|          _mm256_storeu_si256((__m256i *)(cur + 96), v3);
 1409|  3.55M|          cur += 128;
 1410|  3.55M|          src += 128;
 1411|  3.55M|        }
 1412|  8.96M|      }
 1413|  1.44M|      else {
 1414|       |        /* Keep each 32B load/store ordered so distances in [32, 128) propagate safely. */
 1415|  15.9M|        while (cur + 128 <= end) {
  ------------------
  |  Branch (1415:16): [True: 14.5M, False: 1.44M]
  ------------------
 1416|  14.5M|          _mm256_storeu_si256((__m256i *)cur, _mm256_loadu_si256((const __m256i *)src));
 1417|  14.5M|          _mm256_storeu_si256((__m256i *)(cur + 32), _mm256_loadu_si256((const __m256i *)(src + 32)));
 1418|  14.5M|          _mm256_storeu_si256((__m256i *)(cur + 64), _mm256_loadu_si256((const __m256i *)(src + 64)));
 1419|  14.5M|          _mm256_storeu_si256((__m256i *)(cur + 96), _mm256_loadu_si256((const __m256i *)(src + 96)));
 1420|  14.5M|          cur += 128;
 1421|  14.5M|          src += 128;
 1422|  14.5M|        }
 1423|  1.44M|      }
 1424|       |      /* Finish remaining <128B using 64B/32B steps and an exact overlapping 32B tail. */
 1425|  10.4M|      if (cur + 64 <= end) {
  ------------------
  |  Branch (1425:11): [True: 6.85M, False: 3.55M]
  ------------------
 1426|  6.85M|        _mm256_storeu_si256((__m256i *)cur, _mm256_loadu_si256((const __m256i *)src));
 1427|  6.85M|        _mm256_storeu_si256((__m256i *)(cur + 32), _mm256_loadu_si256((const __m256i *)(src + 32)));
 1428|  6.85M|        cur += 64;
 1429|  6.85M|        src += 64;
 1430|  6.85M|      }
 1431|  10.4M|      if (cur + 32 <= end) {
  ------------------
  |  Branch (1431:11): [True: 4.43M, False: 5.96M]
  ------------------
 1432|  4.43M|        _mm256_storeu_si256((__m256i *)cur, _mm256_loadu_si256((const __m256i *)src));
 1433|  4.43M|        cur += 32;
 1434|  4.43M|      }
 1435|  10.4M|      if (cur < end) {
  ------------------
  |  Branch (1435:11): [True: 10.1M, False: 227k]
  ------------------
 1436|  10.1M|        _mm256_storeu_si256((__m256i *)(end - 32), _mm256_loadu_si256((const __m256i *)(ref + len - 32)));
 1437|  10.1M|      }
 1438|  10.4M|      return end;
 1439|  10.4M|    }
 1440|       |    /* Exact 16..31-byte copy near end of buffer using two overlapping 16B stores. */
 1441|   395k|    if (len >= 16) {
  ------------------
  |  Branch (1441:9): [True: 216k, False: 179k]
  ------------------
 1442|   216k|      _mm_storeu_si128((__m128i *)op, _mm_loadu_si128((const __m128i *)ref));
 1443|   216k|      _mm_storeu_si128((__m128i *)(end - 16), _mm_loadu_si128((const __m128i *)(ref + len - 16)));
 1444|   216k|      return end;
 1445|   216k|    }
 1446|   179k|    return copy_match(op, ref, (unsigned)len);
 1447|   395k|  }
 1448|       |
 1449|  17.5M|  if (dist >= 16) {
  ------------------
  |  Branch (1449:7): [True: 1.52M, False: 16.0M]
  ------------------
 1450|       |    /* 16..31-byte overlap distance: single 16B overcopy for short matches. */
 1451|  1.52M|    if (len <= 16 && op_limit - op >= 16) {
  ------------------
  |  Branch (1451:9): [True: 82.1k, False: 1.44M]
  |  Branch (1451:22): [True: 70.5k, False: 11.6k]
  ------------------
 1452|  70.5k|      _mm_storeu_si128((__m128i *)op, _mm_loadu_si128((const __m128i *)ref));
 1453|  70.5k|      return end;
 1454|  70.5k|    }
 1455|  1.45M|    if (len >= 32) {
  ------------------
  |  Branch (1455:9): [True: 1.42M, False: 27.9k]
  ------------------
 1456|       |      /* Seed first dist bytes so wide_dist = 2 * dist >= 32, enabling 32B AVX2 copies. */
 1457|  1.42M|      _mm_storeu_si128((__m128i *)op, _mm_loadu_si128((const __m128i *)ref));
 1458|  1.42M|      _mm_storeu_si128((__m128i *)(op + dist - 16), _mm_loadu_si128((const __m128i *)(ref + dist - 16)));
 1459|  1.42M|      uint8_t *cur = op + dist;
 1460|  1.42M|      const uint8_t *src = ref;
 1461|  1.42M|      ptrdiff_t wide_dist = dist * 2;
 1462|  24.7M|      while (cur + 64 <= end) {
  ------------------
  |  Branch (1462:14): [True: 23.3M, False: 1.42M]
  ------------------
 1463|  23.3M|        _mm256_storeu_si256((__m256i *)cur, _mm256_loadu_si256((const __m256i *)src));
 1464|  23.3M|        _mm256_storeu_si256((__m256i *)(cur + 32), _mm256_loadu_si256((const __m256i *)(src + 32)));
 1465|  23.3M|        cur += 64;
 1466|  23.3M|        src += 64;
 1467|  23.3M|      }
 1468|  1.42M|      if (cur + 32 <= end) {
  ------------------
  |  Branch (1468:11): [True: 569k, False: 859k]
  ------------------
 1469|   569k|        _mm256_storeu_si256((__m256i *)cur, _mm256_loadu_si256((const __m256i *)src));
 1470|   569k|        cur += 32;
 1471|   569k|        src += 32;
 1472|   569k|      }
 1473|       |      /* Overlapping 32B tail if the wide loop ran; otherwise finish safely with 16B ops. */
 1474|  1.42M|      if (cur < end) {
  ------------------
  |  Branch (1474:11): [True: 1.35M, False: 72.6k]
  ------------------
 1475|  1.35M|        if (cur > op + dist) {
  ------------------
  |  Branch (1475:13): [True: 846k, False: 510k]
  ------------------
 1476|   846k|          _mm256_storeu_si256((__m256i *)(end - 32), _mm256_loadu_si256((const __m256i *)(end - 32 - wide_dist)));
 1477|   846k|        }
 1478|   510k|        else {
 1479|   510k|          if (cur + 16 <= end) {
  ------------------
  |  Branch (1479:15): [True: 307k, False: 202k]
  ------------------
 1480|   307k|            _mm_storeu_si128((__m128i *)cur, _mm_loadu_si128((const __m128i *)src));
 1481|   307k|            cur += 16;
 1482|   307k|          }
 1483|   510k|          if (cur < end) {
  ------------------
  |  Branch (1483:15): [True: 502k, False: 7.45k]
  ------------------
 1484|   502k|            _mm_storeu_si128((__m128i *)(end - 16), _mm_loadu_si128((const __m128i *)(end - 16 - dist)));
 1485|   502k|          }
 1486|   510k|        }
 1487|  1.35M|      }
 1488|  1.42M|      return end;
 1489|  1.42M|    }
 1490|       |    /* Exact 16..31-byte copy with two overlapping 16B stores. */
 1491|  27.9k|    if (len >= 16) {
  ------------------
  |  Branch (1491:9): [True: 16.3k, False: 11.6k]
  ------------------
 1492|  16.3k|      _mm_storeu_si128((__m128i *)op, _mm_loadu_si128((const __m128i *)ref));
 1493|  16.3k|      if (len > 16) {
  ------------------
  |  Branch (1493:11): [True: 16.3k, False: 0]
  ------------------
 1494|  16.3k|        _mm_storeu_si128((__m128i *)(end - 16), _mm_loadu_si128((const __m128i *)(ref + len - 16)));
 1495|  16.3k|      }
 1496|  16.3k|      return end;
 1497|  16.3k|    }
 1498|  11.6k|    return copy_match(op, ref, (unsigned)len);
 1499|  27.9k|  }
 1500|       |
 1501|  16.0M|  if (dist == 1) {
  ------------------
  |  Branch (1501:7): [True: 7.25M, False: 8.81M]
  ------------------
 1502|       |    /* Inline AVX2 RLE fills up to 256B to avoid memset call overhead; longer runs use memset. */
 1503|  7.25M|    if (len <= 32 && op_limit - op >= 32) {
  ------------------
  |  Branch (1503:9): [True: 292k, False: 6.96M]
  |  Branch (1503:22): [True: 0, False: 292k]
  ------------------
 1504|      0|      _mm256_storeu_si256((__m256i *)op, _mm256_set1_epi8((char)*ref));
 1505|      0|      return end;
 1506|      0|    }
 1507|  7.25M|    if (len <= 64 && op_limit - op >= 64) {
  ------------------
  |  Branch (1507:9): [True: 1.95M, False: 5.30M]
  |  Branch (1507:22): [True: 1.55M, False: 403k]
  ------------------
 1508|  1.55M|      __m256i v = _mm256_set1_epi8((char)*ref);
 1509|  1.55M|      _mm256_storeu_si256((__m256i *)op, v);
 1510|  1.55M|      _mm256_storeu_si256((__m256i *)(op + 32), v);
 1511|  1.55M|      return end;
 1512|  1.55M|    }
 1513|  5.70M|    if (len >= 32 && len <= 256) {
  ------------------
  |  Branch (1513:9): [True: 5.41M, False: 292k]
  |  Branch (1513:22): [True: 2.27M, False: 3.14M]
  ------------------
 1514|  2.27M|      __m256i v = _mm256_set1_epi8((char)*ref);
 1515|  2.27M|      uint8_t *cur = op;
 1516|  6.08M|      while (cur + 64 <= end) {
  ------------------
  |  Branch (1516:14): [True: 3.81M, False: 2.27M]
  ------------------
 1517|  3.81M|        _mm256_storeu_si256((__m256i *)cur, v);
 1518|  3.81M|        _mm256_storeu_si256((__m256i *)(cur + 32), v);
 1519|  3.81M|        cur += 64;
 1520|  3.81M|      }
 1521|  2.27M|      if (cur + 32 <= end) {
  ------------------
  |  Branch (1521:11): [True: 1.00M, False: 1.26M]
  ------------------
 1522|  1.00M|        _mm256_storeu_si256((__m256i *)cur, v);
 1523|  1.00M|        cur += 32;
 1524|  1.00M|      }
 1525|  2.27M|      if (cur < end) {
  ------------------
  |  Branch (1525:11): [True: 2.23M, False: 35.9k]
  ------------------
 1526|  2.23M|        _mm256_storeu_si256((__m256i *)(end - 32), v);
 1527|  2.23M|      }
 1528|  2.27M|      return end;
 1529|  2.27M|    }
 1530|  3.43M|    memset(op, *ref, (size_t)len);
 1531|  3.43M|    return end;
 1532|  5.70M|  }
 1533|       |
 1534|  8.81M|  if (dist >= 8) {
  ------------------
  |  Branch (1534:7): [True: 3.09M, False: 5.72M]
  ------------------
 1535|       |    /* 8..15-byte overlap distance: fast short copies, or double distance to >=16B for loops. */
 1536|  3.09M|    if (len <= dist && op_limit - op >= 16) {
  ------------------
  |  Branch (1536:9): [True: 94.4k, False: 2.99M]
  |  Branch (1536:24): [True: 87.9k, False: 6.59k]
  ------------------
 1537|  87.9k|      _mm_storeu_si128((__m128i *)op, _mm_loadu_si128((const __m128i *)ref));
 1538|  87.9k|      return end;
 1539|  87.9k|    }
 1540|  3.00M|    if (len <= 16 && op_limit - op >= 16) {
  ------------------
  |  Branch (1540:9): [True: 37.7k, False: 2.96M]
  |  Branch (1540:22): [True: 14.9k, False: 22.8k]
  ------------------
 1541|  14.9k|      memcpy(op, ref, 8);
 1542|  14.9k|      memcpy(op + 8, ref + 8, 8);
 1543|  14.9k|      return end;
 1544|  14.9k|    }
 1545|  2.98M|    if (len > 16) {
  ------------------
  |  Branch (1545:9): [True: 2.96M, False: 22.8k]
  ------------------
 1546|       |      /* Seed first dist bytes so wide_dist = 2 * dist >= 16. */
 1547|  2.96M|      _mm_storeu_si128((__m128i *)op, _mm_loadu_si128((const __m128i *)ref));
 1548|  2.96M|      uint8_t *cur = op + dist;
 1549|  2.96M|      const uint8_t *src = ref;
 1550|  2.96M|      ptrdiff_t wide_dist = dist * 2;
 1551|   212M|      while (cur + 16 <= end) {
  ------------------
  |  Branch (1551:14): [True: 209M, False: 2.96M]
  ------------------
 1552|   209M|        _mm_storeu_si128((__m128i *)cur, _mm_loadu_si128((const __m128i *)src));
 1553|   209M|        cur += 16;
 1554|   209M|        src += 16;
 1555|   209M|      }
 1556|       |      /* Finish tail via overlapping 16B copy if wide loop ran, else bytewise fallback. */
 1557|  2.96M|      if (cur < end) {
  ------------------
  |  Branch (1557:11): [True: 2.74M, False: 222k]
  ------------------
 1558|  2.74M|        if (cur > op + dist) {
  ------------------
  |  Branch (1558:13): [True: 2.73M, False: 8.38k]
  ------------------
 1559|  2.73M|          _mm_storeu_si128((__m128i *)(end - 16), _mm_loadu_si128((const __m128i *)(end - 16 - wide_dist)));
 1560|  2.73M|        }
 1561|  8.38k|        else {
 1562|  83.4k|          while (cur < end) {
  ------------------
  |  Branch (1562:18): [True: 75.0k, False: 8.38k]
  ------------------
 1563|  75.0k|            *cur++ = *src++;
 1564|  75.0k|          }
 1565|  8.38k|        }
 1566|  2.74M|      }
 1567|  2.96M|      return end;
 1568|  2.96M|    }
 1569|  22.8k|    return copy_match(op, ref, (unsigned)len);
 1570|  2.98M|  }
 1571|       |
 1572|  5.72M|  if ((dist == 2 || dist == 4) && len >= 16) {
  ------------------
  |  Branch (1572:8): [True: 332k, False: 5.38M]
  |  Branch (1572:21): [True: 1.25M, False: 4.13M]
  |  Branch (1572:35): [True: 1.58M, False: 1.77k]
  ------------------
 1573|  1.58M|    __m256i v256;
 1574|  1.58M|    if (dist == 2) {
  ------------------
  |  Branch (1574:9): [True: 331k, False: 1.25M]
  ------------------
 1575|   331k|      int16_t pat2;
 1576|   331k|      memcpy(&pat2, ref, sizeof(pat2));
 1577|   331k|      v256 = _mm256_set1_epi16(pat2);
 1578|   331k|    }
 1579|  1.25M|    else {
 1580|  1.25M|      int32_t pat4;
 1581|  1.25M|      memcpy(&pat4, ref, sizeof(pat4));
 1582|  1.25M|      v256 = _mm256_set1_epi32(pat4);
 1583|  1.25M|    }
 1584|  1.58M|    __m128i v128 = _mm256_castsi256_si128(v256);
 1585|  1.58M|    uint8_t *cur = op;
 1586|  36.9M|    while (cur + 64 <= end) {
  ------------------
  |  Branch (1586:12): [True: 35.3M, False: 1.58M]
  ------------------
 1587|  35.3M|      _mm256_storeu_si256((__m256i *)cur, v256);
 1588|  35.3M|      _mm256_storeu_si256((__m256i *)(cur + 32), v256);
 1589|  35.3M|      cur += 64;
 1590|  35.3M|    }
 1591|  1.58M|    if (cur + 32 <= end) {
  ------------------
  |  Branch (1591:9): [True: 829k, False: 755k]
  ------------------
 1592|   829k|      _mm256_storeu_si256((__m256i *)cur, v256);
 1593|   829k|      cur += 32;
 1594|   829k|    }
 1595|  1.58M|    if (cur + 16 <= end) {
  ------------------
  |  Branch (1595:9): [True: 807k, False: 776k]
  ------------------
 1596|   807k|      _mm_storeu_si128((__m128i *)cur, v128);
 1597|   807k|      cur += 16;
 1598|   807k|    }
 1599|  1.58M|    if (cur < end) {
  ------------------
  |  Branch (1599:9): [True: 1.49M, False: 92.5k]
  ------------------
 1600|  1.49M|      if (op_limit - cur >= 16) {
  ------------------
  |  Branch (1600:11): [True: 1.47M, False: 18.4k]
  ------------------
 1601|  1.47M|        _mm_storeu_si128((__m128i *)cur, v128);
 1602|  1.47M|      }
 1603|  18.4k|      else {
 1604|  18.4k|        const uint8_t *tail_src = ref;
 1605|  95.1k|        while (cur < end) {
  ------------------
  |  Branch (1605:16): [True: 76.7k, False: 18.4k]
  ------------------
 1606|  76.7k|          *cur++ = *tail_src++;
 1607|  76.7k|        }
 1608|  18.4k|      }
 1609|  1.49M|    }
 1610|  1.58M|    return end;
 1611|  1.58M|  }
 1612|       |
 1613|  4.13M|  return copy_match(op, ref, (unsigned)len);
 1614|  5.72M|}

blosc2.c:ctx_clear_maskout:
  170|  2.08M|static inline void ctx_clear_maskout(blosc2_context *context) {
  171|  2.08M|  free(context->block_maskout);
  172|       |  context->block_maskout = NULL;
  173|  2.08M|  context->block_maskout_nitems = 0;
  174|  2.08M|}
schunk.c:ctx_uses_parallel_backend:
  165|  60.1k|static inline bool ctx_uses_parallel_backend(const blosc2_context *context) {
  166|  60.1k|  return context != NULL && context->thread_backend != BLOSC_BACKEND_SERIAL && context->nthreads > 1;
  ------------------
  |  |   33|   120k|#define BLOSC_BACKEND_SERIAL 0
  ------------------
  |  Branch (166:10): [True: 60.1k, False: 0]
  |  Branch (166:29): [True: 0, False: 60.1k]
  |  Branch (166:80): [True: 0, False: 0]
  ------------------
  167|  60.1k|}
schunk.c:ctx_clear_maskout:
  170|   446k|static inline void ctx_clear_maskout(blosc2_context *context) {
  171|   446k|  free(context->block_maskout);
  172|       |  context->block_maskout = NULL;
  173|   446k|  context->block_maskout_nitems = 0;
  174|   446k|}

delta_decoder:
   97|  1.06k|                   int32_t typesize, uint8_t* dest) {
   98|  1.06k|  int32_t i;
   99|       |
  100|  1.06k|  if (offset == 0) {
  ------------------
  |  Branch (100:7): [True: 601, False: 459]
  ------------------
  101|       |    /* Decode delta for the reference block */
  102|    601|    switch (typesize) {
  103|    137|      case 1:
  ------------------
  |  Branch (103:7): [True: 137, False: 464]
  ------------------
  104|   683M|        for (i = 1; i < nbytes; i++) {
  ------------------
  |  Branch (104:21): [True: 683M, False: 137]
  ------------------
  105|   683M|          dest[i] ^= dref[i-1];
  106|   683M|        }
  107|    137|        break;
  108|     72|      case 2:
  ------------------
  |  Branch (108:7): [True: 72, False: 529]
  ------------------
  109|  20.5M|        for (i = 1; i < nbytes / 2; i++) {
  ------------------
  |  Branch (109:21): [True: 20.5M, False: 72]
  ------------------
  110|  20.5M|          ((uint16_t *)dest)[i] ^= ((uint16_t *)dref)[i-1];
  111|  20.5M|        }
  112|     72|        break;
  113|     74|      case 4:
  ------------------
  |  Branch (113:7): [True: 74, False: 527]
  ------------------
  114|   222M|        for (i = 1; i < nbytes / 4; i++) {
  ------------------
  |  Branch (114:21): [True: 222M, False: 74]
  ------------------
  115|   222M|          ((uint32_t *)dest)[i] ^= ((uint32_t *)dref)[i-1];
  116|   222M|        }
  117|     74|        break;
  118|    157|      case 8:
  ------------------
  |  Branch (118:7): [True: 157, False: 444]
  ------------------
  119|  94.7M|        for (i = 1; i < nbytes / 8; i++) {
  ------------------
  |  Branch (119:21): [True: 94.7M, False: 157]
  ------------------
  120|  94.7M|          ((uint64_t *)dest)[i] ^= ((uint64_t *)dref)[i-1];
  121|  94.7M|        }
  122|    157|        break;
  123|    161|      default:
  ------------------
  |  Branch (123:7): [True: 161, False: 440]
  ------------------
  124|    161|        if ((typesize % 8) == 0) {
  ------------------
  |  Branch (124:13): [True: 69, False: 92]
  ------------------
  125|     69|          delta_decoder(dref, offset, nbytes, 8, dest);
  126|     92|        } else {
  127|     92|          delta_decoder(dref, offset, nbytes, 1, dest);
  128|     92|        }
  129|    601|    }
  130|    601|  } else {
  131|       |    /* Decode delta for the non-reference blocks */
  132|    459|    switch (typesize) {
  133|    106|      case 1:
  ------------------
  |  Branch (133:7): [True: 106, False: 353]
  ------------------
  134|  83.5M|        for (i = 0; i < nbytes; i++) {
  ------------------
  |  Branch (134:21): [True: 83.5M, False: 106]
  ------------------
  135|  83.5M|          dest[i] ^= dref[i];
  136|  83.5M|        }
  137|    106|        break;
  138|     48|      case 2:
  ------------------
  |  Branch (138:7): [True: 48, False: 411]
  ------------------
  139|  2.13M|        for (i = 0; i < nbytes / 2; i++) {
  ------------------
  |  Branch (139:21): [True: 2.13M, False: 48]
  ------------------
  140|  2.13M|          ((uint16_t *)dest)[i] ^= ((uint16_t *)dref)[i];
  141|  2.13M|        }
  142|     48|        break;
  143|     73|      case 4:
  ------------------
  |  Branch (143:7): [True: 73, False: 386]
  ------------------
  144|  32.0M|        for (i = 0; i < nbytes / 4; i++) {
  ------------------
  |  Branch (144:21): [True: 32.0M, False: 73]
  ------------------
  145|  32.0M|          ((uint32_t *)dest)[i] ^= ((uint32_t *)dref)[i];
  146|  32.0M|        }
  147|     73|        break;
  148|    102|      case 8:
  ------------------
  |  Branch (148:7): [True: 102, False: 357]
  ------------------
  149|  67.3M|        for (i = 0; i < nbytes / 8; i++) {
  ------------------
  |  Branch (149:21): [True: 67.3M, False: 102]
  ------------------
  150|  67.3M|          ((uint64_t *)dest)[i] ^= ((uint64_t *)dref)[i];
  151|  67.3M|        }
  152|    102|        break;
  153|    130|      default:
  ------------------
  |  Branch (153:7): [True: 130, False: 329]
  ------------------
  154|    130|        if ((typesize % 8) == 0) {
  ------------------
  |  Branch (154:13): [True: 54, False: 76]
  ------------------
  155|     54|          delta_decoder(dref, offset, nbytes, 8, dest);
  156|     76|        } else {
  157|     76|          delta_decoder(dref, offset, nbytes, 1, dest);
  158|     76|        }
  159|    459|    }
  160|    459|  }
  161|  1.06k|}

fastcopy:
  516|   188k|unsigned char *fastcopy(unsigned char *out, const unsigned char *from, unsigned len) {
  517|   188k|  switch (len) {
  518|      0|    case 32:
  ------------------
  |  Branch (518:5): [True: 0, False: 188k]
  ------------------
  519|      0|      return copy_32_bytes(out, from);
  520|      0|    case 16:
  ------------------
  |  Branch (520:5): [True: 0, False: 188k]
  ------------------
  521|      0|      return copy_16_bytes(out, from);
  522|  19.4k|    case 8:
  ------------------
  |  Branch (522:5): [True: 19.4k, False: 169k]
  ------------------
  523|  19.4k|      return copy_8_bytes(out, from);
  524|   169k|    default: {
  ------------------
  |  Branch (524:5): [True: 169k, False: 19.4k]
  ------------------
  525|   169k|    }
  526|   188k|  }
  527|   169k|  if (len < 8) {
  ------------------
  |  Branch (527:7): [True: 88.3k, False: 80.7k]
  ------------------
  528|  88.3k|    return copy_bytes(out, from, len);
  529|  88.3k|  }
  530|  80.7k|#if defined(__SSE2__)
  531|  80.7k|  if (len < 16) {
  ------------------
  |  Branch (531:7): [True: 80.7k, False: 0]
  ------------------
  532|  80.7k|    return chunk_memcpy(out, from, len);
  533|  80.7k|  }
  534|      0|#if !defined(__AVX2__)
  535|      0|  return chunk_memcpy_unaligned(out, from, len);
  536|       |#else
  537|       |  if (len < 32) {
  538|       |    return chunk_memcpy_16(out, from, len);
  539|       |  }
  540|       |  return chunk_memcpy_unaligned(out, from, len);
  541|       |#endif  // !__AVX2__
  542|       |#else
  543|       |  return chunk_memcpy(out, from, len);
  544|       |#endif  // __SSE2__
  545|  80.7k|}
copy_match:
  549|  4.35M|unsigned char* copy_match(unsigned char *out, const unsigned char *from, unsigned len) {
  550|       |#if defined(__AVX2__)
  551|       |  unsigned sz = sizeof(__m256i);
  552|       |#elif defined(__SSE2__)
  553|       |  unsigned sz = sizeof(__m128i);
  554|       |#else
  555|       |  unsigned sz = sizeof(uint64_t);
  556|       |#endif
  557|       |
  558|       |#if ((defined(__GNUC__) && BLOSC_GCC_VERSION < 800) && !defined(__clang__) && !defined(__ICC) && !defined(__ICL))
  559|       |  // GCC < 8 in fully optimization mode seems to have problems with the code further below so stop here
  560|       |  for (; len > 0; len--) {
  561|       |    *out++ = *from++;
  562|       |  }
  563|       |  return out;
  564|       |#endif
  565|       |
  566|       |  // If out and from are away more than the size of the copy, then a fastcopy is safe
  567|  4.35M|  unsigned overlap_dist = (unsigned) (out - from);
  568|  4.35M|  if (overlap_dist > sz) {
  ------------------
  |  Branch (568:7): [True: 188k, False: 4.16M]
  ------------------
  569|   188k|    return fastcopy(out, from, len);
  570|   188k|  }
  571|       |
  572|       |  // Otherwise we need to be more careful so as not to overwrite destination
  573|  4.16M|  switch (overlap_dist) {
  574|      0|    case 32:
  ------------------
  |  Branch (574:5): [True: 0, False: 4.16M]
  ------------------
  575|      0|      for (; len >= 32; len -= 32) {
  ------------------
  |  Branch (575:14): [True: 0, False: 0]
  ------------------
  576|      0|        out = copy_32_bytes(out, from);
  577|      0|      }
  578|      0|      break;
  579|      0|    case 30:
  ------------------
  |  Branch (579:5): [True: 0, False: 4.16M]
  ------------------
  580|      0|      for (; len >= 30; len -= 30) {
  ------------------
  |  Branch (580:14): [True: 0, False: 0]
  ------------------
  581|      0|        out = copy_16_bytes(out, from);
  582|      0|        out = copy_8_bytes(out, from + 16);
  583|      0|        out = copy_4_bytes(out, from + 24);
  584|      0|        out = copy_2_bytes(out, from + 28);
  585|      0|      }
  586|      0|      break;
  587|      0|    case 28:
  ------------------
  |  Branch (587:5): [True: 0, False: 4.16M]
  ------------------
  588|      0|      for (; len >= 28; len -= 28) {
  ------------------
  |  Branch (588:14): [True: 0, False: 0]
  ------------------
  589|      0|        out = copy_16_bytes(out, from);
  590|      0|        out = copy_8_bytes(out, from + 16);
  591|      0|        out = copy_4_bytes(out, from + 24);
  592|      0|      }
  593|      0|      break;
  594|      0|    case 26:
  ------------------
  |  Branch (594:5): [True: 0, False: 4.16M]
  ------------------
  595|      0|      for (; len >= 26; len -= 26) {
  ------------------
  |  Branch (595:14): [True: 0, False: 0]
  ------------------
  596|      0|        out = copy_16_bytes(out, from);
  597|      0|        out = copy_8_bytes(out, from + 16);
  598|      0|        out = copy_2_bytes(out, from + 24);
  599|      0|      }
  600|      0|      break;
  601|      0|    case 24:
  ------------------
  |  Branch (601:5): [True: 0, False: 4.16M]
  ------------------
  602|      0|      for (; len >= 24; len -= 24) {
  ------------------
  |  Branch (602:14): [True: 0, False: 0]
  ------------------
  603|      0|        out = copy_16_bytes(out, from);
  604|      0|        out = copy_8_bytes(out, from + 16);
  605|      0|      }
  606|      0|      break;
  607|      0|    case 22:
  ------------------
  |  Branch (607:5): [True: 0, False: 4.16M]
  ------------------
  608|      0|      for (; len >= 22; len -= 22) {
  ------------------
  |  Branch (608:14): [True: 0, False: 0]
  ------------------
  609|      0|        out = copy_16_bytes(out, from);
  610|      0|        out = copy_4_bytes(out, from + 16);
  611|      0|        out = copy_2_bytes(out, from + 20);
  612|      0|      }
  613|      0|      break;
  614|      0|    case 20:
  ------------------
  |  Branch (614:5): [True: 0, False: 4.16M]
  ------------------
  615|      0|      for (; len >= 20; len -= 20) {
  ------------------
  |  Branch (615:14): [True: 0, False: 0]
  ------------------
  616|      0|        out = copy_16_bytes(out, from);
  617|      0|        out = copy_4_bytes(out, from + 16);
  618|      0|      }
  619|      0|      break;
  620|      0|    case 18:
  ------------------
  |  Branch (620:5): [True: 0, False: 4.16M]
  ------------------
  621|      0|      for (; len >= 18; len -= 18) {
  ------------------
  |  Branch (621:14): [True: 0, False: 0]
  ------------------
  622|      0|        out = copy_16_bytes(out, from);
  623|      0|        out = copy_2_bytes(out, from + 16);
  624|      0|      }
  625|      0|      break;
  626|  2.20k|    case 16:
  ------------------
  |  Branch (626:5): [True: 2.20k, False: 4.16M]
  ------------------
  627|  2.20k|      for (; len >= 16; len -= 16) {
  ------------------
  |  Branch (627:14): [True: 0, False: 2.20k]
  ------------------
  628|      0|        out = copy_16_bytes(out, from);
  629|      0|      }
  630|  2.20k|      break;
  631|  6.24k|    case 8:
  ------------------
  |  Branch (631:5): [True: 6.24k, False: 4.15M]
  ------------------
  632|  12.3k|      for (; len >= 8; len -= 8) {
  ------------------
  |  Branch (632:14): [True: 6.12k, False: 6.24k]
  ------------------
  633|  6.12k|        out = copy_8_bytes(out, from);
  634|  6.12k|      }
  635|  6.24k|      break;
  636|  1.19k|    case 4:
  ------------------
  |  Branch (636:5): [True: 1.19k, False: 4.16M]
  ------------------
  637|  3.38k|      for (; len >= 4; len -= 4) {
  ------------------
  |  Branch (637:14): [True: 2.18k, False: 1.19k]
  ------------------
  638|  2.18k|        out = copy_4_bytes(out, from);
  639|  2.18k|      }
  640|  1.19k|      break;
  641|    577|    case 2:
  ------------------
  |  Branch (641:5): [True: 577, False: 4.16M]
  ------------------
  642|  2.46k|      for (; len >= 2; len -= 2) {
  ------------------
  |  Branch (642:14): [True: 1.89k, False: 577]
  ------------------
  643|  1.89k|        out = copy_2_bytes(out, from);
  644|  1.89k|      }
  645|    577|      break;
  646|  4.15M|    default:
  ------------------
  |  Branch (646:5): [True: 4.15M, False: 10.2k]
  ------------------
  647|  8.37G|      for (; len > 0; len--) {
  ------------------
  |  Branch (647:14): [True: 8.37G, False: 4.15M]
  ------------------
  648|  8.37G|        *out++ = *from++;
  649|  8.37G|      }
  650|  4.16M|  }
  651|       |
  652|       |  // Copy the leftovers
  653|  4.20M|  for (; len > 0; len--) {
  ------------------
  |  Branch (653:10): [True: 42.1k, False: 4.16M]
  ------------------
  654|  42.1k|    *out++ = *from++;
  655|  42.1k|  }
  656|       |
  657|  4.16M|  return out;
  658|  4.16M|}
fastcopy.c:copy_8_bytes:
   89|   187k|static inline unsigned char *copy_8_bytes(unsigned char *out, const unsigned char *from) {
   90|       |#if defined(BLOSC_STRICT_ALIGN)
   91|       |  uint64_t chunk;
   92|       |  memcpy(&chunk, from, 8);
   93|       |  memcpy(out, &chunk, 8);
   94|       |#else
   95|   187k|  *(uint64_t *) out = *(uint64_t *) from;
   96|   187k|#endif
   97|   187k|  return out + 8;
   98|   187k|}
fastcopy.c:copy_bytes:
  173|  88.3k|static inline unsigned char *copy_bytes(unsigned char *out, const unsigned char *from, unsigned len) {
  174|  88.3k|  assert(len < 8);
  175|       |
  176|       |#ifdef BLOSC_STRICT_ALIGN
  177|       |  while (len--) {
  178|       |    *out++ = *from++;
  179|       |  }
  180|       |#else
  181|  88.3k|  switch (len) {
  182|  32.7k|    case 7:
  ------------------
  |  Branch (182:5): [True: 32.7k, False: 55.6k]
  ------------------
  183|  32.7k|      return copy_7_bytes(out, from);
  184|  55.6k|    case 6:
  ------------------
  |  Branch (184:5): [True: 55.6k, False: 32.7k]
  ------------------
  185|  55.6k|      return copy_6_bytes(out, from);
  186|      0|    case 5:
  ------------------
  |  Branch (186:5): [True: 0, False: 88.3k]
  ------------------
  187|      0|      return copy_5_bytes(out, from);
  188|      0|    case 4:
  ------------------
  |  Branch (188:5): [True: 0, False: 88.3k]
  ------------------
  189|      0|      return copy_4_bytes(out, from);
  190|      1|    case 3:
  ------------------
  |  Branch (190:5): [True: 1, False: 88.3k]
  ------------------
  191|      1|      return copy_3_bytes(out, from);
  192|      0|    case 2:
  ------------------
  |  Branch (192:5): [True: 0, False: 88.3k]
  ------------------
  193|      0|      return copy_2_bytes(out, from);
  194|      0|    case 1:
  ------------------
  |  Branch (194:5): [True: 0, False: 88.3k]
  ------------------
  195|      0|      return copy_1_bytes(out, from);
  196|      0|    case 0:
  ------------------
  |  Branch (196:5): [True: 0, False: 88.3k]
  ------------------
  197|      0|      return out;
  198|      0|    default:
  ------------------
  |  Branch (198:5): [True: 0, False: 88.3k]
  ------------------
  199|      0|      assert(0);
  200|  88.3k|  }
  201|      0|#endif /* BLOSC_STRICT_ALIGN */
  202|      0|  return out;
  203|  88.3k|}
fastcopy.c:copy_7_bytes:
   83|  32.7k|static inline unsigned char *copy_7_bytes(unsigned char *out, const unsigned char *from) {
   84|  32.7k|  out = copy_3_bytes(out, from);
   85|  32.7k|  return copy_4_bytes(out, from + 3);
   86|  32.7k|}
fastcopy.c:copy_6_bytes:
   78|  55.6k|static inline unsigned char *copy_6_bytes(unsigned char *out, const unsigned char *from) {
   79|  55.6k|  out = copy_2_bytes(out, from);
   80|  55.6k|  return copy_4_bytes(out, from + 2);
   81|  55.6k|}
fastcopy.c:copy_3_bytes:
   68|  32.7k|static inline unsigned char *copy_3_bytes(unsigned char *out, const unsigned char *from) {
   69|  32.7k|  out = copy_1_bytes(out, from);
   70|  32.7k|  return copy_2_bytes(out, from + 1);
   71|  32.7k|}
fastcopy.c:copy_1_bytes:
   63|  32.7k|static inline unsigned char *copy_1_bytes(unsigned char *out, const unsigned char *from) {
   64|  32.7k|  *out++ = *from;
   65|  32.7k|  return out;
   66|  32.7k|}
fastcopy.c:chunk_memcpy:
  212|  80.7k|static inline unsigned char *chunk_memcpy(unsigned char *out, const unsigned char *from, unsigned len) {
  213|  80.7k|  unsigned sz = sizeof(uint64_t);
  214|  80.7k|  unsigned rem = len % sz;
  215|  80.7k|  unsigned by8;
  216|       |
  217|  80.7k|  assert(len >= sz);
  218|       |
  219|       |  /* Copy a few bytes to make sure the loop below has a multiple of SZ bytes to be copied. */
  220|  80.7k|  copy_8_bytes(out, from);
  221|       |
  222|  80.7k|  len /= sz;
  223|  80.7k|  out += rem;
  224|  80.7k|  from += rem;
  225|       |
  226|  80.7k|  by8 = len % 8;
  227|  80.7k|  len -= by8;
  228|  80.7k|  switch (by8) {
  229|      0|    case 7:
  ------------------
  |  Branch (229:5): [True: 0, False: 80.7k]
  ------------------
  230|      0|      out = copy_8_bytes(out, from);
  231|      0|      from += sz;
  232|       |      #ifdef AVOID_FALLTHROUGH_WARNING
  233|       |      __attribute__ ((fallthrough));  // Shut-up -Wimplicit-fallthrough warning in GCC
  234|       |      #endif
  235|      0|    case 6:
  ------------------
  |  Branch (235:5): [True: 0, False: 80.7k]
  ------------------
  236|      0|      out = copy_8_bytes(out, from);
  237|      0|      from += sz;
  238|       |      #ifdef AVOID_FALLTHROUGH_WARNING
  239|       |      __attribute__ ((fallthrough));
  240|       |      #endif
  241|      0|    case 5:
  ------------------
  |  Branch (241:5): [True: 0, False: 80.7k]
  ------------------
  242|      0|      out = copy_8_bytes(out, from);
  243|      0|      from += sz;
  244|       |      #ifdef AVOID_FALLTHROUGH_WARNING
  245|       |      __attribute__ ((fallthrough));
  246|       |      #endif
  247|      0|    case 4:
  ------------------
  |  Branch (247:5): [True: 0, False: 80.7k]
  ------------------
  248|      0|      out = copy_8_bytes(out, from);
  249|      0|      from += sz;
  250|       |      #ifdef AVOID_FALLTHROUGH_WARNING
  251|       |      __attribute__ ((fallthrough));
  252|       |      #endif
  253|      0|    case 3:
  ------------------
  |  Branch (253:5): [True: 0, False: 80.7k]
  ------------------
  254|      0|      out = copy_8_bytes(out, from);
  255|      0|      from += sz;
  256|       |      #ifdef AVOID_FALLTHROUGH_WARNING
  257|       |      __attribute__ ((fallthrough));
  258|       |      #endif
  259|      0|    case 2:
  ------------------
  |  Branch (259:5): [True: 0, False: 80.7k]
  ------------------
  260|      0|      out = copy_8_bytes(out, from);
  261|      0|      from += sz;
  262|       |      #ifdef AVOID_FALLTHROUGH_WARNING
  263|       |      __attribute__ ((fallthrough));
  264|       |      #endif
  265|  80.7k|    case 1:
  ------------------
  |  Branch (265:5): [True: 80.7k, False: 0]
  ------------------
  266|  80.7k|      out = copy_8_bytes(out, from);
  267|  80.7k|      from += sz;
  268|       |      #ifdef AVOID_FALLTHROUGH_WARNING
  269|       |      __attribute__ ((fallthrough));
  270|       |      #endif
  271|  80.7k|    default:
  ------------------
  |  Branch (271:5): [True: 0, False: 80.7k]
  ------------------
  272|  80.7k|      break;
  273|  80.7k|  }
  274|       |
  275|  80.7k|  while (len) {
  ------------------
  |  Branch (275:10): [True: 0, False: 80.7k]
  ------------------
  276|      0|    out = copy_8_bytes(out, from);
  277|      0|    from += sz;
  278|      0|    out = copy_8_bytes(out, from);
  279|      0|    from += sz;
  280|      0|    out = copy_8_bytes(out, from);
  281|      0|    from += sz;
  282|      0|    out = copy_8_bytes(out, from);
  283|      0|    from += sz;
  284|      0|    out = copy_8_bytes(out, from);
  285|      0|    from += sz;
  286|      0|    out = copy_8_bytes(out, from);
  287|      0|    from += sz;
  288|      0|    out = copy_8_bytes(out, from);
  289|      0|    from += sz;
  290|      0|    out = copy_8_bytes(out, from);
  291|      0|    from += sz;
  292|       |
  293|      0|    len -= 8;
  294|      0|  }
  295|       |
  296|  80.7k|  return out;
  297|  80.7k|}
fastcopy.c:copy_4_bytes:
   51|  90.5k|static inline unsigned char *copy_4_bytes(unsigned char *out, const unsigned char *from) {
   52|       |#if defined(BLOSC_STRICT_ALIGN)
   53|       |  uint32_t chunk;
   54|       |  memcpy(&chunk, from, 4);
   55|       |  memcpy(out, &chunk, 4);
   56|       |#else
   57|  90.5k|  *(uint32_t *) out = *(uint32_t *) from;
   58|  90.5k|#endif
   59|  90.5k|  return out + 4;
   60|  90.5k|}
fastcopy.c:copy_2_bytes:
   40|  90.2k|static inline unsigned char *copy_2_bytes(unsigned char *out, const unsigned char *from) {
   41|       |#if defined(BLOSC_STRICT_ALIGN)
   42|       |  uint16_t chunk;
   43|       |  memcpy(&chunk, from, 2);
   44|       |  memcpy(out, &chunk, 2);
   45|       |#else
   46|  90.2k|  *(uint16_t *) out = *(uint16_t *) from;
   47|  90.2k|#endif
   48|  90.2k|  return out + 2;
   49|  90.2k|}

frame_reader_invalidate:
  495|  6.31k|int frame_reader_invalidate(blosc2_frame_s* frame) {
  496|  6.31k|  blosc2_pthread_mutex_lock(&frame->read_fp_mutex);
  ------------------
  |  |   92|  6.31k|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
  497|  6.31k|  int w_rc = frame_writer_close_locked(frame);
  498|  6.31k|  int r_rc = frame_reader_close_locked(frame, true);
  499|  6.31k|  blosc2_pthread_mutex_unlock(&frame->read_fp_mutex);
  ------------------
  |  |   93|  6.31k|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
  500|  6.31k|  if (w_rc < 0) {
  ------------------
  |  Branch (500:7): [True: 0, False: 6.31k]
  ------------------
  501|      0|    return w_rc;
  502|      0|  }
  503|  6.31k|  return r_rc < 0 ? r_rc : BLOSC2_ERROR_SUCCESS;
  ------------------
  |  Branch (503:10): [True: 0, False: 6.31k]
  ------------------
  504|  6.31k|}
frame_new:
  782|  2.94k|blosc2_frame_s* frame_new(const char* urlpath) {
  783|  2.94k|  blosc2_frame_s* new_frame = frame_alloc();
  784|  2.94k|  if (new_frame == NULL) {
  ------------------
  |  Branch (784:7): [True: 0, False: 2.94k]
  ------------------
  785|      0|    return NULL;
  786|      0|  }
  787|  2.94k|  if (urlpath != NULL) {
  ------------------
  |  Branch (787:7): [True: 0, False: 2.94k]
  ------------------
  788|      0|    char* new_urlpath = malloc(strlen(urlpath) + 1);  // + 1 for the trailing NULL
  789|      0|    if (new_urlpath == NULL) {
  ------------------
  |  Branch (789:9): [True: 0, False: 0]
  ------------------
  790|      0|      blosc2_pthread_mutex_destroy(&new_frame->read_fp_mutex);
  ------------------
  |  |   91|      0|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
  791|      0|      free(new_frame);
  792|      0|      return NULL;
  793|      0|    }
  794|      0|    new_frame->urlpath = strcpy(new_urlpath, urlpath);
  795|      0|    new_frame->file_offset = 0;
  796|      0|  }
  797|  2.94k|  return new_frame;
  798|  2.94k|}
frame_set_locking:
  819|  2.94k|void frame_set_locking(blosc2_frame_s* frame, const blosc2_io* io) {
  820|  2.94k|  if (frame->urlpath == NULL) {
  ------------------
  |  Branch (820:7): [True: 2.94k, False: 0]
  ------------------
  821|  2.94k|    return;
  822|  2.94k|  }
  823|      0|  if (frame_locking_requested(io)) {
  ------------------
  |  Branch (823:7): [True: 0, False: 0]
  ------------------
  824|       |    frame->locking = true;
  825|      0|    frame->lock_fd = -1;
  826|      0|  }
  827|      0|}
frame_lock:
  938|  3.35M|int frame_lock(blosc2_frame_s* frame, bool exclusive) {
  939|  3.35M|  if (frame == NULL || !frame->locking) {
  ------------------
  |  Branch (939:7): [True: 1.55M, False: 1.80M]
  |  Branch (939:24): [True: 1.80M, False: 0]
  ------------------
  940|  3.35M|    return BLOSC2_ERROR_SUCCESS;
  941|  3.35M|  }
  942|      0|  if (frame->lock_depth > 0) {
  ------------------
  |  Branch (942:7): [True: 0, False: 0]
  ------------------
  943|       |    // Already held by this handle (a nested call); the outer lock covers us
  944|      0|    frame->lock_depth++;
  945|      0|    return BLOSC2_ERROR_SUCCESS;
  946|      0|  }
  947|      0|  if (frame->lock_fd == -1) {
  ------------------
  |  Branch (947:7): [True: 0, False: 0]
  ------------------
  948|       |    // Lazily open the sidecar, kept for the frame's lifetime
  949|      0|    char* path = frame_lock_path(frame);
  950|      0|    if (path == NULL) {
  ------------------
  |  Branch (950:9): [True: 0, False: 0]
  ------------------
  951|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
  952|      0|    }
  953|       |#if defined(_WIN32)
  954|       |    HANDLE h = CreateFileA(path, GENERIC_READ | GENERIC_WRITE,
  955|       |                           FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
  956|       |                           NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  957|       |    if (h == INVALID_HANDLE_VALUE) {
  958|       |      BLOSC_TRACE_ERROR("Cannot open the lock file in: %s", path);
  959|       |      free(path);
  960|       |      return BLOSC2_ERROR_LOCK;
  961|       |    }
  962|       |    frame->lock_fd = (intptr_t)h;
  963|       |#else
  964|      0|    int fd = open(path, O_CREAT | O_RDWR | O_CLOEXEC, 0666);
  965|      0|    if (fd < 0) {
  ------------------
  |  Branch (965:9): [True: 0, False: 0]
  ------------------
  966|      0|      BLOSC_TRACE_ERROR("Cannot open the lock file in: %s", path);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  967|      0|      free(path);
  968|      0|      return BLOSC2_ERROR_LOCK;
  969|      0|    }
  970|      0|    frame->lock_fd = fd;
  971|      0|#endif
  972|      0|    free(path);
  973|      0|  }
  974|      0|  if (frame_os_lock(frame, exclusive) < 0) {
  ------------------
  |  Branch (974:7): [True: 0, False: 0]
  ------------------
  975|      0|    BLOSC_TRACE_ERROR("Cannot lock the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  976|      0|    return BLOSC2_ERROR_LOCK;
  977|      0|  }
  978|       |  // Generation counter: writers bump it, everyone compares it with the last
  979|       |  // value it saw.  This detects mutations by other handles exactly, even when
  980|       |  // the frame length on disk ends up unchanged (which the length-based
  981|       |  // staleness check in frame_refresh_if_stale() cannot see).
  982|      0|  uint64_t seq;
  983|      0|  if (frame_lock_read_seq(frame, &seq) < 0 ||
  ------------------
  |  Branch (983:7): [True: 0, False: 0]
  ------------------
  984|      0|      (exclusive && frame_lock_write_seq(frame, seq + 1) < 0)) {
  ------------------
  |  Branch (984:8): [True: 0, False: 0]
  |  Branch (984:21): [True: 0, False: 0]
  ------------------
  985|      0|    BLOSC_TRACE_ERROR("Cannot access the frame lock generation counter.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  986|      0|    frame_os_unlock(frame);
  987|      0|    return BLOSC2_ERROR_LOCK;
  988|      0|  }
  989|      0|  if (seq != frame->lock_seq) {
  ------------------
  |  Branch (989:7): [True: 0, False: 0]
  ------------------
  990|      0|    frame->force_refresh = true;
  991|      0|  }
  992|      0|  if (exclusive) {
  ------------------
  |  Branch (992:7): [True: 0, False: 0]
  ------------------
  993|      0|    seq++;
  994|      0|  }
  995|      0|  frame->lock_seq = seq;
  996|      0|  frame->lock_depth = 1;
  997|      0|  return BLOSC2_ERROR_SUCCESS;
  998|      0|}
frame_unlock:
 1001|  3.35M|int frame_unlock(blosc2_frame_s* frame) {
 1002|  3.35M|  if (frame == NULL || !frame->locking || frame->lock_depth == 0) {
  ------------------
  |  Branch (1002:7): [True: 1.55M, False: 1.80M]
  |  Branch (1002:24): [True: 1.80M, False: 0]
  |  Branch (1002:43): [True: 0, False: 0]
  ------------------
 1003|  3.35M|    return BLOSC2_ERROR_SUCCESS;
 1004|  3.35M|  }
 1005|      0|  if (--frame->lock_depth > 0) {
  ------------------
  |  Branch (1005:7): [True: 0, False: 0]
  ------------------
 1006|      0|    return BLOSC2_ERROR_SUCCESS;
 1007|      0|  }
 1008|       |  // Hand our writes over before the next lock holder looks: closing the cached
 1009|       |  // writer is what pushes them to the server on NFS (close-to-open consistency).
 1010|       |  // A no-op unless this handle wrote since it last let go of the lock.
 1011|      0|  int close_rc = frame_writer_close(frame);
 1012|      0|  if (frame_os_unlock(frame) < 0) {
  ------------------
  |  Branch (1012:7): [True: 0, False: 0]
  ------------------
 1013|      0|    BLOSC_TRACE_ERROR("Cannot unlock the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1014|      0|    return BLOSC2_ERROR_LOCK;
 1015|      0|  }
 1016|      0|  return close_rc;
 1017|      0|}
frame_free:
 1021|  6.31k|int frame_free(blosc2_frame_s* frame) {
 1022|       |
 1023|  6.31k|  int rc = frame_reader_invalidate(frame);
 1024|  6.31k|  blosc2_pthread_mutex_destroy(&frame->read_fp_mutex);
  ------------------
  |  |   91|  6.31k|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 1025|       |
 1026|  6.31k|  if (frame->locking && frame->lock_fd != -1) {
  ------------------
  |  Branch (1026:7): [True: 0, False: 6.31k]
  |  Branch (1026:25): [True: 0, False: 0]
  ------------------
 1027|       |#if defined(_WIN32)
 1028|       |    CloseHandle((HANDLE)frame->lock_fd);
 1029|       |#else
 1030|      0|    close((int)frame->lock_fd);
 1031|      0|#endif
 1032|      0|  }
 1033|       |
 1034|  6.31k|  if (frame->cframe != NULL && !frame->avoid_cframe_free) {
  ------------------
  |  Branch (1034:7): [True: 6.31k, False: 0]
  |  Branch (1034:32): [True: 2.94k, False: 3.37k]
  ------------------
 1035|  2.94k|    free(frame->cframe);
 1036|  2.94k|  }
 1037|       |
 1038|  6.31k|  if (frame->coffsets != NULL && frame->coffsets_needs_free) {
  ------------------
  |  Branch (1038:7): [True: 0, False: 6.31k]
  |  Branch (1038:34): [True: 0, False: 0]
  ------------------
 1039|      0|    free(frame->coffsets);
 1040|      0|  }
 1041|       |
 1042|  6.31k|  if (frame->urlpath != NULL) {
  ------------------
  |  Branch (1042:7): [True: 0, False: 6.31k]
  ------------------
 1043|      0|    free(frame->urlpath);
 1044|      0|  }
 1045|  6.31k|  free(frame->holes);
 1046|       |
 1047|  6.31k|  free(frame);
 1048|       |
 1049|  6.31k|  return rc;
 1050|  6.31k|}
new_header_frame:
 1053|  1.15M|void *new_header_frame(blosc2_schunk *schunk, blosc2_frame_s *frame) {
 1054|  1.15M|  if (frame == NULL) {
  ------------------
  |  Branch (1054:7): [True: 0, False: 1.15M]
  ------------------
 1055|      0|    return NULL;
 1056|      0|  }
 1057|  1.15M|  uint8_t* h2 = calloc(FRAME_HEADER_MINLEN, 1);
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1058|  1.15M|  uint8_t* h2p = h2;
 1059|       |
 1060|       |  // The msgpack header starts here
 1061|  1.15M|  *h2p = 0x90;  // fixarray...
 1062|  1.15M|  *h2p += 14;   // ...with 13 elements
 1063|  1.15M|  h2p += 1;
 1064|       |
 1065|       |  // Magic number
 1066|  1.15M|  *h2p = 0xa0 + 8;  // str with 8 elements
 1067|  1.15M|  h2p += 1;
 1068|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1068:7): [True: 0, False: 1.15M]
  ------------------
 1069|      0|    return NULL;
 1070|      0|  }
 1071|  1.15M|  strcpy((char*)h2p, "b2frame");
 1072|  1.15M|  h2p += 8;
 1073|       |
 1074|       |  // Header size
 1075|  1.15M|  *h2p = 0xd2;  // int32
 1076|  1.15M|  h2p += 1 + 4;
 1077|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1077:7): [True: 0, False: 1.15M]
  ------------------
 1078|      0|    return NULL;
 1079|      0|  }
 1080|       |
 1081|       |  // Total frame size
 1082|  1.15M|  *h2p = 0xcf;  // uint64
 1083|       |  // Fill it with frame->len which is known *after* the creation of the frame (e.g. when updating the header)
 1084|  1.15M|  int64_t flen = frame->len;
 1085|  1.15M|  to_big(h2 + FRAME_LEN, &flen, sizeof(flen));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1086|  1.15M|  h2p += 1 + 8;
 1087|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1087:7): [True: 0, False: 1.15M]
  ------------------
 1088|      0|    return NULL;
 1089|      0|  }
 1090|       |
 1091|       |  // Flags
 1092|  1.15M|  *h2p = 0xa0 + 4;  // str with 4 elements
 1093|  1.15M|  h2p += 1;
 1094|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1094:7): [True: 0, False: 1.15M]
  ------------------
 1095|      0|    return NULL;
 1096|      0|  }
 1097|       |  // General flags
 1098|  1.15M|  if (schunk->chunksize == 0 || (schunk->flags2 & BLOSC2_VL_BLOCKS)) {
  ------------------
  |  Branch (1098:7): [True: 0, False: 1.15M]
  |  Branch (1098:33): [True: 0, False: 1.15M]
  ------------------
 1099|      0|    *h2p = BLOSC2_VERSION_FRAME_FORMAT_VL_BLOCKS;  // version
 1100|      0|  }
 1101|  1.15M|  else {
 1102|  1.15M|    *h2p = BLOSC2_VERSION_FRAME_FORMAT_RC1;  // version
 1103|  1.15M|  }
 1104|  1.15M|  *h2p += 0x10;  // 64-bit offsets.  We only support this for now.
 1105|  1.15M|  if (schunk->chunksize == 0) {
  ------------------
  |  Branch (1105:7): [True: 0, False: 1.15M]
  ------------------
 1106|      0|    *h2p |= FRAME_VARIABLE_CHUNKS;
  ------------------
  |  |   26|      0|#define FRAME_VARIABLE_CHUNKS (1U << 6)
  ------------------
 1107|      0|  }
 1108|  1.15M|  if (schunk->flags2 & BLOSC2_VL_BLOCKS) {
  ------------------
  |  Branch (1108:7): [True: 0, False: 1.15M]
  ------------------
 1109|      0|    *h2p |= FRAME_VL_BLOCKS;
  ------------------
  |  |   27|      0|#define FRAME_VL_BLOCKS (1U << 7)
  ------------------
 1110|      0|  }
 1111|  1.15M|  h2p += 1;
 1112|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1112:7): [True: 0, False: 1.15M]
  ------------------
 1113|      0|    return NULL;
 1114|      0|  }
 1115|       |
 1116|       |  // Frame type
 1117|       |  // We only support contiguous and sparse directories frames currently
 1118|  1.15M|  *h2p = frame->sframe ? 1 : 0;
  ------------------
  |  Branch (1118:10): [True: 0, False: 1.15M]
  ------------------
 1119|  1.15M|  h2p += 1;
 1120|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1120:7): [True: 0, False: 1.15M]
  ------------------
 1121|      0|    return NULL;
 1122|      0|  }
 1123|       |
 1124|       |  // Codec flags
 1125|  1.15M|  *h2p = schunk->compcode;
 1126|  1.15M|  if (schunk->compcode >= BLOSC_LAST_CODEC) {
  ------------------
  |  Branch (1126:7): [True: 0, False: 1.15M]
  ------------------
 1127|      0|    *h2p = BLOSC_UDCODEC_FORMAT;
 1128|      0|  }
 1129|  1.15M|  *h2p += (schunk->clevel) << 4u;  // clevel
 1130|  1.15M|  h2p += 1;
 1131|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1131:7): [True: 0, False: 1.15M]
  ------------------
 1132|      0|    return NULL;
 1133|      0|  }
 1134|       |
 1135|       |  // Other flags
 1136|  1.15M|  *h2p = schunk->splitmode - 1;
 1137|  1.15M|  h2p += 1;
 1138|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1138:7): [True: 0, False: 1.15M]
  ------------------
 1139|      0|    return NULL;
 1140|      0|  }
 1141|       |
 1142|       |  // Uncompressed size
 1143|  1.15M|  *h2p = 0xd3;  // int64
 1144|  1.15M|  h2p += 1;
 1145|  1.15M|  int64_t nbytes = schunk->nbytes;
 1146|  1.15M|  to_big(h2p, &nbytes, sizeof(nbytes));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1147|  1.15M|  h2p += 8;
 1148|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1148:7): [True: 0, False: 1.15M]
  ------------------
 1149|      0|    return NULL;
 1150|      0|  }
 1151|       |
 1152|       |  // Compressed size
 1153|  1.15M|  *h2p = 0xd3;  // int64
 1154|  1.15M|  h2p += 1;
 1155|  1.15M|  int64_t cbytes = schunk->cbytes;
 1156|  1.15M|  to_big(h2p, &cbytes, sizeof(cbytes));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1157|  1.15M|  h2p += 8;
 1158|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1158:7): [True: 0, False: 1.15M]
  ------------------
 1159|      0|    return NULL;
 1160|      0|  }
 1161|       |
 1162|       |  // Type size
 1163|  1.15M|  *h2p = 0xd2;  // int32
 1164|  1.15M|  h2p += 1;
 1165|  1.15M|  int32_t typesize = schunk->typesize;
 1166|  1.15M|  to_big(h2p, &typesize, sizeof(typesize));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1167|  1.15M|  h2p += 4;
 1168|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1168:7): [True: 0, False: 1.15M]
  ------------------
 1169|      0|    return NULL;
 1170|      0|  }
 1171|       |
 1172|       |  // Block size
 1173|  1.15M|  *h2p = 0xd2;  // int32
 1174|  1.15M|  h2p += 1;
 1175|  1.15M|  int32_t blocksize = schunk->blocksize;
 1176|  1.15M|  to_big(h2p, &blocksize, sizeof(blocksize));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1177|  1.15M|  h2p += 4;
 1178|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1178:7): [True: 0, False: 1.15M]
  ------------------
 1179|      0|    return NULL;
 1180|      0|  }
 1181|       |
 1182|       |  // Chunk size
 1183|  1.15M|  *h2p = 0xd2;  // int32
 1184|  1.15M|  h2p += 1;
 1185|  1.15M|  int32_t chunksize = schunk->chunksize;
 1186|  1.15M|  to_big(h2p, &chunksize, sizeof(chunksize));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1187|  1.15M|  h2p += 4;
 1188|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1188:7): [True: 0, False: 1.15M]
  ------------------
 1189|      0|    return NULL;
 1190|      0|  }
 1191|       |
 1192|       |  // Number of threads for compression
 1193|  1.15M|  *h2p = 0xd1;  // int16
 1194|  1.15M|  h2p += 1;
 1195|  1.15M|  int16_t nthreads = (int16_t)schunk->cctx->nthreads;
 1196|  1.15M|  to_big(h2p, &nthreads, sizeof(nthreads));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1197|  1.15M|  h2p += 2;
 1198|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1198:7): [True: 0, False: 1.15M]
  ------------------
 1199|      0|    return NULL;
 1200|      0|  }
 1201|       |
 1202|       |  // Number of threads for decompression
 1203|  1.15M|  *h2p = 0xd1;  // int16
 1204|  1.15M|  h2p += 1;
 1205|  1.15M|  nthreads = (int16_t)schunk->dctx->nthreads;
 1206|  1.15M|  to_big(h2p, &nthreads, sizeof(nthreads));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1207|  1.15M|  h2p += 2;
 1208|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1208:7): [True: 0, False: 1.15M]
  ------------------
 1209|      0|    return NULL;
 1210|      0|  }
 1211|       |
 1212|       |  // The boolean for variable-length metalayers
 1213|  1.15M|  *h2p = (schunk->nvlmetalayers > 0) ? (uint8_t)0xc3 : (uint8_t)0xc2;
  ------------------
  |  Branch (1213:10): [True: 0, False: 1.15M]
  ------------------
 1214|  1.15M|  h2p += 1;
 1215|  1.15M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1215:7): [True: 0, False: 1.15M]
  ------------------
 1216|      0|    return NULL;
 1217|      0|  }
 1218|       |
 1219|       |  // The space for FRAME_FILTER_PIPELINE
 1220|  1.15M|  *h2p = 0xd8;  //  fixext 16
 1221|  1.15M|  h2p += 1;
 1222|  1.15M|  if (BLOSC2_MAX_FILTERS > FRAME_FILTER_PIPELINE_MAX) {
  ------------------
  |  |   53|  1.15M|#define FRAME_FILTER_PIPELINE_MAX (8)  // the maximum number of filters that can be stored in header
  ------------------
  |  Branch (1222:7): [Folded, False: 1.15M]
  ------------------
 1223|      0|    return NULL;
 1224|      0|  }
 1225|       |  // Store the filter pipeline in header
 1226|  1.15M|  uint8_t* mp_filters = h2 + FRAME_FILTER_PIPELINE + 1;
  ------------------
  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  ------------------
  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1227|  1.15M|  uint8_t* mp_meta = h2 + FRAME_FILTER_PIPELINE + 1 + FRAME_FILTER_PIPELINE_MAX;
  ------------------
  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  ------------------
  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                uint8_t* mp_meta = h2 + FRAME_FILTER_PIPELINE + 1 + FRAME_FILTER_PIPELINE_MAX;
  ------------------
  |  |   53|  1.15M|#define FRAME_FILTER_PIPELINE_MAX (8)  // the maximum number of filters that can be stored in header
  ------------------
 1228|  8.10M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (1228:19): [True: 6.94M, False: 1.15M]
  ------------------
 1229|  6.94M|      mp_filters[i] = schunk->filters[i];
 1230|  6.94M|      mp_meta[i] = schunk->filters_meta[i];
 1231|  6.94M|  }
 1232|  1.15M|  *h2p = (uint8_t) BLOSC2_MAX_FILTERS;
 1233|  1.15M|  h2p += 1;
 1234|  1.15M|  h2p += 16;
 1235|       |
 1236|       |  // User-defined codec and codec metadata
 1237|  1.15M|  uint8_t* udcodec = h2 + FRAME_UDCODEC;
  ------------------
  |  |   45|  1.15M|#define FRAME_UDCODEC (FRAME_FILTER_PIPELINE + 1 + 6) // 77
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1238|  1.15M|  *udcodec = schunk->compcode;
 1239|  1.15M|  uint8_t* codec_meta = h2 + FRAME_CODEC_META;
  ------------------
  |  |   46|  1.15M|#define FRAME_CODEC_META (FRAME_FILTER_PIPELINE + 1 + 7) // 78
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1240|  1.15M|  *codec_meta = schunk->compcode_meta;
 1241|       |
 1242|       |  // Other flags 2 (byte 0x55): bit 0 = use_dict
 1243|  1.15M|  h2[FRAME_OTHER_FLAGS2] = schunk->use_dict ? FRAME_USE_DICT : 0;
  ------------------
  |  |   47|  1.15M|#define FRAME_OTHER_FLAGS2 (FRAME_FILTER_PIPELINE + 1 + 14)  // 85
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                h2[FRAME_OTHER_FLAGS2] = schunk->use_dict ? FRAME_USE_DICT : 0;
  ------------------
  |  |   48|      0|#define FRAME_USE_DICT (1U << 0)   //!< bit 0 of other_flags2: use dictionary compression
  ------------------
  |  Branch (1243:28): [True: 0, False: 1.15M]
  ------------------
 1244|       |
 1245|  1.15M|  if (h2p - h2 != FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1245:7): [True: 0, False: 1.15M]
  ------------------
 1246|      0|    return NULL;
 1247|      0|  }
 1248|       |
 1249|  1.15M|  int32_t hsize = FRAME_HEADER_MINLEN;
  ------------------
  |  |   49|  1.15M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.15M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.15M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.15M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.15M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.15M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.15M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.15M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.15M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.15M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.15M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.15M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.15M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.15M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1250|       |
 1251|       |  // Now, deal with metalayers
 1252|  1.15M|  uint16_t nmetalayers = schunk->nmetalayers;
 1253|  1.15M|  if (nmetalayers > BLOSC2_MAX_METALAYERS) {
  ------------------
  |  | 1895|  1.15M|#define BLOSC2_MAX_METALAYERS 16
  ------------------
  |  Branch (1253:7): [True: 0, False: 1.15M]
  ------------------
 1254|      0|    return NULL;
 1255|      0|  }
 1256|       |
 1257|       |  // Make space for the header of metalayers (array marker, size, map of offsets)
 1258|  1.15M|  h2 = realloc(h2, (size_t)hsize + 1 + 1 + 2 + 1 + 2);
 1259|  1.15M|  h2p = h2 + hsize;
 1260|       |
 1261|       |  // The msgpack header for the metalayers (array_marker, size, map of offsets, list of metalayers)
 1262|  1.15M|  *h2p = 0x90 + 3;  // array with 3 elements
 1263|  1.15M|  h2p += 1;
 1264|       |
 1265|       |  // Size for the map (index) of offsets, including this uint16 size (to be filled out later on)
 1266|  1.15M|  *h2p = 0xcd;  // uint16
 1267|  1.15M|  h2p += 1 + 2;
 1268|       |
 1269|       |  // Map (index) of offsets for optional metalayers
 1270|  1.15M|  *h2p = 0xde;  // map 16 with N keys
 1271|  1.15M|  h2p += 1;
 1272|  1.15M|  to_big(h2p, &nmetalayers, sizeof(nmetalayers));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1273|  1.15M|  h2p += sizeof(nmetalayers);
 1274|  1.15M|  int32_t current_header_len = (int32_t)(h2p - h2);
 1275|  1.15M|  int32_t *offtooff = malloc(nmetalayers * sizeof(int32_t));
 1276|  1.15M|  if (offtooff == NULL) {
  ------------------
  |  Branch (1276:7): [True: 0, False: 1.15M]
  ------------------
 1277|      0|    free(h2);
 1278|      0|    return NULL;
 1279|      0|  }
 1280|  2.31M|  for (int nmetalayer = 0; nmetalayer < nmetalayers; nmetalayer++) {
  ------------------
  |  Branch (1280:28): [True: 1.15M, False: 1.15M]
  ------------------
 1281|  1.15M|    if (frame == NULL) {
  ------------------
  |  Branch (1281:9): [True: 0, False: 1.15M]
  ------------------
 1282|      0|      free(offtooff);
 1283|      0|      free(h2);
 1284|      0|      return NULL;
 1285|      0|    }
 1286|  1.15M|    blosc2_metalayer *metalayer = schunk->metalayers[nmetalayer];
 1287|  1.15M|    uint8_t namelen = (uint8_t) strlen(metalayer->name);
 1288|  1.15M|    h2 = realloc(h2, (size_t)current_header_len + 1 + namelen + 1 + 4);
 1289|  1.15M|    h2p = h2 + current_header_len;
 1290|       |    // Store the metalayer
 1291|  1.15M|    if (namelen >= (1U << 5U)) {  // metalayer strings cannot be longer than 32 bytes
  ------------------
  |  Branch (1291:9): [True: 0, False: 1.15M]
  ------------------
 1292|      0|      free(offtooff);
 1293|      0|      free(h2);
 1294|      0|      return NULL;
 1295|      0|    }
 1296|  1.15M|    *h2p = (uint8_t)0xa0 + namelen;  // str
 1297|  1.15M|    h2p += 1;
 1298|  1.15M|    memcpy(h2p, metalayer->name, namelen);
 1299|  1.15M|    h2p += namelen;
 1300|       |    // Space for storing the offset for the value of this metalayer
 1301|  1.15M|    *h2p = 0xd2;  // int32
 1302|  1.15M|    h2p += 1;
 1303|  1.15M|    offtooff[nmetalayer] = (int32_t)(h2p - h2);
 1304|  1.15M|    h2p += 4;
 1305|  1.15M|    current_header_len += 1 + namelen + 1 + 4;
 1306|  1.15M|  }
 1307|  1.15M|  int32_t hsize2 = (int32_t)(h2p - h2);
 1308|  1.15M|  if (hsize2 != current_header_len) {  // sanity check
  ------------------
  |  Branch (1308:7): [True: 0, False: 1.15M]
  ------------------
 1309|      0|    free(offtooff);
 1310|      0|    free(h2);
 1311|      0|    return NULL;
 1312|      0|  }
 1313|       |
 1314|       |  // Map size + int16 size
 1315|  1.15M|  if ((uint32_t) (hsize2 - hsize) >= (1U << 16U)) {
  ------------------
  |  Branch (1315:7): [True: 0, False: 1.15M]
  ------------------
 1316|      0|    free(offtooff);
 1317|      0|    free(h2);
 1318|      0|    return NULL;
 1319|      0|  }
 1320|  1.15M|  uint16_t map_size = (uint16_t) (hsize2 - hsize);
 1321|  1.15M|  to_big(h2 + FRAME_IDX_SIZE, &map_size, sizeof(map_size));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1322|       |
 1323|       |  // Make space for an (empty) array
 1324|  1.15M|  hsize = (int32_t)(h2p - h2);
 1325|  1.15M|  h2 = realloc(h2, (size_t)hsize + 2 + 1 + 2);
 1326|  1.15M|  h2p = h2 + hsize;
 1327|       |
 1328|       |  // Now, store the values in an array
 1329|  1.15M|  *h2p = 0xdc;  // array 16 with N elements
 1330|  1.15M|  h2p += 1;
 1331|  1.15M|  to_big(h2p, &nmetalayers, sizeof(nmetalayers));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1332|  1.15M|  h2p += sizeof(nmetalayers);
 1333|  1.15M|  current_header_len = (int32_t)(h2p - h2);
 1334|  2.31M|  for (int nmetalayer = 0; nmetalayer < nmetalayers; nmetalayer++) {
  ------------------
  |  Branch (1334:28): [True: 1.15M, False: 1.15M]
  ------------------
 1335|  1.15M|    if (frame == NULL) {
  ------------------
  |  Branch (1335:9): [True: 0, False: 1.15M]
  ------------------
 1336|      0|      free(offtooff);
 1337|      0|      free(h2);
 1338|      0|      return NULL;
 1339|      0|    }
 1340|  1.15M|    blosc2_metalayer *metalayer = schunk->metalayers[nmetalayer];
 1341|  1.15M|    h2 = realloc(h2, (size_t)current_header_len + 1 + 4 + metalayer->content_len);
 1342|  1.15M|    h2p = h2 + current_header_len;
 1343|       |    // Store the serialized contents for this metalayer
 1344|  1.15M|    *h2p = 0xc6;  // bin32
 1345|  1.15M|    h2p += 1;
 1346|  1.15M|    to_big(h2p, &(metalayer->content_len), sizeof(metalayer->content_len));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1347|  1.15M|    h2p += 4;
 1348|  1.15M|    memcpy(h2p, metalayer->content, metalayer->content_len);  // buffer, no need to swap
 1349|  1.15M|    h2p += metalayer->content_len;
 1350|       |    // Update the offset now that we know it
 1351|  1.15M|    to_big(h2 + offtooff[nmetalayer], &current_header_len, sizeof(current_header_len));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1352|  1.15M|    current_header_len += 1 + 4 + metalayer->content_len;
 1353|  1.15M|  }
 1354|  1.15M|  free(offtooff);
 1355|  1.15M|  hsize = (int32_t)(h2p - h2);
 1356|  1.15M|  if (hsize != current_header_len) {  // sanity check
  ------------------
  |  Branch (1356:7): [True: 0, False: 1.15M]
  ------------------
 1357|      0|    free(h2);
 1358|      0|    return NULL;
 1359|      0|  }
 1360|       |
 1361|       |  // Set the length of the whole header now that we know it
 1362|  1.15M|  to_big(h2 + FRAME_HEADER_LEN, &hsize, sizeof(hsize));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1363|       |
 1364|  1.15M|  return h2;
 1365|  1.15M|}
get_header_info:
 1374|  5.16M|                    uint8_t *splitmode, uint8_t *use_dict, const blosc2_io *io) {
 1375|  5.16M|  uint8_t* framep = frame->cframe;
 1376|  5.16M|  uint8_t* header_ptr;
 1377|  5.16M|  uint8_t header[FRAME_HEADER_MINLEN];
 1378|       |
 1379|  5.16M|  blosc2_io_cb *io_cb = blosc2_get_io_cb(io->id);
 1380|  5.16M|  if (io_cb == NULL) {
  ------------------
  |  Branch (1380:7): [True: 0, False: 5.16M]
  ------------------
 1381|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1382|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 1383|      0|  }
 1384|       |
 1385|  5.16M|  if (frame->len <= 0) {
  ------------------
  |  Branch (1385:7): [True: 0, False: 5.16M]
  ------------------
 1386|      0|    return BLOSC2_ERROR_READ_BUFFER;
 1387|      0|  }
 1388|       |
 1389|  5.16M|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (1389:7): [True: 0, False: 5.16M]
  ------------------
 1390|      0|    int64_t rbytes = 0;
 1391|      0|    void* fp = NULL;
 1392|      0|    int64_t io_pos = 0;
 1393|      0|    if (frame->sframe) {
  ------------------
  |  Branch (1393:9): [True: 0, False: 0]
  ------------------
 1394|      0|      fp = sframe_open_index(frame->urlpath, "rb", io);
 1395|      0|      if (fp == NULL) {
  ------------------
  |  Branch (1395:11): [True: 0, False: 0]
  ------------------
 1396|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1397|      0|        return BLOSC2_ERROR_FILE_OPEN;
 1398|      0|      }
 1399|      0|    }
 1400|      0|    else {
 1401|       |      /* Ahead of the header read, not after it: everything downstream (and
 1402|       |         frame_refresh_if_stale in particular) trusts the length this read
 1403|       |         returns, so a stale handle here would pair old metadata with the
 1404|       |         replacement's bytes. */
 1405|      0|      frame_reader_revalidate(frame);
 1406|      0|      fp = frame_reader_acquire(frame, io);
 1407|      0|      if (fp == NULL) {
  ------------------
  |  Branch (1407:11): [True: 0, False: 0]
  ------------------
 1408|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1409|      0|        return BLOSC2_ERROR_FILE_OPEN;
 1410|      0|      }
 1411|      0|      io_pos = frame->file_offset;
 1412|      0|    }
 1413|      0|    if (io_cb->is_allocation_necessary)
  ------------------
  |  Branch (1413:9): [True: 0, False: 0]
  ------------------
 1414|      0|      header_ptr = header;
 1415|      0|    rbytes = io_cb->read((void**)&header_ptr, 1, FRAME_HEADER_MINLEN, io_pos, fp);
  ------------------
  |  |   49|      0|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|      0|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|      0|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|      0|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|      0|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|      0|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|      0|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|      0|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|      0|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|      0|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1416|      0|    frame_reader_release(frame, io_cb, fp);
 1417|      0|    if (rbytes != FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|      0|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|      0|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|      0|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|      0|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|      0|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|      0|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|      0|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|      0|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|      0|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|      0|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1417:9): [True: 0, False: 0]
  ------------------
 1418|      0|      return BLOSC2_ERROR_FILE_READ;
 1419|      0|    }
 1420|      0|    framep = header_ptr;
 1421|      0|  }
 1422|       |
 1423|       |  // Consistency check for frame type
 1424|  5.16M|  uint8_t frame_type = framep[FRAME_TYPE];
  ------------------
  |  |   33|  5.16M|#define FRAME_TYPE (FRAME_FLAGS + 1)  // 26
  |  |  ------------------
  |  |  |  |   32|  5.16M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  ------------------
  |  |  |  |  |  |   31|  5.16M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   30|  5.16M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   29|  5.16M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1425|  5.16M|  uint8_t frame_version = framep[FRAME_FLAGS] & 0x0fu;
  ------------------
  |  |   32|  5.16M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|  5.16M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|  5.16M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|  5.16M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1426|  5.16M|  if (frame_version > BLOSC2_VERSION_FRAME_FORMAT) {
  ------------------
  |  Branch (1426:7): [True: 1, False: 5.16M]
  ------------------
 1427|      1|    BLOSC_TRACE_ERROR("Unsupported cframe version: %u", frame_version);
  ------------------
  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1428|      1|    return BLOSC2_ERROR_VERSION_SUPPORT;
 1429|      1|  }
 1430|  5.16M|  if (frame->sframe) {
  ------------------
  |  Branch (1430:7): [True: 0, False: 5.16M]
  ------------------
 1431|      0|    if (frame_type != FRAME_DIRECTORY_TYPE) {
  ------------------
  |  |   22|      0|#define FRAME_DIRECTORY_TYPE 1
  ------------------
  |  Branch (1431:9): [True: 0, False: 0]
  ------------------
 1432|      0|      return BLOSC2_ERROR_FRAME_TYPE;
 1433|      0|    }
 1434|  5.16M|  } else {
 1435|  5.16M|    if (frame_type != FRAME_CONTIGUOUS_TYPE) {
  ------------------
  |  |   21|  5.16M|#define FRAME_CONTIGUOUS_TYPE 0
  ------------------
  |  Branch (1435:9): [True: 0, False: 5.16M]
  ------------------
 1436|      0|      return BLOSC2_ERROR_FRAME_TYPE;
 1437|      0|    }
 1438|  5.16M|  }
 1439|       |
 1440|       |  // Fetch some internal lengths
 1441|  5.16M|  from_big(header_len, framep + FRAME_HEADER_LEN, sizeof(*header_len));
  ------------------
  |  |   38|  5.16M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1442|  5.16M|  if (*header_len < FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  5.16M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  5.16M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  5.16M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  5.16M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  5.16M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  5.16M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  5.16M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  5.16M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  5.16M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  5.16M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  5.16M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  5.16M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  5.16M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  5.16M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1442:7): [True: 21, False: 5.16M]
  ------------------
 1443|     21|    BLOSC_TRACE_ERROR("Header length is zero or smaller than min allowed.");
  ------------------
  |  |   93|     21|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     21|    do {                                            \
  |  |  |  |   98|     21|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     21|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     21|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1444|     21|    return BLOSC2_ERROR_INVALID_HEADER;
 1445|     21|  }
 1446|  5.16M|  from_big(frame_len, framep + FRAME_LEN, sizeof(*frame_len));
  ------------------
  |  |   38|  5.16M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1447|  5.16M|  if (*header_len > *frame_len) {
  ------------------
  |  Branch (1447:7): [True: 6, False: 5.16M]
  ------------------
 1448|      6|    BLOSC_TRACE_ERROR("Header length exceeds length of the frame.");
  ------------------
  |  |   93|      6|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      6|    do {                                            \
  |  |  |  |   98|      6|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      6|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      6|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1449|      6|    return BLOSC2_ERROR_INVALID_HEADER;
 1450|      6|  }
 1451|  5.16M|  from_big(nbytes, framep + FRAME_NBYTES, sizeof(*nbytes));
  ------------------
  |  |   38|  5.16M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1452|  5.16M|  from_big(cbytes, framep + FRAME_CBYTES, sizeof(*cbytes));
  ------------------
  |  |   38|  5.16M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1453|  5.16M|  from_big(blocksize, framep + FRAME_BLOCKSIZE, sizeof(*blocksize));
  ------------------
  |  |   38|  5.16M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1454|  5.16M|  if (chunksize != NULL) {
  ------------------
  |  Branch (1454:7): [True: 5.16M, False: 1.84k]
  ------------------
 1455|  5.16M|    from_big(chunksize, framep + FRAME_CHUNKSIZE, sizeof(*chunksize));
  ------------------
  |  |   38|  5.16M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1456|  5.16M|  }
 1457|  5.16M|  if (typesize != NULL) {
  ------------------
  |  Branch (1457:7): [True: 2.85M, False: 2.30M]
  ------------------
 1458|  2.85M|    from_big(typesize, framep + FRAME_TYPESIZE, sizeof(*typesize));
  ------------------
  |  |   38|  2.85M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1459|  2.85M|    if (*typesize <= 0) {
  ------------------
  |  Branch (1459:9): [True: 23, False: 2.85M]
  ------------------
 1460|     23|      BLOSC_TRACE_ERROR("`typesize` cannot be zero or negative.");
  ------------------
  |  |   93|     23|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     23|    do {                                            \
  |  |  |  |   98|     23|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     23|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     23|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1461|     23|      return BLOSC2_ERROR_INVALID_HEADER;
 1462|     23|    }
 1463|  2.85M|  }
 1464|       |
 1465|       |  // Codecs
 1466|  5.16M|  uint8_t frame_codecs = framep[FRAME_CODECS];
  ------------------
  |  |   34|  5.16M|#define FRAME_CODECS (FRAME_FLAGS + 2)  // 27
  |  |  ------------------
  |  |  |  |   32|  5.16M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  ------------------
  |  |  |  |  |  |   31|  5.16M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   30|  5.16M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   29|  5.16M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1467|  5.16M|  if (clevel != NULL) {
  ------------------
  |  Branch (1467:7): [True: 3.32k, False: 5.15M]
  ------------------
 1468|  3.32k|    *clevel = frame_codecs >> 4u;
 1469|  3.32k|  }
 1470|  5.16M|  if (compcode != NULL) {
  ------------------
  |  Branch (1470:7): [True: 3.32k, False: 5.15M]
  ------------------
 1471|  3.32k|    *compcode = frame_codecs & 0xFu;
 1472|  3.32k|    if (*compcode == BLOSC_UDCODEC_FORMAT) {
  ------------------
  |  Branch (1472:9): [True: 106, False: 3.21k]
  ------------------
 1473|    106|      from_big(compcode, framep + FRAME_UDCODEC, sizeof(*compcode));
  ------------------
  |  |   38|    106|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1474|    106|    }
 1475|  3.32k|  }
 1476|       |
 1477|       |  // Other flags
 1478|  5.16M|  uint8_t other_flags = framep[FRAME_OTHER_FLAGS];
  ------------------
  |  |   35|  5.16M|#define FRAME_OTHER_FLAGS (FRAME_FLAGS + 3)  // 28
  |  |  ------------------
  |  |  |  |   32|  5.16M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  ------------------
  |  |  |  |  |  |   31|  5.16M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   30|  5.16M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   29|  5.16M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1479|  5.16M|  if (splitmode != NULL) {
  ------------------
  |  Branch (1479:7): [True: 3.32k, False: 5.15M]
  ------------------
 1480|  3.32k|    *splitmode = (other_flags & 0x03u) + 1;
 1481|  3.32k|  }
 1482|       |
 1483|       |  // Other flags 2: bit 0 = use_dict
 1484|  5.16M|  if (use_dict != NULL) {
  ------------------
  |  Branch (1484:7): [True: 3.32k, False: 5.15M]
  ------------------
 1485|  3.32k|    *use_dict = (framep[FRAME_OTHER_FLAGS2] & FRAME_USE_DICT) ? 1 : 0;
  ------------------
  |  |   47|  3.32k|#define FRAME_OTHER_FLAGS2 (FRAME_FILTER_PIPELINE + 1 + 14)  // 85
  |  |  ------------------
  |  |  |  |   44|  3.32k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  3.32k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  3.32k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  3.32k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  3.32k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  3.32k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  3.32k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.32k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  3.32k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  3.32k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  3.32k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  3.32k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  3.32k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  *use_dict = (framep[FRAME_OTHER_FLAGS2] & FRAME_USE_DICT) ? 1 : 0;
  ------------------
  |  |   48|  3.32k|#define FRAME_USE_DICT (1U << 0)   //!< bit 0 of other_flags2: use dictionary compression
  ------------------
  |  Branch (1485:17): [True: 222, False: 3.09k]
  ------------------
 1486|  3.32k|  }
 1487|       |
 1488|  5.16M|  if (compcode_meta != NULL) {
  ------------------
  |  Branch (1488:7): [True: 3.32k, False: 5.15M]
  ------------------
 1489|  3.32k|    from_big(compcode_meta, framep + FRAME_CODEC_META, sizeof(*compcode_meta));
  ------------------
  |  |   38|  3.32k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1490|  3.32k|  }
 1491|       |
 1492|       |  // Filters
 1493|  5.16M|  if (filters != NULL && filters_meta != NULL) {
  ------------------
  |  Branch (1493:7): [True: 3.32k, False: 5.15M]
  |  Branch (1493:26): [True: 3.32k, False: 0]
  ------------------
 1494|  3.32k|    uint8_t nfilters = framep[FRAME_FILTER_PIPELINE];
  ------------------
  |  |   44|  3.32k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  ------------------
  |  |  |  |   43|  3.32k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  3.32k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|  3.32k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   40|  3.32k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   39|  3.32k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  3.32k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.32k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  3.32k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  3.32k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  3.32k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  3.32k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  3.32k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1495|  3.32k|    if (nfilters > BLOSC2_MAX_FILTERS) {
  ------------------
  |  Branch (1495:9): [True: 4, False: 3.31k]
  ------------------
 1496|      4|      BLOSC_TRACE_ERROR("The number of filters in frame header are too large for Blosc2.");
  ------------------
  |  |   93|      4|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      4|    do {                                            \
  |  |  |  |   98|      4|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      4|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      4|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1497|      4|      return BLOSC2_ERROR_INVALID_HEADER;
 1498|      4|    }
 1499|  3.31k|    uint8_t *filters_ = framep + FRAME_FILTER_PIPELINE + 1;
  ------------------
  |  |   44|  3.31k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  ------------------
  |  |  |  |   43|  3.31k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  3.31k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|  3.31k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   40|  3.31k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   39|  3.31k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  3.31k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.31k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  3.31k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  3.31k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  3.31k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  3.31k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  3.31k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1500|  3.31k|    uint8_t *filters_meta_ = framep + FRAME_FILTER_PIPELINE + 1 + FRAME_FILTER_PIPELINE_MAX;
  ------------------
  |  |   44|  3.31k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  ------------------
  |  |  |  |   43|  3.31k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  3.31k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|  3.31k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   40|  3.31k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   39|  3.31k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  3.31k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.31k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  3.31k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  3.31k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  3.31k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  3.31k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  3.31k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  uint8_t *filters_meta_ = framep + FRAME_FILTER_PIPELINE + 1 + FRAME_FILTER_PIPELINE_MAX;
  ------------------
  |  |   53|  3.31k|#define FRAME_FILTER_PIPELINE_MAX (8)  // the maximum number of filters that can be stored in header
  ------------------
 1501|  12.4k|    for (int i = 0; i < nfilters; i++) {
  ------------------
  |  Branch (1501:21): [True: 9.09k, False: 3.31k]
  ------------------
 1502|  9.09k|      filters[i] = filters_[i];
 1503|  9.09k|      filters_meta[i] = filters_meta_[i];
 1504|  9.09k|    }
 1505|  3.31k|  }
 1506|       |
 1507|  5.16M|  if (*nbytes > 0) {
  ------------------
  |  Branch (1507:7): [True: 5.15M, False: 8.11k]
  ------------------
 1508|  5.15M|    if (*chunksize > 0) {
  ------------------
  |  Branch (1508:9): [True: 5.15M, False: 1.53k]
  ------------------
 1509|       |      // We can compute the number of chunks directly when there is a fixed chunk size.
 1510|  5.15M|      *nchunks = *nbytes / *chunksize;
 1511|  5.15M|      if (*nbytes % *chunksize > 0) {
  ------------------
  |  Branch (1511:11): [True: 215, False: 5.15M]
  ------------------
 1512|    215|        *nchunks += 1;
 1513|    215|      }
 1514|       |
 1515|       |      // Sanity check for compressed sizes
 1516|  5.15M|      if ((*cbytes < 0) || ((int64_t)*nchunks * *chunksize < *nbytes)) {
  ------------------
  |  Branch (1516:11): [True: 21, False: 5.15M]
  |  Branch (1516:28): [True: 2, False: 5.15M]
  ------------------
 1517|     23|        BLOSC_TRACE_ERROR("Invalid compressed size in frame header.");
  ------------------
  |  |   93|     23|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     23|    do {                                            \
  |  |  |  |   98|     23|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     23|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     23|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1518|     23|        return BLOSC2_ERROR_INVALID_HEADER;
 1519|     23|      }
 1520|  5.15M|    }
 1521|  1.53k|    else if (*chunksize == 0) {
  ------------------
  |  Branch (1521:14): [True: 1.51k, False: 23]
  ------------------
 1522|  1.51k|      int32_t coffsets_nbytes;
 1523|  1.51k|      int rc2 = get_coffsets_nbytes(frame, *header_len, *cbytes, &coffsets_nbytes, io);
 1524|  1.51k|      if (rc2 < 0) {
  ------------------
  |  Branch (1524:11): [True: 241, False: 1.27k]
  ------------------
 1525|    241|        return rc2;
 1526|    241|      }
 1527|  1.27k|      if (coffsets_nbytes < 0 || coffsets_nbytes % (int32_t)sizeof(int64_t) != 0) {
  ------------------
  |  Branch (1527:11): [True: 22, False: 1.24k]
  |  Branch (1527:34): [True: 1, False: 1.24k]
  ------------------
 1528|     23|        BLOSC_TRACE_ERROR("Invalid offsets chunk in frame header.");
  ------------------
  |  |   93|     23|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     23|    do {                                            \
  |  |  |  |   98|     23|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     23|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     23|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1529|     23|        return BLOSC2_ERROR_INVALID_HEADER;
 1530|     23|      }
 1531|  1.24k|      *nchunks = coffsets_nbytes / (int32_t)sizeof(int64_t);
 1532|  1.24k|    }
 1533|     23|    else {
 1534|     23|      BLOSC_TRACE_ERROR("Invalid chunk size in frame header.");
  ------------------
  |  |   93|     23|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     23|    do {                                            \
  |  |  |  |   98|     23|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     23|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     23|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1535|     23|      return BLOSC2_ERROR_INVALID_HEADER;
 1536|     23|    }
 1537|  5.15M|  } else {
 1538|  8.11k|    *nchunks = 0;
 1539|  8.11k|  }
 1540|       |
 1541|  5.16M|  if (*nchunks > 0) {
  ------------------
  |  Branch (1541:7): [True: 5.15M, False: 8.12k]
  ------------------
 1542|  5.15M|    int32_t off_nbytes;
 1543|  5.15M|    if (!blosc2_nchunks_to_offsets_nbytes(*nchunks, &off_nbytes)) {
  ------------------
  |  Branch (1543:9): [True: 37, False: 5.15M]
  ------------------
 1544|     37|      BLOSC_TRACE_ERROR("Invalid number of chunks in frame header.");
  ------------------
  |  |   93|     37|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     37|    do {                                            \
  |  |  |  |   98|     37|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     37|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 37, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     37|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1545|     37|      return BLOSC2_ERROR_INVALID_HEADER;
 1546|     37|    }
 1547|  5.15M|  }
 1548|       |
 1549|  5.16M|  return 0;
 1550|  5.16M|}
get_trailer_offset:
 1553|  1.15M|int64_t get_trailer_offset(blosc2_frame_s *frame, int32_t header_len, bool has_coffsets) {
 1554|  1.15M|  if (!has_coffsets) {
  ------------------
  |  Branch (1554:7): [True: 5.95k, False: 1.15M]
  ------------------
 1555|       |    // No data chunks yet
 1556|  5.95k|    return header_len;
 1557|  5.95k|  }
 1558|  1.15M|  return frame->len - frame->trailer_len;
 1559|  1.15M|}
frame_check_stale:
 1745|  2.20M|int frame_check_stale(blosc2_frame_s *frame) {
 1746|  2.20M|  if (frame == NULL || frame->cframe != NULL || frame->schunk == NULL) {
  ------------------
  |  Branch (1746:7): [True: 1.55M, False: 645k]
  |  Branch (1746:24): [True: 645k, False: 0]
  |  Branch (1746:49): [True: 0, False: 0]
  ------------------
 1747|  2.20M|    return 0;
 1748|  2.20M|  }
 1749|      0|  if (frame_lock(frame, false) < 0) {
  ------------------
  |  Branch (1749:7): [True: 0, False: 0]
  ------------------
 1750|      0|    return BLOSC2_ERROR_LOCK;
 1751|      0|  }
 1752|      0|  int32_t header_len;
 1753|      0|  int64_t frame_len;
 1754|      0|  int64_t nbytes;
 1755|      0|  int64_t cbytes;
 1756|      0|  int32_t blocksize;
 1757|      0|  int32_t chunksize;
 1758|      0|  int64_t nchunks;
 1759|      0|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 1760|      0|                           &blocksize, &chunksize, &nchunks,
 1761|      0|                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 1762|      0|                           frame->schunk->storage->io);
 1763|      0|  if (rc < 0) {
  ------------------
  |  Branch (1763:7): [True: 0, False: 0]
  ------------------
 1764|       |    // The on-disk header cannot be read right now (e.g. a freshly created
 1765|       |    // frame not yet flushed to disk, or another process mid-write).  The
 1766|       |    // poll is opportunistic: keep the cached view, exactly as before polling
 1767|       |    // existed.  A genuinely torn frame still errors out in the data-access
 1768|       |    // paths that need it.
 1769|      0|    frame_unlock(frame);
 1770|      0|    return 0;
 1771|      0|  }
 1772|      0|  rc = frame_refresh_if_stale(frame, frame_len);
 1773|      0|  if (rc > 0) {
  ------------------
  |  Branch (1773:7): [True: 0, False: 0]
  ------------------
 1774|      0|    frame->schunk->nbytes = nbytes;
 1775|      0|    frame->schunk->cbytes = cbytes;
 1776|      0|    frame->schunk->nchunks = nchunks;
 1777|      0|  }
 1778|      0|  frame_unlock(frame);
 1779|      0|  return rc;
 1780|      0|}
update_frame_len:
 1866|  1.15M|int update_frame_len(blosc2_frame_s* frame, int64_t len) {
 1867|  1.15M|  int rc = 1;
 1868|  1.15M|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 1869|  1.15M|  if (io_cb == NULL) {
  ------------------
  |  Branch (1869:7): [True: 0, False: 1.15M]
  ------------------
 1870|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1871|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 1872|      0|  }
 1873|       |
 1874|  1.15M|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (1874:7): [True: 1.15M, False: 0]
  ------------------
 1875|  1.15M|    to_big(frame->cframe + FRAME_LEN, &len, sizeof(int64_t));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1876|  1.15M|  }
 1877|      0|  else {
 1878|      0|    void* fp = NULL;
 1879|      0|    if (frame->sframe) {
  ------------------
  |  Branch (1879:9): [True: 0, False: 0]
  ------------------
 1880|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 1881|      0|                             frame->schunk->storage->io);
 1882|      0|    }
 1883|      0|    else {
 1884|      0|      fp = frame_writer_acquire(frame, io_cb);
 1885|      0|    }
 1886|      0|    if (fp == NULL) {
  ------------------
  |  Branch (1886:9): [True: 0, False: 0]
  ------------------
 1887|      0|      BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1888|      0|      return BLOSC2_ERROR_FILE_OPEN;
 1889|      0|    }
 1890|      0|    int64_t io_pos = frame->file_offset + FRAME_LEN;
  ------------------
  |  |   31|      0|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  ------------------
  |  |  |  |   30|      0|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  ------------------
  |  |  |  |  |  |   29|      0|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1891|      0|    int64_t swap_len;
 1892|      0|    to_big(&swap_len, &len, sizeof(int64_t));
  ------------------
  |  |   37|      0|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1893|      0|    int64_t wbytes = io_cb->write(&swap_len, 1, sizeof(int64_t), io_pos, fp);
 1894|      0|    int close_rc = frame_writer_release(frame, io_cb, fp);
 1895|      0|    if (wbytes != sizeof(int64_t)) {
  ------------------
  |  Branch (1895:9): [True: 0, False: 0]
  ------------------
 1896|      0|      BLOSC_TRACE_ERROR("Cannot write the frame length in header.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1897|      0|      return BLOSC2_ERROR_FILE_WRITE;
 1898|      0|    }
 1899|      0|    if (close_rc < 0) {
  ------------------
  |  Branch (1899:9): [True: 0, False: 0]
  ------------------
 1900|      0|      return close_rc;
 1901|      0|    }
 1902|      0|  }
 1903|  1.15M|  return rc;
 1904|  1.15M|}
frame_update_trailer:
 1907|  1.15M|int frame_update_trailer(blosc2_frame_s* frame, blosc2_schunk* schunk) {
 1908|  1.15M|  if (frame != NULL && frame->len == 0) {
  ------------------
  |  Branch (1908:7): [True: 1.15M, False: 0]
  |  Branch (1908:24): [True: 0, False: 1.15M]
  ------------------
 1909|      0|    BLOSC_TRACE_ERROR("The trailer cannot be updated on empty frames.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1910|      0|  }
 1911|       |
 1912|       |  // Create the trailer in msgpack (see the frame format document)
 1913|  1.15M|  uint32_t trailer_len = FRAME_TRAILER_MINLEN;
  ------------------
  |  |   58|  1.15M|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
 1914|  1.15M|  uint8_t* trailer = (uint8_t*)calloc((size_t)trailer_len, 1);
 1915|  1.15M|  uint8_t* ptrailer = trailer;
 1916|  1.15M|  *ptrailer = 0x90 + 4;  // fixarray with 4 elements
 1917|  1.15M|  ptrailer += 1;
 1918|       |  // Trailer format version
 1919|  1.15M|  *ptrailer = FRAME_TRAILER_VERSION;
  ------------------
  |  |   56|  1.15M|#define FRAME_TRAILER_VERSION (1U)        // can be up to 127
  ------------------
 1920|  1.15M|  ptrailer += 1;
 1921|       |
 1922|  1.15M|  int32_t current_trailer_len = (int32_t)(ptrailer - trailer);
 1923|       |
 1924|       |  // Now, deal with variable-length metalayers
 1925|  1.15M|  int16_t nvlmetalayers = schunk->nvlmetalayers;
 1926|  1.15M|  if (nvlmetalayers < 0 || nvlmetalayers > BLOSC2_MAX_METALAYERS) {
  ------------------
  |  | 1895|  1.15M|#define BLOSC2_MAX_METALAYERS 16
  ------------------
  |  Branch (1926:7): [True: 0, False: 1.15M]
  |  Branch (1926:28): [True: 0, False: 1.15M]
  ------------------
 1927|      0|    return -1;
 1928|      0|  }
 1929|       |
 1930|       |  // Make space for the header of metalayers (array marker, size, map of offsets)
 1931|  1.15M|  trailer = realloc(trailer, (size_t) current_trailer_len + 1 + 1 + 2 + 1 + 2);
 1932|  1.15M|  ptrailer = trailer + current_trailer_len;
 1933|       |
 1934|       |  // The msgpack header for the metalayers (array_marker, size, map of offsets, list of metalayers)
 1935|  1.15M|  *ptrailer = 0x90 + 3;  // array with 3 elements
 1936|  1.15M|  ptrailer += 1;
 1937|       |
 1938|  1.15M|  int32_t tsize = (int32_t)(ptrailer - trailer);
 1939|       |
 1940|       |  // Size for the map (index) of metalayer offsets, including this uint16 size (to be filled out later on)
 1941|  1.15M|  *ptrailer = 0xcd;  // uint16
 1942|  1.15M|  ptrailer += 1 + 2;
 1943|       |
 1944|       |  // Map (index) of offsets for optional metalayers
 1945|  1.15M|  *ptrailer = 0xde;  // map 16 with N keys
 1946|  1.15M|  ptrailer += 1;
 1947|  1.15M|  to_big(ptrailer, &nvlmetalayers, sizeof(nvlmetalayers));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1948|  1.15M|  ptrailer += sizeof(nvlmetalayers);
 1949|  1.15M|  current_trailer_len = (int32_t)(ptrailer - trailer);
 1950|  1.15M|  int32_t *offtodata = malloc(nvlmetalayers * sizeof(int32_t));
 1951|  1.15M|  for (int nvlmetalayer = 0; nvlmetalayer < nvlmetalayers; nvlmetalayer++) {
  ------------------
  |  Branch (1951:30): [True: 0, False: 1.15M]
  ------------------
 1952|      0|    if (frame == NULL) {
  ------------------
  |  Branch (1952:9): [True: 0, False: 0]
  ------------------
 1953|      0|      return -1;
 1954|      0|    }
 1955|      0|    blosc2_metalayer *vlmetalayer = schunk->vlmetalayers[nvlmetalayer];
 1956|      0|    uint8_t name_len = (uint8_t) strlen(vlmetalayer->name);
 1957|      0|    trailer = realloc(trailer, (size_t)current_trailer_len + 1 + name_len + 1 + 4);
 1958|      0|    ptrailer = trailer + current_trailer_len;
 1959|       |    // Store the vlmetalayer
 1960|      0|    if (name_len >= (1U << 5U)) {  // metalayer strings cannot be longer than 32 bytes
  ------------------
  |  Branch (1960:9): [True: 0, False: 0]
  ------------------
 1961|      0|      free(offtodata);
 1962|      0|      return -1;
 1963|      0|    }
 1964|      0|    *ptrailer = (uint8_t)0xa0 + name_len;  // str
 1965|      0|    ptrailer += 1;
 1966|      0|    memcpy(ptrailer, vlmetalayer->name, name_len);
 1967|      0|    ptrailer += name_len;
 1968|       |    // Space for storing the offset for the value of this vlmetalayer
 1969|      0|    *ptrailer = 0xd2;  // int32
 1970|      0|    ptrailer += 1;
 1971|      0|    offtodata[nvlmetalayer] = (int32_t)(ptrailer - trailer);
 1972|      0|    ptrailer += 4;
 1973|      0|    current_trailer_len += 1 + name_len + 1 + 4;
 1974|      0|  }
 1975|  1.15M|  int32_t tsize2 = (int32_t)(ptrailer - trailer);
 1976|  1.15M|  if (tsize2 != current_trailer_len) {  // sanity check
  ------------------
  |  Branch (1976:7): [True: 0, False: 1.15M]
  ------------------
 1977|      0|    return -1;
 1978|      0|  }
 1979|       |
 1980|       |  // Map size + int16 size
 1981|  1.15M|  if ((uint32_t) (tsize2 - tsize) >= (1U << 16U)) {
  ------------------
  |  Branch (1981:7): [True: 0, False: 1.15M]
  ------------------
 1982|      0|    return -1;
 1983|      0|  }
 1984|  1.15M|  uint16_t map_size = (uint16_t) (tsize2 - tsize);
 1985|  1.15M|  to_big(trailer + 4, &map_size, sizeof(map_size));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1986|       |
 1987|       |  // Make space for an (empty) array
 1988|  1.15M|  tsize = (int32_t)(ptrailer - trailer);
 1989|  1.15M|  trailer = realloc(trailer, (size_t) tsize + 2 + 1 + 2);
 1990|  1.15M|  ptrailer = trailer + tsize;
 1991|       |
 1992|       |  // Now, store the values in an array
 1993|  1.15M|  *ptrailer = 0xdc;  // array 16 with N elements
 1994|  1.15M|  ptrailer += 1;
 1995|  1.15M|  to_big(ptrailer, &nvlmetalayers, sizeof(nvlmetalayers));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1996|  1.15M|  ptrailer += sizeof(nvlmetalayers);
 1997|  1.15M|  current_trailer_len = (int32_t)(ptrailer - trailer);
 1998|  1.15M|  for (int nvlmetalayer = 0; nvlmetalayer < nvlmetalayers; nvlmetalayer++) {
  ------------------
  |  Branch (1998:30): [True: 0, False: 1.15M]
  ------------------
 1999|      0|    if (frame == NULL) {
  ------------------
  |  Branch (1999:9): [True: 0, False: 0]
  ------------------
 2000|      0|      return -1;
 2001|      0|    }
 2002|      0|    blosc2_metalayer *vlmetalayer = schunk->vlmetalayers[nvlmetalayer];
 2003|      0|    trailer = realloc(trailer, (size_t)current_trailer_len + 1 + 4 + vlmetalayer->content_len);
 2004|      0|    ptrailer = trailer + current_trailer_len;
 2005|       |    // Store the serialized contents for this vlmetalayer
 2006|      0|    *ptrailer = 0xc6;  // bin32
 2007|      0|    ptrailer += 1;
 2008|      0|    to_big(ptrailer, &(vlmetalayer->content_len), sizeof(vlmetalayer->content_len));
  ------------------
  |  |   37|      0|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 2009|      0|    ptrailer += 4;
 2010|      0|    memcpy(ptrailer, vlmetalayer->content, vlmetalayer->content_len);  // buffer, no need to swap
 2011|      0|    ptrailer += vlmetalayer->content_len;
 2012|       |    // Update the offset now that we know it
 2013|      0|    to_big(trailer + offtodata[nvlmetalayer], &current_trailer_len, sizeof(current_trailer_len));
  ------------------
  |  |   37|      0|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 2014|      0|    current_trailer_len += 1 + 4 + vlmetalayer->content_len;
 2015|      0|  }
 2016|  1.15M|  free(offtodata);
 2017|  1.15M|  tsize = (int32_t)(ptrailer - trailer);
 2018|  1.15M|  if (tsize != current_trailer_len) {  // sanity check
  ------------------
  |  Branch (2018:7): [True: 0, False: 1.15M]
  ------------------
 2019|      0|    return -1;
 2020|      0|  }
 2021|       |
 2022|  1.15M|  trailer = realloc(trailer, (size_t)current_trailer_len + 23);
 2023|  1.15M|  ptrailer = trailer + current_trailer_len;
 2024|  1.15M|  trailer_len = (ptrailer - trailer) + 23;
 2025|       |
 2026|       |  // Trailer length
 2027|  1.15M|  *ptrailer = 0xce;  // uint32
 2028|  1.15M|  ptrailer += 1;
 2029|  1.15M|  to_big(ptrailer, &trailer_len, sizeof(uint32_t));
  ------------------
  |  |   37|  1.15M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 2030|  1.15M|  ptrailer += sizeof(uint32_t);
 2031|       |  // Up to 16 bytes for frame fingerprint (using XXH3 included in https://github.com/Cyan4973/xxHash)
 2032|       |  // Maybe someone would need 256-bit in the future, but for the time being 128-bit seems like a good tradeoff
 2033|  1.15M|  *ptrailer = 0xd8;  // fixext 16
 2034|  1.15M|  ptrailer += 1;
 2035|  1.15M|  *ptrailer = 0;  // fingerprint type: 0 -> no fp; 1 -> 32-bit; 2 -> 64-bit; 3 -> 128-bit
 2036|  1.15M|  ptrailer += 1;
 2037|       |
 2038|       |  // Remove call to memset when we compute an actual fingerprint
 2039|  1.15M|  memset(ptrailer, 0, 16);
 2040|       |  // Uncomment call to memcpy when we compute an actual fingerprint
 2041|       |  // memcpy(ptrailer, xxh3_fingerprint, sizeof(xxh3_fingerprint));
 2042|  1.15M|  ptrailer += 16;
 2043|       |
 2044|       |  // Sanity check
 2045|  1.15M|  ptrdiff_t actual_trailer_len = ptrailer - trailer;
 2046|  1.15M|  if (actual_trailer_len < 0 || (uint64_t)actual_trailer_len != (uint64_t)trailer_len) {
  ------------------
  |  Branch (2046:7): [True: 0, False: 1.15M]
  |  Branch (2046:33): [True: 0, False: 1.15M]
  ------------------
 2047|      0|    return BLOSC2_ERROR_DATA;
 2048|      0|  }
 2049|       |
 2050|  1.15M|  int32_t header_len;
 2051|  1.15M|  int64_t frame_len;
 2052|  1.15M|  int64_t nbytes;
 2053|  1.15M|  int64_t cbytes;
 2054|  1.15M|  int32_t blocksize;
 2055|  1.15M|  int32_t chunksize;
 2056|  1.15M|  int64_t nchunks;
 2057|  1.15M|  int ret = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 2058|  1.15M|                            &blocksize, &chunksize, &nchunks,
 2059|  1.15M|                            NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 2060|  1.15M|                            frame->schunk->storage->io);
 2061|  1.15M|  if (ret < 0) {
  ------------------
  |  Branch (2061:7): [True: 0, False: 1.15M]
  ------------------
 2062|      0|    BLOSC_TRACE_ERROR("Unable to get meta info from frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2063|      0|    return ret;
 2064|      0|  }
 2065|       |
 2066|  1.15M|  int64_t trailer_offset = get_trailer_offset(frame, header_len, nbytes > 0);
 2067|       |
 2068|  1.15M|  if (trailer_offset < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (2068:7): [True: 0, False: 1.15M]
  ------------------
 2069|      0|    BLOSC_TRACE_ERROR("Unable to get trailer offset in frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2070|      0|    return BLOSC2_ERROR_READ_BUFFER;
 2071|      0|  }
 2072|       |
 2073|  1.15M|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 2074|  1.15M|  if (io_cb == NULL) {
  ------------------
  |  Branch (2074:7): [True: 0, False: 1.15M]
  ------------------
 2075|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2076|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 2077|      0|  }
 2078|       |  // Update the trailer.  As there are no internal offsets to the trailer section,
 2079|       |  // and it is always at the end of the frame, we can just write (or overwrite) it
 2080|       |  // at the end of the frame.
 2081|  1.15M|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (2081:7): [True: 1.15M, False: 0]
  ------------------
 2082|  1.15M|    frame->cframe = realloc(frame->cframe, (size_t)(trailer_offset + trailer_len));
 2083|  1.15M|    if (frame->cframe == NULL) {
  ------------------
  |  Branch (2083:9): [True: 0, False: 1.15M]
  ------------------
 2084|      0|      BLOSC_TRACE_ERROR("Cannot realloc space for the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2085|      0|      free(trailer);
 2086|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 2087|      0|    }
 2088|  1.15M|    memcpy(frame->cframe + trailer_offset, trailer, trailer_len);
 2089|  1.15M|  }
 2090|      0|  else {
 2091|      0|    void* fp = NULL;
 2092|      0|    if (frame->sframe) {
  ------------------
  |  Branch (2092:9): [True: 0, False: 0]
  ------------------
 2093|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 2094|      0|                             frame->schunk->storage->io);
 2095|      0|    }
 2096|      0|    else {
 2097|      0|      fp = frame_writer_acquire(frame, io_cb);
 2098|      0|    }
 2099|      0|    if (fp == NULL) {
  ------------------
  |  Branch (2099:9): [True: 0, False: 0]
  ------------------
 2100|      0|      BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2101|      0|      free(trailer);
 2102|      0|      return BLOSC2_ERROR_FILE_OPEN;
 2103|      0|    }
 2104|      0|    int64_t io_pos = frame->file_offset + trailer_offset;
 2105|      0|    int64_t wbytes = io_cb->write(trailer, 1, trailer_len, io_pos, fp);
 2106|      0|    if (wbytes != trailer_len) {
  ------------------
  |  Branch (2106:9): [True: 0, False: 0]
  ------------------
 2107|      0|      BLOSC_TRACE_ERROR("Cannot write the trailer length in trailer.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2108|      0|      frame->file_end = 0;  // a partial write may have moved the end of the file
 2109|      0|      frame_writer_release(frame, io_cb, fp);
 2110|      0|      free(trailer);
 2111|      0|      return BLOSC2_ERROR_FILE_WRITE;
 2112|      0|    }
 2113|      0|    int64_t trunc_pos = frame->file_offset + trailer_offset + trailer_len;
 2114|       |    // Only cut the file when the frame really got shorter than it.  A growing
 2115|       |    // frame leaves no stale bytes behind its trailer, and a truncate is never
 2116|       |    // free: on NFS it is a synchronous flush plus a SETATTR round trip, and XFS
 2117|       |    // flushes the file on the next close after any truncate that does not grow
 2118|       |    // it.  Other backends keep truncating unconditionally.
 2119|       |    //
 2120|       |    // file_end is the size we last left the file at.  A write that failed
 2121|       |    // halfway through an earlier update can have left bytes past it, which are
 2122|       |    // then only cut by the next update that shrinks the frame.  That is
 2123|       |    // harmless: the frame length is read from the header, not the file size.
 2124|      0|    bool must_truncate = true;
 2125|      0|    if (!frame->sframe && frame->schunk->storage->io->id == BLOSC2_IO_FILESYSTEM) {
  ------------------
  |  Branch (2125:9): [True: 0, False: 0]
  |  Branch (2125:27): [True: 0, False: 0]
  ------------------
 2126|      0|      if (frame->file_end <= 0) {
  ------------------
  |  Branch (2126:11): [True: 0, False: 0]
  ------------------
 2127|      0|        frame->file_end = io_cb->size(fp);  // once per handle; negative on error
 2128|      0|      }
 2129|      0|      must_truncate = frame->file_end <= 0 || trunc_pos < frame->file_end;
  ------------------
  |  Branch (2129:23): [True: 0, False: 0]
  |  Branch (2129:47): [True: 0, False: 0]
  ------------------
 2130|      0|    }
 2131|      0|    if (must_truncate && io_cb->truncate(fp, trunc_pos) != 0) {
  ------------------
  |  Branch (2131:9): [True: 0, False: 0]
  |  Branch (2131:26): [True: 0, False: 0]
  ------------------
 2132|      0|      BLOSC_TRACE_ERROR("Cannot truncate the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2133|      0|      frame->file_end = 0;
 2134|      0|      frame_writer_release(frame, io_cb, fp);
 2135|      0|      free(trailer);
 2136|      0|      return BLOSC2_ERROR_FILE_TRUNCATE;
 2137|      0|    }
 2138|      0|    frame->file_end = trunc_pos;
 2139|      0|    if (frame_writer_release(frame, io_cb, fp) < 0) {
  ------------------
  |  Branch (2139:9): [True: 0, False: 0]
  ------------------
 2140|      0|      frame->file_end = 0;
 2141|      0|      free(trailer);
 2142|      0|      return BLOSC2_ERROR_FILE_WRITE;
 2143|      0|    }
 2144|       |
 2145|      0|  }
 2146|  1.15M|  free(trailer);
 2147|       |
 2148|  1.15M|  int rc = update_frame_len(frame, trailer_offset + trailer_len);
 2149|  1.15M|  if (rc < 0) {
  ------------------
  |  Branch (2149:7): [True: 0, False: 1.15M]
  ------------------
 2150|      0|    return rc;
 2151|      0|  }
 2152|  1.15M|  frame->len = trailer_offset + trailer_len;
 2153|  1.15M|  frame->trailer_len = trailer_len;
 2154|       |
 2155|  1.15M|  return 1;
 2156|  1.15M|}
frame_from_cframe:
 2394|  3.39k|blosc2_frame_s* frame_from_cframe(uint8_t *cframe, int64_t len, bool copy) {
 2395|       |  // Get the length of the frame
 2396|  3.39k|  const uint8_t* header = cframe;
 2397|  3.39k|  int64_t frame_len;
 2398|  3.39k|  if (len < FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  3.39k|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  3.39k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  3.39k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  3.39k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  3.39k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  3.39k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  3.39k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  3.39k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.39k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  3.39k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  3.39k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  3.39k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  3.39k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  3.39k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2398:7): [True: 0, False: 3.39k]
  ------------------
 2399|      0|    return NULL;
 2400|      0|  }
 2401|       |
 2402|  3.39k|  from_big(&frame_len, header + FRAME_LEN, sizeof(frame_len));
  ------------------
  |  |   38|  3.39k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2403|  3.39k|  if (frame_len != len) {   // sanity check
  ------------------
  |  Branch (2403:7): [True: 0, False: 3.39k]
  ------------------
 2404|      0|    return NULL;
 2405|      0|  }
 2406|       |
 2407|  3.39k|  blosc2_frame_s* frame = frame_alloc();
 2408|  3.39k|  if (frame == NULL) {
  ------------------
  |  Branch (2408:7): [True: 0, False: 3.39k]
  ------------------
 2409|      0|    return NULL;
 2410|      0|  }
 2411|  3.39k|  frame->len = frame_len;
 2412|  3.39k|  frame->file_offset = 0;
 2413|       |
 2414|       |  // Now, the trailer length
 2415|  3.39k|  const uint8_t* trailer = cframe + frame_len - FRAME_TRAILER_MINLEN;
  ------------------
  |  |   58|  3.39k|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
 2416|  3.39k|  int trailer_offset = FRAME_TRAILER_MINLEN - FRAME_TRAILER_LEN_OFFSET;
  ------------------
  |  |   58|  3.39k|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
                int trailer_offset = FRAME_TRAILER_MINLEN - FRAME_TRAILER_LEN_OFFSET;
  ------------------
  |  |   59|  3.39k|#define FRAME_TRAILER_LEN_OFFSET (22)  // offset to trailer length (counting from the end)
  ------------------
 2417|  3.39k|  if (trailer[trailer_offset - 1] != 0xce) {
  ------------------
  |  Branch (2417:7): [True: 5, False: 3.38k]
  ------------------
 2418|      5|    blosc2_pthread_mutex_destroy(&frame->read_fp_mutex);
  ------------------
  |  |   91|      5|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 2419|      5|    free(frame);
 2420|      5|    return NULL;
 2421|      5|  }
 2422|  3.38k|  uint32_t trailer_len;
 2423|  3.38k|  from_big(&trailer_len, trailer + trailer_offset, sizeof(trailer_len));
  ------------------
  |  |   38|  3.38k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2424|  3.38k|  if (trailer_len < FRAME_TRAILER_MINLEN || trailer_len > INT32_MAX ||
  ------------------
  |  |   58|  6.77k|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
  |  Branch (2424:7): [True: 1, False: 3.38k]
  |  Branch (2424:45): [True: 8, False: 3.37k]
  ------------------
 2425|  3.37k|      (int64_t)trailer_len > frame_len ||
  ------------------
  |  Branch (2425:7): [True: 4, False: 3.37k]
  ------------------
 2426|  3.37k|      (int64_t)trailer_len > frame_len - FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  3.37k|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  3.37k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  3.37k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  3.37k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  3.37k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  3.37k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  3.37k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  3.37k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.37k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  3.37k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  3.37k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  3.37k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  3.37k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  3.37k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2426:7): [True: 2, False: 3.37k]
  ------------------
 2427|     15|    blosc2_pthread_mutex_destroy(&frame->read_fp_mutex);
  ------------------
  |  |   91|     15|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 2428|     15|    free(frame);
 2429|     15|    return NULL;
 2430|     15|  }
 2431|  3.37k|  frame->trailer_len = trailer_len;
 2432|       |
 2433|  3.37k|  if (copy) {
  ------------------
  |  Branch (2433:7): [True: 0, False: 3.37k]
  ------------------
 2434|      0|    frame->cframe = malloc((size_t)len);
 2435|      0|    memcpy(frame->cframe, cframe, (size_t)len);
 2436|      0|  }
 2437|  3.37k|  else {
 2438|  3.37k|    frame->cframe = cframe;
 2439|  3.37k|    frame->avoid_cframe_free = true;
 2440|  3.37k|  }
 2441|       |
 2442|  3.37k|  return frame;
 2443|  3.38k|}
frame_from_schunk:
 2450|  2.94k|int64_t frame_from_schunk(blosc2_schunk *schunk, blosc2_frame_s *frame) {
 2451|  2.94k|  frame->file_offset = 0;
 2452|  2.94k|  int64_t nchunks = schunk->nchunks;
 2453|  2.94k|  int64_t cbytes = schunk->cbytes;
 2454|  2.94k|  int32_t chunk_cbytes;
 2455|  2.94k|  int32_t chunk_nbytes;
 2456|  2.94k|  uint64_t* data_tmp = NULL;
 2457|  2.94k|  uint8_t* off_chunk = NULL;
 2458|  2.94k|  blosc2_io_cb* io_cb = NULL;
 2459|  2.94k|  void* fp = NULL;
 2460|  2.94k|  int rc;
 2461|       |
 2462|  2.94k|  uint8_t* h2 = new_header_frame(schunk, frame);
 2463|  2.94k|  if (h2 == NULL) {
  ------------------
  |  Branch (2463:7): [True: 0, False: 2.94k]
  ------------------
 2464|      0|    return BLOSC2_ERROR_DATA;
 2465|      0|  }
 2466|  2.94k|  uint32_t h2len;
 2467|  2.94k|  from_big(&h2len, h2 + FRAME_HEADER_LEN, sizeof(h2len));
  ------------------
  |  |   38|  2.94k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2468|       |  // Build the offsets chunk
 2469|  2.94k|  int32_t chunksize = -1;
 2470|  2.94k|  int32_t off_cbytes = 0;
 2471|  2.94k|  uint64_t coffset = 0;
 2472|  2.94k|  int32_t off_nbytes;
 2473|  2.94k|  if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &off_nbytes)) {
  ------------------
  |  Branch (2473:7): [True: 0, False: 2.94k]
  ------------------
 2474|      0|    BLOSC_TRACE_ERROR("Too many chunks for offsets representation.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2475|      0|    rc = BLOSC2_ERROR_DATA;
 2476|      0|    goto failed;
 2477|      0|  }
 2478|  2.94k|  data_tmp = malloc((size_t)off_nbytes);
 2479|  2.94k|  if (data_tmp == NULL) {
  ------------------
  |  Branch (2479:7): [True: 0, False: 2.94k]
  ------------------
 2480|      0|    BLOSC_TRACE_ERROR("Cannot allocate memory for offset data.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2481|      0|    rc = BLOSC2_ERROR_MEMORY_ALLOC;
 2482|      0|    goto failed;
 2483|      0|  }
 2484|  2.94k|  for (int64_t i = 0; i < nchunks; i++) {
  ------------------
  |  Branch (2484:23): [True: 0, False: 2.94k]
  ------------------
 2485|      0|    rc = blosc2_cbuffer_sizes(schunk->data[i], &chunk_nbytes, &chunk_cbytes, NULL);
 2486|      0|    if (rc < 0) {
  ------------------
  |  Branch (2486:9): [True: 0, False: 0]
  ------------------
 2487|      0|      goto failed;
 2488|      0|    }
 2489|      0|    data_tmp[i] = coffset;
 2490|      0|    coffset += chunk_cbytes;
 2491|      0|    if (i == 0) {
  ------------------
  |  Branch (2491:9): [True: 0, False: 0]
  ------------------
 2492|      0|      chunksize = chunk_nbytes;
 2493|      0|    }
 2494|      0|    else if (chunksize != chunk_nbytes) {
  ------------------
  |  Branch (2494:14): [True: 0, False: 0]
  ------------------
 2495|       |      // Variable size  // TODO: update flags for this (or do not use them at all)
 2496|      0|      chunksize = 0;
 2497|      0|    }
 2498|      0|  }
 2499|  2.94k|  if ((int64_t)coffset != cbytes) {
  ------------------
  |  Branch (2499:7): [True: 0, False: 2.94k]
  ------------------
 2500|      0|    rc = BLOSC2_ERROR_DATA;
 2501|      0|    goto failed;
 2502|      0|  }
 2503|  2.94k|  if (nchunks > 0) {
  ------------------
  |  Branch (2503:7): [True: 0, False: 2.94k]
  ------------------
 2504|      0|    off_cbytes = compress_offsets((const int64_t*)data_tmp, off_nbytes, off_nbytes + BLOSC2_MAX_OVERHEAD,
 2505|      0|                                  &off_chunk);
 2506|      0|    if (off_cbytes < 0) {
  ------------------
  |  Branch (2506:9): [True: 0, False: 0]
  ------------------
 2507|      0|      rc = off_cbytes;
 2508|      0|      goto failed;
 2509|      0|    }
 2510|      0|  }
 2511|  2.94k|  else {
 2512|  2.94k|    off_cbytes = 0;
 2513|  2.94k|  }
 2514|       |
 2515|       |  // Now that we know them, fill the chunksize and frame length in header
 2516|  2.94k|  to_big(h2 + FRAME_CHUNKSIZE, &chunksize, sizeof(chunksize));
  ------------------
  |  |   37|  2.94k|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 2517|  2.94k|  if (chunksize == 0) {
  ------------------
  |  Branch (2517:7): [True: 0, False: 2.94k]
  ------------------
 2518|      0|    h2[FRAME_FLAGS] |= FRAME_VARIABLE_CHUNKS;
  ------------------
  |  |   32|      0|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|      0|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|      0|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|      0|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  h2[FRAME_FLAGS] |= FRAME_VARIABLE_CHUNKS;
  ------------------
  |  |   26|      0|#define FRAME_VARIABLE_CHUNKS (1U << 6)
  ------------------
 2519|      0|  }
 2520|  2.94k|  else {
 2521|  2.94k|    h2[FRAME_FLAGS] &= (uint8_t)~FRAME_VARIABLE_CHUNKS;
  ------------------
  |  |   32|  2.94k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|  2.94k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|  2.94k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|  2.94k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  h2[FRAME_FLAGS] &= (uint8_t)~FRAME_VARIABLE_CHUNKS;
  ------------------
  |  |   26|  2.94k|#define FRAME_VARIABLE_CHUNKS (1U << 6)
  ------------------
 2522|  2.94k|  }
 2523|  2.94k|  if (schunk->chunksize == 0 || (schunk->flags2 & BLOSC2_VL_BLOCKS)) {
  ------------------
  |  Branch (2523:7): [True: 0, False: 2.94k]
  |  Branch (2523:33): [True: 0, False: 2.94k]
  ------------------
 2524|      0|    h2[FRAME_FLAGS] = (uint8_t)((h2[FRAME_FLAGS] & (uint8_t)~0x0fu) | BLOSC2_VERSION_FRAME_FORMAT_VL_BLOCKS);
  ------------------
  |  |   32|      0|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|      0|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|      0|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|      0|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  h2[FRAME_FLAGS] = (uint8_t)((h2[FRAME_FLAGS] & (uint8_t)~0x0fu) | BLOSC2_VERSION_FRAME_FORMAT_VL_BLOCKS);
  ------------------
  |  |   32|      0|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|      0|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|      0|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|      0|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2525|      0|    h2[FRAME_FLAGS] |= FRAME_VL_BLOCKS;
  ------------------
  |  |   32|      0|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|      0|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|      0|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|      0|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  h2[FRAME_FLAGS] |= FRAME_VL_BLOCKS;
  ------------------
  |  |   27|      0|#define FRAME_VL_BLOCKS (1U << 7)
  ------------------
 2526|      0|  }
 2527|  2.94k|  else {
 2528|  2.94k|    h2[FRAME_FLAGS] = (uint8_t)((h2[FRAME_FLAGS] & (uint8_t)~0x0fu) | BLOSC2_VERSION_FRAME_FORMAT_RC1);
  ------------------
  |  |   32|  2.94k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|  2.94k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|  2.94k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|  2.94k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  h2[FRAME_FLAGS] = (uint8_t)((h2[FRAME_FLAGS] & (uint8_t)~0x0fu) | BLOSC2_VERSION_FRAME_FORMAT_RC1);
  ------------------
  |  |   32|  2.94k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|  2.94k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|  2.94k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|  2.94k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2529|  2.94k|    h2[FRAME_FLAGS] &= (uint8_t)~FRAME_VL_BLOCKS;
  ------------------
  |  |   32|  2.94k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|  2.94k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|  2.94k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|  2.94k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  h2[FRAME_FLAGS] &= (uint8_t)~FRAME_VL_BLOCKS;
  ------------------
  |  |   27|  2.94k|#define FRAME_VL_BLOCKS (1U << 7)
  ------------------
 2530|  2.94k|  }
 2531|  2.94k|  frame->len = h2len + cbytes + off_cbytes + FRAME_TRAILER_MINLEN;
  ------------------
  |  |   58|  2.94k|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
 2532|  2.94k|  if (frame->sframe) {
  ------------------
  |  Branch (2532:7): [True: 0, False: 2.94k]
  ------------------
 2533|      0|    frame->len = h2len + off_cbytes + FRAME_TRAILER_MINLEN;
  ------------------
  |  |   58|      0|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
 2534|      0|  }
 2535|  2.94k|  int64_t tbytes = frame->len;
 2536|  2.94k|  to_big(h2 + FRAME_LEN, &tbytes, sizeof(tbytes));
  ------------------
  |  |   37|  2.94k|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 2537|       |
 2538|  2.94k|  const blosc2_io* io = frame->schunk->storage->io;
 2539|  2.94k|  io_cb = blosc2_get_io_cb(io->id);
 2540|  2.94k|  if (io_cb == NULL) {
  ------------------
  |  Branch (2540:7): [True: 0, False: 2.94k]
  ------------------
 2541|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2542|      0|    rc = BLOSC2_ERROR_PLUGIN_IO;
 2543|      0|    goto failed;
 2544|      0|  }
 2545|       |
 2546|       |  // Create the frame and put the header at the beginning
 2547|  2.94k|  int64_t io_pos = 0;
 2548|  2.94k|  if (frame->urlpath == NULL) {
  ------------------
  |  Branch (2548:7): [True: 2.94k, False: 0]
  ------------------
 2549|  2.94k|    frame->cframe = malloc((size_t)frame->len);
 2550|  2.94k|    memcpy(frame->cframe, h2, h2len);
 2551|  2.94k|  }
 2552|      0|  else {
 2553|      0|    if (frame->sframe) {
  ------------------
  |  Branch (2553:9): [True: 0, False: 0]
  ------------------
 2554|      0|      fp = sframe_open_index(frame->urlpath, "wb", io);
 2555|      0|    }
 2556|      0|    else {
 2557|       |      // The file is about to be recreated from scratch; drop any cached reader
 2558|      0|      frame_reader_invalidate(frame);
 2559|       |      // Where the handle can stay open as the cached writer (which is "rb+"
 2560|       |      // everywhere else), open it readable too
 2561|      0|      fp = io_cb->open(frame->urlpath, reader_cacheable(io) ? "wb+" : "wb", io->params);
  ------------------
  |  Branch (2561:40): [True: 0, False: 0]
  ------------------
 2562|      0|    }
 2563|      0|    if (fp == NULL) {
  ------------------
  |  Branch (2563:9): [True: 0, False: 0]
  ------------------
 2564|      0|      BLOSC_TRACE_ERROR("Error creating file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2565|      0|      rc = BLOSC2_ERROR_FILE_OPEN;
 2566|      0|      goto failed;
 2567|      0|    }
 2568|      0|    if (io_cb->write(h2, h2len, 1, io_pos, fp) != 1) {
  ------------------
  |  Branch (2568:9): [True: 0, False: 0]
  ------------------
 2569|      0|      BLOSC_TRACE_ERROR("Cannot write the header to %s.", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2570|      0|      rc = BLOSC2_ERROR_FILE_WRITE;
 2571|      0|      goto failed;
 2572|      0|    }
 2573|      0|    io_pos += h2len;
 2574|      0|  }
 2575|       |
 2576|       |  // Fill the frame with the actual data chunks
 2577|  2.94k|  if (!frame->sframe) {
  ------------------
  |  Branch (2577:7): [True: 2.94k, False: 0]
  ------------------
 2578|  2.94k|    coffset = 0;
 2579|  2.94k|    for (int64_t i = 0; i < nchunks; i++) {
  ------------------
  |  Branch (2579:25): [True: 0, False: 2.94k]
  ------------------
 2580|      0|      uint8_t* data_chunk = schunk->data[i];
 2581|      0|      rc = blosc2_cbuffer_sizes(data_chunk, NULL, &chunk_cbytes, NULL);
 2582|      0|      if (rc < 0) {
  ------------------
  |  Branch (2582:11): [True: 0, False: 0]
  ------------------
 2583|      0|        goto failed;
 2584|      0|      }
 2585|      0|      if (frame->urlpath == NULL) {
  ------------------
  |  Branch (2585:11): [True: 0, False: 0]
  ------------------
 2586|      0|        memcpy(frame->cframe + h2len + coffset, data_chunk, (size_t)chunk_cbytes);
 2587|      0|      } else {
 2588|      0|        if (io_cb->write(data_chunk, chunk_cbytes, 1, io_pos, fp) != 1) {
  ------------------
  |  Branch (2588:13): [True: 0, False: 0]
  ------------------
 2589|      0|          BLOSC_TRACE_ERROR("Cannot write chunk %" PRId64 " to %s.", i, frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2590|      0|          rc = BLOSC2_ERROR_FILE_WRITE;
 2591|      0|          goto failed;
 2592|      0|        }
 2593|      0|        io_pos += chunk_cbytes;
 2594|      0|      }
 2595|      0|      coffset += chunk_cbytes;
 2596|      0|    }
 2597|  2.94k|    if ((int64_t)coffset != cbytes) {
  ------------------
  |  Branch (2597:9): [True: 0, False: 2.94k]
  ------------------
 2598|      0|      rc = BLOSC2_ERROR_FAILURE;
 2599|      0|      goto failed;
 2600|      0|    }
 2601|  2.94k|  }
 2602|       |
 2603|       |  // Copy the offsets chunk at the end of the frame (there is none without chunks)
 2604|  2.94k|  if (frame->urlpath == NULL) {
  ------------------
  |  Branch (2604:7): [True: 2.94k, False: 0]
  ------------------
 2605|  2.94k|    if (off_cbytes > 0) {
  ------------------
  |  Branch (2605:9): [True: 0, False: 2.94k]
  ------------------
 2606|      0|      memcpy(frame->cframe + h2len + cbytes, off_chunk, off_cbytes);
 2607|      0|    }
 2608|  2.94k|  }
 2609|      0|  else {
 2610|      0|    if (off_cbytes > 0) {
  ------------------
  |  Branch (2610:9): [True: 0, False: 0]
  ------------------
 2611|      0|      if (io_cb->write(off_chunk, off_cbytes, 1, io_pos, fp) != 1) {
  ------------------
  |  Branch (2611:11): [True: 0, False: 0]
  ------------------
 2612|      0|        BLOSC_TRACE_ERROR("Cannot write offsets chunk to %s.", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2613|      0|        rc = BLOSC2_ERROR_FILE_WRITE;
 2614|      0|        goto failed;
 2615|      0|      }
 2616|      0|    }
 2617|      0|    if (!frame->sframe) {
  ------------------
  |  Branch (2617:9): [True: 0, False: 0]
  ------------------
 2618|      0|      frame->needs_sync = true;
 2619|      0|    }
 2620|       |    // Only a handle opened readable above can be adopted
 2621|      0|    if (!frame_writer_adopt(frame, io, fp)) {
  ------------------
  |  Branch (2621:9): [True: 0, False: 0]
  ------------------
 2622|      0|      int close_rc = io_cb->close(fp);
 2623|      0|      fp = NULL;
 2624|      0|      if (close_rc != 0) {
  ------------------
  |  Branch (2624:11): [True: 0, False: 0]
  ------------------
 2625|      0|        BLOSC_TRACE_ERROR("Cannot close the frame file %s.", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2626|      0|        rc = BLOSC2_ERROR_FILE_WRITE;
 2627|      0|        goto failed;
 2628|      0|      }
 2629|      0|    }
 2630|      0|    fp = NULL;
 2631|       |    // The file was created from scratch, so its size is exactly what we wrote
 2632|      0|    frame->file_end = frame->sframe ? 0 : io_pos + off_cbytes;
  ------------------
  |  Branch (2632:23): [True: 0, False: 0]
  ------------------
 2633|      0|  }
 2634|  2.94k|  free(off_chunk);
 2635|  2.94k|  free(data_tmp);
 2636|  2.94k|  free(h2);
 2637|  2.94k|  rc = frame_update_trailer(frame, schunk);
 2638|  2.94k|  if (rc < 0) {
  ------------------
  |  Branch (2638:7): [True: 0, False: 2.94k]
  ------------------
 2639|      0|    return rc;
 2640|      0|  }
 2641|       |
 2642|  2.94k|  return frame->len;
 2643|       |
 2644|      0|  failed:
 2645|      0|  if (fp != NULL) {
  ------------------
  |  Branch (2645:7): [True: 0, False: 0]
  ------------------
 2646|      0|    io_cb->close(fp);
 2647|      0|  }
 2648|      0|  free(off_chunk);
 2649|      0|  free(data_tmp);
 2650|      0|  free(h2);
 2651|      0|  return rc;
 2652|  2.94k|}
get_coffsets:
 2657|  4.00M|                      int64_t nchunks, int32_t *off_cbytes) {
 2658|  4.00M|  int32_t chunk_cbytes;
 2659|  4.00M|  int rc;
 2660|       |
 2661|  4.00M|  if (frame->coffsets != NULL) {
  ------------------
  |  Branch (2661:7): [True: 0, False: 4.00M]
  ------------------
 2662|      0|    if (off_cbytes != NULL) {
  ------------------
  |  Branch (2662:9): [True: 0, False: 0]
  ------------------
 2663|      0|      rc = blosc2_cbuffer_sizes(frame->coffsets, NULL, &chunk_cbytes, NULL);
 2664|      0|      if (rc < 0) {
  ------------------
  |  Branch (2664:11): [True: 0, False: 0]
  ------------------
 2665|      0|        return NULL;
 2666|      0|      }
 2667|      0|      *off_cbytes = (int32_t)chunk_cbytes;
 2668|      0|    }
 2669|      0|    return frame->coffsets;
 2670|      0|  }
 2671|  4.00M|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (2671:7): [True: 4.00M, False: 0]
  ------------------
 2672|  4.00M|    int64_t off_pos = header_len;
 2673|  4.00M|    if (cbytes < INT64_MAX - header_len) {
  ------------------
  |  Branch (2673:9): [True: 4.00M, False: 60]
  ------------------
 2674|  4.00M|      off_pos += cbytes;
 2675|  4.00M|    }
 2676|       |    // Check that there is enough room to read Blosc header
 2677|  4.00M|    if (off_pos < 0 || off_pos > INT64_MAX - BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (2677:9): [True: 0, False: 4.00M]
  |  Branch (2677:24): [True: 1, False: 4.00M]
  ------------------
 2678|  4.00M|        off_pos + BLOSC_EXTENDED_HEADER_LENGTH > frame->len) {
  ------------------
  |  Branch (2678:9): [True: 97, False: 4.00M]
  ------------------
 2679|     98|      BLOSC_TRACE_ERROR("Cannot read the offsets outside of frame boundary.");
  ------------------
  |  |   93|     98|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     98|    do {                                            \
  |  |  |  |   98|     98|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     98|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 98, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     98|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2680|     98|      return NULL;
 2681|     98|    }
 2682|       |    // For in-memory frames, the coffset is just one pointer away
 2683|  4.00M|    uint8_t* off_start = frame->cframe + off_pos;
 2684|  4.00M|    if (off_cbytes != NULL) {
  ------------------
  |  Branch (2684:9): [True: 4.00M, False: 0]
  ------------------
 2685|  4.00M|      int32_t chunk_nbytes;
 2686|  4.00M|      int32_t chunk_blocksize;
 2687|  4.00M|      rc = blosc2_cbuffer_sizes(off_start, &chunk_nbytes, &chunk_cbytes, &chunk_blocksize);
 2688|  4.00M|      if (rc < 0) {
  ------------------
  |  Branch (2688:11): [True: 8, False: 4.00M]
  ------------------
 2689|      8|        return NULL;
 2690|      8|      }
 2691|  4.00M|      *off_cbytes = (int32_t)chunk_cbytes;
 2692|  4.00M|      if (*off_cbytes < 0 || off_pos + *off_cbytes > frame->len) {
  ------------------
  |  Branch (2692:11): [True: 0, False: 4.00M]
  |  Branch (2692:30): [True: 24, False: 4.00M]
  ------------------
 2693|     24|        BLOSC_TRACE_ERROR("Cannot read the cbytes outside of frame boundary.");
  ------------------
  |  |   93|     24|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     24|    do {                                            \
  |  |  |  |   98|     24|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     24|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 24, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     24|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2694|     24|        return NULL;
 2695|     24|      }
 2696|  4.00M|      int32_t expected_off_nbytes;
 2697|  4.00M|      if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &expected_off_nbytes)) {
  ------------------
  |  Branch (2697:11): [True: 0, False: 4.00M]
  ------------------
 2698|      0|        BLOSC_TRACE_ERROR("Too many chunks for offsets representation.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2699|      0|        return NULL;
 2700|      0|      }
 2701|  4.00M|      if (chunk_nbytes != expected_off_nbytes) {
  ------------------
  |  Branch (2701:11): [True: 24, False: 4.00M]
  ------------------
 2702|     24|        BLOSC_TRACE_ERROR("The number of chunks in offset idx "
  ------------------
  |  |   93|     24|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     24|    do {                                            \
  |  |  |  |   98|     24|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     24|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 24, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     24|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2703|     24|                          "does not match the ones in the header frame.");
 2704|     24|        return NULL;
 2705|     24|      }
 2706|       |
 2707|  4.00M|    }
 2708|  4.00M|    return off_start;
 2709|  4.00M|  }
 2710|       |
 2711|      0|  int64_t trailer_offset = get_trailer_offset(frame, header_len, true);
 2712|       |
 2713|      0|  if (trailer_offset < BLOSC_EXTENDED_HEADER_LENGTH || trailer_offset + FRAME_TRAILER_MINLEN > frame->len) {
  ------------------
  |  |   58|      0|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
  |  Branch (2713:7): [True: 0, False: 0]
  |  Branch (2713:56): [True: 0, False: 0]
  ------------------
 2714|      0|    BLOSC_TRACE_ERROR("Cannot read the trailer out of the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2715|      0|    return NULL;
 2716|      0|  }
 2717|       |
 2718|      0|  int64_t coffsets_cbytes64;
 2719|      0|  if (frame->sframe) {
  ------------------
  |  Branch (2719:7): [True: 0, False: 0]
  ------------------
 2720|      0|    coffsets_cbytes64 = trailer_offset - header_len;
 2721|      0|  }
 2722|      0|  else {
 2723|      0|    coffsets_cbytes64 = trailer_offset - (header_len + cbytes);
 2724|      0|  }
 2725|      0|  if (coffsets_cbytes64 <= 0 || coffsets_cbytes64 > INT32_MAX) {
  ------------------
  |  Branch (2725:7): [True: 0, False: 0]
  |  Branch (2725:33): [True: 0, False: 0]
  ------------------
 2726|      0|    BLOSC_TRACE_ERROR("Offsets chunk size is out of bounds.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2727|      0|    return NULL;
 2728|      0|  }
 2729|      0|  int32_t coffsets_cbytes = (int32_t)coffsets_cbytes64;
 2730|       |
 2731|      0|  if (off_cbytes != NULL) {
  ------------------
  |  Branch (2731:7): [True: 0, False: 0]
  ------------------
 2732|      0|    *off_cbytes = coffsets_cbytes;
 2733|      0|  }
 2734|       |
 2735|      0|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 2736|      0|  if (io_cb == NULL) {
  ------------------
  |  Branch (2736:7): [True: 0, False: 0]
  ------------------
 2737|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2738|      0|    return NULL;
 2739|      0|  }
 2740|       |
 2741|      0|  void* fp = NULL;
 2742|      0|  uint8_t* coffsets;
 2743|      0|  if (io_cb->is_allocation_necessary) {
  ------------------
  |  Branch (2743:7): [True: 0, False: 0]
  ------------------
 2744|      0|    coffsets = malloc((size_t)coffsets_cbytes);
 2745|      0|    frame->coffsets_needs_free = true;
 2746|      0|  }
 2747|      0|  else {
 2748|      0|    frame->coffsets_needs_free = false;
 2749|      0|  }
 2750|       |
 2751|      0|  int64_t io_pos = 0;
 2752|      0|  if (frame->sframe) {
  ------------------
  |  Branch (2752:7): [True: 0, False: 0]
  ------------------
 2753|      0|    fp = sframe_open_index(frame->urlpath, "rb",
 2754|      0|                           frame->schunk->storage->io);
 2755|      0|    if (fp == NULL) {
  ------------------
  |  Branch (2755:9): [True: 0, False: 0]
  ------------------
 2756|      0|      BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2757|      0|      return NULL;
 2758|      0|    }
 2759|      0|    io_pos = header_len + 0;
 2760|      0|  }
 2761|      0|  else {
 2762|      0|    fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 2763|      0|    if (fp == NULL) {
  ------------------
  |  Branch (2763:9): [True: 0, False: 0]
  ------------------
 2764|      0|      BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2765|      0|      return NULL;
 2766|      0|    }
 2767|      0|    io_pos = frame->file_offset + header_len + cbytes;
 2768|      0|  }
 2769|      0|  int64_t rbytes = io_cb->read((void**)&coffsets, 1, coffsets_cbytes, io_pos, fp);
 2770|      0|  frame_reader_release(frame, io_cb, fp);
 2771|      0|  if (rbytes != coffsets_cbytes) {
  ------------------
  |  Branch (2771:7): [True: 0, False: 0]
  ------------------
 2772|      0|    BLOSC_TRACE_ERROR("Cannot read the offsets out of the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2773|      0|    if (frame->coffsets_needs_free)
  ------------------
  |  Branch (2773:9): [True: 0, False: 0]
  ------------------
 2774|      0|      free(coffsets);
 2775|      0|    return NULL;
 2776|      0|  }
 2777|      0|  frame->coffsets = coffsets;
 2778|      0|  return coffsets;
 2779|      0|}
frame_update_header:
 2839|  1.15M|int frame_update_header(blosc2_frame_s* frame, blosc2_schunk* schunk, bool new) {
 2840|  1.15M|  uint8_t* framep = frame->cframe;
 2841|  1.15M|  uint8_t* header_ptr;
 2842|  1.15M|  uint8_t header[FRAME_HEADER_MINLEN];
 2843|       |
 2844|  1.15M|  if (frame->len <= 0) {
  ------------------
  |  Branch (2844:7): [True: 0, False: 1.15M]
  ------------------
 2845|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2846|      0|  }
 2847|       |
 2848|  1.15M|  if (new && schunk->cbytes > 0) {
  ------------------
  |  Branch (2848:7): [True: 2.94k, False: 1.15M]
  |  Branch (2848:14): [True: 0, False: 2.94k]
  ------------------
 2849|      0|    BLOSC_TRACE_ERROR("New metalayers cannot be added after actual data "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2850|      0|                      "has been appended.");
 2851|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2852|      0|  }
 2853|       |
 2854|  1.15M|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 2855|  1.15M|  if (io_cb == NULL) {
  ------------------
  |  Branch (2855:7): [True: 0, False: 1.15M]
  ------------------
 2856|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2857|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 2858|      0|  }
 2859|       |
 2860|  1.15M|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (2860:7): [True: 0, False: 1.15M]
  ------------------
 2861|      0|    int64_t rbytes = 0;
 2862|      0|    void* fp = NULL;
 2863|      0|    int64_t io_pos = 0;
 2864|      0|    if (frame->sframe) {
  ------------------
  |  Branch (2864:9): [True: 0, False: 0]
  ------------------
 2865|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 2866|      0|                             frame->schunk->storage->io);
 2867|      0|      if (fp == NULL) {
  ------------------
  |  Branch (2867:11): [True: 0, False: 0]
  ------------------
 2868|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2869|      0|        return BLOSC2_ERROR_FILE_OPEN;
 2870|      0|      }
 2871|      0|    }
 2872|      0|    else {
 2873|      0|      frame_reader_revalidate(frame);
 2874|      0|      fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 2875|      0|      if (fp == NULL) {
  ------------------
  |  Branch (2875:11): [True: 0, False: 0]
  ------------------
 2876|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2877|      0|        return BLOSC2_ERROR_FILE_OPEN;
 2878|      0|      }
 2879|      0|      io_pos = frame->file_offset;
 2880|      0|    }
 2881|      0|    if (fp != NULL) {
  ------------------
  |  Branch (2881:9): [True: 0, False: 0]
  ------------------
 2882|      0|      if (io_cb->is_allocation_necessary)
  ------------------
  |  Branch (2882:11): [True: 0, False: 0]
  ------------------
 2883|      0|        header_ptr = header;
 2884|      0|      rbytes = io_cb->read((void**)&header_ptr, 1, FRAME_HEADER_MINLEN, io_pos, fp);
  ------------------
  |  |   49|      0|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|      0|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|      0|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|      0|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|      0|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|      0|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|      0|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|      0|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|      0|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|      0|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2885|      0|      frame_reader_release(frame, io_cb, fp);
 2886|      0|    }
 2887|      0|    (void) rbytes;
 2888|      0|    if (rbytes != FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|      0|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|      0|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|      0|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|      0|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|      0|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|      0|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|      0|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|      0|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|      0|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|      0|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2888:9): [True: 0, False: 0]
  ------------------
 2889|      0|      return BLOSC2_ERROR_FILE_WRITE;
 2890|      0|    }
 2891|      0|    framep = header_ptr;
 2892|      0|  }
 2893|  1.15M|  uint32_t prev_h2len;
 2894|  1.15M|  from_big(&prev_h2len, framep + FRAME_HEADER_LEN, sizeof(prev_h2len));
  ------------------
  |  |   38|  1.15M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2895|       |
 2896|       |  // Build a new header
 2897|  1.15M|  uint8_t* h2 = new_header_frame(schunk, frame);
 2898|  1.15M|  if (h2 == NULL) {
  ------------------
  |  Branch (2898:7): [True: 0, False: 1.15M]
  ------------------
 2899|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2900|      0|  }
 2901|  1.15M|  uint32_t h2len;
 2902|  1.15M|  from_big(&h2len, h2 + FRAME_HEADER_LEN, sizeof(h2len));
  ------------------
  |  |   38|  1.15M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2903|       |
 2904|       |  // The frame length is outdated when adding a new metalayer, so update it
 2905|  1.15M|  if (new) {
  ------------------
  |  Branch (2905:7): [True: 2.94k, False: 1.15M]
  ------------------
 2906|  2.94k|    int64_t frame_len = h2len;  // at adding time, we only have to worry of the header for now
 2907|  2.94k|    to_big(h2 + FRAME_LEN, &frame_len, sizeof(frame_len));
  ------------------
  |  |   37|  2.94k|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 2908|  2.94k|    frame->len = frame_len;
 2909|  2.94k|  }
 2910|       |
 2911|  1.15M|  if (!new && prev_h2len != h2len) {
  ------------------
  |  Branch (2911:7): [True: 1.15M, False: 2.94k]
  |  Branch (2911:15): [True: 0, False: 1.15M]
  ------------------
 2912|      0|    BLOSC_TRACE_ERROR("The new metalayer sizes should be equal the existing ones.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2913|      0|    free(h2);
 2914|      0|    return BLOSC2_ERROR_DATA;
 2915|      0|  }
 2916|       |
 2917|  1.15M|  void* fp = NULL;
 2918|  1.15M|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (2918:7): [True: 0, False: 1.15M]
  ------------------
 2919|       |    // Write updated header down to file
 2920|      0|    if (frame->sframe) {
  ------------------
  |  Branch (2920:9): [True: 0, False: 0]
  ------------------
 2921|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 2922|      0|                             frame->schunk->storage->io);
 2923|      0|    }
 2924|      0|    else {
 2925|      0|      fp = frame_writer_acquire(frame, io_cb);
 2926|      0|    }
 2927|      0|    if (fp == NULL) {
  ------------------
  |  Branch (2927:9): [True: 0, False: 0]
  ------------------
 2928|      0|      BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2929|      0|      free(h2);
 2930|      0|      return BLOSC2_ERROR_FILE_OPEN;
 2931|      0|    }
 2932|      0|    int64_t io_pos = frame->file_offset;
 2933|      0|    int64_t wbytes = io_cb->write(h2, h2len, 1, io_pos, fp);
 2934|      0|    int close_rc = frame_writer_release(frame, io_cb, fp);
 2935|      0|    if (wbytes != 1) {
  ------------------
  |  Branch (2935:9): [True: 0, False: 0]
  ------------------
 2936|      0|      BLOSC_TRACE_ERROR("Cannot write the header to %s.", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2937|      0|      free(h2);
 2938|      0|      return BLOSC2_ERROR_FILE_WRITE;
 2939|      0|    }
 2940|      0|    if (close_rc < 0) {
  ------------------
  |  Branch (2940:9): [True: 0, False: 0]
  ------------------
 2941|      0|      free(h2);
 2942|      0|      return close_rc;
 2943|      0|    }
 2944|      0|  }
 2945|  1.15M|  else {
 2946|  1.15M|    if (new) {
  ------------------
  |  Branch (2946:9): [True: 2.94k, False: 1.15M]
  ------------------
 2947|  2.94k|      void *new_cframe = realloc(frame->cframe, h2len);
 2948|  2.94k|      if (new_cframe == NULL) {
  ------------------
  |  Branch (2948:11): [True: 0, False: 2.94k]
  ------------------
 2949|      0|        free(h2);
 2950|      0|        return BLOSC2_ERROR_MEMORY_ALLOC;
 2951|      0|      }
 2952|  2.94k|      frame->cframe = new_cframe;
 2953|  2.94k|    }
 2954|  1.15M|    memcpy(frame->cframe, h2, h2len);
 2955|  1.15M|  }
 2956|  1.15M|  free(h2);
 2957|       |
 2958|  1.15M|  return 1;
 2959|  1.15M|}
frame_get_metalayers:
 3088|  1.60k|int frame_get_metalayers(blosc2_frame_s* frame, blosc2_schunk* schunk) {
 3089|  1.60k|  int32_t header_len;
 3090|  1.60k|  int64_t frame_len;
 3091|  1.60k|  int64_t nbytes;
 3092|  1.60k|  int64_t cbytes;
 3093|  1.60k|  int32_t blocksize;
 3094|  1.60k|  int32_t chunksize;
 3095|  1.60k|  int64_t nchunks;
 3096|  1.60k|  int ret = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 3097|  1.60k|                            &blocksize, &chunksize, &nchunks,
 3098|  1.60k|                            NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 3099|  1.60k|                            schunk->storage->io);
 3100|  1.60k|  if (ret < 0) {
  ------------------
  |  Branch (3100:7): [True: 0, False: 1.60k]
  ------------------
 3101|      0|    BLOSC_TRACE_ERROR("Unable to get the header info from frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3102|      0|    return ret;
 3103|      0|  }
 3104|       |
 3105|       |  // Get the header
 3106|  1.60k|  uint8_t* header = NULL;
 3107|  1.60k|  bool needs_free = false;
 3108|  1.60k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (3108:7): [True: 1.60k, False: 0]
  ------------------
 3109|  1.60k|    header = frame->cframe;
 3110|  1.60k|  } else {
 3111|      0|    int64_t rbytes = 0;
 3112|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 3113|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (3113:9): [True: 0, False: 0]
  ------------------
 3114|      0|      BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3115|      0|      return BLOSC2_ERROR_PLUGIN_IO;
 3116|      0|    }
 3117|       |
 3118|      0|    if (io_cb->is_allocation_necessary) {
  ------------------
  |  Branch (3118:9): [True: 0, False: 0]
  ------------------
 3119|      0|      header = malloc(header_len);
 3120|      0|      needs_free = true;
 3121|      0|    }
 3122|      0|    else {
 3123|      0|      needs_free = false;
 3124|      0|    }
 3125|       |
 3126|      0|    void* fp = NULL;
 3127|      0|    int64_t io_pos = 0;
 3128|      0|    if (frame->sframe) {
  ------------------
  |  Branch (3128:9): [True: 0, False: 0]
  ------------------
 3129|      0|      fp = sframe_open_index(frame->urlpath, "rb",
 3130|      0|                             frame->schunk->storage->io);
 3131|      0|      if (fp == NULL) {
  ------------------
  |  Branch (3131:11): [True: 0, False: 0]
  ------------------
 3132|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3133|      0|        return BLOSC2_ERROR_FILE_OPEN;
 3134|      0|      }
 3135|      0|    }
 3136|      0|    else {
 3137|      0|      fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 3138|      0|      if (fp == NULL) {
  ------------------
  |  Branch (3138:11): [True: 0, False: 0]
  ------------------
 3139|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3140|      0|        return BLOSC2_ERROR_FILE_OPEN;
 3141|      0|      }
 3142|      0|      io_pos = frame->file_offset;
 3143|      0|    }
 3144|      0|    if (fp != NULL) {
  ------------------
  |  Branch (3144:9): [True: 0, False: 0]
  ------------------
 3145|      0|      rbytes = io_cb->read((void**)&header, 1, header_len, io_pos, fp);
 3146|      0|      frame_reader_release(frame, io_cb, fp);
 3147|      0|    }
 3148|      0|    if (rbytes != header_len) {
  ------------------
  |  Branch (3148:9): [True: 0, False: 0]
  ------------------
 3149|      0|      BLOSC_TRACE_ERROR("Cannot access the header out of the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3150|      0|      if (needs_free)
  ------------------
  |  Branch (3150:11): [True: 0, False: 0]
  ------------------
 3151|      0|        free(header);
 3152|      0|      return BLOSC2_ERROR_FILE_READ;
 3153|      0|    }
 3154|      0|  }
 3155|       |
 3156|  1.60k|  ret = get_meta_from_header(frame, schunk, header, header_len);
 3157|       |
 3158|  1.60k|  if (frame->cframe == NULL && needs_free) {
  ------------------
  |  Branch (3158:7): [True: 0, False: 1.60k]
  |  Branch (3158:32): [True: 0, False: 0]
  ------------------
 3159|      0|    free(header);
 3160|      0|  }
 3161|       |
 3162|  1.60k|  return ret;
 3163|  1.60k|}
frame_get_vlmetalayers:
 3299|  1.53k|int frame_get_vlmetalayers(blosc2_frame_s* frame, blosc2_schunk* schunk) {
 3300|  1.53k|  int32_t header_len;
 3301|  1.53k|  int64_t frame_len;
 3302|  1.53k|  int64_t nbytes;
 3303|  1.53k|  int64_t cbytes;
 3304|  1.53k|  int32_t blocksize;
 3305|  1.53k|  int32_t chunksize;
 3306|  1.53k|  int64_t nchunks;
 3307|  1.53k|  int ret = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 3308|  1.53k|                            &blocksize, &chunksize, &nchunks,
 3309|  1.53k|                            NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 3310|  1.53k|                            schunk->storage->io);
 3311|  1.53k|  if (ret < 0) {
  ------------------
  |  Branch (3311:7): [True: 0, False: 1.53k]
  ------------------
 3312|      0|    BLOSC_TRACE_ERROR("Unable to get the trailer info from frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3313|      0|    return ret;
 3314|      0|  }
 3315|       |
 3316|  1.53k|  int64_t trailer_offset = get_trailer_offset(frame, header_len, nbytes > 0);
 3317|  1.53k|  int32_t trailer_len = (int32_t) frame->trailer_len;
 3318|       |
 3319|  1.53k|  if (trailer_offset < BLOSC_EXTENDED_HEADER_LENGTH || trailer_offset + trailer_len > frame->len) {
  ------------------
  |  Branch (3319:7): [True: 0, False: 1.53k]
  |  Branch (3319:56): [True: 3, False: 1.53k]
  ------------------
 3320|      3|    BLOSC_TRACE_ERROR("Cannot access the trailer out of the frame.");
  ------------------
  |  |   93|      3|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      3|    do {                                            \
  |  |  |  |   98|      3|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      3|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      3|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3321|      3|    return BLOSC2_ERROR_READ_BUFFER;
 3322|      3|  }
 3323|       |
 3324|       |  // Get the trailer
 3325|  1.53k|  uint8_t* trailer = NULL;
 3326|  1.53k|  bool needs_free = false;
 3327|  1.53k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (3327:7): [True: 1.53k, False: 0]
  ------------------
 3328|  1.53k|    trailer = frame->cframe + trailer_offset;
 3329|  1.53k|  } else {
 3330|      0|    int64_t rbytes = 0;
 3331|       |
 3332|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 3333|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (3333:9): [True: 0, False: 0]
  ------------------
 3334|      0|      BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3335|      0|      return BLOSC2_ERROR_PLUGIN_IO;
 3336|      0|    }
 3337|       |
 3338|      0|    if (io_cb->is_allocation_necessary) {
  ------------------
  |  Branch (3338:9): [True: 0, False: 0]
  ------------------
 3339|      0|      trailer = malloc(trailer_len);
 3340|      0|      needs_free = true;
 3341|      0|    }
 3342|      0|    else {
 3343|      0|      needs_free = false;
 3344|      0|    }
 3345|       |
 3346|      0|    void* fp = NULL;
 3347|      0|    int64_t io_pos = 0;
 3348|      0|    if (frame->sframe) {
  ------------------
  |  Branch (3348:9): [True: 0, False: 0]
  ------------------
 3349|       |      // Check for overflow before calculating length
 3350|      0|      if (strlen(frame->urlpath) > SIZE_MAX - strlen("/chunks.b2frame") - 1) {
  ------------------
  |  Branch (3350:11): [True: 0, False: 0]
  ------------------
 3351|      0|        BLOSC_TRACE_ERROR("Path too long for frame filename.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3352|      0|        if (needs_free) free(trailer);
  ------------------
  |  Branch (3352:13): [True: 0, False: 0]
  ------------------
 3353|      0|        return BLOSC2_ERROR_INVALID_PARAM;
 3354|      0|      }
 3355|      0|      size_t _len = strlen(frame->urlpath) + strlen("/chunks.b2frame") + 1;
 3356|      0|      char* eframe_name = malloc(_len);
 3357|      0|      if (eframe_name == NULL) {
  ------------------
  |  Branch (3357:11): [True: 0, False: 0]
  ------------------
 3358|      0|        BLOSC_TRACE_ERROR("Unable to allocate memory for frame filename.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3359|      0|        if (needs_free) free(trailer);
  ------------------
  |  Branch (3359:13): [True: 0, False: 0]
  ------------------
 3360|      0|        return BLOSC2_ERROR_MEMORY_ALLOC;
 3361|      0|      }
 3362|      0|      int _w = snprintf(eframe_name, _len, "%s/chunks.b2frame", frame->urlpath);
 3363|      0|      if (_w < 0 || (size_t)_w >= _len) {
  ------------------
  |  Branch (3363:11): [True: 0, False: 0]
  |  Branch (3363:21): [True: 0, False: 0]
  ------------------
 3364|      0|        BLOSC_TRACE_ERROR("Error building frame filename");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3365|      0|        free(eframe_name);
 3366|      0|        if (needs_free) free(trailer);
  ------------------
  |  Branch (3366:13): [True: 0, False: 0]
  ------------------
 3367|      0|        return BLOSC2_ERROR_INVALID_PARAM;
 3368|      0|      }
 3369|      0|      fp = io_cb->open(eframe_name, "rb", frame->schunk->storage->io->params);
 3370|      0|      if (fp == NULL) {
  ------------------
  |  Branch (3370:11): [True: 0, False: 0]
  ------------------
 3371|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", eframe_name);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3372|      0|        free(eframe_name);
 3373|      0|        return BLOSC2_ERROR_FILE_OPEN;
 3374|      0|      }
 3375|      0|      free(eframe_name);
 3376|      0|      io_pos = trailer_offset;
 3377|      0|    }
 3378|      0|    else {
 3379|      0|      fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 3380|      0|      if (fp == NULL) {
  ------------------
  |  Branch (3380:11): [True: 0, False: 0]
  ------------------
 3381|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3382|      0|        return BLOSC2_ERROR_FILE_OPEN;
 3383|      0|      }
 3384|      0|      io_pos = frame->file_offset + trailer_offset;
 3385|      0|    }
 3386|      0|    if (fp != NULL) {
  ------------------
  |  Branch (3386:9): [True: 0, False: 0]
  ------------------
 3387|      0|      rbytes = io_cb->read((void**)&trailer, 1, trailer_len, io_pos, fp);
 3388|      0|      frame_reader_release(frame, io_cb, fp);
 3389|      0|    }
 3390|      0|    if (rbytes != trailer_len) {
  ------------------
  |  Branch (3390:9): [True: 0, False: 0]
  ------------------
 3391|      0|      BLOSC_TRACE_ERROR("Cannot access the trailer out of the fileframe.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3392|      0|      if (needs_free)
  ------------------
  |  Branch (3392:11): [True: 0, False: 0]
  ------------------
 3393|      0|        free(trailer);
 3394|      0|      return BLOSC2_ERROR_FILE_READ;
 3395|      0|    }
 3396|      0|  }
 3397|       |
 3398|  1.53k|  ret = get_vlmeta_from_trailer(frame, schunk, trailer, trailer_len);
 3399|       |
 3400|  1.53k|  if (frame->cframe == NULL && needs_free) {
  ------------------
  |  Branch (3400:7): [True: 0, False: 1.53k]
  |  Branch (3400:32): [True: 0, False: 0]
  ------------------
 3401|      0|    free(trailer);
 3402|      0|  }
 3403|       |
 3404|  1.53k|  return ret;
 3405|  1.53k|}
get_new_storage:
 3411|  10.1k|                                const blosc2_io* iodefaults) {
 3412|       |
 3413|  10.1k|  blosc2_storage* new_storage = (blosc2_storage*)calloc(1, sizeof(blosc2_storage));
 3414|  10.1k|  memcpy(new_storage, storage, sizeof(blosc2_storage));
 3415|  10.1k|  if (storage->urlpath != NULL) {
  ------------------
  |  Branch (3415:7): [True: 0, False: 10.1k]
  ------------------
 3416|      0|    char* urlpath = normalize_urlpath(storage->urlpath);
 3417|      0|    new_storage->urlpath = malloc(strlen(urlpath) + 1);
 3418|      0|    strcpy(new_storage->urlpath, urlpath);
 3419|      0|  }
 3420|       |
 3421|       |  // cparams
 3422|  10.1k|  blosc2_cparams* cparams = malloc(sizeof(blosc2_cparams));
 3423|  10.1k|  if (storage->cparams != NULL) {
  ------------------
  |  Branch (3423:7): [True: 7.20k, False: 2.95k]
  ------------------
 3424|  7.20k|    memcpy(cparams, storage->cparams, sizeof(blosc2_cparams));
 3425|  7.20k|  } else {
 3426|  2.95k|    memcpy(cparams, cdefaults, sizeof(blosc2_cparams));
 3427|  2.95k|  }
 3428|  10.1k|  new_storage->cparams = cparams;
 3429|       |
 3430|       |  // dparams
 3431|  10.1k|  blosc2_dparams* dparams = malloc(sizeof(blosc2_dparams));
 3432|  10.1k|  if (storage->dparams != NULL) {
  ------------------
  |  Branch (3432:7): [True: 7.20k, False: 2.95k]
  ------------------
 3433|  7.20k|    memcpy(dparams, storage->dparams, sizeof(blosc2_dparams));
 3434|  7.20k|  }
 3435|  2.95k|  else {
 3436|  2.95k|    memcpy(dparams, ddefaults, sizeof(blosc2_dparams));
 3437|  2.95k|  }
 3438|  10.1k|  new_storage->dparams = dparams;
 3439|       |
 3440|       |  // iodefaults
 3441|  10.1k|  blosc2_io* udio = malloc(sizeof(blosc2_io));
 3442|  10.1k|  if (storage->io != NULL) {
  ------------------
  |  Branch (3442:7): [True: 0, False: 10.1k]
  ------------------
 3443|      0|    memcpy(udio, storage->io, sizeof(blosc2_io));
 3444|      0|  }
 3445|  10.1k|  else {
 3446|  10.1k|    memcpy(udio, iodefaults, sizeof(blosc2_io));
 3447|  10.1k|  }
 3448|  10.1k|  new_storage->io = udio;
 3449|       |
 3450|  10.1k|  return new_storage;
 3451|  10.1k|}
frame_to_schunk:
 3515|  3.37k|blosc2_schunk* frame_to_schunk(blosc2_frame_s* frame, bool copy, const blosc2_io *udio) {
 3516|  3.37k|  int32_t header_len;
 3517|  3.37k|  int64_t frame_len;
 3518|  3.37k|  int rc;
 3519|  3.37k|  bool frame_attached = true;
 3520|  3.37k|  blosc2_schunk* schunk = calloc(1, sizeof(blosc2_schunk));
 3521|  3.37k|  blosc2_cparams *cparams = NULL;
 3522|  3.37k|  blosc2_dparams *dparams = NULL;
 3523|  3.37k|  int64_t *offsets = NULL;
 3524|  3.37k|  if (schunk == NULL) {
  ------------------
  |  Branch (3524:7): [True: 0, False: 3.37k]
  ------------------
 3525|      0|    return NULL;
 3526|      0|  }
 3527|  3.37k|  schunk->frame = (blosc2_frame*)frame;
 3528|  3.37k|  frame->schunk = schunk;
 3529|       |
 3530|  3.37k|  rc = get_header_info(frame, &header_len, &frame_len, &schunk->nbytes,
 3531|  3.37k|                       &schunk->cbytes, &schunk->blocksize,
 3532|  3.37k|                       &schunk->chunksize, &schunk->nchunks, &schunk->typesize,
 3533|  3.37k|                       &schunk->compcode, &schunk->compcode_meta, &schunk->clevel, schunk->filters,
 3534|  3.37k|                       schunk->filters_meta, &schunk->splitmode, &schunk->use_dict, udio);
 3535|  3.37k|  if (rc < 0) {
  ------------------
  |  Branch (3535:7): [True: 402, False: 2.97k]
  ------------------
 3536|    402|    BLOSC_TRACE_ERROR("Unable to get meta info from frame.");
  ------------------
  |  |   93|    402|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    402|    do {                                            \
  |  |  |  |   98|    402|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    402|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 402, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    402|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3537|    402|    goto error;
 3538|    402|  }
 3539|  2.97k|  int64_t nchunks = schunk->nchunks;
 3540|  2.97k|  int64_t nbytes = schunk->nbytes;
 3541|  2.97k|  (void) nbytes;
 3542|  2.97k|  int64_t cbytes = schunk->cbytes;
 3543|       |
 3544|       |  // Compression and decompression contexts
 3545|  2.97k|  blosc2_schunk_get_cparams(schunk, &cparams);
 3546|  2.97k|  schunk->cctx = blosc2_create_cctx(*cparams);
 3547|  2.97k|  if (schunk->cctx == NULL) {
  ------------------
  |  Branch (3547:7): [True: 18, False: 2.95k]
  ------------------
 3548|     18|    BLOSC_TRACE_ERROR("Error while creating the compression context");
  ------------------
  |  |   93|     18|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     18|    do {                                            \
  |  |  |  |   98|     18|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     18|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 18, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     18|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3549|     18|    goto error;
 3550|     18|  }
 3551|  2.95k|  blosc2_schunk_get_dparams(schunk, &dparams);
 3552|  2.95k|  schunk->dctx = blosc2_create_dctx(*dparams);
 3553|  2.95k|  if (schunk->dctx == NULL) {
  ------------------
  |  Branch (3553:7): [True: 0, False: 2.95k]
  ------------------
 3554|      0|    BLOSC_TRACE_ERROR("Error while creating the decompression context");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3555|      0|    goto error;
 3556|      0|  }
 3557|  2.95k|  blosc2_storage storage = {.contiguous = copy ? false : true};
  ------------------
  |  Branch (3557:43): [True: 0, False: 2.95k]
  ------------------
 3558|  2.95k|  schunk->storage = get_new_storage(&storage, cparams, dparams, udio);
 3559|  2.95k|  free(cparams);
 3560|  2.95k|  cparams = NULL;
 3561|  2.95k|  free(dparams);
 3562|  2.95k|  dparams = NULL;
 3563|  2.95k|  if (nchunks > 0) {
  ------------------
  |  Branch (3563:7): [True: 2.81k, False: 138]
  ------------------
 3564|  2.81k|    rc = validate_offsets_chunk(frame, header_len, cbytes, nchunks);
 3565|  2.81k|    if (rc < 0) {
  ------------------
  |  Branch (3565:9): [True: 1.29k, False: 1.51k]
  ------------------
 3566|  1.29k|      BLOSC_TRACE_ERROR("Cannot validate frame offsets.");
  ------------------
  |  |   93|  1.29k|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|  1.29k|    do {                                            \
  |  |  |  |   98|  1.29k|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|  1.29k|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1.29k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|  1.29k|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3567|  1.29k|      goto error;
 3568|  1.29k|    }
 3569|  2.81k|  }
 3570|  1.65k|  if (nchunks > 0) {
  ------------------
  |  Branch (3570:7): [True: 1.51k, False: 138]
  ------------------
 3571|  1.51k|    uint8_t *chunk;
 3572|  1.51k|    bool needs_free;
 3573|       |    // A lazy chunk is enough here: only the header is needed for the flags2 byte
 3574|  1.51k|    rc = frame_get_lazychunk(frame, 0, &chunk, &needs_free);
 3575|  1.51k|    if (rc < 0) {
  ------------------
  |  Branch (3575:9): [True: 52, False: 1.46k]
  ------------------
 3576|     52|      BLOSC_TRACE_ERROR("Cannot inspect the first chunk in frame.");
  ------------------
  |  |   93|     52|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     52|    do {                                            \
  |  |  |  |   98|     52|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     52|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 52, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     52|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3577|     52|      goto error;
 3578|     52|    }
 3579|  1.46k|    schunk->flags2 = (rc >= BLOSC_EXTENDED_HEADER_LENGTH) ? chunk[BLOSC2_CHUNK_BLOSC2_FLAGS2] : 0;
  ------------------
  |  Branch (3579:22): [True: 1.46k, False: 0]
  ------------------
 3580|  1.46k|    if (needs_free) {
  ------------------
  |  Branch (3580:9): [True: 238, False: 1.22k]
  ------------------
 3581|    238|      free(chunk);
 3582|    238|    }
 3583|  1.46k|  }
 3584|  1.60k|  if (!copy) {
  ------------------
  |  Branch (3584:7): [True: 1.60k, False: 0]
  ------------------
 3585|  1.60k|    goto out;
 3586|  1.60k|  }
 3587|       |
 3588|       |  // We are not attached to a frame anymore
 3589|      0|  schunk->frame = NULL;
 3590|      0|  frame_attached = false;
 3591|       |
 3592|      0|  if (nchunks == 0) {
  ------------------
  |  Branch (3592:7): [True: 0, False: 0]
  ------------------
 3593|      0|    frame->schunk = NULL;
 3594|      0|    goto out;
 3595|      0|  }
 3596|       |
 3597|       |  // Get the compressed offsets
 3598|      0|  int32_t coffsets_cbytes = 0;
 3599|      0|  uint8_t* coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &coffsets_cbytes);
 3600|      0|  if (coffsets == NULL) {
  ------------------
  |  Branch (3600:7): [True: 0, False: 0]
  ------------------
 3601|      0|    BLOSC_TRACE_ERROR("Cannot get the offsets for the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3602|      0|    goto error;
 3603|      0|  }
 3604|       |
 3605|       |  // Decompress offsets
 3606|      0|  blosc2_dparams off_dparams = BLOSC2_DPARAMS_DEFAULTS;
 3607|      0|  blosc2_context *dctx = blosc2_create_dctx(off_dparams);
 3608|      0|  if (dctx == NULL) {
  ------------------
  |  Branch (3608:7): [True: 0, False: 0]
  ------------------
 3609|      0|    BLOSC_TRACE_ERROR("Error while creating the decompression context");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3610|      0|    goto error;
 3611|      0|  }
 3612|      0|  int32_t offsets_nbytes;
 3613|      0|  if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &offsets_nbytes)) {
  ------------------
  |  Branch (3613:7): [True: 0, False: 0]
  ------------------
 3614|      0|    blosc2_free_ctx(dctx);
 3615|      0|    BLOSC_TRACE_ERROR("Too many chunks for offsets representation.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3616|      0|    goto error;
 3617|      0|  }
 3618|      0|  offsets = (int64_t *) malloc((size_t)offsets_nbytes);
 3619|      0|  if (offsets == NULL) {
  ------------------
  |  Branch (3619:7): [True: 0, False: 0]
  ------------------
 3620|      0|    blosc2_free_ctx(dctx);
 3621|      0|    BLOSC_TRACE_ERROR("Cannot allocate memory for offsets.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3622|      0|    goto error;
 3623|      0|  }
 3624|      0|  int32_t off_nbytes = blosc2_decompress_ctx(dctx, coffsets, coffsets_cbytes,
 3625|      0|                                             offsets, offsets_nbytes);
 3626|      0|  blosc2_free_ctx(dctx);
 3627|      0|  if (off_nbytes < 0) {
  ------------------
  |  Branch (3627:7): [True: 0, False: 0]
  ------------------
 3628|      0|    BLOSC_TRACE_ERROR("Cannot decompress the offsets chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3629|      0|    goto error;
 3630|      0|  }
 3631|       |
 3632|       |  // We want the contiguous schunk, so create the actual data chunks (and, while doing this,
 3633|       |  // get a guess at the blocksize used in this frame)
 3634|      0|  int64_t acc_nbytes = 0;
 3635|      0|  int64_t acc_cbytes = 0;
 3636|      0|  int32_t blocksize = 0;
 3637|      0|  int32_t chunk_nbytes;
 3638|      0|  int32_t chunk_cbytes;
 3639|      0|  int32_t chunk_blocksize;
 3640|      0|  size_t prev_alloc = BLOSC_EXTENDED_HEADER_LENGTH;
 3641|      0|  uint8_t* data_chunk = NULL;
 3642|      0|  bool needs_free = false;
 3643|      0|  const blosc2_io_cb *io_cb = blosc2_get_io_cb(udio->id);
 3644|      0|  if (io_cb == NULL) {
  ------------------
  |  Branch (3644:7): [True: 0, False: 0]
  ------------------
 3645|      0|    blosc2_schunk_free(schunk);
 3646|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3647|      0|    return NULL;
 3648|      0|  }
 3649|       |
 3650|      0|  void* fp = NULL;
 3651|      0|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (3651:7): [True: 0, False: 0]
  ------------------
 3652|      0|    if (io_cb->is_allocation_necessary) {
  ------------------
  |  Branch (3652:9): [True: 0, False: 0]
  ------------------
 3653|      0|      data_chunk = malloc((size_t)prev_alloc);
 3654|      0|      needs_free = true;
 3655|      0|    }
 3656|      0|    else {
 3657|      0|      needs_free = false;
 3658|      0|    }
 3659|       |
 3660|      0|    if (!frame->sframe) {
  ------------------
  |  Branch (3660:9): [True: 0, False: 0]
  ------------------
 3661|       |      // If not the chunks won't be in the frame
 3662|      0|      fp = frame_reader_acquire(frame, udio);
 3663|      0|      if (fp == NULL) {
  ------------------
  |  Branch (3663:11): [True: 0, False: 0]
  ------------------
 3664|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3665|      0|        rc = BLOSC2_ERROR_FILE_OPEN;
 3666|      0|        goto end;
 3667|      0|      }
 3668|      0|    }
 3669|      0|  }
 3670|       |  /* calloc(): the loop below can stop at a bad chunk, and the error path frees
 3671|       |     every data[i] with i < nchunks, also the ones never set */
 3672|      0|  schunk->data = calloc(nchunks, sizeof(void*));
 3673|      0|  if (schunk->data == NULL && nchunks > 0) {
  ------------------
  |  Branch (3673:7): [True: 0, False: 0]
  |  Branch (3673:31): [True: 0, False: 0]
  ------------------
 3674|      0|    BLOSC_TRACE_ERROR("Cannot allocate the chunk pointers.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3675|      0|    rc = BLOSC2_ERROR_MEMORY_ALLOC;
 3676|      0|    goto end;
 3677|      0|  }
 3678|      0|  for (int64_t i = 0; i < nchunks; i++) {
  ------------------
  |  Branch (3678:23): [True: 0, False: 0]
  ------------------
 3679|      0|    if (frame->cframe != NULL) {
  ------------------
  |  Branch (3679:9): [True: 0, False: 0]
  ------------------
 3680|      0|      if (needs_free) {
  ------------------
  |  Branch (3680:11): [True: 0, False: 0]
  ------------------
 3681|      0|        free(data_chunk);
 3682|      0|      }
 3683|      0|      if (offsets[i] < 0) {
  ------------------
  |  Branch (3683:11): [True: 0, False: 0]
  ------------------
 3684|      0|        int64_t rbytes = frame_get_chunk(frame, i, &data_chunk, &needs_free);
 3685|      0|        if (rbytes < 0) {
  ------------------
  |  Branch (3685:13): [True: 0, False: 0]
  ------------------
 3686|      0|          break;
 3687|      0|        }
 3688|      0|      }
 3689|      0|      else {
 3690|      0|        if (offsets[i] > INT64_MAX - header_len ||
  ------------------
  |  Branch (3690:13): [True: 0, False: 0]
  ------------------
 3691|      0|            header_len + offsets[i] > frame->len - BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (3691:13): [True: 0, False: 0]
  ------------------
 3692|      0|            offsets[i] > cbytes - BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (3692:13): [True: 0, False: 0]
  ------------------
 3693|      0|          rc = BLOSC2_ERROR_INVALID_HEADER;
 3694|      0|          break;
 3695|      0|        }
 3696|      0|        data_chunk = frame->cframe + header_len + offsets[i];
 3697|      0|        needs_free = false;
 3698|      0|      }
 3699|      0|      rc = blosc2_cbuffer_sizes(data_chunk, NULL, &chunk_cbytes, NULL);
 3700|      0|      if (rc < 0) {
  ------------------
  |  Branch (3700:11): [True: 0, False: 0]
  ------------------
 3701|      0|        break;
 3702|      0|      }
 3703|      0|      if (offsets[i] >= 0 &&
  ------------------
  |  Branch (3703:11): [True: 0, False: 0]
  ------------------
 3704|      0|          (chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (3704:12): [True: 0, False: 0]
  ------------------
 3705|      0|           offsets[i] > INT64_MAX - chunk_cbytes ||
  ------------------
  |  Branch (3705:12): [True: 0, False: 0]
  ------------------
 3706|      0|           offsets[i] + chunk_cbytes > cbytes)) {
  ------------------
  |  Branch (3706:12): [True: 0, False: 0]
  ------------------
 3707|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 3708|      0|        break;
 3709|      0|      }
 3710|      0|    }
 3711|      0|    else {
 3712|      0|      int64_t rbytes;
 3713|      0|      if (offsets[i] < 0 || frame->sframe) {
  ------------------
  |  Branch (3713:11): [True: 0, False: 0]
  |  Branch (3713:29): [True: 0, False: 0]
  ------------------
 3714|      0|        if (needs_free) {
  ------------------
  |  Branch (3714:13): [True: 0, False: 0]
  ------------------
 3715|      0|          free(data_chunk);
 3716|      0|        }
 3717|      0|        rbytes = frame_get_chunk(frame, i, &data_chunk, &needs_free);
 3718|      0|        if (rbytes < 0) {
  ------------------
  |  Branch (3718:13): [True: 0, False: 0]
  ------------------
 3719|      0|          break;
 3720|      0|        }
 3721|      0|      }
 3722|      0|      else {
 3723|      0|        if (offsets[i] > INT64_MAX - header_len ||
  ------------------
  |  Branch (3723:13): [True: 0, False: 0]
  ------------------
 3724|      0|            header_len + offsets[i] > frame->len - BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (3724:13): [True: 0, False: 0]
  ------------------
 3725|      0|            offsets[i] > cbytes - BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (3725:13): [True: 0, False: 0]
  ------------------
 3726|      0|          rc = BLOSC2_ERROR_INVALID_HEADER;
 3727|      0|          break;
 3728|      0|        }
 3729|      0|        int64_t io_pos = frame->file_offset + header_len + offsets[i];
 3730|      0|        rbytes = io_cb->read((void**)&data_chunk, 1, BLOSC_EXTENDED_HEADER_LENGTH, io_pos, fp);
 3731|      0|      }
 3732|      0|      if (rbytes != BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (3732:11): [True: 0, False: 0]
  ------------------
 3733|      0|        rc = BLOSC2_ERROR_READ_BUFFER;
 3734|      0|        break;
 3735|      0|      }
 3736|      0|      rc = blosc2_cbuffer_sizes(data_chunk, NULL, &chunk_cbytes, NULL);
 3737|      0|      if (rc < 0) {
  ------------------
  |  Branch (3737:11): [True: 0, False: 0]
  ------------------
 3738|      0|        break;
 3739|      0|      }
 3740|      0|      if (offsets[i] >= 0 &&
  ------------------
  |  Branch (3740:11): [True: 0, False: 0]
  ------------------
 3741|      0|          (chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (3741:12): [True: 0, False: 0]
  ------------------
 3742|      0|           offsets[i] > INT64_MAX - chunk_cbytes ||
  ------------------
  |  Branch (3742:12): [True: 0, False: 0]
  ------------------
 3743|      0|           offsets[i] + chunk_cbytes > cbytes)) {
  ------------------
  |  Branch (3743:12): [True: 0, False: 0]
  ------------------
 3744|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 3745|      0|        break;
 3746|      0|      }
 3747|      0|      if (chunk_cbytes > (int32_t)prev_alloc) {
  ------------------
  |  Branch (3747:11): [True: 0, False: 0]
  ------------------
 3748|      0|        if (io_cb->is_allocation_necessary)
  ------------------
  |  Branch (3748:13): [True: 0, False: 0]
  ------------------
 3749|      0|          data_chunk = realloc(data_chunk, chunk_cbytes);
 3750|      0|        if (data_chunk == NULL) {
  ------------------
  |  Branch (3750:13): [True: 0, False: 0]
  ------------------
 3751|      0|          BLOSC_TRACE_ERROR("Cannot realloc space for the data_chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3752|      0|          rc = BLOSC2_ERROR_MEMORY_ALLOC;
 3753|      0|          break;
 3754|      0|        }
 3755|      0|        prev_alloc = chunk_cbytes;
 3756|      0|      }
 3757|      0|      if (!frame->sframe) {
  ------------------
  |  Branch (3757:11): [True: 0, False: 0]
  ------------------
 3758|      0|        int64_t io_pos = frame->file_offset + header_len + offsets[i];
 3759|      0|        rbytes = io_cb->read((void**)&data_chunk, 1, chunk_cbytes, io_pos, fp);
 3760|      0|        if (rbytes != chunk_cbytes) {
  ------------------
  |  Branch (3760:13): [True: 0, False: 0]
  ------------------
 3761|      0|          rc = BLOSC2_ERROR_READ_BUFFER;
 3762|      0|          break;
 3763|      0|        }
 3764|      0|      }
 3765|      0|    }
 3766|      0|    uint8_t* new_chunk = malloc(chunk_cbytes);
 3767|      0|    memcpy(new_chunk, data_chunk, chunk_cbytes);
 3768|      0|    schunk->data[i] = new_chunk;
 3769|      0|    rc = blosc2_cbuffer_sizes(data_chunk, &chunk_nbytes, NULL, &chunk_blocksize);
 3770|      0|    if (rc < 0) {
  ------------------
  |  Branch (3770:9): [True: 0, False: 0]
  ------------------
 3771|      0|      break;
 3772|      0|    }
 3773|      0|    acc_nbytes += chunk_nbytes;
 3774|      0|    acc_cbytes += chunk_cbytes;
 3775|      0|    if (i == 0) {
  ------------------
  |  Branch (3775:9): [True: 0, False: 0]
  ------------------
 3776|      0|      blocksize = chunk_blocksize;
 3777|      0|    }
 3778|      0|    else if (blocksize != chunk_blocksize) {
  ------------------
  |  Branch (3778:14): [True: 0, False: 0]
  ------------------
 3779|       |      // Blocksize varies
 3780|      0|      blocksize = 0;
 3781|      0|    }
 3782|      0|  }
 3783|       |
 3784|       |  // We are not attached to a schunk anymore
 3785|      0|  frame->schunk = NULL;
 3786|       |
 3787|      0|  end:
 3788|      0|  if (needs_free) {
  ------------------
  |  Branch (3788:7): [True: 0, False: 0]
  ------------------
 3789|      0|    free(data_chunk);
 3790|      0|  }
 3791|      0|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (3791:7): [True: 0, False: 0]
  ------------------
 3792|      0|    if (!frame->sframe) {
  ------------------
  |  Branch (3792:9): [True: 0, False: 0]
  ------------------
 3793|      0|      frame_reader_release(frame, io_cb, fp);
 3794|      0|    }
 3795|      0|  }
 3796|      0|  free(offsets);
 3797|       |  // Avoid a double-free in the `error:` cleanup below, which is reached
 3798|       |  // when frame_get_metalayers / frame_get_vlmetalayers reject a malformed
 3799|       |  // metalayer index after we've already freed `offsets` here.
 3800|      0|  offsets = NULL;
 3801|       |
 3802|       |  // cframes and sframes have different ways to store chunks with special values:
 3803|       |  // 1) cframes represent special chunks as negative offsets
 3804|       |  // 2) sframes does not have the concept of offsets, but rather of data pointers (.data)
 3805|       |  //    so they always have a pointer to a special chunk
 3806|       |  // This is why cframes and sframes have different cbytes and hence, we cannot enforce acc_bytes == schunk->cbytes
 3807|       |  // In the future, maybe we could provide special meanings for .data[i] > 0x7FFFFFFF, but not there yet
 3808|       |  // if (rc < 0 || acc_nbytes != nbytes || acc_cbytes != cbytes) {
 3809|      0|  if (rc < 0 || acc_nbytes != nbytes) {
  ------------------
  |  Branch (3809:7): [True: 0, False: 0]
  |  Branch (3809:17): [True: 0, False: 0]
  ------------------
 3810|      0|    goto error;
 3811|      0|  }
 3812|       |  // Update counters
 3813|      0|  schunk->cbytes = acc_cbytes;
 3814|      0|  schunk->blocksize = blocksize;
 3815|       |
 3816|  1.60k|  out:
 3817|  1.60k|  rc = frame_get_metalayers(frame, schunk);
 3818|  1.60k|  if (rc < 0) {
  ------------------
  |  Branch (3818:7): [True: 69, False: 1.53k]
  ------------------
 3819|     69|    BLOSC_TRACE_ERROR("Cannot access the metalayers.");
  ------------------
  |  |   93|     69|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     69|    do {                                            \
  |  |  |  |   98|     69|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     69|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 69, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     69|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3820|     69|    goto error;
 3821|     69|  }
 3822|       |
 3823|  1.53k|  rc = frame_get_vlmetalayers(frame, schunk);
 3824|  1.53k|  if (rc < 0) {
  ------------------
  |  Branch (3824:7): [True: 62, False: 1.47k]
  ------------------
 3825|     62|    BLOSC_TRACE_ERROR("Cannot access the vlmetalayers.");
  ------------------
  |  |   93|     62|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     62|    do {                                            \
  |  |  |  |   98|     62|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     62|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 62, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     62|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3826|     62|    goto error;
 3827|     62|  }
 3828|       |
 3829|  1.47k|  return schunk;
 3830|       |
 3831|  1.90k|error:
 3832|  1.90k|  free(cparams);
 3833|  1.90k|  free(dparams);
 3834|  1.90k|  free(offsets);
 3835|  1.90k|  if (schunk != NULL) {
  ------------------
  |  Branch (3835:7): [True: 1.90k, False: 0]
  ------------------
 3836|  1.90k|    blosc2_schunk_free(schunk);
 3837|  1.90k|  }
 3838|  1.90k|  if (!frame_attached) {
  ------------------
  |  Branch (3838:7): [True: 0, False: 1.90k]
  ------------------
 3839|      0|    frame->schunk = NULL;
 3840|      0|    frame_free(frame);
 3841|      0|  }
 3842|       |  return NULL;
 3843|  1.53k|}
get_coffset:
 3865|  2.84M|                int64_t nchunk, int64_t nchunks, int64_t *offset) {
 3866|  2.84M|  int32_t off_cbytes;
 3867|       |  // Get the offset to nchunk
 3868|  2.84M|  uint8_t *coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &off_cbytes);
 3869|  2.84M|  if (coffsets == NULL) {
  ------------------
  |  Branch (3869:7): [True: 0, False: 2.84M]
  ------------------
 3870|      0|    BLOSC_TRACE_ERROR("Cannot get the offset for chunk %" PRId64 " for the frame.", nchunk);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3871|      0|    return BLOSC2_ERROR_DATA;
 3872|      0|  }
 3873|       |
 3874|       |  // Get the 64-bit offset
 3875|  2.84M|  int rc = blosc2_getitem(coffsets, off_cbytes, (int32_t)nchunk, 1, offset, (int32_t)sizeof(int64_t));
 3876|  2.84M|  if (rc < 0) {
  ------------------
  |  Branch (3876:7): [True: 11, False: 2.84M]
  ------------------
 3877|     11|    BLOSC_TRACE_ERROR("Problems retrieving a chunk offset.");
  ------------------
  |  |   93|     11|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     11|    do {                                            \
  |  |  |  |   98|     11|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     11|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     11|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3878|  2.84M|  } else if (!frame->sframe && *offset >= 0) {
  ------------------
  |  Branch (3878:14): [True: 2.84M, False: 0]
  |  Branch (3878:32): [True: 1.31M, False: 1.53M]
  ------------------
 3879|  1.31M|    if (cbytes < 0 || cbytes > INT64_MAX - header_len) {
  ------------------
  |  Branch (3879:9): [True: 0, False: 1.31M]
  |  Branch (3879:23): [True: 13, False: 1.31M]
  ------------------
 3880|     13|      BLOSC_TRACE_ERROR("Invalid compressed size in frame header.");
  ------------------
  |  |   93|     13|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     13|    do {                                            \
  |  |  |  |   98|     13|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     13|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     13|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3881|     13|      return BLOSC2_ERROR_INVALID_HEADER;
 3882|     13|    }
 3883|  1.31M|    if (*offset > INT64_MAX - header_len) {
  ------------------
  |  Branch (3883:9): [True: 0, False: 1.31M]
  ------------------
 3884|      0|      BLOSC_TRACE_ERROR("Offset for chunk %" PRId64 " overflows frame position.", nchunk);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3885|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 3886|      0|    }
 3887|  1.31M|    int64_t chunk_pos = header_len + *offset;
 3888|  1.31M|    int64_t data_limit = header_len + cbytes;
 3889|  1.31M|    if (chunk_pos < header_len ||
  ------------------
  |  Branch (3889:9): [True: 0, False: 1.31M]
  ------------------
 3890|  1.31M|        chunk_pos > data_limit - BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (3890:9): [True: 13, False: 1.31M]
  ------------------
 3891|  1.31M|        chunk_pos > frame->len - BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (3891:9): [True: 15, False: 1.31M]
  ------------------
 3892|     28|      BLOSC_TRACE_ERROR("Cannot read chunk %" PRId64 " outside of frame boundary.", nchunk);
  ------------------
  |  |   93|     28|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     28|    do {                                            \
  |  |  |  |   98|     28|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     28|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 28, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     28|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3893|     28|      return BLOSC2_ERROR_INVALID_HEADER;
 3894|     28|    }
 3895|  1.31M|  }
 3896|       |
 3897|  2.84M|  return rc;
 3898|  2.84M|}
frame_get_chunks_special:
 3969|  2.38k|int frame_get_chunks_special(blosc2_frame_s *frame, const int64_t *nchunks, int64_t n, uint8_t *special) {
 3970|  2.38k|  int64_t *off;
 3971|  2.38k|  int64_t lo;
 3972|  2.38k|  int64_t span_end;
 3973|  2.38k|  int32_t header_len;
 3974|  2.38k|  int64_t cbytes;
 3975|  2.38k|  int32_t chunksize;
 3976|  2.38k|  int rc = frame_read_index_span(frame, nchunks, n, 0, &off, &lo, &span_end, &header_len, &cbytes, &chunksize);
 3977|  2.38k|  if (rc < 0 || off == NULL) {
  ------------------
  |  Branch (3977:7): [True: 249, False: 2.13k]
  |  Branch (3977:17): [True: 0, False: 2.13k]
  ------------------
 3978|    249|    return rc;
 3979|    249|  }
 3980|   608k|  for (int64_t k = 0; k < n; ++k) {
  ------------------
  |  Branch (3980:23): [True: 606k, False: 2.13k]
  ------------------
 3981|   606k|    int64_t offset = off[nchunks[k] - lo];
 3982|   606k|    special[k] = offset < 0 ? (uint8_t) (((uint64_t) offset >> (8 * 7)) & BLOSC2_SPECIAL_MASK) : 0;
  ------------------
  |  Branch (3982:18): [True: 112k, False: 493k]
  ------------------
 3983|   606k|  }
 3984|  2.13k|  free(off);
 3985|  2.13k|  return BLOSC2_ERROR_SUCCESS;
 3986|  2.38k|}
frame_special_chunk:
 4081|  7.11k|                        uint8_t** chunk, int32_t cbytes, bool *needs_free) {
 4082|  7.11k|  *chunk = malloc(cbytes);
 4083|  7.11k|  *needs_free = true;
 4084|  7.11k|  int rc = *chunk == NULL ? BLOSC2_ERROR_MEMORY_ALLOC
  ------------------
  |  Branch (4084:12): [True: 0, False: 7.11k]
  ------------------
 4085|  7.11k|                          : special_chunk_into(special_value, nbytes, typesize, blocksize, *chunk, cbytes);
 4086|  7.11k|  if (rc < 0) {
  ------------------
  |  Branch (4086:7): [True: 0, False: 7.11k]
  ------------------
 4087|      0|    free(*chunk);
 4088|      0|    *needs_free = false;
 4089|      0|    *chunk = NULL;
 4090|      0|  }
 4091|       |
 4092|  7.11k|  return rc;
 4093|  7.11k|}
frame_get_lazychunk:
 4290|  61.6k|int frame_get_lazychunk(blosc2_frame_s *frame, int64_t nchunk, uint8_t **chunk, bool *needs_free) {
 4291|  61.6k|  int32_t header_len;
 4292|  61.6k|  int64_t frame_len;
 4293|  61.6k|  int64_t nbytes;
 4294|  61.6k|  int64_t cbytes;
 4295|  61.6k|  int32_t blocksize;
 4296|  61.6k|  int32_t chunksize;
 4297|  61.6k|  int64_t nchunks;
 4298|  61.6k|  int32_t typesize;
 4299|  61.6k|  int32_t lazychunk_cbytes;
 4300|  61.6k|  int64_t offset;
 4301|  61.6k|  void* fp = NULL;
 4302|  61.6k|  int32_t* block_csizes = NULL;
 4303|  61.6k|  struct csize_idx *csize_idx = NULL;
 4304|       |
 4305|  61.6k|  *chunk = NULL;
 4306|  61.6k|  *needs_free = false;
 4307|  61.6k|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 4308|  61.6k|                           &blocksize, &chunksize, &nchunks,
 4309|  61.6k|                           &typesize, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 4310|  61.6k|                           frame->schunk->storage->io);
 4311|  61.6k|  if (rc < 0) {
  ------------------
  |  Branch (4311:7): [True: 0, False: 61.6k]
  ------------------
 4312|      0|    BLOSC_TRACE_ERROR("Unable to get meta info from frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4313|      0|    return rc;
 4314|      0|  }
 4315|  61.6k|  rc = frame_refresh_if_stale(frame, frame_len);
 4316|  61.6k|  if (rc < 0) {
  ------------------
  |  Branch (4316:7): [True: 0, False: 61.6k]
  ------------------
 4317|      0|    BLOSC_TRACE_ERROR("Unable to refresh the frame state from disk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4318|      0|    return rc;
 4319|      0|  }
 4320|  61.6k|  if (rc > 0) {
  ------------------
  |  Branch (4320:7): [True: 0, False: 61.6k]
  ------------------
 4321|       |    // Keep the schunk-level counters in sync with the refreshed on-disk state
 4322|       |    // (see frame_get_chunk).
 4323|      0|    frame->schunk->nbytes = nbytes;
 4324|      0|    frame->schunk->cbytes = cbytes;
 4325|      0|    frame->schunk->nchunks = nchunks;
 4326|      0|  }
 4327|       |
 4328|  61.6k|  if (nchunk >= nchunks) {
  ------------------
  |  Branch (4328:7): [True: 0, False: 61.6k]
  ------------------
 4329|      0|    BLOSC_TRACE_ERROR("nchunk ('%" PRId64 "') exceeds the number of chunks "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4330|      0|                      "('%" PRId64 "') in frame.", nchunk, nchunks);
 4331|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4332|      0|  }
 4333|       |
 4334|       |  // Get the offset to nchunk
 4335|  61.6k|  rc = get_coffset(frame, header_len, cbytes, nchunk, nchunks, &offset);
 4336|  61.6k|  if (rc < 0) {
  ------------------
  |  Branch (4336:7): [True: 52, False: 61.5k]
  ------------------
 4337|     52|    BLOSC_TRACE_ERROR("Unable to get offset to chunk %" PRId64 ".", nchunk);
  ------------------
  |  |   93|     52|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     52|    do {                                            \
  |  |  |  |   98|     52|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     52|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 52, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     52|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4338|     52|    return rc;
 4339|     52|  }
 4340|       |
 4341|  61.5k|  if (offset < 0) {
  ------------------
  |  Branch (4341:7): [True: 356, False: 61.2k]
  ------------------
 4342|       |    // Special value
 4343|    356|    if (chunksize <= 0) {
  ------------------
  |  Branch (4343:9): [True: 0, False: 356]
  ------------------
 4344|      0|      BLOSC_TRACE_ERROR("Cannot synthesize special chunk with chunksize <= 0.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4345|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 4346|      0|    }
 4347|    356|    lazychunk_cbytes = BLOSC_EXTENDED_HEADER_LENGTH;
 4348|    356|    int32_t chunksize_ = chunksize;
 4349|    356|    if ((nchunk == nchunks - 1) && (nbytes % chunksize)) {
  ------------------
  |  Branch (4349:9): [True: 39, False: 317]
  |  Branch (4349:36): [True: 0, False: 39]
  ------------------
 4350|       |      // Last chunk is incomplete.  Compute its actual size.
 4351|      0|      chunksize_ = (int32_t) (nbytes % chunksize);
 4352|      0|    }
 4353|    356|    rc = frame_special_chunk(offset, chunksize_, typesize, blocksize, chunk,
 4354|    356|                             (int32_t)lazychunk_cbytes, needs_free);
 4355|    356|    goto end;
 4356|    356|  }
 4357|       |
 4358|  61.2k|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 4359|  61.2k|  if (io_cb == NULL) {
  ------------------
  |  Branch (4359:7): [True: 0, False: 61.2k]
  ------------------
 4360|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4361|      0|    rc = BLOSC2_ERROR_PLUGIN_IO;
 4362|      0|    goto end;
 4363|      0|  }
 4364|       |
 4365|  61.2k|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (4365:7): [True: 0, False: 61.2k]
  ------------------
 4366|       |    // TODO: make this portable across different endianness
 4367|       |    // Get info for building a lazy chunk
 4368|      0|    int32_t chunk_nbytes;
 4369|      0|    int32_t chunk_cbytes;
 4370|      0|    int32_t chunk_blocksize;
 4371|      0|    uint8_t* header_ptr;
 4372|      0|    uint8_t header[BLOSC_EXTENDED_HEADER_LENGTH];
 4373|      0|    int64_t io_pos = 0;
 4374|      0|    if (frame->sframe) {
  ------------------
  |  Branch (4374:9): [True: 0, False: 0]
  ------------------
 4375|       |      // The chunk is not in the frame
 4376|      0|      fp = sframe_open_chunk(frame->urlpath, offset, "rb",
 4377|      0|                             frame->schunk->storage->io);
 4378|      0|      if (fp == NULL) {
  ------------------
  |  Branch (4378:11): [True: 0, False: 0]
  ------------------
 4379|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4380|      0|        return BLOSC2_ERROR_FILE_OPEN;
 4381|      0|      }
 4382|      0|    }
 4383|      0|    else {
 4384|      0|      fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 4385|      0|      if (fp == NULL) {
  ------------------
  |  Branch (4385:11): [True: 0, False: 0]
  ------------------
 4386|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4387|      0|        return BLOSC2_ERROR_FILE_OPEN;
 4388|      0|      }
 4389|      0|      io_pos = frame->file_offset + header_len + offset;
 4390|      0|    }
 4391|      0|    if (io_cb->is_allocation_necessary)
  ------------------
  |  Branch (4391:9): [True: 0, False: 0]
  ------------------
 4392|      0|      header_ptr = header;
 4393|      0|    int64_t rbytes = io_cb->read((void**)&header_ptr, 1, BLOSC_EXTENDED_HEADER_LENGTH, io_pos, fp);
 4394|      0|    if (rbytes != BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (4394:9): [True: 0, False: 0]
  ------------------
 4395|      0|      BLOSC_TRACE_ERROR("Cannot read the header for chunk in the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4396|      0|      rc = BLOSC2_ERROR_FILE_READ;
 4397|      0|      goto end;
 4398|      0|    }
 4399|      0|    rc = blosc2_cbuffer_sizes(header_ptr, &chunk_nbytes, &chunk_cbytes, &chunk_blocksize);
 4400|      0|    if (rc < 0) {
  ------------------
  |  Branch (4400:9): [True: 0, False: 0]
  ------------------
 4401|      0|      goto end;
 4402|      0|    }
 4403|      0|    if (chunk_nbytes < 0 || chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH || chunk_blocksize <= 0) {
  ------------------
  |  Branch (4403:9): [True: 0, False: 0]
  |  Branch (4403:29): [True: 0, False: 0]
  |  Branch (4403:76): [True: 0, False: 0]
  ------------------
 4404|      0|      rc = BLOSC2_ERROR_INVALID_HEADER;
 4405|      0|      goto end;
 4406|      0|    }
 4407|      0|    bool vlblocks = (header_ptr[BLOSC2_CHUNK_BLOSC2_FLAGS2] & BLOSC2_VL_BLOCKS) != 0;
 4408|      0|    size_t nblocks;
 4409|      0|    size_t leftover_block = 0;
 4410|      0|    if (vlblocks) {
  ------------------
  |  Branch (4410:9): [True: 0, False: 0]
  ------------------
 4411|      0|      nblocks = (size_t)chunk_blocksize;
 4412|      0|    }
 4413|      0|    else {
 4414|      0|      nblocks = (size_t)chunk_nbytes / (size_t)chunk_blocksize;
 4415|      0|      leftover_block = (size_t)chunk_nbytes % (size_t)chunk_blocksize;
 4416|      0|      if (leftover_block) {
  ------------------
  |  Branch (4416:11): [True: 0, False: 0]
  ------------------
 4417|      0|        if (nblocks == SIZE_MAX) {
  ------------------
  |  Branch (4417:13): [True: 0, False: 0]
  ------------------
 4418|      0|          rc = BLOSC2_ERROR_INVALID_HEADER;
 4419|      0|          goto end;
 4420|      0|        }
 4421|      0|        nblocks += 1;
 4422|      0|      }
 4423|      0|    }
 4424|      0|    if (nblocks == 0 || nblocks > (size_t)INT_MAX) {
  ------------------
  |  Branch (4424:9): [True: 0, False: 0]
  |  Branch (4424:25): [True: 0, False: 0]
  ------------------
 4425|      0|      rc = BLOSC2_ERROR_INVALID_HEADER;
 4426|      0|      goto end;
 4427|      0|    }
 4428|       |    // Allocate space for the lazy chunk
 4429|      0|    int32_t special_type = (header_ptr[BLOSC2_CHUNK_BLOSC2_FLAGS] >> 4) & BLOSC2_SPECIAL_MASK;
 4430|      0|    int memcpyed = header_ptr[BLOSC2_CHUNK_FLAGS] & (uint8_t) BLOSC_MEMCPYED;
 4431|       |
 4432|      0|    int32_t trailer_offset;
 4433|      0|    size_t streams_offset = BLOSC_EXTENDED_HEADER_LENGTH;
 4434|      0|    size_t trailer_offset_sz = BLOSC_EXTENDED_HEADER_LENGTH;
 4435|      0|    size_t trailer_len_sz = 0;
 4436|      0|    size_t lazychunk_cbytes_sz = 0;
 4437|      0|    size_t bstarts_nbytes = 0;
 4438|      0|    if (special_type == 0) {
  ------------------
  |  Branch (4438:9): [True: 0, False: 0]
  ------------------
 4439|      0|      if (nblocks > SIZE_MAX / sizeof(int32_t)) {
  ------------------
  |  Branch (4439:11): [True: 0, False: 0]
  ------------------
 4440|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4441|      0|        goto end;
 4442|      0|      }
 4443|      0|      bstarts_nbytes = nblocks * sizeof(int32_t);
 4444|       |
 4445|      0|      if (!memcpyed) {
  ------------------
  |  Branch (4445:11): [True: 0, False: 0]
  ------------------
 4446|      0|        if ((size_t)chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (4446:13): [True: 0, False: 0]
  ------------------
 4447|      0|            bstarts_nbytes > (size_t)chunk_cbytes - BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (4447:13): [True: 0, False: 0]
  ------------------
 4448|      0|          rc = BLOSC2_ERROR_INVALID_HEADER;
 4449|      0|          goto end;
 4450|      0|        }
 4451|      0|      }
 4452|       |
 4453|      0|      if (bstarts_nbytes > SIZE_MAX - trailer_offset_sz) {
  ------------------
  |  Branch (4453:11): [True: 0, False: 0]
  ------------------
 4454|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4455|      0|        goto end;
 4456|      0|      }
 4457|      0|      trailer_offset_sz += bstarts_nbytes;
 4458|       |      // Regular values have offsets for blocks
 4459|      0|      if (!memcpyed) {
  ------------------
  |  Branch (4459:11): [True: 0, False: 0]
  ------------------
 4460|      0|        if (bstarts_nbytes > SIZE_MAX - streams_offset) {
  ------------------
  |  Branch (4460:13): [True: 0, False: 0]
  ------------------
 4461|      0|          rc = BLOSC2_ERROR_INVALID_HEADER;
 4462|      0|          goto end;
 4463|      0|        }
 4464|      0|        streams_offset += bstarts_nbytes;
 4465|      0|      }
 4466|       |
 4467|      0|      if (bstarts_nbytes > SIZE_MAX - (sizeof(int32_t) + sizeof(int64_t))) {
  ------------------
  |  Branch (4467:11): [True: 0, False: 0]
  ------------------
 4468|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4469|      0|        goto end;
 4470|      0|      }
 4471|      0|      trailer_len_sz = sizeof(int32_t) + sizeof(int64_t) + bstarts_nbytes;
 4472|      0|      if (trailer_len_sz > SIZE_MAX - trailer_offset_sz) {
  ------------------
  |  Branch (4472:11): [True: 0, False: 0]
  ------------------
 4473|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4474|      0|        goto end;
 4475|      0|      }
 4476|      0|      lazychunk_cbytes_sz = trailer_offset_sz + trailer_len_sz;
 4477|      0|    }
 4478|      0|    else if (special_type == BLOSC2_SPECIAL_VALUE) {
  ------------------
  |  Branch (4478:14): [True: 0, False: 0]
  ------------------
 4479|      0|      if (typesize <= 0) {
  ------------------
  |  Branch (4479:11): [True: 0, False: 0]
  ------------------
 4480|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4481|      0|        goto end;
 4482|      0|      }
 4483|      0|      if ((size_t)typesize > SIZE_MAX - trailer_offset_sz ||
  ------------------
  |  Branch (4483:11): [True: 0, False: 0]
  ------------------
 4484|      0|          (size_t)typesize > SIZE_MAX - streams_offset) {
  ------------------
  |  Branch (4484:11): [True: 0, False: 0]
  ------------------
 4485|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4486|      0|        goto end;
 4487|      0|      }
 4488|      0|      trailer_offset_sz += (size_t)typesize;
 4489|      0|      streams_offset += (size_t)typesize;
 4490|      0|      lazychunk_cbytes_sz = trailer_offset_sz;
 4491|      0|    }
 4492|      0|    else {
 4493|      0|      rc = BLOSC2_ERROR_INVALID_HEADER;
 4494|      0|      goto end;
 4495|      0|    }
 4496|       |
 4497|      0|    if (streams_offset > (size_t)chunk_cbytes ||
  ------------------
  |  Branch (4497:9): [True: 0, False: 0]
  ------------------
 4498|      0|        trailer_offset_sz > INT32_MAX ||
  ------------------
  |  Branch (4498:9): [True: 0, False: 0]
  ------------------
 4499|      0|        trailer_len_sz > INT32_MAX ||
  ------------------
  |  Branch (4499:9): [True: 0, False: 0]
  ------------------
 4500|      0|        lazychunk_cbytes_sz > INT32_MAX) {
  ------------------
  |  Branch (4500:9): [True: 0, False: 0]
  ------------------
 4501|      0|      rc = BLOSC2_ERROR_INVALID_HEADER;
 4502|      0|      goto end;
 4503|      0|    }
 4504|       |
 4505|      0|    trailer_offset = (int32_t)trailer_offset_sz;
 4506|      0|    lazychunk_cbytes = (int32_t)lazychunk_cbytes_sz;
 4507|       |
 4508|       |    // Read just the full header and bstarts section too (lazy partial length)
 4509|      0|    if (frame->sframe) {
  ------------------
  |  Branch (4509:9): [True: 0, False: 0]
  ------------------
 4510|      0|      io_pos = 0;
 4511|      0|    }
 4512|      0|    else {
 4513|      0|      io_pos = frame->file_offset + header_len + offset;
 4514|      0|    }
 4515|       |
 4516|       |    // The case here is a bit special because more memory is allocated than read from the file
 4517|       |    // and the chunk is modified after reading. Due to the modification, we cannot directly use
 4518|       |    // the memory provided by the io
 4519|      0|    *chunk = malloc((size_t)lazychunk_cbytes);
 4520|      0|    if (*chunk == NULL) {
  ------------------
  |  Branch (4520:9): [True: 0, False: 0]
  ------------------
 4521|      0|      rc = BLOSC2_ERROR_MEMORY_ALLOC;
 4522|      0|      goto end;
 4523|      0|    }
 4524|      0|    *needs_free = true;
 4525|       |
 4526|      0|    if (io_cb->is_allocation_necessary) {
  ------------------
  |  Branch (4526:9): [True: 0, False: 0]
  ------------------
 4527|      0|      rbytes = io_cb->read((void**)chunk, 1, (int64_t)streams_offset, io_pos, fp);
 4528|      0|    }
 4529|      0|    else {
 4530|       |      // The io hands out its own memory (mmap) and none at all for a read past
 4531|       |      // its end, which a damaged offset or header asks for: copy only after a
 4532|       |      // complete read
 4533|      0|      uint8_t* chunk_ptr = NULL;
 4534|      0|      rbytes = io_cb->read((void**)&chunk_ptr, 1, (int64_t)streams_offset, io_pos, fp);
 4535|      0|      if (rbytes == (int64_t)streams_offset && chunk_ptr != NULL) {
  ------------------
  |  Branch (4535:11): [True: 0, False: 0]
  |  Branch (4535:48): [True: 0, False: 0]
  ------------------
 4536|      0|        memcpy(*chunk, chunk_ptr, streams_offset);
 4537|      0|      }
 4538|      0|      else {
 4539|      0|        rbytes = BLOSC2_ERROR_FILE_READ;
 4540|      0|      }
 4541|      0|    }
 4542|       |
 4543|      0|    if (rbytes != (int64_t)streams_offset) {
  ------------------
  |  Branch (4543:9): [True: 0, False: 0]
  ------------------
 4544|      0|      BLOSC_TRACE_ERROR("Cannot read the (lazy) chunk out of the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4545|      0|      rc = BLOSC2_ERROR_FILE_READ;
 4546|      0|      goto end;
 4547|      0|    }
 4548|      0|    if (special_type == BLOSC2_SPECIAL_VALUE) {
  ------------------
  |  Branch (4548:9): [True: 0, False: 0]
  ------------------
 4549|       |      // Value runlen is not returning a lazy chunk.  We are done.
 4550|      0|      goto end;
 4551|      0|    }
 4552|       |
 4553|       |    // Mark chunk as lazy
 4554|      0|    uint8_t* blosc2_flags = *chunk + BLOSC2_CHUNK_BLOSC2_FLAGS;
 4555|      0|    *blosc2_flags |= 0x08U;
 4556|       |
 4557|       |    // Add the trailer (currently, nchunk + offset + block_csizes)
 4558|      0|    if (frame->sframe) {
  ------------------
  |  Branch (4558:9): [True: 0, False: 0]
  ------------------
 4559|      0|      *(int32_t*)(*chunk + trailer_offset) = (int32_t)offset;   // offset is nchunk for sframes
 4560|      0|      *(int64_t*)(*chunk + trailer_offset + sizeof(int32_t)) = offset;
 4561|      0|    }
 4562|      0|    else {
 4563|      0|      *(int32_t*)(*chunk + trailer_offset) = (int32_t)nchunk;
 4564|      0|      *(int64_t*)(*chunk + trailer_offset + sizeof(int32_t)) = header_len + offset;
 4565|      0|    }
 4566|       |
 4567|      0|    block_csizes = malloc(nblocks * sizeof(int32_t));
 4568|      0|    if (block_csizes == NULL) {
  ------------------
  |  Branch (4568:9): [True: 0, False: 0]
  ------------------
 4569|      0|      rc = BLOSC2_ERROR_MEMORY_ALLOC;
 4570|      0|      goto end;
 4571|      0|    }
 4572|       |
 4573|      0|    if (memcpyed) {
  ------------------
  |  Branch (4573:9): [True: 0, False: 0]
  ------------------
 4574|       |      // When memcpyed the blocksizes are trivial to compute
 4575|      0|      for (size_t i = 0; i + 1 < nblocks; i++) {
  ------------------
  |  Branch (4575:26): [True: 0, False: 0]
  ------------------
 4576|      0|        block_csizes[i] = (int)chunk_blocksize;
 4577|      0|      }
 4578|       |      // The last block could be incomplete, mainly due to the fact that the block size is not divisible
 4579|       |      // by the typesize
 4580|      0|      block_csizes[nblocks - 1] = (int32_t)leftover_block ? (int32_t)leftover_block : chunk_blocksize;
  ------------------
  |  Branch (4580:35): [True: 0, False: 0]
  ------------------
 4581|      0|    }
 4582|      0|    else {
 4583|       |      // In regular, compressed chunks, we need to sort the bstarts (they can be out
 4584|       |      // of order because of multi-threading), and get a reverse index too.
 4585|      0|      memcpy(block_csizes, *chunk + BLOSC_EXTENDED_HEADER_LENGTH, nblocks * sizeof(int32_t));
 4586|       |      // Helper structure to keep track of original indexes
 4587|      0|      csize_idx = malloc(nblocks * sizeof(struct csize_idx));
 4588|      0|      if (csize_idx == NULL) {
  ------------------
  |  Branch (4588:11): [True: 0, False: 0]
  ------------------
 4589|      0|        rc = BLOSC2_ERROR_MEMORY_ALLOC;
 4590|      0|        goto end;
 4591|      0|      }
 4592|      0|      for (size_t n = 0; n < nblocks; n++) {
  ------------------
  |  Branch (4592:26): [True: 0, False: 0]
  ------------------
 4593|       |        // A block starts within its chunk, at or after streams_offset; damaged
 4594|       |        // starts would point into chunk headers or overflow the differences below
 4595|       |        // (and in sort_offset())
 4596|      0|        if (block_csizes[n] < (int64_t)streams_offset || block_csizes[n] > chunk_cbytes) {
  ------------------
  |  Branch (4596:13): [True: 0, False: 0]
  |  Branch (4596:58): [True: 0, False: 0]
  ------------------
 4597|      0|          rc = BLOSC2_ERROR_INVALID_HEADER;
 4598|      0|          goto end;
 4599|      0|        }
 4600|      0|        csize_idx[n].val = block_csizes[n];
 4601|      0|        csize_idx[n].idx = (int)n;
 4602|      0|      }
 4603|      0|      qsort(csize_idx, nblocks, sizeof(struct csize_idx), &sort_offset);
 4604|       |      // Compute the actual csizes
 4605|      0|      int idx;
 4606|      0|      for (size_t n = 0; n + 1 < nblocks; n++) {
  ------------------
  |  Branch (4606:26): [True: 0, False: 0]
  ------------------
 4607|      0|        idx = csize_idx[n].idx;
 4608|      0|        block_csizes[idx] = csize_idx[n + 1].val - csize_idx[n].val;
 4609|      0|      }
 4610|      0|      idx = csize_idx[nblocks - 1].idx;
 4611|      0|      block_csizes[idx] = chunk_cbytes - csize_idx[nblocks - 1].val;
 4612|      0|      free(csize_idx);
 4613|      0|      csize_idx = NULL;
 4614|      0|    }
 4615|       |    // Copy the csizes at the end of the trailer
 4616|      0|    void *trailer_csizes = *chunk + lazychunk_cbytes - nblocks * sizeof(int32_t);
 4617|      0|    memcpy(trailer_csizes, block_csizes, nblocks * sizeof(int32_t));
 4618|      0|    free(block_csizes);
 4619|      0|    block_csizes = NULL;
 4620|  61.2k|  } else {
 4621|       |    // The chunk is in memory and just one pointer away
 4622|  61.2k|    int64_t chunk_header_offset = header_len + offset;
 4623|  61.2k|    int64_t chunk_cbytes_offset = chunk_header_offset + BLOSC_MIN_HEADER_LENGTH;
 4624|       |
 4625|  61.2k|    *chunk = frame->cframe + chunk_header_offset;
 4626|       |
 4627|  61.2k|    if (chunk_header_offset < 0 ||
  ------------------
  |  Branch (4627:9): [True: 0, False: 61.2k]
  ------------------
 4628|  61.2k|        chunk_cbytes_offset < chunk_header_offset ||
  ------------------
  |  Branch (4628:9): [True: 0, False: 61.2k]
  ------------------
 4629|  61.2k|        chunk_cbytes_offset > frame->len) {
  ------------------
  |  Branch (4629:9): [True: 0, False: 61.2k]
  ------------------
 4630|      0|      BLOSC_TRACE_ERROR("Cannot read the header for chunk in the (contiguous) frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4631|      0|      rc = BLOSC2_ERROR_READ_BUFFER;
 4632|  61.2k|    } else {
 4633|  61.2k|      int32_t chunk_blocksize = 0;
 4634|  61.2k|      rc = blosc2_cbuffer_sizes(*chunk, NULL, &lazychunk_cbytes, &chunk_blocksize);
 4635|  61.2k|      if (rc < 0) {
  ------------------
  |  Branch (4635:11): [True: 0, False: 61.2k]
  ------------------
 4636|      0|        BLOSC_TRACE_ERROR("Cannot read the chunk header.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4637|      0|        rc = BLOSC2_ERROR_READ_BUFFER;
 4638|      0|      }
 4639|  61.2k|      else if (chunk_blocksize <= 0) {
  ------------------
  |  Branch (4639:16): [True: 0, False: 61.2k]
  ------------------
 4640|      0|        BLOSC_TRACE_ERROR("Invalid blocksize %d in chunk header.", chunk_blocksize);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4641|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4642|      0|      }
 4643|  61.2k|      else if (lazychunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (4643:16): [True: 0, False: 61.2k]
  ------------------
 4644|  61.2k|               chunk_header_offset > INT64_MAX - lazychunk_cbytes ||
  ------------------
  |  Branch (4644:16): [True: 0, False: 61.2k]
  ------------------
 4645|  61.2k|               chunk_header_offset + lazychunk_cbytes > frame_len) {
  ------------------
  |  Branch (4645:16): [True: 0, False: 61.2k]
  ------------------
 4646|      0|        BLOSC_TRACE_ERROR("Compressed bytes exceed beyond frame length.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4647|      0|        rc = BLOSC2_ERROR_READ_BUFFER;
 4648|      0|      }
 4649|  61.2k|    }
 4650|  61.2k|  }
 4651|       |
 4652|  61.5k|  end:
 4653|  61.5k|  if (csize_idx != NULL) {
  ------------------
  |  Branch (4653:7): [True: 0, False: 61.5k]
  ------------------
 4654|      0|    free(csize_idx);
 4655|      0|  }
 4656|  61.5k|  if (block_csizes != NULL) {
  ------------------
  |  Branch (4656:7): [True: 0, False: 61.5k]
  ------------------
 4657|      0|    free(block_csizes);
 4658|      0|  }
 4659|  61.5k|  if (fp != NULL) {
  ------------------
  |  Branch (4659:7): [True: 0, False: 61.5k]
  ------------------
 4660|      0|    frame_reader_release(frame, io_cb, fp);
 4661|      0|  }
 4662|  61.5k|  if (rc < 0) {
  ------------------
  |  Branch (4662:7): [True: 0, False: 61.5k]
  ------------------
 4663|      0|    if (*needs_free) {
  ------------------
  |  Branch (4663:9): [True: 0, False: 0]
  ------------------
 4664|      0|      free(*chunk);
 4665|      0|      *chunk = NULL;
 4666|      0|      *needs_free = false;
 4667|      0|    }
 4668|      0|    return rc;
 4669|      0|  }
 4670|       |
 4671|  61.5k|  return (int)lazychunk_cbytes;
 4672|  61.5k|}
frame_get_chunk_header:
 4799|  2.29M|int frame_get_chunk_header(blosc2_frame_s* frame, int64_t nchunk, uint8_t* header) {
 4800|  2.29M|  frame_fields f;
 4801|  2.29M|  int rc = get_frame_fields(frame, &f);
 4802|  2.29M|  if (rc < 0) {
  ------------------
  |  Branch (4802:7): [True: 0, False: 2.29M]
  ------------------
 4803|      0|    return rc;
 4804|      0|  }
 4805|  2.29M|  int64_t offset;
 4806|       |  return read_frame_chunk_header(frame, &f, nchunk, NULL, header, &offset);
 4807|  2.29M|}
frame_fill_special:
 4812|  1.84k|                       int32_t chunksize, blosc2_schunk* schunk) {
 4813|  1.84k|  int32_t header_len;
 4814|  1.84k|  int64_t frame_len;
 4815|  1.84k|  int64_t nbytes;
 4816|  1.84k|  int64_t cbytes;
 4817|  1.84k|  int32_t blocksize;
 4818|  1.84k|  int32_t typesize;
 4819|  1.84k|  int64_t nchunks;
 4820|       |
 4821|  1.84k|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes, &blocksize, NULL,
 4822|  1.84k|                           &nchunks, &typesize, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 4823|  1.84k|                           schunk->storage->io);
 4824|  1.84k|  if (rc < 0) {
  ------------------
  |  Branch (4824:7): [True: 0, False: 1.84k]
  ------------------
 4825|      0|    BLOSC_TRACE_ERROR("Unable to get meta info from frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4826|      0|    return BLOSC2_ERROR_DATA;
 4827|      0|  }
 4828|       |
 4829|  1.84k|  if (nitems == 0) {
  ------------------
  |  Branch (4829:7): [True: 0, False: 1.84k]
  ------------------
 4830|      0|    return frame_len;
 4831|      0|  }
 4832|       |
 4833|  1.84k|  if ((nitems / chunksize) > INT_MAX) {
  ------------------
  |  Branch (4833:7): [True: 0, False: 1.84k]
  ------------------
 4834|      0|    BLOSC_TRACE_ERROR("nitems is too large.  Try increasing the chunksize.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4835|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4836|      0|  }
 4837|       |
 4838|  1.84k|  if ((nbytes > 0) || (cbytes > 0)) {
  ------------------
  |  Branch (4838:7): [True: 0, False: 1.84k]
  |  Branch (4838:23): [True: 0, False: 1.84k]
  ------------------
 4839|      0|    BLOSC_TRACE_ERROR("Filling with special values only works on empty frames");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4840|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4841|      0|  }
 4842|       |
 4843|       |  // Compute the number of chunks and the length of the offsets chunk
 4844|  1.84k|  int32_t chunkitems = chunksize / typesize;
 4845|  1.84k|  if (chunkitems <= 0) {
  ------------------
  |  Branch (4845:7): [True: 0, False: 1.84k]
  ------------------
 4846|      0|    BLOSC_TRACE_ERROR("chunksize must be >= typesize for frame special fill.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4847|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4848|      0|  }
 4849|  1.84k|  nchunks = nitems / chunkitems;
 4850|  1.84k|  int32_t leftover_items = (int32_t)(nitems % chunkitems);
 4851|  1.84k|  if (leftover_items) {
  ------------------
  |  Branch (4851:7): [True: 0, False: 1.84k]
  ------------------
 4852|      0|    nchunks += 1;
 4853|      0|  }
 4854|       |
 4855|  1.84k|  blosc2_cparams* cparams;
 4856|  1.84k|  blosc2_schunk_get_cparams(schunk, &cparams);
 4857|       |
 4858|       |  // Build the offsets with a special chunk
 4859|  1.84k|  int new_off_cbytes = BLOSC_EXTENDED_HEADER_LENGTH + sizeof(int64_t);
 4860|  1.84k|  uint8_t* off_chunk = malloc(new_off_cbytes);
 4861|  1.84k|  uint64_t offset_value = ((uint64_t)1 << 63);
 4862|  1.84k|  uint8_t* sample_chunk = malloc(BLOSC_EXTENDED_HEADER_LENGTH);
 4863|  1.84k|  if (off_chunk == NULL || sample_chunk == NULL) {
  ------------------
  |  Branch (4863:7): [True: 0, False: 1.84k]
  |  Branch (4863:28): [True: 0, False: 1.84k]
  ------------------
 4864|      0|    free(off_chunk);
 4865|      0|    free(sample_chunk);
 4866|      0|    free(cparams);
 4867|      0|    BLOSC_TRACE_ERROR("Cannot allocate memory for special fill chunks.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4868|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 4869|      0|  }
 4870|  1.84k|  int csize;
 4871|  1.84k|  switch (special_value) {
 4872|  1.84k|    case BLOSC2_SPECIAL_ZERO:
  ------------------
  |  Branch (4872:5): [True: 1.84k, False: 0]
  ------------------
 4873|  1.84k|      offset_value += (uint64_t) BLOSC2_SPECIAL_ZERO << (8 * 7);
 4874|  1.84k|      csize = blosc2_chunk_zeros(*cparams, chunksize, sample_chunk, BLOSC_EXTENDED_HEADER_LENGTH);
 4875|  1.84k|      break;
 4876|      0|    case BLOSC2_SPECIAL_UNINIT:
  ------------------
  |  Branch (4876:5): [True: 0, False: 1.84k]
  ------------------
 4877|      0|      offset_value += (uint64_t) BLOSC2_SPECIAL_UNINIT << (8 * 7);
 4878|      0|      csize = blosc2_chunk_uninit(*cparams, chunksize, sample_chunk, BLOSC_EXTENDED_HEADER_LENGTH);
 4879|      0|      break;
 4880|      0|    case BLOSC2_SPECIAL_NAN:
  ------------------
  |  Branch (4880:5): [True: 0, False: 1.84k]
  ------------------
 4881|      0|      offset_value += (uint64_t)BLOSC2_SPECIAL_NAN << (8 * 7);
 4882|      0|      csize = blosc2_chunk_nans(*cparams, chunksize, sample_chunk, BLOSC_EXTENDED_HEADER_LENGTH);
 4883|      0|      break;
 4884|      0|    default:
  ------------------
  |  Branch (4884:5): [True: 0, False: 1.84k]
  ------------------
 4885|      0|      free(off_chunk);
 4886|      0|      free(sample_chunk);
 4887|      0|      free(cparams);
 4888|      0|      BLOSC_TRACE_ERROR("Only zeros, NaNs or non-initialized values are supported.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4889|      0|      return BLOSC2_ERROR_FRAME_SPECIAL;
 4890|  1.84k|  }
 4891|  1.84k|  if (csize < 0) {
  ------------------
  |  Branch (4891:7): [True: 0, False: 1.84k]
  ------------------
 4892|      0|    free(off_chunk);
 4893|      0|    free(sample_chunk);
 4894|      0|    free(cparams);
 4895|      0|    BLOSC_TRACE_ERROR("Error creating sample chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4896|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4897|      0|  }
 4898|  1.84k|  cparams->typesize = sizeof(int64_t);  // change it to offsets typesize
 4899|       |  // cparams->blocksize = 0;   // automatic blocksize
 4900|  1.84k|  cparams->blocksize = 8 * 2 * 1024;  // based on experiments with create_frame.c bench
 4901|  1.84k|  cparams->clevel = 5;
 4902|  1.84k|  cparams->compcode = BLOSC_BLOSCLZ;
 4903|  1.84k|  int32_t special_nbytes;
 4904|  1.84k|  if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &special_nbytes)) {
  ------------------
  |  Branch (4904:7): [True: 0, False: 1.84k]
  ------------------
 4905|      0|    free(off_chunk);
 4906|      0|    free(sample_chunk);
 4907|      0|    free(cparams);
 4908|      0|    BLOSC_TRACE_ERROR("Too many chunks for offsets representation.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4909|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4910|      0|  }
 4911|  1.84k|  rc = blosc2_chunk_repeatval(*cparams, special_nbytes, off_chunk, new_off_cbytes, &offset_value);
 4912|  1.84k|  free(cparams);
 4913|  1.84k|  if (rc < 0) {
  ------------------
  |  Branch (4913:7): [True: 0, False: 1.84k]
  ------------------
 4914|      0|    BLOSC_TRACE_ERROR("Error creating a special offsets chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4915|      0|    return BLOSC2_ERROR_DATA;
 4916|      0|  }
 4917|       |
 4918|       |  // Get the blocksize associated to the sample chunk
 4919|  1.84k|  blosc2_cbuffer_sizes(sample_chunk, NULL, NULL, &blocksize);
 4920|  1.84k|  free(sample_chunk);
 4921|       |  // and use it for the super-chunk
 4922|  1.84k|  schunk->blocksize = blocksize;
 4923|       |  // schunk->blocksize = 0;  // for experimenting with automatic blocksize
 4924|       |
 4925|       |  // We have the new offsets; update the frame.
 4926|  1.84k|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 4927|  1.84k|  if (io_cb == NULL) {
  ------------------
  |  Branch (4927:7): [True: 0, False: 1.84k]
  ------------------
 4928|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4929|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 4930|      0|  }
 4931|       |
 4932|  1.84k|  int64_t new_frame_len = header_len + new_off_cbytes + frame->trailer_len;
 4933|  1.84k|  void* fp = NULL;
 4934|  1.84k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (4934:7): [True: 1.84k, False: 0]
  ------------------
 4935|  1.84k|    uint8_t* framep = frame->cframe;
 4936|       |    /* Make space for the new chunk and copy it */
 4937|  1.84k|    frame->cframe = framep = realloc(framep, (size_t)new_frame_len);
 4938|  1.84k|    if (framep == NULL) {
  ------------------
  |  Branch (4938:9): [True: 0, False: 1.84k]
  ------------------
 4939|      0|      BLOSC_TRACE_ERROR("Cannot realloc space for the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4940|      0|      return BLOSC2_ERROR_FRAME_SPECIAL;
 4941|      0|    }
 4942|       |    /* Copy the offsets */
 4943|  1.84k|    memcpy(framep + header_len, off_chunk, (size_t)new_off_cbytes);
 4944|  1.84k|  }
 4945|      0|  else {
 4946|      0|    size_t wbytes;
 4947|      0|    int64_t io_pos = 0;
 4948|      0|    if (frame->sframe) {
  ------------------
  |  Branch (4948:9): [True: 0, False: 0]
  ------------------
 4949|       |      // Update the offsets chunk in the chunks frame
 4950|      0|      fp = sframe_open_index(frame->urlpath, "rb+", frame->schunk->storage->io);
 4951|      0|      if (fp == NULL) {
  ------------------
  |  Branch (4951:11): [True: 0, False: 0]
  ------------------
 4952|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4953|      0|        return BLOSC2_ERROR_FILE_OPEN;
 4954|      0|      }
 4955|      0|      io_pos = frame->file_offset + header_len;
 4956|      0|    }
 4957|      0|    else {
 4958|       |      // Regular frame
 4959|      0|      fp = frame_writer_acquire(frame, io_cb);
 4960|      0|      if (fp == NULL) {
  ------------------
  |  Branch (4960:11): [True: 0, False: 0]
  ------------------
 4961|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4962|      0|        return BLOSC2_ERROR_FILE_OPEN;
 4963|      0|      }
 4964|      0|      io_pos = frame->file_offset + header_len + cbytes;
 4965|      0|    }
 4966|      0|    wbytes = io_cb->write(off_chunk, 1, new_off_cbytes, io_pos, fp);  // the new offsets
 4967|      0|    int close_rc = frame_writer_release(frame, io_cb, fp);
 4968|      0|    if (wbytes != (size_t)new_off_cbytes) {
  ------------------
  |  Branch (4968:9): [True: 0, False: 0]
  ------------------
 4969|      0|      BLOSC_TRACE_ERROR("Cannot write the offsets to frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4970|      0|      return BLOSC2_ERROR_FRAME_SPECIAL;
 4971|      0|    }
 4972|      0|    if (close_rc < 0) {
  ------------------
  |  Branch (4972:9): [True: 0, False: 0]
  ------------------
 4973|      0|      return close_rc;
 4974|      0|    }
 4975|      0|  }
 4976|       |
 4977|       |  // Invalidate the cache for chunk offsets
 4978|  1.84k|  if (frame->coffsets != NULL) {
  ------------------
  |  Branch (4978:7): [True: 0, False: 1.84k]
  ------------------
 4979|      0|    if (frame->coffsets_needs_free)
  ------------------
  |  Branch (4979:9): [True: 0, False: 0]
  ------------------
 4980|      0|      free(frame->coffsets);
 4981|      0|    frame->coffsets = NULL;
 4982|      0|  }
 4983|  1.84k|  free(off_chunk);
 4984|       |
 4985|  1.84k|  frame->len = new_frame_len;
 4986|  1.84k|  rc = frame_update_header(frame, schunk, false);
 4987|  1.84k|  if (rc < 0) {
  ------------------
  |  Branch (4987:7): [True: 0, False: 1.84k]
  ------------------
 4988|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4989|      0|  }
 4990|       |
 4991|  1.84k|  rc = frame_update_trailer(frame, schunk);
 4992|  1.84k|  if (rc < 0) {
  ------------------
  |  Branch (4992:7): [True: 0, False: 1.84k]
  ------------------
 4993|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4994|      0|  }
 4995|       |
 4996|  1.84k|  return frame->len;
 4997|  1.84k|}
frame_append_chunk:
 5067|      8|void* frame_append_chunk(blosc2_frame_s* frame, void* chunk, blosc2_schunk* schunk) {
 5068|      8|  int32_t header_len;
 5069|      8|  int64_t frame_len;
 5070|      8|  int64_t nbytes;
 5071|      8|  int64_t cbytes;
 5072|      8|  int32_t blocksize;
 5073|      8|  int32_t chunksize;
 5074|      8|  int64_t nchunks;
 5075|      8|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes, &blocksize, &chunksize,
 5076|      8|                           &nchunks, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 5077|      8|                           frame->schunk->storage->io);
 5078|      8|  if (rc < 0) {
  ------------------
  |  Branch (5078:7): [True: 0, False: 8]
  ------------------
 5079|      0|    BLOSC_TRACE_ERROR("Unable to get meta info from frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5080|      0|    return NULL;
 5081|      0|  }
 5082|      8|  rc = frame_refresh_if_stale(frame, frame_len);
 5083|      8|  if (rc < 0) {
  ------------------
  |  Branch (5083:7): [True: 0, False: 8]
  ------------------
 5084|      0|    BLOSC_TRACE_ERROR("Unable to refresh the frame state from disk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5085|      0|    return NULL;
 5086|      0|  }
 5087|       |
 5088|       |  /* The uncompressed and compressed sizes start at byte 4 and 12 */
 5089|      8|  int32_t chunk_nbytes;
 5090|      8|  int32_t chunk_cbytes;
 5091|      8|  rc = blosc2_cbuffer_sizes(chunk, &chunk_nbytes, &chunk_cbytes, NULL);
 5092|      8|  if (rc < 0) {
  ------------------
  |  Branch (5092:7): [True: 0, False: 8]
  ------------------
 5093|      0|    return NULL;
 5094|      0|  }
 5095|       |
 5096|      8|  if ((nchunks > 0) && (chunksize > 0) && (schunk->chunksize != 0) && (chunk_nbytes > chunksize)) {
  ------------------
  |  Branch (5096:7): [True: 7, False: 1]
  |  Branch (5096:24): [True: 7, False: 0]
  |  Branch (5096:43): [True: 7, False: 0]
  |  Branch (5096:71): [True: 0, False: 7]
  ------------------
 5097|      0|    BLOSC_TRACE_ERROR("Appending chunks with a larger chunksize than frame is "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5098|      0|                      "not allowed yet %d != %d.", chunk_nbytes, chunksize);
 5099|      0|    return NULL;
 5100|      0|  }
 5101|       |
 5102|       |  // Check that we are not appending a small chunk after another small chunk
 5103|      8|  int32_t chunk_nbytes_last = 0;
 5104|      8|  if (frame_needs_last_nbytes(chunksize, nchunks, chunk_nbytes)) {
  ------------------
  |  Branch (5104:7): [True: 0, False: 8]
  ------------------
 5105|      0|    uint8_t last_header[BLOSC_EXTENDED_HEADER_LENGTH];
 5106|      0|    rc = frame_get_chunk_header(frame, nchunks - 1, last_header);
 5107|      0|    if (rc < 0) {
  ------------------
  |  Branch (5107:9): [True: 0, False: 0]
  ------------------
 5108|      0|      BLOSC_TRACE_ERROR("Cannot get the last chunk (in position %" PRId64 ").", nchunks - 1);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5109|      0|    } else {
 5110|      0|      rc = blosc2_cbuffer_sizes(last_header, &chunk_nbytes_last, NULL, NULL);
 5111|      0|    }
 5112|      0|    if (rc < 0) {
  ------------------
  |  Branch (5112:9): [True: 0, False: 0]
  ------------------
 5113|      0|      return NULL;
 5114|      0|    }
 5115|      0|  }
 5116|      8|  if (!frame_takes_chunk(chunksize, nchunks, nbytes, chunk_nbytes_last, chunk_nbytes)) {
  ------------------
  |  Branch (5116:7): [True: 0, False: 8]
  ------------------
 5117|      0|    return NULL;
 5118|      0|  }
 5119|       |
 5120|       |  // Get the current offsets and add one more
 5121|      8|  int32_t off_nbytes = (int32_t) ((nchunks + 1) * sizeof(int64_t));
 5122|      8|  int64_t* offsets = (int64_t *) malloc((size_t)off_nbytes);
 5123|      8|  if (offsets == NULL) {
  ------------------
  |  Branch (5123:7): [True: 0, False: 8]
  ------------------
 5124|      0|    BLOSC_TRACE_ERROR("Cannot allocate memory for offsets.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5125|      0|    return NULL;
 5126|      0|  }
 5127|      8|  if (nchunks > 0) {
  ------------------
  |  Branch (5127:7): [True: 7, False: 1]
  ------------------
 5128|      7|    int32_t coffsets_cbytes;
 5129|      7|    uint8_t *coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &coffsets_cbytes);
 5130|      7|    if (coffsets == NULL) {
  ------------------
  |  Branch (5130:9): [True: 0, False: 7]
  ------------------
 5131|      0|      BLOSC_TRACE_ERROR("Cannot get the offsets for the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5132|      0|      free(offsets);
 5133|      0|      return NULL;
 5134|      0|    }
 5135|       |    // Decompress offsets
 5136|      7|    blosc2_dparams off_dparams = BLOSC2_DPARAMS_DEFAULTS;
 5137|      7|    blosc2_context *dctx = blosc2_create_dctx(off_dparams);
 5138|      7|    if (dctx == NULL) {
  ------------------
  |  Branch (5138:9): [True: 0, False: 7]
  ------------------
 5139|      0|      BLOSC_TRACE_ERROR("Error while creating the decompression context");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5140|      0|      free(offsets);
 5141|      0|      return NULL;
 5142|      0|    }
 5143|      7|    int32_t prev_nbytes = blosc2_decompress_ctx(dctx, coffsets, coffsets_cbytes, offsets,
 5144|      7|                                                off_nbytes);
 5145|      7|    blosc2_free_ctx(dctx);
 5146|      7|    if (prev_nbytes < 0) {
  ------------------
  |  Branch (5146:9): [True: 0, False: 7]
  ------------------
 5147|      0|      free(offsets);
 5148|      0|      BLOSC_TRACE_ERROR("Cannot decompress the offsets chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5149|      0|      return NULL;
 5150|      0|    }
 5151|      7|  }
 5152|       |
 5153|       |  // Add the new offset
 5154|      8|  int64_t sframe_chunk_id = -1;
 5155|      8|  int special_value = chunk_special_in_offset(chunk, chunk_cbytes);
 5156|      8|  if (special_value) {
  ------------------
  |  Branch (5156:7): [True: 1, False: 7]
  ------------------
 5157|      1|    special_offset(offsets + nchunks, special_value);
 5158|      1|    chunk_cbytes = 0;   // we don't need to store the chunk
 5159|      1|  }
 5160|      7|  else if (frame->sframe) {
  ------------------
  |  Branch (5160:12): [True: 0, False: 7]
  ------------------
 5161|       |    // Compute the sframe_chunk_id value
 5162|      0|    for (int64_t i = 0; i < nchunks; ++i) {
  ------------------
  |  Branch (5162:25): [True: 0, False: 0]
  ------------------
 5163|      0|      if (offsets[i] > sframe_chunk_id) {
  ------------------
  |  Branch (5163:11): [True: 0, False: 0]
  ------------------
 5164|      0|        sframe_chunk_id = offsets[i];
 5165|      0|      }
 5166|      0|    }
 5167|      0|    offsets[nchunks] = ++sframe_chunk_id;
 5168|      0|  }
 5169|      7|  else {
 5170|      7|    offsets[nchunks] = cbytes;
 5171|      7|  }
 5172|       |
 5173|       |  // Re-compress the offsets again
 5174|      8|  uint8_t* off_chunk;
 5175|      8|  int32_t new_off_cbytes = compress_offsets(offsets, off_nbytes, off_nbytes + BLOSC2_MAX_OVERHEAD,
 5176|      8|                                            &off_chunk);
 5177|      8|  free(offsets);
 5178|      8|  if (new_off_cbytes < 0) {
  ------------------
  |  Branch (5178:7): [True: 0, False: 8]
  ------------------
 5179|      0|    return NULL;
 5180|      0|  }
 5181|       |
 5182|      8|  int64_t new_cbytes = cbytes + chunk_cbytes;
 5183|      8|  int64_t new_frame_len;
 5184|      8|  if (frame->sframe) {
  ------------------
  |  Branch (5184:7): [True: 0, False: 8]
  ------------------
 5185|      0|    new_frame_len = header_len + 0 + new_off_cbytes + frame->trailer_len;
 5186|      0|  }
 5187|      8|  else {
 5188|      8|    new_frame_len = header_len + new_cbytes + new_off_cbytes + frame->trailer_len;
 5189|      8|  }
 5190|       |
 5191|      8|  void* fp = NULL;
 5192|      8|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (5192:7): [True: 8, False: 0]
  ------------------
 5193|       |    /* Make space for the new chunk and copy it (keeping the frame if that fails) */
 5194|      8|    uint8_t* framep = realloc(frame->cframe, (size_t)new_frame_len);
 5195|      8|    if (framep == NULL) {
  ------------------
  |  Branch (5195:9): [True: 0, False: 8]
  ------------------
 5196|      0|      BLOSC_TRACE_ERROR("Cannot realloc space for the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5197|      0|      goto failed;
 5198|      0|    }
 5199|      8|    frame->cframe = framep;
 5200|       |    /* Copy the chunk */
 5201|      8|    memcpy(framep + header_len + cbytes, chunk, (size_t)chunk_cbytes);
 5202|       |    /* Copy the offsets */
 5203|      8|    memcpy(framep + header_len + new_cbytes, off_chunk, (size_t)new_off_cbytes);
 5204|      8|  }
 5205|      0|  else {
 5206|      0|    int64_t wbytes;
 5207|      0|    int64_t io_pos = 0;
 5208|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 5209|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (5209:9): [True: 0, False: 0]
  ------------------
 5210|      0|      BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5211|      0|      goto failed;
 5212|      0|    }
 5213|       |
 5214|      0|    if (frame->sframe) {
  ------------------
  |  Branch (5214:9): [True: 0, False: 0]
  ------------------
 5215|       |      // Update the offsets chunk in the chunks frame
 5216|      0|      if (chunk_cbytes != 0) {
  ------------------
  |  Branch (5216:11): [True: 0, False: 0]
  ------------------
 5217|      0|        if (sframe_chunk_id < 0) {
  ------------------
  |  Branch (5217:13): [True: 0, False: 0]
  ------------------
 5218|      0|          BLOSC_TRACE_ERROR("The chunk id (%" PRId64 ") is not correct", sframe_chunk_id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5219|      0|          goto failed;
 5220|      0|        }
 5221|      0|        if (sframe_create_chunk(frame, chunk, sframe_chunk_id, chunk_cbytes) == NULL) {
  ------------------
  |  Branch (5221:13): [True: 0, False: 0]
  ------------------
 5222|      0|          BLOSC_TRACE_ERROR("Cannot write the full chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5223|      0|          goto failed;
 5224|      0|        }
 5225|      0|      }
 5226|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 5227|      0|                             frame->schunk->storage->io);
 5228|      0|      if (fp == NULL) {
  ------------------
  |  Branch (5228:11): [True: 0, False: 0]
  ------------------
 5229|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5230|      0|        goto failed;
 5231|      0|      }
 5232|      0|      io_pos = frame->file_offset + header_len;
 5233|      0|    }
 5234|      0|    else {
 5235|       |      // Regular frame
 5236|      0|      fp = frame_writer_acquire(frame, io_cb);
 5237|      0|      if (fp == NULL) {
  ------------------
  |  Branch (5237:11): [True: 0, False: 0]
  ------------------
 5238|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5239|      0|        goto failed;
 5240|      0|      }
 5241|      0|      io_pos = frame->file_offset + header_len + cbytes;
 5242|      0|      wbytes = io_cb->write(chunk, 1, chunk_cbytes, io_pos, fp);  // the new chunk
 5243|      0|      io_pos += chunk_cbytes;
 5244|      0|      if (wbytes != chunk_cbytes) {
  ------------------
  |  Branch (5244:11): [True: 0, False: 0]
  ------------------
 5245|      0|        BLOSC_TRACE_ERROR("Cannot write the full chunk to frame (wrote %" PRId64 " of %" PRId64
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5246|      0|                          " bytes at position %" PRId64 ", nchunk=%" PRId64 ").",
 5247|      0|                          wbytes, (int64_t)chunk_cbytes, io_pos - (int64_t)chunk_cbytes, nchunks);
 5248|      0|        frame->file_end = 0;
 5249|      0|        frame_writer_release(frame, io_cb, fp);
 5250|      0|        goto failed;
 5251|      0|      }
 5252|      0|    }
 5253|      0|    wbytes = io_cb->write(off_chunk, 1, new_off_cbytes, io_pos, fp);  // the new offsets
 5254|      0|    int close_rc = frame_writer_release(frame, io_cb, fp);
 5255|      0|    if (wbytes != new_off_cbytes || close_rc < 0) {
  ------------------
  |  Branch (5255:9): [True: 0, False: 0]
  |  Branch (5255:37): [True: 0, False: 0]
  ------------------
 5256|      0|      BLOSC_TRACE_ERROR("Cannot write or close the offsets in frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5257|      0|      frame->file_end = 0;
 5258|      0|      goto failed;
 5259|      0|    }
 5260|      0|  }
 5261|       |  // Invalidate the cache for chunk offsets
 5262|      8|  if (frame->coffsets != NULL) {
  ------------------
  |  Branch (5262:7): [True: 0, False: 8]
  ------------------
 5263|      0|    if (frame->coffsets_needs_free)
  ------------------
  |  Branch (5263:9): [True: 0, False: 0]
  ------------------
 5264|      0|      free(frame->coffsets);
 5265|      0|    frame->coffsets = NULL;
 5266|      0|  }
 5267|      8|  free(off_chunk);
 5268|       |
 5269|      8|  frame->len = new_frame_len;
 5270|      8|  rc = frame_update_header(frame, schunk, false);
 5271|      8|  if (rc < 0) {
  ------------------
  |  Branch (5271:7): [True: 0, False: 8]
  ------------------
 5272|      0|    frame->len = frame_len;
 5273|      0|    return NULL;
 5274|      0|  }
 5275|       |
 5276|      8|  rc = frame_update_trailer(frame, schunk);
 5277|      8|  if (rc < 0) {
  ------------------
  |  Branch (5277:7): [True: 0, False: 8]
  ------------------
 5278|      0|    frame->len = frame_len;
 5279|      0|    return NULL;
 5280|      0|  }
 5281|       |
 5282|      8|  return frame;
 5283|       |
 5284|      0|  failed:
 5285|       |  // The caller still owns the chunk; the offsets chunk is ours
 5286|      0|  free(off_chunk);
 5287|       |  return NULL;
 5288|      8|}
frame_insert_chunk:
 5827|   532k|void* frame_insert_chunk(blosc2_frame_s* frame, int64_t nchunk, void* chunk, blosc2_schunk* schunk) {
 5828|   532k|  uint8_t* chunk_ = chunk;
 5829|   532k|  int32_t header_len;
 5830|   532k|  int64_t frame_len;
 5831|   532k|  int64_t nbytes;
 5832|   532k|  int64_t cbytes;
 5833|   532k|  int32_t blocksize;
 5834|   532k|  int32_t chunksize;
 5835|   532k|  int64_t nchunks;
 5836|   532k|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 5837|   532k|                           &blocksize, &chunksize, &nchunks,
 5838|   532k|                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 5839|   532k|                           frame->schunk->storage->io);
 5840|   532k|  if (rc < 0) {
  ------------------
  |  Branch (5840:7): [True: 0, False: 532k]
  ------------------
 5841|      0|    BLOSC_TRACE_ERROR("Unable to get meta info from frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5842|      0|    return NULL;
 5843|      0|  }
 5844|   532k|  rc = frame_refresh_if_stale(frame, frame_len);
 5845|   532k|  if (rc < 0) {
  ------------------
  |  Branch (5845:7): [True: 0, False: 532k]
  ------------------
 5846|      0|    BLOSC_TRACE_ERROR("Unable to refresh the frame state from disk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5847|      0|    return NULL;
 5848|      0|  }
 5849|   532k|  int32_t chunk_cbytes;
 5850|   532k|  rc = blosc2_cbuffer_sizes(chunk_, NULL, &chunk_cbytes, NULL);
 5851|   532k|  if (rc < 0) {
  ------------------
  |  Branch (5851:7): [True: 0, False: 532k]
  ------------------
 5852|      0|    return NULL;
 5853|      0|  }
 5854|       |
 5855|       |  // Get the current offsets
 5856|   532k|  int32_t off_nbytes = (int32_t) ((nchunks + 1) * sizeof(int64_t));
 5857|   532k|  int64_t* offsets = (int64_t *) malloc((size_t)off_nbytes);
 5858|   532k|  if (offsets == NULL) {
  ------------------
  |  Branch (5858:7): [True: 0, False: 532k]
  ------------------
 5859|      0|    BLOSC_TRACE_ERROR("Cannot allocate memory for offsets.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5860|      0|    return NULL;
 5861|      0|  }
 5862|   532k|  if (nchunks > 0) {
  ------------------
  |  Branch (5862:7): [True: 532k, False: 37]
  ------------------
 5863|   532k|    int32_t coffsets_cbytes = 0;
 5864|   532k|    uint8_t *coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &coffsets_cbytes);
 5865|   532k|    if (coffsets == NULL) {
  ------------------
  |  Branch (5865:9): [True: 0, False: 532k]
  ------------------
 5866|      0|      BLOSC_TRACE_ERROR("Cannot get the offsets for the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5867|      0|      free(offsets);
 5868|      0|      return NULL;
 5869|      0|    }
 5870|       |    // Decompress offsets
 5871|   532k|    blosc2_dparams off_dparams = BLOSC2_DPARAMS_DEFAULTS;
 5872|   532k|    blosc2_context *dctx = blosc2_create_dctx(off_dparams);
 5873|   532k|    if (dctx == NULL) {
  ------------------
  |  Branch (5873:9): [True: 0, False: 532k]
  ------------------
 5874|      0|      BLOSC_TRACE_ERROR("Error while creating the decompression context");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5875|      0|      free(offsets);
 5876|      0|      return NULL;
 5877|      0|    }
 5878|   532k|    int32_t prev_nbytes = blosc2_decompress_ctx(dctx, coffsets, coffsets_cbytes, offsets, off_nbytes);
 5879|   532k|    blosc2_free_ctx(dctx);
 5880|   532k|    if (prev_nbytes < 0) {
  ------------------
  |  Branch (5880:9): [True: 0, False: 532k]
  ------------------
 5881|      0|      free(offsets);
 5882|      0|      BLOSC_TRACE_ERROR("Cannot decompress the offsets chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5883|      0|      return NULL;
 5884|      0|    }
 5885|   532k|  }
 5886|       |
 5887|       |  // TODO: Improvement: Check if new chunk is smaller than previous one
 5888|       |
 5889|       |  // Move offsets
 5890|   245M|  for (int64_t i = nchunks; i > nchunk; i--) {
  ------------------
  |  Branch (5890:29): [True: 244M, False: 532k]
  ------------------
 5891|   244M|    offsets[i] = offsets[i - 1];
 5892|   244M|  }
 5893|       |  // Add the new offset
 5894|   532k|  int64_t sframe_chunk_id = -1;
 5895|   532k|  int special_value = chunk_special_in_offset(chunk_, chunk_cbytes);
 5896|   532k|  if (special_value) {
  ------------------
  |  Branch (5896:7): [True: 532k, False: 0]
  ------------------
 5897|   532k|    special_offset(offsets + nchunk, special_value);
 5898|   532k|    chunk_cbytes = 0;   // we don't need to store the chunk
 5899|   532k|  }
 5900|      0|  else if (frame->sframe) {
  ------------------
  |  Branch (5900:12): [True: 0, False: 0]
  ------------------
 5901|      0|    for (int64_t i = 0; i <= nchunks; ++i) {
  ------------------
  |  Branch (5901:25): [True: 0, False: 0]
  ------------------
 5902|       |      // offsets[nchunk] is still uninitialized here
 5903|      0|      if (i != nchunk && offsets[i] > sframe_chunk_id) {
  ------------------
  |  Branch (5903:11): [True: 0, False: 0]
  |  Branch (5903:26): [True: 0, False: 0]
  ------------------
 5904|      0|        sframe_chunk_id = offsets[i];
 5905|      0|      }
 5906|      0|    }
 5907|      0|    offsets[nchunk] = ++sframe_chunk_id;
 5908|      0|  }
 5909|      0|  else {
 5910|      0|    offsets[nchunk] = cbytes;
 5911|      0|  }
 5912|       |
 5913|       |  // Re-compress the offsets again
 5914|   532k|  uint8_t* off_chunk;
 5915|   532k|  int32_t new_off_cbytes = compress_offsets(offsets, off_nbytes, off_nbytes + BLOSC2_MAX_OVERHEAD,
 5916|   532k|                                            &off_chunk);
 5917|   532k|  free(offsets);
 5918|   532k|  if (new_off_cbytes < 0) {
  ------------------
  |  Branch (5918:7): [True: 0, False: 532k]
  ------------------
 5919|      0|    return NULL;
 5920|      0|  }
 5921|       |
 5922|   532k|  int64_t new_cbytes = cbytes + chunk_cbytes;
 5923|       |
 5924|   532k|  int64_t new_frame_len;
 5925|   532k|  if (frame->sframe) {
  ------------------
  |  Branch (5925:7): [True: 0, False: 532k]
  ------------------
 5926|      0|    new_frame_len = header_len + 0 + new_off_cbytes + frame->trailer_len;
 5927|      0|  }
 5928|   532k|  else {
 5929|   532k|    new_frame_len = header_len + new_cbytes + new_off_cbytes + frame->trailer_len;
 5930|   532k|  }
 5931|       |
 5932|       |  // Add the chunk and update meta
 5933|   532k|  void* fp = NULL;
 5934|   532k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (5934:7): [True: 532k, False: 0]
  ------------------
 5935|       |    /* Make space for the new chunk and copy it (keeping the frame if that fails) */
 5936|   532k|    uint8_t* framep = realloc(frame->cframe, (size_t)new_frame_len);
 5937|   532k|    if (framep == NULL) {
  ------------------
  |  Branch (5937:9): [True: 0, False: 532k]
  ------------------
 5938|      0|      BLOSC_TRACE_ERROR("Cannot realloc space for the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5939|      0|      goto failed;
 5940|      0|    }
 5941|   532k|    frame->cframe = framep;
 5942|       |    /* Copy the chunk */
 5943|   532k|    memcpy(framep + header_len + cbytes, chunk, (size_t)chunk_cbytes);
 5944|       |    /* Copy the offsets */
 5945|   532k|    memcpy(framep + header_len + new_cbytes, off_chunk, (size_t)new_off_cbytes);
 5946|   532k|  } else {
 5947|      0|    int64_t wbytes;
 5948|       |
 5949|      0|    int64_t io_pos = 0;
 5950|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 5951|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (5951:9): [True: 0, False: 0]
  ------------------
 5952|      0|      BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5953|      0|      goto failed;
 5954|      0|    }
 5955|       |
 5956|      0|    if (frame->sframe) {
  ------------------
  |  Branch (5956:9): [True: 0, False: 0]
  ------------------
 5957|      0|      if (chunk_cbytes != 0) {
  ------------------
  |  Branch (5957:11): [True: 0, False: 0]
  ------------------
 5958|      0|        if (sframe_chunk_id < 0) {
  ------------------
  |  Branch (5958:13): [True: 0, False: 0]
  ------------------
 5959|      0|          BLOSC_TRACE_ERROR("The chunk id (%" PRId64 ") is not correct", sframe_chunk_id);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5960|      0|          goto failed;
 5961|      0|        }
 5962|      0|        if (sframe_create_chunk(frame, chunk, sframe_chunk_id, chunk_cbytes) == NULL) {
  ------------------
  |  Branch (5962:13): [True: 0, False: 0]
  ------------------
 5963|      0|          BLOSC_TRACE_ERROR("Cannot write the full chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5964|      0|          goto failed;
 5965|      0|        }
 5966|      0|      }
 5967|       |      // Update the offsets chunk in the chunks frame
 5968|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 5969|      0|                             frame->schunk->storage->io);
 5970|      0|      if (fp == NULL) {
  ------------------
  |  Branch (5970:11): [True: 0, False: 0]
  ------------------
 5971|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5972|      0|        goto failed;
 5973|      0|      }
 5974|      0|      io_pos = frame->file_offset + header_len + 0;
 5975|      0|    }
 5976|      0|    else {
 5977|       |      // Regular frame
 5978|      0|      fp = frame_writer_acquire(frame, io_cb);
 5979|      0|      if (fp == NULL) {
  ------------------
  |  Branch (5979:11): [True: 0, False: 0]
  ------------------
 5980|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5981|      0|        goto failed;
 5982|      0|      }
 5983|      0|      io_pos = frame->file_offset + header_len + cbytes;
 5984|      0|      wbytes = io_cb->write(chunk, 1, chunk_cbytes, io_pos, fp);  // the new chunk
 5985|      0|      io_pos += chunk_cbytes;
 5986|      0|      if (wbytes != chunk_cbytes) {
  ------------------
  |  Branch (5986:11): [True: 0, False: 0]
  ------------------
 5987|      0|        BLOSC_TRACE_ERROR("Cannot write the full chunk to frame (wrote %" PRId64 " of %" PRId64
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5988|      0|                          " bytes at position %" PRId64 ", nchunk=%" PRId64 ").",
 5989|      0|                          wbytes, (int64_t)chunk_cbytes, io_pos - (int64_t)chunk_cbytes, nchunk);
 5990|      0|        frame->file_end = 0;
 5991|      0|        frame_writer_release(frame, io_cb, fp);
 5992|      0|        goto failed;
 5993|      0|      }
 5994|      0|    }
 5995|      0|    wbytes = io_cb->write(off_chunk, 1, new_off_cbytes, io_pos, fp);  // the new offsets
 5996|      0|    int close_rc = frame_writer_release(frame, io_cb, fp);
 5997|      0|    if (wbytes != new_off_cbytes || close_rc < 0) {
  ------------------
  |  Branch (5997:9): [True: 0, False: 0]
  |  Branch (5997:37): [True: 0, False: 0]
  ------------------
 5998|      0|      BLOSC_TRACE_ERROR("Cannot write or close the offsets in frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5999|      0|      frame->file_end = 0;
 6000|      0|      goto failed;
 6001|      0|    }
 6002|       |    // Invalidate the cache for chunk offsets
 6003|      0|    if (frame->coffsets != NULL) {
  ------------------
  |  Branch (6003:9): [True: 0, False: 0]
  ------------------
 6004|      0|      if (frame->coffsets_needs_free)
  ------------------
  |  Branch (6004:11): [True: 0, False: 0]
  ------------------
 6005|      0|        free(frame->coffsets);
 6006|      0|      frame->coffsets = NULL;
 6007|      0|    }
 6008|      0|  }
 6009|   532k|  free(off_chunk);
 6010|       |
 6011|   532k|  frame->len = new_frame_len;
 6012|   532k|  rc = frame_update_header(frame, schunk, false);
 6013|   532k|  if (rc < 0) {
  ------------------
  |  Branch (6013:7): [True: 0, False: 532k]
  ------------------
 6014|      0|    frame->len = frame_len;
 6015|      0|    return NULL;
 6016|      0|  }
 6017|       |
 6018|   532k|  rc = frame_update_trailer(frame, schunk);
 6019|   532k|  if (rc < 0) {
  ------------------
  |  Branch (6019:7): [True: 0, False: 532k]
  ------------------
 6020|      0|    frame->len = frame_len;
 6021|      0|    return NULL;
 6022|      0|  }
 6023|       |
 6024|   532k|  return frame;
 6025|       |
 6026|      0|  failed:
 6027|       |  // The caller still owns the chunk; the offsets chunk is ours
 6028|      0|  free(off_chunk);
 6029|       |  return NULL;
 6030|   532k|}
frame_update_chunk:
 6216|   615k|                         int32_t cbytes_old) {
 6217|   615k|  uint8_t *chunk_ = (uint8_t *) chunk;
 6218|   615k|  int64_t* offsets = NULL;
 6219|   615k|  uint8_t* off_chunk = NULL;
 6220|   615k|  int32_t header_len;
 6221|   615k|  int64_t frame_len;
 6222|   615k|  int64_t nbytes;
 6223|   615k|  int64_t cbytes;
 6224|   615k|  int32_t blocksize;
 6225|   615k|  int32_t chunksize;
 6226|   615k|  int64_t nchunks;
 6227|   615k|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 6228|   615k|                           &blocksize, &chunksize, &nchunks,
 6229|   615k|                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 6230|   615k|                           frame->schunk->storage->io);
 6231|   615k|  if (rc < 0) {
  ------------------
  |  Branch (6231:7): [True: 0, False: 615k]
  ------------------
 6232|      0|    BLOSC_TRACE_ERROR("Unable to get meta info from frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6233|      0|    goto failed;
 6234|      0|  }
 6235|   615k|  rc = frame_refresh_if_stale(frame, frame_len);
 6236|   615k|  if (rc < 0) {
  ------------------
  |  Branch (6236:7): [True: 0, False: 615k]
  ------------------
 6237|      0|    BLOSC_TRACE_ERROR("Unable to refresh the frame state from disk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6238|      0|    goto failed;
 6239|      0|  }
 6240|   615k|  if (nchunk >= nchunks) {
  ------------------
  |  Branch (6240:7): [True: 0, False: 615k]
  ------------------
 6241|      0|    BLOSC_TRACE_ERROR("The chunk must already exist.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6242|      0|    goto failed;
 6243|      0|  }
 6244|       |
 6245|   615k|  int32_t chunk_cbytes;
 6246|   615k|  rc = blosc2_cbuffer_sizes(chunk, NULL, &chunk_cbytes, NULL);
 6247|   615k|  if (rc < 0) {
  ------------------
  |  Branch (6247:7): [True: 0, False: 615k]
  ------------------
 6248|      0|    goto failed;
 6249|      0|  }
 6250|       |
 6251|       |  // Get the current offsets
 6252|   615k|  int32_t off_nbytes;
 6253|   615k|  if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &off_nbytes)) {
  ------------------
  |  Branch (6253:7): [True: 0, False: 615k]
  ------------------
 6254|      0|    BLOSC_TRACE_ERROR("Too many chunks for offsets representation.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6255|      0|    goto failed;
 6256|      0|  }
 6257|   615k|  offsets = (int64_t *) malloc((size_t)off_nbytes);
 6258|   615k|  if (offsets == NULL) {
  ------------------
  |  Branch (6258:7): [True: 0, False: 615k]
  ------------------
 6259|      0|    BLOSC_TRACE_ERROR("Cannot allocate memory for offsets.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6260|      0|    goto failed;
 6261|      0|  }
 6262|   615k|  if (nchunks > 0) {
  ------------------
  |  Branch (6262:7): [True: 615k, False: 0]
  ------------------
 6263|   615k|    int32_t coffsets_cbytes = 0;
 6264|   615k|    uint8_t *coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &coffsets_cbytes);
 6265|   615k|    if (coffsets == NULL) {
  ------------------
  |  Branch (6265:9): [True: 0, False: 615k]
  ------------------
 6266|      0|      BLOSC_TRACE_ERROR("Cannot get the offsets for the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6267|      0|      goto failed;
 6268|      0|    }
 6269|       |    // Decompress offsets
 6270|   615k|    blosc2_dparams off_dparams = BLOSC2_DPARAMS_DEFAULTS;
 6271|   615k|    blosc2_context *dctx = blosc2_create_dctx(off_dparams);
 6272|   615k|    if (dctx == NULL) {
  ------------------
  |  Branch (6272:9): [True: 0, False: 615k]
  ------------------
 6273|      0|      BLOSC_TRACE_ERROR("Error while creating the decompression context");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6274|      0|      goto failed;
 6275|      0|    }
 6276|   615k|    int32_t prev_nbytes = blosc2_decompress_ctx(dctx, coffsets, coffsets_cbytes, offsets, off_nbytes);
 6277|   615k|    blosc2_free_ctx(dctx);
 6278|   615k|    if (prev_nbytes < 0) {
  ------------------
  |  Branch (6278:9): [True: 0, False: 615k]
  ------------------
 6279|      0|      BLOSC_TRACE_ERROR("Cannot decompress the offsets chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6280|      0|      goto failed;
 6281|      0|    }
 6282|   615k|  }
 6283|   615k|  int64_t old_offset = 0;
 6284|   615k|  if (!frame->sframe) {
  ------------------
  |  Branch (6284:7): [True: 615k, False: 0]
  ------------------
 6285|   615k|    old_offset = offsets[nchunk];
 6286|   615k|  }
 6287|       |
 6288|       |  // Add the new offset
 6289|   615k|  int64_t sframe_chunk_id = -1;
 6290|   615k|  int64_t old_sframe_chunk_id = -1;
 6291|   615k|  int64_t delta_cbytes = 0;
 6292|   615k|  bool old_chunk_is_regular = (!frame->sframe && old_offset >= 0);
  ------------------
  |  Branch (6292:32): [True: 615k, False: 0]
  |  Branch (6292:50): [True: 17.4k, False: 598k]
  ------------------
 6293|   615k|  bool new_chunk_is_regular = true;
 6294|   615k|  int64_t new_chunk_offset = cbytes;
 6295|       |  // Inside frame_begin_updates(), a resized chunk leaves a hole instead of moving the payload behind it
 6296|   615k|  bool defer = !frame->sframe && frame->updates_depth > 0;
  ------------------
  |  Branch (6296:16): [True: 615k, False: 0]
  |  Branch (6296:34): [True: 608k, False: 7.94k]
  ------------------
 6297|   615k|  if (frame->sframe) {
  ------------------
  |  Branch (6297:7): [True: 0, False: 615k]
  ------------------
 6298|      0|    if (offsets[nchunk] < 0) {
  ------------------
  |  Branch (6298:9): [True: 0, False: 0]
  ------------------
 6299|      0|      sframe_chunk_id = -1;
 6300|      0|    }
 6301|      0|    else {
 6302|       |      // In case there was a reorder in a sframe
 6303|      0|      sframe_chunk_id = offsets[nchunk];
 6304|      0|      old_sframe_chunk_id = offsets[nchunk];
 6305|      0|    }
 6306|      0|  }
 6307|   615k|  int special_value = chunk_special_in_offset(chunk_, chunk_cbytes);
 6308|   615k|  bool is_special_chunk = special_value != 0;
 6309|   615k|  if (is_special_chunk) {
  ------------------
  |  Branch (6309:7): [True: 107k, False: 508k]
  ------------------
 6310|   107k|    special_offset(offsets + nchunk, special_value);
 6311|   107k|  }
 6312|   508k|  else if (frame->sframe) {
  ------------------
  |  Branch (6312:12): [True: 0, False: 508k]
  ------------------
 6313|      0|    if (sframe_chunk_id < 0) {
  ------------------
  |  Branch (6313:9): [True: 0, False: 0]
  ------------------
 6314|      0|      for (int64_t i = 0; i < nchunks; ++i) {
  ------------------
  |  Branch (6314:27): [True: 0, False: 0]
  ------------------
 6315|      0|        if (offsets[i] > sframe_chunk_id) {
  ------------------
  |  Branch (6315:13): [True: 0, False: 0]
  ------------------
 6316|      0|          sframe_chunk_id = offsets[i];
 6317|      0|        }
 6318|      0|      }
 6319|      0|      offsets[nchunk] = ++sframe_chunk_id;
 6320|      0|    }
 6321|      0|  }
 6322|   508k|  else {
 6323|   508k|    if (old_chunk_is_regular) {
  ------------------
  |  Branch (6323:9): [True: 17.3k, False: 491k]
  ------------------
 6324|  17.3k|      new_chunk_offset = old_offset;
 6325|  17.3k|    }
 6326|   508k|    offsets[nchunk] = new_chunk_offset;
 6327|   508k|  }
 6328|   615k|  if (is_special_chunk) {
  ------------------
  |  Branch (6328:7): [True: 107k, False: 508k]
  ------------------
 6329|   107k|    chunk_cbytes = 0;   // Special chunks are encoded in offsets and have no stored payload.
 6330|   107k|    new_chunk_is_regular = false;
 6331|   107k|  }
 6332|   615k|  if (defer) {
  ------------------
  |  Branch (6332:7): [True: 608k, False: 7.94k]
  ------------------
 6333|   608k|    if (old_chunk_is_regular || new_chunk_is_regular) {
  ------------------
  |  Branch (6333:9): [True: 17.4k, False: 590k]
  |  Branch (6333:33): [True: 483k, False: 107k]
  ------------------
 6334|   500k|      int64_t payload_end = cbytes;
 6335|   500k|      new_chunk_offset = holes_place(frame, old_chunk_is_regular ? old_offset : -1, cbytes_old, chunk_cbytes,
  ------------------
  |  Branch (6335:45): [True: 17.4k, False: 483k]
  ------------------
 6336|   500k|                                     &payload_end);
 6337|   500k|      delta_cbytes = payload_end - cbytes;
 6338|   500k|      if (new_chunk_is_regular) {
  ------------------
  |  Branch (6338:11): [True: 500k, False: 91]
  ------------------
 6339|   500k|        offsets[nchunk] = new_chunk_offset;
 6340|   500k|      }
 6341|   500k|    }
 6342|   608k|  }
 6343|  7.94k|  else if (!frame->sframe) {
  ------------------
  |  Branch (6343:12): [True: 7.94k, False: 0]
  ------------------
 6344|  7.94k|    if (old_chunk_is_regular) {
  ------------------
  |  Branch (6344:9): [True: 0, False: 7.94k]
  ------------------
 6345|      0|      delta_cbytes = (int64_t)chunk_cbytes - cbytes_old;
 6346|      0|      for (int64_t i = 0; i < nchunks; ++i) {
  ------------------
  |  Branch (6346:27): [True: 0, False: 0]
  ------------------
 6347|      0|        if (i == nchunk || offsets[i] < 0) {
  ------------------
  |  Branch (6347:13): [True: 0, False: 0]
  |  Branch (6347:28): [True: 0, False: 0]
  ------------------
 6348|      0|          continue;
 6349|      0|        }
 6350|      0|        if (offsets[i] > old_offset) {
  ------------------
  |  Branch (6350:13): [True: 0, False: 0]
  ------------------
 6351|      0|          offsets[i] += delta_cbytes;
 6352|      0|        }
 6353|      0|      }
 6354|      0|    }
 6355|  7.94k|    else if (new_chunk_is_regular) {
  ------------------
  |  Branch (6355:14): [True: 7.94k, False: 0]
  ------------------
 6356|  7.94k|      delta_cbytes = chunk_cbytes;
 6357|  7.94k|    }
 6358|  7.94k|  }
 6359|       |  // Re-compress the offsets again
 6360|   615k|  int32_t new_off_cbytes = compress_offsets(offsets, off_nbytes, off_nbytes + BLOSC2_MAX_OVERHEAD,
 6361|   615k|                                            &off_chunk);
 6362|   615k|  free(offsets);
 6363|   615k|  offsets = NULL;
 6364|   615k|  if (new_off_cbytes < 0) {
  ------------------
  |  Branch (6364:7): [True: 0, False: 615k]
  ------------------
 6365|      0|    goto failed;
 6366|      0|  }
 6367|       |
 6368|   615k|  int64_t new_cbytes = cbytes;
 6369|   615k|  if (!frame->sframe) {
  ------------------
  |  Branch (6369:7): [True: 615k, False: 0]
  ------------------
 6370|   615k|    new_cbytes += delta_cbytes;
 6371|   615k|  }
 6372|      0|  else {
 6373|      0|    new_cbytes = schunk->cbytes;
 6374|      0|  }
 6375|   615k|  int64_t new_frame_len;
 6376|   615k|  if (frame->sframe) {
  ------------------
  |  Branch (6376:7): [True: 0, False: 615k]
  ------------------
 6377|       |    // The chunk is not stored in the frame
 6378|      0|    new_frame_len = header_len + 0 + new_off_cbytes + frame->trailer_len;
 6379|      0|  }
 6380|   615k|  else {
 6381|   615k|    new_frame_len = header_len + new_cbytes + new_off_cbytes + frame->trailer_len;
 6382|   615k|  }
 6383|       |
 6384|   615k|  void* fp = NULL;
 6385|   615k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (6385:7): [True: 615k, False: 0]
  ------------------
 6386|   615k|    uint8_t* framep = frame->cframe;
 6387|   615k|    if (new_frame_len > frame->len) {
  ------------------
  |  Branch (6387:9): [True: 493k, False: 122k]
  ------------------
 6388|       |      // Keep the frame if the realloc fails
 6389|   493k|      framep = realloc(framep, (size_t)new_frame_len);
 6390|   493k|      if (framep == NULL) {
  ------------------
  |  Branch (6390:11): [True: 0, False: 493k]
  ------------------
 6391|      0|        BLOSC_TRACE_ERROR("Cannot realloc space for the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6392|      0|        goto failed;
 6393|      0|      }
 6394|   493k|      frame->cframe = framep;
 6395|   493k|    }
 6396|   615k|    if (!frame->sframe && old_chunk_is_regular && !defer) {
  ------------------
  |  Branch (6396:9): [True: 615k, False: 0]
  |  Branch (6396:27): [True: 17.4k, False: 598k]
  |  Branch (6396:51): [True: 0, False: 17.4k]
  ------------------
 6397|      0|      int64_t tail_src_offset = old_offset + cbytes_old;
 6398|      0|      int64_t tail_dst_offset = old_offset + chunk_cbytes;
 6399|      0|      int64_t tail_nbytes = cbytes - tail_src_offset;
 6400|      0|      if (tail_nbytes > 0 && tail_src_offset != tail_dst_offset) {
  ------------------
  |  Branch (6400:11): [True: 0, False: 0]
  |  Branch (6400:30): [True: 0, False: 0]
  ------------------
 6401|      0|        memmove(framep + header_len + tail_dst_offset, framep + header_len + tail_src_offset, (size_t)tail_nbytes);
 6402|      0|      }
 6403|      0|    }
 6404|   615k|    if (!frame->sframe && new_chunk_is_regular) {
  ------------------
  |  Branch (6404:9): [True: 615k, False: 0]
  |  Branch (6404:27): [True: 508k, False: 107k]
  ------------------
 6405|   508k|      memcpy(framep + header_len + new_chunk_offset, chunk, (size_t)chunk_cbytes);
 6406|   508k|    }
 6407|       |    /* Copy the offsets */
 6408|   615k|    memcpy(framep + header_len + new_cbytes, off_chunk, (size_t)new_off_cbytes);
 6409|   615k|  } else {
 6410|      0|    int64_t wbytes;
 6411|       |
 6412|      0|    int64_t io_pos = 0;
 6413|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 6414|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (6414:9): [True: 0, False: 0]
  ------------------
 6415|      0|      BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6416|      0|      goto failed;
 6417|      0|    }
 6418|       |
 6419|      0|    if (frame->sframe) {
  ------------------
  |  Branch (6419:9): [True: 0, False: 0]
  ------------------
 6420|       |      // Create or update chunk file only for chunks with stored payload (regular or VALUE)
 6421|      0|      if (!is_special_chunk && sframe_chunk_id >= 0) {
  ------------------
  |  Branch (6421:11): [True: 0, False: 0]
  |  Branch (6421:32): [True: 0, False: 0]
  ------------------
 6422|      0|        if (sframe_create_chunk(frame, chunk, sframe_chunk_id, chunk_cbytes) == NULL) {
  ------------------
  |  Branch (6422:13): [True: 0, False: 0]
  ------------------
 6423|      0|          BLOSC_TRACE_ERROR("Cannot write the full chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6424|      0|          goto failed;
 6425|      0|        }
 6426|      0|      }
 6427|       |      // Update the offsets chunk in the chunks frame
 6428|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 6429|      0|                             frame->schunk->storage->io);
 6430|      0|      if (fp == NULL) {
  ------------------
  |  Branch (6430:11): [True: 0, False: 0]
  ------------------
 6431|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6432|      0|        goto failed;
 6433|      0|      }
 6434|      0|      io_pos = frame->file_offset + header_len + 0;
 6435|      0|    }
 6436|      0|    else {
 6437|       |      // Regular frame
 6438|      0|      fp = frame_writer_acquire(frame, io_cb);
 6439|      0|      if (fp == NULL) {
  ------------------
  |  Branch (6439:11): [True: 0, False: 0]
  ------------------
 6440|      0|        BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6441|      0|        goto failed;
 6442|      0|      }
 6443|      0|      if (old_chunk_is_regular && !defer) {
  ------------------
  |  Branch (6443:11): [True: 0, False: 0]
  |  Branch (6443:35): [True: 0, False: 0]
  ------------------
 6444|      0|        int64_t tail_src_offset = old_offset + cbytes_old;
 6445|      0|        int64_t tail_dst_offset = old_offset + chunk_cbytes;
 6446|      0|        int64_t tail_nbytes = cbytes - tail_src_offset;
 6447|      0|        if (tail_nbytes < 0) {
  ------------------
  |  Branch (6447:13): [True: 0, False: 0]
  ------------------
 6448|      0|          frame_writer_release(frame, io_cb, fp);
 6449|      0|          BLOSC_TRACE_ERROR("Invalid tail length for frame payload compaction.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6450|      0|          goto failed;
 6451|      0|        }
 6452|      0|        if (tail_nbytes > 0 && tail_src_offset != tail_dst_offset) {
  ------------------
  |  Branch (6452:13): [True: 0, False: 0]
  |  Branch (6452:32): [True: 0, False: 0]
  ------------------
 6453|      0|          int rc_move = frame_move_range(io_cb, fp,
 6454|      0|                                         frame->file_offset + header_len + tail_src_offset,
 6455|      0|                                         frame->file_offset + header_len + tail_dst_offset,
 6456|      0|                                         tail_nbytes, 0);
 6457|      0|          if (rc_move < 0) {
  ------------------
  |  Branch (6457:15): [True: 0, False: 0]
  ------------------
 6458|      0|            frame->file_end = 0;
 6459|      0|            frame_writer_release(frame, io_cb, fp);
 6460|      0|            BLOSC_TRACE_ERROR("Cannot compact the payload tail in frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6461|      0|            goto failed;
 6462|      0|          }
 6463|      0|        }
 6464|      0|      }
 6465|      0|      if (new_chunk_is_regular) {
  ------------------
  |  Branch (6465:11): [True: 0, False: 0]
  ------------------
 6466|      0|        io_pos = frame->file_offset + header_len + new_chunk_offset;
 6467|      0|        wbytes = io_cb->write(chunk, 1, chunk_cbytes, io_pos, fp);  // the new chunk
 6468|      0|        if (wbytes != chunk_cbytes) {
  ------------------
  |  Branch (6468:13): [True: 0, False: 0]
  ------------------
 6469|      0|          BLOSC_TRACE_ERROR("Cannot write the full chunk to frame (wrote %" PRId64 " of %" PRId64
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6470|      0|                            " bytes at position %" PRId64 ", nchunk=%" PRId64 ").",
 6471|      0|                            wbytes, (int64_t)chunk_cbytes, io_pos, nchunk);
 6472|      0|          frame->file_end = 0;
 6473|      0|          frame_writer_release(frame, io_cb, fp);
 6474|      0|          goto failed;
 6475|      0|        }
 6476|      0|      }
 6477|      0|      io_pos = frame->file_offset + header_len + new_cbytes;
 6478|      0|    }
 6479|      0|    wbytes = io_cb->write(off_chunk, 1, new_off_cbytes, io_pos, fp);  // the new offsets
 6480|      0|    int close_rc = frame_writer_release(frame, io_cb, fp);
 6481|      0|    if (wbytes != new_off_cbytes || close_rc < 0) {
  ------------------
  |  Branch (6481:9): [True: 0, False: 0]
  |  Branch (6481:37): [True: 0, False: 0]
  ------------------
 6482|      0|      BLOSC_TRACE_ERROR("Cannot write or close the offsets in frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6483|      0|      frame->file_end = 0;
 6484|      0|      goto failed;
 6485|      0|    }
 6486|       |    // Invalidate the cache for chunk offsets
 6487|      0|    if (frame->coffsets != NULL) {
  ------------------
  |  Branch (6487:9): [True: 0, False: 0]
  ------------------
 6488|      0|      if (frame->coffsets_needs_free)
  ------------------
  |  Branch (6488:11): [True: 0, False: 0]
  ------------------
 6489|      0|        free(frame->coffsets);
 6490|      0|      frame->coffsets = NULL;
 6491|      0|    }
 6492|      0|  }
 6493|   615k|  free(off_chunk);
 6494|   615k|  off_chunk = NULL;
 6495|       |
 6496|   615k|  if (defer) {
  ------------------
  |  Branch (6496:7): [True: 608k, False: 7.94k]
  ------------------
 6497|       |    // The header describes the payload as it lies, holes included
 6498|   608k|    schunk->cbytes = new_cbytes;
 6499|   608k|  }
 6500|   615k|  frame->len = new_frame_len;
 6501|   615k|  rc = frame_update_header(frame, schunk, false);
 6502|   615k|  if (rc < 0) {
  ------------------
  |  Branch (6502:7): [True: 0, False: 615k]
  ------------------
 6503|      0|    frame->len = frame_len;
 6504|      0|    goto failed;
 6505|      0|  }
 6506|       |
 6507|   615k|  rc = frame_update_trailer(frame, schunk);
 6508|   615k|  if (rc < 0) {
  ------------------
  |  Branch (6508:7): [True: 0, False: 615k]
  ------------------
 6509|      0|    frame->len = frame_len;
 6510|      0|    goto failed;
 6511|      0|  }
 6512|       |
 6513|   615k|  if (frame->sframe && is_special_chunk && old_sframe_chunk_id >= 0) {
  ------------------
  |  Branch (6513:7): [True: 0, False: 615k]
  |  Branch (6513:24): [True: 0, False: 0]
  |  Branch (6513:44): [True: 0, False: 0]
  ------------------
 6514|      0|    const blosc2_io *io = (frame->schunk && frame->schunk->storage) ? frame->schunk->storage->io : NULL;
  ------------------
  |  Branch (6514:28): [True: 0, False: 0]
  |  Branch (6514:45): [True: 0, False: 0]
  ------------------
 6515|      0|    int err = sframe_delete_chunk(frame->urlpath, old_sframe_chunk_id, io);
 6516|      0|    if (err != BLOSC2_ERROR_SUCCESS) {
  ------------------
  |  Branch (6516:9): [True: 0, False: 0]
  ------------------
 6517|      0|      BLOSC_TRACE_WARNING("Unable to evict old chunk %" PRId64 " from sframe (error %d).",
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6518|      0|                          old_sframe_chunk_id, err);
 6519|       |      // Do not return NULL: the update was already committed to the index and trailer.
 6520|       |      // Distinguish orphan cleanup failure from failure to commit the update.
 6521|      0|    }
 6522|      0|  }
 6523|       |
 6524|   615k|  return frame;
 6525|       |
 6526|      0|  failed:
 6527|      0|  free(offsets);
 6528|      0|  free(off_chunk);
 6529|       |  return NULL;
 6530|   615k|}
frame_begin_updates:
 6716|  48.9k|int frame_begin_updates(blosc2_frame_s* frame) {
 6717|  48.9k|  if (frame == NULL) {
  ------------------
  |  Branch (6717:7): [True: 0, False: 48.9k]
  ------------------
 6718|      0|    return BLOSC2_ERROR_SUCCESS;
 6719|      0|  }
 6720|  48.9k|  int rc = frame_lock(frame, true);
 6721|  48.9k|  if (rc < 0) {
  ------------------
  |  Branch (6721:7): [True: 0, False: 48.9k]
  ------------------
 6722|      0|    return rc;
 6723|      0|  }
 6724|  48.9k|  if (!frame->sframe && frame->updates_depth++ == 0) {
  ------------------
  |  Branch (6724:7): [True: 48.9k, False: 0]
  |  Branch (6724:25): [True: 48.9k, False: 0]
  ------------------
 6725|  48.9k|    frame->nholes = 0;
 6726|       |    frame->holes_lost = false;
 6727|  48.9k|  }
 6728|  48.9k|  return BLOSC2_ERROR_SUCCESS;
 6729|  48.9k|}
frame_end_updates:
 6732|  48.9k|int frame_end_updates(blosc2_frame_s* frame, blosc2_schunk* schunk) {
 6733|  48.9k|  if (frame == NULL) {
  ------------------
  |  Branch (6733:7): [True: 0, False: 48.9k]
  ------------------
 6734|      0|    return BLOSC2_ERROR_SUCCESS;
 6735|      0|  }
 6736|  48.9k|  int rc = BLOSC2_ERROR_SUCCESS;
 6737|  48.9k|  if (!frame->sframe && frame->updates_depth > 0 && --frame->updates_depth == 0) {
  ------------------
  |  Branch (6737:7): [True: 48.9k, False: 0]
  |  Branch (6737:25): [True: 48.9k, False: 0]
  |  Branch (6737:53): [True: 48.9k, False: 0]
  ------------------
 6738|  48.9k|    if (frame->holes_lost) {
  ------------------
  |  Branch (6738:9): [True: 0, False: 48.9k]
  ------------------
 6739|       |      // Valid, just larger: the holes stay as dead space, like the space of deleted chunks
 6740|      0|      BLOSC_TRACE_WARNING("Lost track of the free space in the frame; it stays.");
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6741|      0|    }
 6742|  48.9k|    else if (frame->nholes > 0) {
  ------------------
  |  Branch (6742:14): [True: 243, False: 48.7k]
  ------------------
 6743|    243|      rc = frame_compact(frame, schunk);
 6744|    243|    }
 6745|  48.9k|    frame->nholes = 0;
 6746|  48.9k|    frame->holes_lost = false;
 6747|  48.9k|  }
 6748|  48.9k|  int unlock_rc = frame_unlock(frame);
 6749|  48.9k|  return rc < 0 ? rc : unlock_rc;
  ------------------
  |  Branch (6749:10): [True: 0, False: 48.9k]
  ------------------
 6750|  48.9k|}
frame_decompress_chunk:
 7084|   490k|int frame_decompress_chunk(blosc2_context *dctx, blosc2_frame_s* frame, int64_t nchunk, void *dest, int32_t nbytes) {
 7085|   490k|  uint8_t* src = NULL;
 7086|   490k|  bool needs_free = false;
 7087|   490k|  int32_t srcsize;
 7088|   490k|  int32_t chunk_nbytes;
 7089|   490k|  int32_t chunk_cbytes;
 7090|   490k|  int rc;
 7091|       |
 7092|   490k|  size_t capacity = 0;
 7093|   490k|  rc = get_chunk(frame, nchunk, &src, &needs_free, &capacity);
 7094|   490k|  if (rc < 0) {
  ------------------
  |  Branch (7094:7): [True: 0, False: 490k]
  ------------------
 7095|      0|    BLOSC_TRACE_ERROR("Cannot get the chunk in position %" PRId64 ".", nchunk);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7096|      0|    goto end;
 7097|      0|  }
 7098|   490k|  srcsize = rc;
 7099|   490k|  if (srcsize < BLOSC_MIN_HEADER_LENGTH) {
  ------------------
  |  Branch (7099:7): [True: 0, False: 490k]
  ------------------
 7100|      0|    BLOSC_TRACE_ERROR("Not enough input to read the header of chunk %" PRId64 ".", nchunk);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7101|      0|    rc = BLOSC2_ERROR_READ_BUFFER;
 7102|      0|    goto end;
 7103|      0|  }
 7104|       |
 7105|   490k|  rc = blosc2_cbuffer_sizes(src, &chunk_nbytes, &chunk_cbytes, NULL);
 7106|   490k|  if (rc < 0) {
  ------------------
  |  Branch (7106:7): [True: 0, False: 490k]
  ------------------
 7107|      0|    goto end;
 7108|      0|  }
 7109|       |  /* The header cbytes is used as srcsize below, so it must fit in what was read */
 7110|   490k|  if (chunk_cbytes > srcsize) {
  ------------------
  |  Branch (7110:7): [True: 0, False: 490k]
  ------------------
 7111|      0|    BLOSC_TRACE_ERROR("Invalid chunk size in frame for chunk %" PRId64 ".", nchunk);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7112|      0|    rc = BLOSC2_ERROR_INVALID_HEADER;
 7113|      0|    goto end;
 7114|      0|  }
 7115|       |
 7116|       |  /* Create a buffer for destination */
 7117|   490k|  if (chunk_nbytes > nbytes) {
  ------------------
  |  Branch (7117:7): [True: 0, False: 490k]
  ------------------
 7118|      0|    BLOSC_TRACE_ERROR("Not enough space for decompressing in dest.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7119|      0|    rc = BLOSC2_ERROR_WRITE_BUFFER;
 7120|      0|    goto end;
 7121|      0|  }
 7122|       |  /* And decompress it */
 7123|   490k|  dctx->header_overhead = BLOSC_EXTENDED_HEADER_LENGTH;
 7124|   490k|  int chunksize = rc = blosc2_decompress_ctx(dctx, src, chunk_cbytes, dest, nbytes);
 7125|   490k|  if (chunksize < 0 || chunksize != chunk_nbytes) {
  ------------------
  |  Branch (7125:7): [True: 0, False: 490k]
  |  Branch (7125:24): [True: 0, False: 490k]
  ------------------
 7126|      0|    BLOSC_TRACE_ERROR("Error in decompressing chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7127|      0|    if (chunksize >= 0)
  ------------------
  |  Branch (7127:9): [True: 0, False: 0]
  ------------------
 7128|      0|      rc = BLOSC2_ERROR_FAILURE;
 7129|      0|  }
 7130|   490k|  end:
 7131|   490k|  if (needs_free) {
  ------------------
  |  Branch (7131:7): [True: 6.75k, False: 483k]
  ------------------
 7132|  6.75k|    blosc2_tmp_free(src, capacity);
 7133|  6.75k|  }
 7134|   490k|  return rc;
 7135|   490k|}
frame.c:frame_writer_close_locked:
  474|  6.31k|static int frame_writer_close_locked(blosc2_frame_s* frame) {
  475|  6.31k|  int rc = BLOSC2_ERROR_SUCCESS;
  476|  6.31k|  if (frame->write_fp != NULL) {
  ------------------
  |  Branch (476:7): [True: 0, False: 6.31k]
  ------------------
  477|       |    /* Only the filesystem backend ever populates write_fp */
  478|      0|    int close_rc = blosc2_stdio_close(frame->write_fp);
  479|      0|    frame->write_fp = NULL;
  480|      0|#if !defined(_WIN32)
  481|      0|    reader_cache_return();
  482|      0|#endif
  483|      0|    if (close_rc != 0) {
  ------------------
  |  Branch (483:9): [True: 0, False: 0]
  ------------------
  484|      0|      BLOSC_TRACE_ERROR("Cannot close the cached frame writer handle.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  485|      0|      rc = BLOSC2_ERROR_FILE_WRITE;
  486|      0|    }
  487|      0|  }
  488|       |  frame->write_fp_stale = false;
  489|  6.31k|  frame->file_end = 0;
  490|  6.31k|  return rc;
  491|  6.31k|}
frame.c:frame_reader_close_locked:
  441|  6.31k|static int frame_reader_close_locked(blosc2_frame_s* frame, bool force) {
  442|  6.31k|  if (frame->read_fp == NULL) {
  ------------------
  |  Branch (442:7): [True: 6.31k, False: 0]
  ------------------
  443|  6.31k|    return BLOSC2_ERROR_SUCCESS;
  444|  6.31k|  }
  445|      0|  if (frame->read_fp_refs > 0 && !force) {
  ------------------
  |  Branch (445:7): [True: 0, False: 0]
  |  Branch (445:34): [True: 0, False: 0]
  ------------------
  446|       |    /* A caller up the stack is reading through it (frame_to_schunk holds it
  447|       |       across its whole chunk loop, and that loop re-enters get_header_info).
  448|       |       Closing it here would hand that caller a dangling handle, and its own
  449|       |       release would then close it a second time.  Leave it: the operation in
  450|       |       flight finishes on the file it started on, and the next revalidate --
  451|       |       past that release -- drops it. */
  452|      0|    return 1;
  453|      0|  }
  454|       |  /* read_fp only ever comes from the filesystem backend, so close it directly:
  455|       |     blosc2_get_io_cb() would return NULL after a blosc2_destroy(), and then the
  456|       |     descriptor would leak while its cache slot got handed back anyway. */
  457|      0|  int close_rc = blosc2_stdio_close(frame->read_fp);
  458|      0|  frame->read_fp = NULL;
  459|      0|  frame->read_fp_refs = 0;
  460|      0|#if !defined(_WIN32)
  461|      0|  reader_cache_return();
  462|      0|#endif
  463|      0|  if (close_rc != 0) {
  ------------------
  |  Branch (463:7): [True: 0, False: 0]
  ------------------
  464|      0|    BLOSC_TRACE_ERROR("Cannot close the cached frame reader handle.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  465|      0|    return BLOSC2_ERROR_FILE_WRITE;
  466|      0|  }
  467|      0|  return BLOSC2_ERROR_SUCCESS;
  468|      0|}
frame.c:frame_alloc:
  308|  6.33k|static blosc2_frame_s* frame_alloc(void) {
  309|  6.33k|  blosc2_frame_s* frame = calloc(1, sizeof(blosc2_frame_s));
  310|  6.33k|  if (frame != NULL) {
  ------------------
  |  Branch (310:7): [True: 6.33k, False: 0]
  ------------------
  311|  6.33k|    blosc2_pthread_mutex_init(&frame->read_fp_mutex, NULL);
  ------------------
  |  |   90|  6.33k|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
  312|  6.33k|  }
  313|  6.33k|  return frame;
  314|  6.33k|}
frame.c:frame_refresh_if_stale:
 1568|  3.99M|static int frame_refresh_if_stale(blosc2_frame_s *frame, int64_t frame_len_on_disk) {
 1569|  3.99M|  if (frame->cframe != NULL || frame->schunk == NULL ||
  ------------------
  |  Branch (1569:7): [True: 3.99M, False: 0]
  |  Branch (1569:32): [True: 0, False: 0]
  ------------------
 1570|  3.99M|      (!frame->force_refresh && frame_len_on_disk == frame->len)) {
  ------------------
  |  Branch (1570:8): [True: 0, False: 0]
  |  Branch (1570:33): [True: 0, False: 0]
  ------------------
 1571|  3.99M|    return 0;
 1572|  3.99M|  }
 1573|       |  // Saved so the metalayer-reload retry loop below can roll back to a fully
 1574|       |  // consistent state on exhaustion, rather than leaving frame->len/trailer_len
 1575|       |  // committed to the new value with no metalayers to match it.
 1576|      0|  int64_t old_len = frame->len;
 1577|      0|  uint32_t old_trailer_len = frame->trailer_len;
 1578|       |
 1579|      0|  if (frame_len_on_disk < FRAME_HEADER_MINLEN + FRAME_TRAILER_MINLEN) {
  ------------------
  |  |   49|      0|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|      0|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|      0|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|      0|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|      0|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|      0|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|      0|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|      0|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|      0|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|      0|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                if (frame_len_on_disk < FRAME_HEADER_MINLEN + FRAME_TRAILER_MINLEN) {
  ------------------
  |  |   58|      0|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
  |  Branch (1579:7): [True: 0, False: 0]
  ------------------
 1580|      0|    BLOSC_TRACE_ERROR("Invalid on-disk frame length (%" PRId64 ").", frame_len_on_disk);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1581|      0|    return BLOSC2_ERROR_FILE_READ;
 1582|      0|  }
 1583|       |
 1584|       |  // Read and validate the trailer *before* mutating any frame state below,
 1585|       |  // so a transient torn read (a writer without locking has no coordination
 1586|       |  // preventing a reader from landing mid-rewrite here -- the documented
 1587|       |  // SWMR-without-locking tradeoff) can be handled opportunistically: keep
 1588|       |  // the old cached view and let the next access retry, the same way
 1589|       |  // frame_check_stale()'s header read already does a few lines up in the
 1590|       |  // caller. Once frame->len/coffsets are overwritten below, a failure
 1591|       |  // partway through would leave the frame in a self-inconsistent state
 1592|       |  // (new length, stale trailer/offsets), so those mutations only happen
 1593|       |  // after the trailer is confirmed good.
 1594|      0|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 1595|      0|  if (io_cb == NULL) {
  ------------------
  |  Branch (1595:7): [True: 0, False: 0]
  ------------------
 1596|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1597|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 1598|      0|  }
 1599|      0|  void* fp;
 1600|      0|  if (frame->sframe) {
  ------------------
  |  Branch (1600:7): [True: 0, False: 0]
  ------------------
 1601|      0|    fp = sframe_open_index(frame->urlpath, "rb", frame->schunk->storage->io);
 1602|      0|  }
 1603|      0|  else {
 1604|      0|    fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 1605|      0|  }
 1606|      0|  if (fp == NULL) {
  ------------------
  |  Branch (1606:7): [True: 0, False: 0]
  ------------------
 1607|      0|    BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1608|      0|    return BLOSC2_ERROR_FILE_OPEN;
 1609|      0|  }
 1610|      0|  uint8_t trailer[FRAME_TRAILER_MINLEN];
 1611|      0|  uint8_t* trailer_ptr = trailer;
 1612|      0|  int64_t io_pos = frame->file_offset + frame_len_on_disk - FRAME_TRAILER_MINLEN;
  ------------------
  |  |   58|      0|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
 1613|      0|  int64_t rbytes = io_cb->read((void**)&trailer_ptr, 1, FRAME_TRAILER_MINLEN, io_pos, fp);
  ------------------
  |  |   58|      0|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
 1614|      0|  frame_reader_release(frame, io_cb, fp);
 1615|      0|  if (rbytes != FRAME_TRAILER_MINLEN) {
  ------------------
  |  |   58|      0|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
  |  Branch (1615:7): [True: 0, False: 0]
  ------------------
 1616|      0|    BLOSC_TRACE_ERROR("Cannot read the trailer out of the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1617|      0|    return 0;  // opportunistic: transient, keep the cached view, retry later
 1618|      0|  }
 1619|      0|  int trailer_offset = FRAME_TRAILER_MINLEN - FRAME_TRAILER_LEN_OFFSET;
  ------------------
  |  |   58|      0|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
                int trailer_offset = FRAME_TRAILER_MINLEN - FRAME_TRAILER_LEN_OFFSET;
  ------------------
  |  |   59|      0|#define FRAME_TRAILER_LEN_OFFSET (22)  // offset to trailer length (counting from the end)
  ------------------
 1620|      0|  if (trailer_ptr[trailer_offset - 1] != 0xce) {
  ------------------
  |  Branch (1620:7): [True: 0, False: 0]
  ------------------
 1621|       |    // Not a valid trailer; most likely we are reading a frame in the middle of
 1622|       |    // being rewritten by another handle without locking (locked handles
 1623|       |    // fully serialize, so this only happens under the no-locking contract).
 1624|      0|    BLOSC_TRACE_ERROR("Invalid trailer in frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1625|      0|    return 0;  // opportunistic, same reasoning as above
 1626|      0|  }
 1627|      0|  uint32_t trailer_len;
 1628|      0|  from_big(&trailer_len, trailer_ptr + trailer_offset, sizeof(trailer_len));
  ------------------
  |  |   38|      0|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1629|      0|  if (trailer_len < FRAME_TRAILER_MINLEN || trailer_len > INT32_MAX ||
  ------------------
  |  |   58|      0|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
  |  Branch (1629:7): [True: 0, False: 0]
  |  Branch (1629:45): [True: 0, False: 0]
  ------------------
 1630|      0|      (int64_t)trailer_len > frame_len_on_disk - FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|      0|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|      0|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|      0|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|      0|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|      0|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|      0|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|      0|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|      0|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|      0|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|      0|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|      0|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|      0|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|      0|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1630:7): [True: 0, False: 0]
  ------------------
 1631|      0|    BLOSC_TRACE_ERROR("Invalid trailer length (%" PRIu32 ") in frame.", trailer_len);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1632|      0|    return 0;  // opportunistic, same reasoning as above
 1633|      0|  }
 1634|       |
 1635|       |  // Trailer confirmed good: now safe to commit the new length. The lock
 1636|       |  // generation counter (see frame_lock) may have flagged a mutation that
 1637|       |  // left the frame length unchanged; only clear that flag here, once a
 1638|       |  // refresh has actually happened -- clearing it earlier and then bailing
 1639|       |  // out opportunistically above would permanently lose a same-length
 1640|       |  // mutation notification on a torn-read retry. The cached offsets index is
 1641|       |  // dropped further down, only once the metalayer/vlmetalayer reload below
 1642|       |  // has actually succeeded -- neither of those touches frame->coffsets, so
 1643|       |  // deferring this keeps the old view of it fully intact for the
 1644|       |  // opportunistic rollback path below, exactly as strong as the trailer
 1645|       |  // read's own bail-outs above.
 1646|      0|  frame->force_refresh = false;
 1647|      0|  frame->len = frame_len_on_disk;
 1648|      0|  frame->file_end = 0;  // another handle wrote the file; its size is unknown again
 1649|      0|  if (frame->nholes > 0) {
  ------------------
  |  Branch (1649:7): [True: 0, False: 0]
  ------------------
 1650|       |    // Nor do we know its free space any more (only an unlocked writer gets here inside frame_begin_updates())
 1651|      0|    frame->nholes = 0;
 1652|      0|    frame->holes_lost = true;
 1653|      0|  }
 1654|      0|  frame->trailer_len = trailer_len;
 1655|       |
 1656|       |  // The header metalayers and trailer vlmetalayers were cached at open time;
 1657|       |  // reload them so metadata changes made by another handle (e.g. a b2nd shape
 1658|       |  // update) become visible too.  The guard protects against re-entering from
 1659|       |  // the reload path itself (get_header_info does not refresh, but cheap
 1660|       |  // insurance against future changes there).
 1661|       |  //
 1662|       |  // frame_get_metalayers()/frame_get_vlmetalayers() each do their own fully
 1663|       |  // independent header/trailer re-read (separate from the trailer read
 1664|       |  // above), so without locking they can hit the same transient torn-read
 1665|       |  // window. Unlike that trailer read, there's no way to validate first and
 1666|       |  // commit after: schunk_free_metalayers()/schunk_free_vlmetalayers() must
 1667|       |  // run before a reload attempt (the parsers write straight into
 1668|       |  // schunk->metalayers[]/vlmetalayers[] as they go), so a single failed
 1669|       |  // attempt already discards the old cached set. Retry a bounded number of
 1670|       |  // times -- both free helpers are NULL-safe and re-run cleanly against a
 1671|       |  // partial prior attempt, and each attempt is a fresh independent read, so
 1672|       |  // this self-heals once the writer's rewrite stabilizes.
 1673|       |  //
 1674|       |  // This reasoning only holds without locking, though: frame_check_stale()
 1675|       |  // (the only caller) holds the shared frame lock across this entire call
 1676|       |  // when frame->locking is set, which fully excludes writers for its
 1677|       |  // duration -- so under locking a reload failure here cannot be a torn
 1678|       |  // read, it is a genuine problem (corruption or a real I/O error), and
 1679|       |  // retrying 50 times would just waste ~50ms holding that shared lock
 1680|       |  // before silently masking it. Retry once (i.e. don't retry) and propagate
 1681|       |  // the error under locking; keep the opportunistic bounded retry + silent
 1682|       |  // rollback for the no-locking case only.
 1683|       |  //
 1684|       |  // On exhaustion in the no-locking case, roll back frame->len/trailer_len
 1685|       |  // to what they were before this call and force a full retry on the next
 1686|       |  // poll (frame->force_refresh = true) -- otherwise frame_len_on_disk ==
 1687|       |  // frame->len would short-circuit every subsequent call at the top of this
 1688|       |  // function, permanently stranding this handle with an empty metalayer set.
 1689|      0|  if (!frame->refreshing) {
  ------------------
  |  Branch (1689:7): [True: 0, False: 0]
  ------------------
 1690|      0|    frame->refreshing = true;
 1691|      0|    int rc = -1;
 1692|      0|    const int max_attempts = frame->locking ? 1 : 50;
  ------------------
  |  Branch (1692:30): [True: 0, False: 0]
  ------------------
 1693|      0|    for (int attempt = 0; attempt < max_attempts; attempt++) {
  ------------------
  |  Branch (1693:27): [True: 0, False: 0]
  ------------------
 1694|      0|      schunk_free_metalayers(frame->schunk);
 1695|      0|      rc = frame_get_metalayers(frame, frame->schunk);
 1696|      0|      if (rc >= 0) {
  ------------------
  |  Branch (1696:11): [True: 0, False: 0]
  ------------------
 1697|      0|        schunk_free_vlmetalayers(frame->schunk);
 1698|      0|        rc = frame_get_vlmetalayers(frame, frame->schunk);
 1699|      0|      }
 1700|      0|      if (rc >= 0 || attempt + 1 == max_attempts) {
  ------------------
  |  Branch (1700:11): [True: 0, False: 0]
  |  Branch (1700:22): [True: 0, False: 0]
  ------------------
 1701|      0|        break;
 1702|      0|      }
 1703|       |#if defined(_WIN32)
 1704|       |      Sleep(1);
 1705|       |#else
 1706|      0|      usleep(1000);
 1707|      0|#endif
 1708|      0|    }
 1709|      0|    frame->refreshing = false;
 1710|      0|    if (rc < 0) {
  ------------------
  |  Branch (1710:9): [True: 0, False: 0]
  ------------------
 1711|      0|      if (frame->locking) {
  ------------------
  |  Branch (1711:11): [True: 0, False: 0]
  ------------------
 1712|      0|        BLOSC_TRACE_ERROR("Cannot reload the metalayers from the refreshed frame "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1713|      0|                          "(locked handle: this is not a transient race).");
 1714|      0|        return rc;
 1715|      0|      }
 1716|      0|      BLOSC_TRACE_ERROR("Cannot reload the metalayers from the refreshed frame "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1717|      0|                        "after retries; rolling back to the previous cached view.");
 1718|      0|      frame->len = old_len;
 1719|      0|      frame->trailer_len = old_trailer_len;
 1720|      0|      frame->force_refresh = true;
 1721|      0|      return 0;
 1722|      0|    }
 1723|      0|  }
 1724|      0|  frame->schunk->change_tick++;
 1725|       |
 1726|       |  // Cached offsets index invalidated only now, after a fully successful
 1727|       |  // refresh: recomputed lazily from the fresh trailer on demand.
 1728|      0|  if (frame->coffsets != NULL) {
  ------------------
  |  Branch (1728:7): [True: 0, False: 0]
  ------------------
 1729|      0|    if (frame->coffsets_needs_free) {
  ------------------
  |  Branch (1729:9): [True: 0, False: 0]
  ------------------
 1730|      0|      free(frame->coffsets);
 1731|      0|    }
 1732|      0|    frame->coffsets = NULL;
 1733|      0|  }
 1734|       |
 1735|      0|  return 1;
 1736|      0|}
frame.c:get_coffsets_nbytes:
 1783|  1.51k|                               int32_t *coffsets_nbytes, const blosc2_io *io) {
 1784|  1.51k|  int32_t chunk_cbytes;
 1785|  1.51k|  int rc;
 1786|  1.51k|  int64_t off_pos = header_len;
 1787|  1.51k|  if (!frame->sframe) {
  ------------------
  |  Branch (1787:7): [True: 1.51k, False: 0]
  ------------------
 1788|  1.51k|    if (cbytes < INT64_MAX - header_len) {
  ------------------
  |  Branch (1788:9): [True: 1.44k, False: 63]
  ------------------
 1789|  1.44k|      off_pos += cbytes;
 1790|  1.44k|    }
 1791|  1.51k|  }
 1792|       |
 1793|  1.51k|  if (off_pos < 0 || off_pos > INT64_MAX - BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (1793:7): [True: 67, False: 1.44k]
  |  Branch (1793:22): [True: 1, False: 1.44k]
  ------------------
 1794|  1.44k|      off_pos + BLOSC_EXTENDED_HEADER_LENGTH > frame->len) {
  ------------------
  |  Branch (1794:7): [True: 95, False: 1.34k]
  ------------------
 1795|    163|    BLOSC_TRACE_ERROR("Cannot read the offsets outside of frame boundary.");
  ------------------
  |  |   93|    163|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    163|    do {                                            \
  |  |  |  |   98|    163|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    163|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 163, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    163|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1796|    163|    return BLOSC2_ERROR_INVALID_HEADER;
 1797|    163|  }
 1798|       |
 1799|  1.34k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (1799:7): [True: 1.34k, False: 0]
  ------------------
 1800|  1.34k|    uint8_t *off_start = frame->cframe + off_pos;
 1801|  1.34k|    rc = blosc2_cbuffer_sizes(off_start, coffsets_nbytes, &chunk_cbytes, NULL);
 1802|  1.34k|    if (rc < 0) {
  ------------------
  |  Branch (1802:9): [True: 38, False: 1.31k]
  ------------------
 1803|     38|      return rc;
 1804|     38|    }
 1805|  1.31k|    if (chunk_cbytes < 0 || off_pos + chunk_cbytes > frame->len) {
  ------------------
  |  Branch (1805:9): [True: 0, False: 1.31k]
  |  Branch (1805:29): [True: 40, False: 1.27k]
  ------------------
 1806|     40|      BLOSC_TRACE_ERROR("Cannot read the cbytes outside of frame boundary.");
  ------------------
  |  |   93|     40|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     40|    do {                                            \
  |  |  |  |   98|     40|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     40|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 40, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     40|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1807|     40|      return BLOSC2_ERROR_INVALID_HEADER;
 1808|     40|    }
 1809|  1.27k|    return 0;
 1810|  1.31k|  }
 1811|       |
 1812|      0|  int64_t trailer_offset = get_trailer_offset(frame, header_len, true);
 1813|      0|  if (trailer_offset < BLOSC_EXTENDED_HEADER_LENGTH || trailer_offset + FRAME_TRAILER_MINLEN > frame->len) {
  ------------------
  |  |   58|      0|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
  |  Branch (1813:7): [True: 0, False: 0]
  |  Branch (1813:56): [True: 0, False: 0]
  ------------------
 1814|      0|    BLOSC_TRACE_ERROR("Cannot read the trailer out of the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1815|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 1816|      0|  }
 1817|       |
 1818|      0|  blosc2_io_cb *io_cb = blosc2_get_io_cb(io->id);
 1819|      0|  if (io_cb == NULL) {
  ------------------
  |  Branch (1819:7): [True: 0, False: 0]
  ------------------
 1820|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1821|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 1822|      0|  }
 1823|       |
 1824|      0|  uint8_t header[BLOSC_EXTENDED_HEADER_LENGTH];
 1825|      0|  uint8_t *header_ptr = header;
 1826|      0|  void *fp = NULL;
 1827|      0|  int64_t io_pos = 0;
 1828|      0|  if (frame->sframe) {
  ------------------
  |  Branch (1828:7): [True: 0, False: 0]
  ------------------
 1829|      0|    fp = sframe_open_index(frame->urlpath, "rb", io);
 1830|      0|    if (fp == NULL) {
  ------------------
  |  Branch (1830:9): [True: 0, False: 0]
  ------------------
 1831|      0|      BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1832|      0|      return BLOSC2_ERROR_FILE_OPEN;
 1833|      0|    }
 1834|      0|    io_pos = off_pos;
 1835|      0|  }
 1836|      0|  else {
 1837|      0|    fp = frame_reader_acquire(frame, io);
 1838|      0|    if (fp == NULL) {
  ------------------
  |  Branch (1838:9): [True: 0, False: 0]
  ------------------
 1839|      0|      BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1840|      0|      return BLOSC2_ERROR_FILE_OPEN;
 1841|      0|    }
 1842|      0|    io_pos = frame->file_offset + off_pos;
 1843|      0|  }
 1844|      0|  int64_t rbytes = io_cb->read((void**)&header_ptr, 1, BLOSC_EXTENDED_HEADER_LENGTH, io_pos, fp);
 1845|      0|  frame_reader_release(frame, io_cb, fp);
 1846|      0|  if (rbytes != BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (1846:7): [True: 0, False: 0]
  ------------------
 1847|      0|    BLOSC_TRACE_ERROR("Cannot read the offsets header out of the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1848|      0|    return BLOSC2_ERROR_FILE_READ;
 1849|      0|  }
 1850|       |
 1851|      0|  rc = blosc2_cbuffer_sizes(header_ptr, coffsets_nbytes, &chunk_cbytes, NULL);
 1852|      0|  if (rc < 0) {
  ------------------
  |  Branch (1852:7): [True: 0, False: 0]
  ------------------
 1853|      0|    return rc;
 1854|      0|  }
 1855|       |
 1856|      0|  if (chunk_cbytes < 0 || off_pos + chunk_cbytes > trailer_offset) {
  ------------------
  |  Branch (1856:7): [True: 0, False: 0]
  |  Branch (1856:27): [True: 0, False: 0]
  ------------------
 1857|      0|    BLOSC_TRACE_ERROR("Cannot read the offsets outside of frame boundary.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1858|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 1859|      0|  }
 1860|       |
 1861|      0|  return 0;
 1862|      0|}
frame.c:get_meta_from_header:
 2963|  1.60k|                                int32_t header_len) {
 2964|  1.60k|  BLOSC_UNUSED_PARAM(frame);
  ------------------
  |  |   28|  1.60k|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
 2965|  1.60k|  int64_t header_pos = FRAME_IDX_SIZE;
  ------------------
  |  |   51|  1.60k|#define FRAME_IDX_SIZE (FRAME_METALAYERS + 1 + 1)  // 89
  |  |  ------------------
  |  |  |  |   50|  1.60k|#define FRAME_METALAYERS (FRAME_HEADER_MINLEN)  // 87
  |  |  |  |  ------------------
  |  |  |  |  |  |   49|  1.60k|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|  1.60k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.60k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   42|  1.60k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   41|  1.60k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.60k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.60k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.60k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.60k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.60k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.60k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.60k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.60k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.60k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2966|       |
 2967|       |  // Get the size for the index of metalayers
 2968|  1.60k|  uint16_t idx_size;
 2969|  1.60k|  header_pos += sizeof(idx_size);
 2970|  1.60k|  if (header_len < header_pos) {
  ------------------
  |  Branch (2970:7): [True: 0, False: 1.60k]
  ------------------
 2971|      0|    return BLOSC2_ERROR_READ_BUFFER;
 2972|      0|  }
 2973|  1.60k|  from_big(&idx_size, header + FRAME_IDX_SIZE, sizeof(idx_size));
  ------------------
  |  |   38|  1.60k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2974|       |
 2975|       |  // Get the actual index of metalayers
 2976|  1.60k|  uint8_t* metalayers_idx = header + FRAME_IDX_SIZE + 2;
  ------------------
  |  |   51|  1.60k|#define FRAME_IDX_SIZE (FRAME_METALAYERS + 1 + 1)  // 89
  |  |  ------------------
  |  |  |  |   50|  1.60k|#define FRAME_METALAYERS (FRAME_HEADER_MINLEN)  // 87
  |  |  |  |  ------------------
  |  |  |  |  |  |   49|  1.60k|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|  1.60k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  1.60k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   42|  1.60k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   41|  1.60k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.60k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.60k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.60k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.60k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.60k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.60k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.60k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.60k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.60k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2977|  1.60k|  header_pos += 1;
 2978|  1.60k|  if (header_len < header_pos) {
  ------------------
  |  Branch (2978:7): [True: 1, False: 1.60k]
  ------------------
 2979|      1|    return BLOSC2_ERROR_READ_BUFFER;
 2980|      1|  }
 2981|  1.60k|  if (metalayers_idx[0] != 0xde) {   // sanity check
  ------------------
  |  Branch (2981:7): [True: 25, False: 1.57k]
  ------------------
 2982|     25|    return BLOSC2_ERROR_DATA;
 2983|     25|  }
 2984|  1.57k|  uint8_t* idxp = metalayers_idx + 1;
 2985|  1.57k|  uint16_t nmetalayers;
 2986|  1.57k|  header_pos += sizeof(nmetalayers);
 2987|  1.57k|  if (header_len < header_pos) {
  ------------------
  |  Branch (2987:7): [True: 1, False: 1.57k]
  ------------------
 2988|      1|    return BLOSC2_ERROR_READ_BUFFER;
 2989|      1|  }
 2990|  1.57k|  from_big(&nmetalayers, idxp, sizeof(uint16_t));
  ------------------
  |  |   38|  1.57k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2991|  1.57k|  idxp += 2;
 2992|  1.57k|  if (nmetalayers > BLOSC2_MAX_METALAYERS) {
  ------------------
  |  | 1895|  1.57k|#define BLOSC2_MAX_METALAYERS 16
  ------------------
  |  Branch (2992:7): [True: 0, False: 1.57k]
  ------------------
 2993|      0|    return BLOSC2_ERROR_DATA;
 2994|      0|  }
 2995|  1.57k|  schunk->nmetalayers = nmetalayers;
 2996|       |
 2997|       |  // Populate the metalayers and its serialized values
 2998|  3.06k|  for (int nmetalayer = 0; nmetalayer < nmetalayers; nmetalayer++) {
  ------------------
  |  Branch (2998:28): [True: 1.52k, False: 1.53k]
  ------------------
 2999|  1.52k|    header_pos += 1;
 3000|  1.52k|    if (header_len < header_pos) {
  ------------------
  |  Branch (3000:9): [True: 1, False: 1.52k]
  ------------------
 3001|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3002|      1|    }
 3003|  1.52k|    if ((*idxp & 0xe0u) != 0xa0u) {   // sanity check
  ------------------
  |  Branch (3003:9): [True: 5, False: 1.52k]
  ------------------
 3004|      5|      return BLOSC2_ERROR_DATA;
 3005|      5|    }
 3006|  1.52k|    blosc2_metalayer* metalayer = calloc(1, sizeof(blosc2_metalayer));
 3007|  1.52k|    if (metalayer == NULL) {
  ------------------
  |  Branch (3007:9): [True: 0, False: 1.52k]
  ------------------
 3008|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 3009|      0|    }
 3010|  1.52k|    schunk->metalayers[nmetalayer] = metalayer;
 3011|       |
 3012|       |    // Populate the metalayer string
 3013|  1.52k|    uint8_t nslen = *idxp & (uint8_t)0x1F;
 3014|  1.52k|    idxp += 1;
 3015|  1.52k|    header_pos += nslen;
 3016|  1.52k|    if (header_len < header_pos) {
  ------------------
  |  Branch (3016:9): [True: 1, False: 1.52k]
  ------------------
 3017|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3018|      1|    }
 3019|  1.52k|    char* ns = malloc((size_t)nslen + 1);
 3020|  1.52k|    if (ns == NULL) {
  ------------------
  |  Branch (3020:9): [True: 0, False: 1.52k]
  ------------------
 3021|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 3022|      0|    }
 3023|  1.52k|    memcpy(ns, idxp, nslen);
 3024|  1.52k|    ns[nslen] = '\0';
 3025|  1.52k|    idxp += nslen;
 3026|  1.52k|    metalayer->name = ns;
 3027|       |
 3028|       |    // Populate the serialized value for this metalayer
 3029|       |    // Get the offset
 3030|  1.52k|    header_pos += 1;
 3031|  1.52k|    if (header_len < header_pos) {
  ------------------
  |  Branch (3031:9): [True: 1, False: 1.51k]
  ------------------
 3032|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3033|      1|    }
 3034|  1.51k|    if ((*idxp & 0xffu) != 0xd2u) {   // sanity check
  ------------------
  |  Branch (3034:9): [True: 6, False: 1.51k]
  ------------------
 3035|      6|      return BLOSC2_ERROR_DATA;
 3036|      6|    }
 3037|  1.51k|    idxp += 1;
 3038|  1.51k|    int32_t offset;
 3039|  1.51k|    header_pos += sizeof(offset);
 3040|  1.51k|    if (header_len < header_pos) {
  ------------------
  |  Branch (3040:9): [True: 1, False: 1.51k]
  ------------------
 3041|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3042|      1|    }
 3043|  1.51k|    from_big(&offset, idxp, sizeof(offset));
  ------------------
  |  |   38|  1.51k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 3044|  1.51k|    idxp += 4;
 3045|  1.51k|    if (offset < 0 || offset >= header_len) {
  ------------------
  |  Branch (3045:9): [True: 6, False: 1.50k]
  |  Branch (3045:23): [True: 5, False: 1.50k]
  ------------------
 3046|       |      // Offset is less than zero or exceeds header length
 3047|     11|      return BLOSC2_ERROR_DATA;
 3048|     11|    }
 3049|       |    // Go to offset and see if we have the correct marker
 3050|  1.50k|    uint8_t* content_marker = header + offset;
 3051|  1.50k|    if ((int64_t)header_len < (int64_t)offset + 1 + 4) {
  ------------------
  |  Branch (3051:9): [True: 1, False: 1.50k]
  ------------------
 3052|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3053|      1|    }
 3054|  1.50k|    if (*content_marker != 0xc6) {
  ------------------
  |  Branch (3054:9): [True: 1, False: 1.49k]
  ------------------
 3055|      1|      return BLOSC2_ERROR_DATA;
 3056|      1|    }
 3057|       |
 3058|       |    // Read the size of the content
 3059|  1.49k|    int32_t content_len;
 3060|  1.49k|    from_big(&content_len, content_marker + 1, sizeof(content_len));
  ------------------
  |  |   38|  1.49k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 3061|  1.49k|    if (content_len < 0) {
  ------------------
  |  Branch (3061:9): [True: 1, False: 1.49k]
  ------------------
 3062|      1|      return BLOSC2_ERROR_DATA;
 3063|      1|    }
 3064|  1.49k|    metalayer->content_len = content_len;
 3065|       |
 3066|       |    // Finally, read the content. Use 64-bit arithmetic so a malicious
 3067|       |    // (offset, content_len) pair near INT32_MAX cannot wrap and bypass the
 3068|       |    // bounds check, which would let memcpy below read past the header buffer.
 3069|  1.49k|    if ((int64_t)header_len < (int64_t)offset + 1 + 4 + (int64_t)content_len) {
  ------------------
  |  Branch (3069:9): [True: 13, False: 1.48k]
  ------------------
 3070|     13|      return BLOSC2_ERROR_READ_BUFFER;
 3071|     13|    }
 3072|  1.48k|    char* content = malloc((size_t)content_len);
 3073|       |    // malloc(0) is allowed to return NULL, and blosc2_meta_add accepts
 3074|       |    // content_len == 0, so only treat NULL as an allocation failure when
 3075|       |    // a non-zero allocation was requested.
 3076|  1.48k|    if (content_len > 0 && content == NULL) {
  ------------------
  |  Branch (3076:9): [True: 1.48k, False: 1]
  |  Branch (3076:28): [True: 0, False: 1.48k]
  ------------------
 3077|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 3078|      0|    }
 3079|  1.48k|    if (content_len > 0) {
  ------------------
  |  Branch (3079:9): [True: 1.48k, False: 1]
  ------------------
 3080|  1.48k|      memcpy(content, content_marker + 1 + 4, (size_t)content_len);
 3081|  1.48k|    }
 3082|  1.48k|    metalayer->content = (uint8_t*)content;
 3083|  1.48k|  }
 3084|       |
 3085|  1.53k|  return 1;
 3086|  1.57k|}
frame.c:get_vlmeta_from_trailer:
 3166|  1.53k|                                   int32_t trailer_len) {
 3167|       |
 3168|  1.53k|  BLOSC_UNUSED_PARAM(frame);
  ------------------
  |  |   28|  1.53k|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
 3169|  1.53k|  int64_t trailer_pos = FRAME_TRAILER_VLMETALAYERS + 2;
  ------------------
  |  |   60|  1.53k|#define FRAME_TRAILER_VLMETALAYERS (2)
  ------------------
 3170|  1.53k|  uint8_t* idxp = trailer + trailer_pos;
 3171|       |
 3172|       |  // Get the size for the index of metalayers
 3173|  1.53k|  trailer_pos += 2;
 3174|  1.53k|  if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (3174:7): [True: 0, False: 1.53k]
  ------------------
 3175|      0|    return BLOSC2_ERROR_READ_BUFFER;
 3176|      0|  }
 3177|  1.53k|  uint16_t idx_size;
 3178|  1.53k|  from_big(&idx_size, idxp, sizeof(idx_size));
  ------------------
  |  |   38|  1.53k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 3179|  1.53k|  idxp += 2;
 3180|       |
 3181|  1.53k|  trailer_pos += 1;
 3182|       |  // Get the actual index of metalayers
 3183|  1.53k|  if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (3183:7): [True: 0, False: 1.53k]
  ------------------
 3184|      0|    return BLOSC2_ERROR_READ_BUFFER;
 3185|      0|  }
 3186|  1.53k|  if (idxp[0] != 0xde) {   // sanity check
  ------------------
  |  Branch (3186:7): [True: 8, False: 1.52k]
  ------------------
 3187|      8|    return BLOSC2_ERROR_DATA;
 3188|      8|  }
 3189|  1.52k|  idxp += 1;
 3190|       |
 3191|       |  // The on-wire encoding is unsigned (uint16 follows the msgpack `0xde`
 3192|       |  // map16 marker), but `schunk->nvlmetalayers` is int16_t. Decoding into a
 3193|       |  // signed local would let raw bytes like 0xff 0xff slip past the
 3194|       |  // `> BLOSC2_MAX_VLMETALAYERS` ceiling as a negative count, after which
 3195|       |  // a later `blosc2_vlmeta_add` would write through `vlmetalayers[-1]`
 3196|       |  // and corrupt adjacent schunk fields. Decode unsigned, then narrow.
 3197|  1.52k|  uint16_t nmetalayers;
 3198|  1.52k|  trailer_pos += sizeof(nmetalayers);
 3199|  1.52k|  if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (3199:7): [True: 0, False: 1.52k]
  ------------------
 3200|      0|    return BLOSC2_ERROR_READ_BUFFER;
 3201|      0|  }
 3202|  1.52k|  from_big(&nmetalayers, idxp, sizeof(uint16_t));
  ------------------
  |  |   38|  1.52k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 3203|  1.52k|  idxp += 2;
 3204|  1.52k|  if (nmetalayers > BLOSC2_MAX_VLMETALAYERS) {
  ------------------
  |  | 1901|  1.52k|#define BLOSC2_MAX_VLMETALAYERS (8 * 1024)
  ------------------
  |  Branch (3204:7): [True: 2, False: 1.52k]
  ------------------
 3205|      2|    return BLOSC2_ERROR_DATA;
 3206|      2|  }
 3207|  1.52k|  schunk->nvlmetalayers = (int16_t)nmetalayers;
 3208|       |
 3209|       |  // Populate the metalayers and its serialized values
 3210|  1.54k|  for (int nmetalayer = 0; nmetalayer < nmetalayers; nmetalayer++) {
  ------------------
  |  Branch (3210:28): [True: 75, False: 1.47k]
  ------------------
 3211|     75|    trailer_pos += 1;
 3212|     75|    if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (3212:9): [True: 1, False: 74]
  ------------------
 3213|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3214|      1|    }
 3215|     74|    if ((*idxp & 0xe0u) != 0xa0u) {   // sanity check
  ------------------
  |  Branch (3215:9): [True: 8, False: 66]
  ------------------
 3216|      8|      return BLOSC2_ERROR_DATA;
 3217|      8|    }
 3218|     66|    blosc2_metalayer* metalayer = calloc(1, sizeof(blosc2_metalayer));
 3219|     66|    if (metalayer == NULL) {
  ------------------
  |  Branch (3219:9): [True: 0, False: 66]
  ------------------
 3220|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 3221|      0|    }
 3222|     66|    schunk->vlmetalayers[nmetalayer] = metalayer;
 3223|       |
 3224|       |    // Populate the metalayer string
 3225|     66|    uint8_t nslen = *idxp & (uint8_t)0x1F;
 3226|     66|    idxp += 1;
 3227|     66|    trailer_pos += nslen;
 3228|     66|    if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (3228:9): [True: 1, False: 65]
  ------------------
 3229|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3230|      1|    }
 3231|     65|    char* ns = malloc((size_t)nslen + 1);
 3232|     65|    if (ns == NULL) {
  ------------------
  |  Branch (3232:9): [True: 0, False: 65]
  ------------------
 3233|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 3234|      0|    }
 3235|     65|    memcpy(ns, idxp, nslen);
 3236|     65|    ns[nslen] = '\0';
 3237|     65|    idxp += nslen;
 3238|     65|    metalayer->name = ns;
 3239|       |
 3240|       |    // Populate the serialized value for this metalayer
 3241|       |    // Get the offset
 3242|     65|    trailer_pos += 1;
 3243|     65|    if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (3243:9): [True: 0, False: 65]
  ------------------
 3244|      0|      return BLOSC2_ERROR_READ_BUFFER;
 3245|      0|    }
 3246|     65|    if ((*idxp & 0xffu) != 0xd2u) {   // sanity check
  ------------------
  |  Branch (3246:9): [True: 6, False: 59]
  ------------------
 3247|      6|      return BLOSC2_ERROR_DATA;
 3248|      6|    }
 3249|     59|    idxp += 1;
 3250|     59|    int32_t offset;
 3251|     59|    trailer_pos += sizeof(offset);
 3252|     59|    if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (3252:9): [True: 1, False: 58]
  ------------------
 3253|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3254|      1|    }
 3255|     58|    from_big(&offset, idxp, sizeof(offset));
  ------------------
  |  |   38|     58|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 3256|     58|    idxp += 4;
 3257|     58|    if (offset < 0 || offset >= trailer_len) {
  ------------------
  |  Branch (3257:9): [True: 2, False: 56]
  |  Branch (3257:23): [True: 13, False: 43]
  ------------------
 3258|       |      // Offset is less than zero or exceeds trailer length
 3259|     15|      return BLOSC2_ERROR_DATA;
 3260|     15|    }
 3261|       |    // Go to offset and see if we have the correct marker
 3262|     43|    uint8_t* content_marker = trailer + offset;
 3263|     43|    if ((int64_t)trailer_len < (int64_t)offset + 1 + 4) {
  ------------------
  |  Branch (3263:9): [True: 0, False: 43]
  ------------------
 3264|      0|      return BLOSC2_ERROR_READ_BUFFER;
 3265|      0|    }
 3266|     43|    if (*content_marker != 0xc6) {
  ------------------
  |  Branch (3266:9): [True: 4, False: 39]
  ------------------
 3267|      4|      return BLOSC2_ERROR_DATA;
 3268|      4|    }
 3269|       |
 3270|       |    // Read the size of the content
 3271|     39|    int32_t content_len;
 3272|     39|    from_big(&content_len, content_marker + 1, sizeof(content_len));
  ------------------
  |  |   38|     39|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 3273|     39|    if (content_len < 0) {
  ------------------
  |  Branch (3273:9): [True: 1, False: 38]
  ------------------
 3274|      1|      return BLOSC2_ERROR_DATA;
 3275|      1|    }
 3276|     38|    metalayer->content_len = content_len;
 3277|       |
 3278|       |    // Finally, read the content. Use 64-bit arithmetic so a malicious
 3279|       |    // (offset, content_len) pair near INT32_MAX cannot wrap and bypass the
 3280|       |    // bounds check, which would let memcpy below read past the trailer buffer.
 3281|     38|    if ((int64_t)trailer_len < (int64_t)offset + 1 + 4 + (int64_t)content_len) {
  ------------------
  |  Branch (3281:9): [True: 12, False: 26]
  ------------------
 3282|     12|      return BLOSC2_ERROR_READ_BUFFER;
 3283|     12|    }
 3284|     26|    char* content = malloc((size_t)content_len);
 3285|       |    // Same zero-length carve-out as in get_meta_from_header: malloc(0) may
 3286|       |    // return NULL on some platforms, and the public API allows
 3287|       |    // content_len == 0, so don't reject a valid empty vlmetalayer.
 3288|     26|    if (content_len > 0 && content == NULL) {
  ------------------
  |  Branch (3288:9): [True: 16, False: 10]
  |  Branch (3288:28): [True: 0, False: 16]
  ------------------
 3289|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 3290|      0|    }
 3291|     26|    if (content_len > 0) {
  ------------------
  |  Branch (3291:9): [True: 16, False: 10]
  ------------------
 3292|     16|      memcpy(content, content_marker + 1 + 4, (size_t)content_len);
 3293|     16|    }
 3294|     26|    metalayer->content = (uint8_t*)content;
 3295|     26|  }
 3296|  1.47k|  return 1;
 3297|  1.52k|}
frame.c:validate_offsets_chunk:
 3455|  2.81k|                                  int64_t nchunks) {
 3456|  2.81k|  int32_t coffsets_cbytes = 0;
 3457|  2.81k|  uint8_t* coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &coffsets_cbytes);
 3458|  2.81k|  if (coffsets == NULL) {
  ------------------
  |  Branch (3458:7): [True: 154, False: 2.66k]
  ------------------
 3459|    154|    BLOSC_TRACE_ERROR("Cannot get compressed offsets from frame.");
  ------------------
  |  |   93|    154|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    154|    do {                                            \
  |  |  |  |   98|    154|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    154|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 154, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    154|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3460|    154|    return BLOSC2_ERROR_DATA;
 3461|    154|  }
 3462|       |
 3463|  2.66k|  int32_t offsets_nbytes;
 3464|  2.66k|  if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &offsets_nbytes)) {
  ------------------
  |  Branch (3464:7): [True: 0, False: 2.66k]
  ------------------
 3465|      0|    BLOSC_TRACE_ERROR("Too many chunks for offsets representation.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3466|      0|    return BLOSC2_ERROR_FAILURE;
 3467|      0|  }
 3468|       |
 3469|  2.66k|  int64_t* offsets = (int64_t*)malloc((size_t)offsets_nbytes);
 3470|  2.66k|  if (offsets == NULL) {
  ------------------
  |  Branch (3470:7): [True: 0, False: 2.66k]
  ------------------
 3471|      0|    BLOSC_TRACE_ERROR("Cannot allocate memory for offsets validation.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3472|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 3473|      0|  }
 3474|       |
 3475|  2.66k|  blosc2_dparams off_dparams = BLOSC2_DPARAMS_DEFAULTS;
 3476|  2.66k|  blosc2_context* dctx = blosc2_create_dctx(off_dparams);
 3477|  2.66k|  if (dctx == NULL) {
  ------------------
  |  Branch (3477:7): [True: 0, False: 2.66k]
  ------------------
 3478|      0|    free(offsets);
 3479|      0|    BLOSC_TRACE_ERROR("Error while creating the decompression context.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3480|      0|    return BLOSC2_ERROR_FAILURE;
 3481|      0|  }
 3482|       |
 3483|  2.66k|  int32_t off_nbytes = blosc2_decompress_ctx(dctx, coffsets, coffsets_cbytes,
 3484|  2.66k|                                             offsets, offsets_nbytes);
 3485|  2.66k|  blosc2_free_ctx(dctx);
 3486|  2.66k|  if (off_nbytes != offsets_nbytes) {
  ------------------
  |  Branch (3486:7): [True: 833, False: 1.82k]
  ------------------
 3487|    833|    free(offsets);
 3488|    833|    BLOSC_TRACE_ERROR("Cannot decompress offsets chunk.");
  ------------------
  |  |   93|    833|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    833|    do {                                            \
  |  |  |  |   98|    833|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    833|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 833, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    833|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3489|    833|    return BLOSC2_ERROR_DATA;
 3490|    833|  }
 3491|       |
 3492|  20.8M|  for (int64_t i = 0; i < nchunks; ++i) {
  ------------------
  |  Branch (3492:23): [True: 20.8M, False: 1.51k]
  ------------------
 3493|  20.8M|    int64_t offset = offsets[i];
 3494|  20.8M|    if (offset < 0) {
  ------------------
  |  Branch (3494:9): [True: 2.95M, False: 17.9M]
  ------------------
 3495|  2.95M|      continue;
 3496|  2.95M|    }
 3497|  17.9M|    if (offset > INT64_MAX - header_len || offset > cbytes - BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (3497:9): [True: 0, False: 17.9M]
  |  Branch (3497:44): [True: 310, False: 17.9M]
  ------------------
 3498|    310|      free(offsets);
 3499|    310|      BLOSC_TRACE_ERROR("Offset for chunk %" PRId64 " is out of bounds.", i);
  ------------------
  |  |   93|    310|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    310|    do {                                            \
  |  |  |  |   98|    310|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    310|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 310, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    310|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3500|    310|      return BLOSC2_ERROR_INVALID_HEADER;
 3501|    310|    }
 3502|       |    /* Offsets do not need to be monotonic.  Frame mutations like insert can append
 3503|       |     * chunk payloads at the end of the cframe while updating the logical chunk order
 3504|       |     * only in the offsets table, so a valid frame may legitimately contain
 3505|       |     * non-monotonic non-negative offsets.
 3506|       |     */
 3507|  17.9M|  }
 3508|       |
 3509|  1.51k|  free(offsets);
 3510|  1.51k|  return 0;
 3511|  1.82k|}
frame.c:frame_read_index_span:
 3911|  2.38k|                                 int64_t *cbytes, int32_t *chunksize) {
 3912|  2.38k|  *off = NULL;
 3913|  2.38k|  int64_t frame_len;
 3914|  2.38k|  int64_t frame_nbytes;
 3915|  2.38k|  int32_t blocksize;
 3916|  2.38k|  int64_t frame_nchunks;
 3917|  2.38k|  int rc = get_header_info(frame, header_len, &frame_len, &frame_nbytes, cbytes, &blocksize, chunksize,
 3918|  2.38k|                           &frame_nchunks, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 3919|  2.38k|                           frame->schunk->storage->io);
 3920|  2.38k|  if (rc < 0) {
  ------------------
  |  Branch (3920:7): [True: 0, False: 2.38k]
  ------------------
 3921|      0|    return rc;
 3922|      0|  }
 3923|       |  // A different handle may have changed the index, including a same-length
 3924|       |  // reorder flagged by frame_lock().  Refresh before reusing cached offsets.
 3925|  2.38k|  rc = frame_refresh_if_stale(frame, frame_len);
 3926|  2.38k|  if (rc < 0) {
  ------------------
  |  Branch (3926:7): [True: 0, False: 2.38k]
  ------------------
 3927|      0|    return rc;
 3928|      0|  }
 3929|  2.38k|  if (rc > 0) {
  ------------------
  |  Branch (3929:7): [True: 0, False: 2.38k]
  ------------------
 3930|      0|    frame->schunk->nbytes = frame_nbytes;
 3931|      0|    frame->schunk->cbytes = *cbytes;
 3932|      0|    frame->schunk->nchunks = frame_nchunks;
 3933|      0|  }
 3934|  2.38k|  int64_t hi = -1;
 3935|  2.38k|  *lo = INT64_MAX;
 3936|   621k|  for (int64_t k = 0; k < n; ++k) {
  ------------------
  |  Branch (3936:23): [True: 619k, False: 2.13k]
  ------------------
 3937|   619k|    if (nchunks[k] < 0 || nchunks[k] >= frame_nchunks) {
  ------------------
  |  Branch (3937:9): [True: 0, False: 619k]
  |  Branch (3937:27): [True: 249, False: 619k]
  ------------------
 3938|    249|      BLOSC_TRACE_ERROR("nchunk ('%" PRId64 "') exceeds the number of chunks ('%" PRId64 "').",
  ------------------
  |  |   93|    249|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    249|    do {                                            \
  |  |  |  |   98|    249|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    249|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 249, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    249|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3939|    249|                        nchunks[k], frame_nchunks);
 3940|    249|      return BLOSC2_ERROR_INVALID_PARAM;
 3941|    249|    }
 3942|   619k|    *lo = nchunks[k] < *lo ? nchunks[k] : *lo;
  ------------------
  |  Branch (3942:11): [True: 2.30k, False: 617k]
  ------------------
 3943|   619k|    hi = nchunks[k] > hi ? nchunks[k] : hi;
  ------------------
  |  Branch (3943:10): [True: 609k, False: 10.1k]
  ------------------
 3944|   619k|  }
 3945|  2.13k|  if (n <= 0) {
  ------------------
  |  Branch (3945:7): [True: 0, False: 2.13k]
  ------------------
 3946|      0|    return BLOSC2_ERROR_SUCCESS;
 3947|      0|  }
 3948|  2.13k|  int32_t off_cbytes;
 3949|  2.13k|  uint8_t *coffsets = get_coffsets(frame, *header_len, *cbytes, frame_nchunks, &off_cbytes);
 3950|  2.13k|  if (coffsets == NULL) {
  ------------------
  |  Branch (3950:7): [True: 0, False: 2.13k]
  ------------------
 3951|      0|    return BLOSC2_ERROR_DATA;
 3952|      0|  }
 3953|  2.13k|  *span_end = hi + 1 + lookahead < frame_nchunks ? hi + 1 + lookahead : frame_nchunks;
  ------------------
  |  Branch (3953:15): [True: 532, False: 1.59k]
  ------------------
 3954|  2.13k|  *off = malloc((size_t) (*span_end - *lo) * sizeof(int64_t));
 3955|  2.13k|  if (*off == NULL) {
  ------------------
  |  Branch (3955:7): [True: 0, False: 2.13k]
  ------------------
 3956|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 3957|      0|  }
 3958|  2.13k|  rc = blosc2_getitem(coffsets, off_cbytes, (int32_t) *lo, (int32_t) (*span_end - *lo), *off,
 3959|  2.13k|                      (int32_t) ((*span_end - *lo) * sizeof(int64_t)));
 3960|  2.13k|  if (rc < 0) {
  ------------------
  |  Branch (3960:7): [True: 0, False: 2.13k]
  ------------------
 3961|      0|    free(*off);
 3962|      0|    *off = NULL;
 3963|      0|    return rc;
 3964|      0|  }
 3965|  2.13k|  return BLOSC2_ERROR_SUCCESS;
 3966|  2.13k|}
frame.c:special_chunk_into:
 4042|  1.53M|                              uint8_t* dest, int32_t cbytes) {
 4043|  1.53M|  int rc = 0;
 4044|       |
 4045|       |  // Detect the kind of special value
 4046|  1.53M|  uint64_t zeros_mask = (uint64_t) BLOSC2_SPECIAL_ZERO << (8 * 7);  // chunk of zeros
 4047|  1.53M|  uint64_t nans_mask = (uint64_t) BLOSC2_SPECIAL_NAN << (8 * 7);  // chunk of NaNs
 4048|  1.53M|  uint64_t uninit_mask = (uint64_t) BLOSC2_SPECIAL_UNINIT << (8 * 7);  // chunk of uninit values
 4049|       |
 4050|  1.53M|  blosc2_cparams cparams = BLOSC2_CPARAMS_DEFAULTS;
 4051|  1.53M|  cparams.typesize = typesize;
 4052|  1.53M|  cparams.blocksize = blocksize;
 4053|  1.53M|  if (special_value & zeros_mask) {
  ------------------
  |  Branch (4053:7): [True: 1.53M, False: 0]
  ------------------
 4054|  1.53M|    rc = blosc2_chunk_zeros(cparams, nbytes, dest, cbytes);
 4055|  1.53M|    if (rc < 0) {
  ------------------
  |  Branch (4055:9): [True: 0, False: 1.53M]
  ------------------
 4056|      0|      BLOSC_TRACE_ERROR("Error creating a zero chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4057|      0|    }
 4058|  1.53M|  }
 4059|      0|  else if (special_value & uninit_mask) {
  ------------------
  |  Branch (4059:12): [True: 0, False: 0]
  ------------------
 4060|      0|    rc = blosc2_chunk_uninit(cparams, nbytes, dest, cbytes);
 4061|      0|    if (rc < 0) {
  ------------------
  |  Branch (4061:9): [True: 0, False: 0]
  ------------------
 4062|      0|      BLOSC_TRACE_ERROR("Error creating a non initialized chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4063|      0|    }
 4064|      0|  }
 4065|      0|  else if (special_value & nans_mask) {
  ------------------
  |  Branch (4065:12): [True: 0, False: 0]
  ------------------
 4066|      0|    rc = blosc2_chunk_nans(cparams, nbytes, dest, cbytes);
 4067|      0|    if (rc < 0) {
  ------------------
  |  Branch (4067:9): [True: 0, False: 0]
  ------------------
 4068|      0|      BLOSC_TRACE_ERROR("Error creating a nan chunk");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4069|      0|    }
 4070|      0|  }
 4071|      0|  else {
 4072|       |    BLOSC_TRACE_ERROR("Special value not recognized: %" PRId64 "", special_value);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4073|      0|    rc = BLOSC2_ERROR_DATA;
 4074|      0|  }
 4075|  1.53M|  return rc;
 4076|  1.53M|}
frame.c:get_chunk:
 4110|   490k|                     size_t *capacity) {
 4111|   490k|  if (capacity != NULL) {
  ------------------
  |  Branch (4111:7): [True: 490k, False: 0]
  ------------------
 4112|   490k|    *capacity = 0;
 4113|   490k|  }
 4114|   490k|  int32_t header_len;
 4115|   490k|  int64_t frame_len;
 4116|   490k|  int64_t nbytes;
 4117|   490k|  int64_t cbytes;
 4118|   490k|  int32_t blocksize;
 4119|   490k|  int32_t chunksize;
 4120|   490k|  int64_t nchunks;
 4121|   490k|  int32_t typesize;
 4122|   490k|  int64_t offset;
 4123|   490k|  int32_t chunk_cbytes;
 4124|   490k|  int rc;
 4125|       |
 4126|   490k|  *chunk = NULL;
 4127|   490k|  *needs_free = false;
 4128|   490k|  rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 4129|   490k|                       &blocksize, &chunksize, &nchunks,
 4130|   490k|                       &typesize, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 4131|   490k|                       frame->schunk->storage->io);
 4132|   490k|  if (rc < 0) {
  ------------------
  |  Branch (4132:7): [True: 0, False: 490k]
  ------------------
 4133|      0|    BLOSC_TRACE_ERROR("Unable to get meta info from frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4134|      0|    return rc;
 4135|      0|  }
 4136|   490k|  rc = frame_refresh_if_stale(frame, frame_len);
 4137|   490k|  if (rc < 0) {
  ------------------
  |  Branch (4137:7): [True: 0, False: 490k]
  ------------------
 4138|      0|    BLOSC_TRACE_ERROR("Unable to refresh the frame state from disk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4139|      0|    return rc;
 4140|      0|  }
 4141|   490k|  if (rc > 0) {
  ------------------
  |  Branch (4141:7): [True: 0, False: 490k]
  ------------------
 4142|       |    // Keep the schunk-level counters in sync with the refreshed on-disk state.
 4143|       |    // Mutating ops (update/delete) read a chunk before adjusting the counters,
 4144|       |    // so this also gives them a fresh base to apply their deltas on.
 4145|      0|    frame->schunk->nbytes = nbytes;
 4146|      0|    frame->schunk->cbytes = cbytes;
 4147|      0|    frame->schunk->nchunks = nchunks;
 4148|      0|  }
 4149|       |
 4150|   490k|  if ((nchunks > 0) && (nchunk >= nchunks)) {
  ------------------
  |  Branch (4150:7): [True: 490k, False: 0]
  |  Branch (4150:24): [True: 0, False: 490k]
  ------------------
 4151|      0|    BLOSC_TRACE_ERROR("nchunk ('%" PRId64 "') exceeds the number of chunks "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4152|      0|                    "('%" PRId64 "') in frame.", nchunk, nchunks);
 4153|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4154|      0|  }
 4155|       |
 4156|       |  // Get the offset to nchunk
 4157|   490k|  rc = get_coffset(frame, header_len, cbytes, nchunk, nchunks, &offset);
 4158|   490k|  if (rc < 0) {
  ------------------
  |  Branch (4158:7): [True: 0, False: 490k]
  ------------------
 4159|      0|    BLOSC_TRACE_ERROR("Unable to get offset to chunk %" PRId64 ".", nchunk);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4160|      0|    return rc;
 4161|      0|  }
 4162|       |
 4163|   490k|  if (offset < 0) {
  ------------------
  |  Branch (4163:7): [True: 6.75k, False: 483k]
  ------------------
 4164|       |    // Special value
 4165|  6.75k|    if (chunksize <= 0) {
  ------------------
  |  Branch (4165:9): [True: 0, False: 6.75k]
  ------------------
 4166|      0|      BLOSC_TRACE_ERROR("Cannot synthesize special chunk with chunksize <= 0.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4167|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 4168|      0|    }
 4169|  6.75k|    chunk_cbytes = BLOSC_EXTENDED_HEADER_LENGTH;
 4170|  6.75k|    int32_t chunksize_ = chunksize;
 4171|  6.75k|    if ((nchunk == nchunks - 1) && (nbytes % chunksize)) {
  ------------------
  |  Branch (4171:9): [True: 825, False: 5.93k]
  |  Branch (4171:36): [True: 0, False: 825]
  ------------------
 4172|       |      // Last chunk is incomplete.  Compute its actual size.
 4173|      0|      chunksize_ = (int32_t) (nbytes % chunksize);
 4174|      0|    }
 4175|  6.75k|    rc = frame_special_chunk(offset, chunksize_, typesize, blocksize, chunk, chunk_cbytes, needs_free);
 4176|  6.75k|    if (rc < 0) {
  ------------------
  |  Branch (4176:9): [True: 0, False: 6.75k]
  ------------------
 4177|      0|      return rc;
 4178|      0|    }
 4179|  6.75k|    goto end;
 4180|  6.75k|  }
 4181|       |
 4182|   483k|  if (frame->sframe) {
  ------------------
  |  Branch (4182:7): [True: 0, False: 483k]
  ------------------
 4183|       |    // Sparse on-disk
 4184|      0|    nchunk = offset;
 4185|      0|    return sframe_get_chunk(frame, nchunk, chunk, needs_free);
 4186|      0|  }
 4187|       |
 4188|   483k|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 4189|   483k|  if (io_cb == NULL) {
  ------------------
  |  Branch (4189:7): [True: 0, False: 483k]
  ------------------
 4190|      0|    BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4191|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 4192|      0|  }
 4193|       |
 4194|   483k|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (4194:7): [True: 0, False: 483k]
  ------------------
 4195|      0|    uint8_t* header_ptr;
 4196|      0|    uint8_t header[BLOSC_EXTENDED_HEADER_LENGTH];
 4197|      0|    void* fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 4198|      0|    if (fp == NULL) {
  ------------------
  |  Branch (4198:9): [True: 0, False: 0]
  ------------------
 4199|      0|      BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4200|      0|      return BLOSC2_ERROR_FILE_OPEN;
 4201|      0|    }
 4202|      0|    if (io_cb->is_allocation_necessary)
  ------------------
  |  Branch (4202:9): [True: 0, False: 0]
  ------------------
 4203|      0|      header_ptr = header;
 4204|      0|    int64_t io_pos = frame->file_offset + header_len + offset;
 4205|      0|    int64_t rbytes = io_cb->read((void**)&header_ptr, 1, sizeof(header), io_pos, fp);
 4206|      0|    if (rbytes != BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (4206:9): [True: 0, False: 0]
  ------------------
 4207|      0|      BLOSC_TRACE_ERROR("Cannot read the cbytes for chunk in the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4208|      0|      frame_reader_release(frame, io_cb, fp);
 4209|      0|      return BLOSC2_ERROR_FILE_READ;
 4210|      0|    }
 4211|      0|    rc = blosc2_cbuffer_sizes(header_ptr, NULL, &chunk_cbytes, NULL);
 4212|      0|    if (rc < 0) {
  ------------------
  |  Branch (4212:9): [True: 0, False: 0]
  ------------------
 4213|      0|      BLOSC_TRACE_ERROR("Cannot read the cbytes for chunk in the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4214|      0|      frame_reader_release(frame, io_cb, fp);
 4215|      0|      return rc;
 4216|      0|    }
 4217|      0|    if (chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (4217:9): [True: 0, False: 0]
  ------------------
 4218|      0|        offset > INT64_MAX - chunk_cbytes ||
  ------------------
  |  Branch (4218:9): [True: 0, False: 0]
  ------------------
 4219|      0|        offset + chunk_cbytes > cbytes) {
  ------------------
  |  Branch (4219:9): [True: 0, False: 0]
  ------------------
 4220|      0|      BLOSC_TRACE_ERROR("Invalid chunk size in frame for chunk %" PRId64 ".", nchunk);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4221|      0|      frame_reader_release(frame, io_cb, fp);
 4222|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 4223|      0|    }
 4224|      0|    if (io_cb->is_allocation_necessary) {
  ------------------
  |  Branch (4224:9): [True: 0, False: 0]
  ------------------
 4225|      0|      *chunk = capacity != NULL ? blosc2_tmp_malloc(chunk_cbytes, capacity) : malloc(chunk_cbytes);
  ------------------
  |  Branch (4225:16): [True: 0, False: 0]
  ------------------
 4226|      0|      if (*chunk == NULL) {
  ------------------
  |  Branch (4226:11): [True: 0, False: 0]
  ------------------
 4227|      0|        BLOSC_TRACE_ERROR("Cannot allocate memory for chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4228|      0|        frame_reader_release(frame, io_cb, fp);
 4229|      0|        return BLOSC2_ERROR_MEMORY_ALLOC;
 4230|      0|      }
 4231|      0|      *needs_free = true;
 4232|      0|    }
 4233|      0|    else {
 4234|      0|      *needs_free = false;
 4235|      0|    }
 4236|       |
 4237|      0|    io_pos = frame->file_offset + header_len + offset;
 4238|      0|    rbytes = io_cb->read((void**)chunk, 1, chunk_cbytes, io_pos, fp);
 4239|      0|    frame_reader_release(frame, io_cb, fp);
 4240|      0|    if (rbytes != chunk_cbytes) {
  ------------------
  |  Branch (4240:9): [True: 0, False: 0]
  ------------------
 4241|      0|      BLOSC_TRACE_ERROR("Cannot read the chunk out of the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4242|      0|      if (*needs_free) {
  ------------------
  |  Branch (4242:11): [True: 0, False: 0]
  ------------------
 4243|      0|        free(*chunk);
 4244|      0|        *chunk = NULL;
 4245|      0|        *needs_free = false;
 4246|      0|      }
 4247|      0|      return BLOSC2_ERROR_FILE_READ;
 4248|      0|    }
 4249|       |
 4250|   483k|  } else {
 4251|       |    // The chunk is in memory and just one pointer away
 4252|   483k|    *chunk = frame->cframe + header_len + offset;
 4253|   483k|    int32_t chunk_blocksize = 0;
 4254|   483k|    rc = blosc2_cbuffer_sizes(*chunk, NULL, &chunk_cbytes, &chunk_blocksize);
 4255|   483k|    if (rc < 0) {
  ------------------
  |  Branch (4255:9): [True: 0, False: 483k]
  ------------------
 4256|      0|      return rc;
 4257|      0|    }
 4258|   483k|    if (chunk_blocksize <= 0) {
  ------------------
  |  Branch (4258:9): [True: 0, False: 483k]
  ------------------
 4259|      0|      BLOSC_TRACE_ERROR("Invalid blocksize %d in chunk header.", chunk_blocksize);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4260|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 4261|      0|    }
 4262|   483k|    if (chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (4262:9): [True: 0, False: 483k]
  ------------------
 4263|   483k|        offset > INT64_MAX - chunk_cbytes ||
  ------------------
  |  Branch (4263:9): [True: 0, False: 483k]
  ------------------
 4264|   483k|        offset + chunk_cbytes > cbytes) {
  ------------------
  |  Branch (4264:9): [True: 0, False: 483k]
  ------------------
 4265|      0|      BLOSC_TRACE_ERROR("Invalid chunk size in frame for chunk %" PRId64 ".", nchunk);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4266|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 4267|      0|    }
 4268|   483k|  }
 4269|       |
 4270|   490k|  end:
 4271|   490k|  return (int32_t)chunk_cbytes;
 4272|   483k|}
frame.c:get_frame_fields:
 4689|  2.29M|static int get_frame_fields(blosc2_frame_s* frame, frame_fields* f) {
 4690|  2.29M|  int64_t frame_len;
 4691|  2.29M|  int rc = get_header_info(frame, &f->header_len, &frame_len, &f->nbytes, &f->cbytes, &f->blocksize,
 4692|  2.29M|                           &f->chunksize, &f->nchunks, &f->typesize, NULL, NULL, NULL, NULL, NULL, NULL,
 4693|  2.29M|                           NULL, frame->schunk->storage->io);
 4694|  2.29M|  if (rc < 0) {
  ------------------
  |  Branch (4694:7): [True: 0, False: 2.29M]
  ------------------
 4695|      0|    BLOSC_TRACE_ERROR("Unable to get meta info from frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4696|      0|    return rc;
 4697|      0|  }
 4698|  2.29M|  rc = frame_refresh_if_stale(frame, frame_len);
 4699|  2.29M|  if (rc < 0) {
  ------------------
  |  Branch (4699:7): [True: 0, False: 2.29M]
  ------------------
 4700|      0|    BLOSC_TRACE_ERROR("Unable to refresh the frame state from disk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4701|      0|    return rc;
 4702|      0|  }
 4703|  2.29M|  if (rc > 0) {
  ------------------
  |  Branch (4703:7): [True: 0, False: 2.29M]
  ------------------
 4704|      0|    frame->schunk->nbytes = f->nbytes;
 4705|      0|    frame->schunk->cbytes = f->cbytes;
 4706|      0|    frame->schunk->nchunks = f->nchunks;
 4707|      0|  }
 4708|  2.29M|  return BLOSC2_ERROR_SUCCESS;
 4709|  2.29M|}
frame.c:read_frame_chunk_header:
 4718|  2.29M|                                   uint8_t* header, int64_t* offset) {
 4719|  2.29M|  if (nchunk < 0 || nchunk >= f->nchunks) {
  ------------------
  |  Branch (4719:7): [True: 0, False: 2.29M]
  |  Branch (4719:21): [True: 0, False: 2.29M]
  ------------------
 4720|      0|    BLOSC_TRACE_ERROR("nchunk ('%" PRId64 "') exceeds the number of chunks "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4721|      0|                      "('%" PRId64 "') in frame.", nchunk, f->nchunks);
 4722|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4723|      0|  }
 4724|  2.29M|  int rc = get_coffset(frame, f->header_len, f->cbytes, nchunk, f->nchunks, offset);
 4725|  2.29M|  if (rc < 0) {
  ------------------
  |  Branch (4725:7): [True: 0, False: 2.29M]
  ------------------
 4726|      0|    BLOSC_TRACE_ERROR("Unable to get offset to chunk %" PRId64 ".", nchunk);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4727|      0|    return rc;
 4728|      0|  }
 4729|  2.29M|  if (*offset < 0) {
  ------------------
  |  Branch (4729:7): [True: 1.52M, False: 769k]
  ------------------
 4730|  1.52M|    if (f->chunksize <= 0) {
  ------------------
  |  Branch (4730:9): [True: 0, False: 1.52M]
  ------------------
 4731|      0|      BLOSC_TRACE_ERROR("Cannot synthesize special chunk with chunksize <= 0.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4732|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 4733|      0|    }
 4734|  1.52M|    int32_t chunksize = f->chunksize;
 4735|  1.52M|    if ((nchunk == f->nchunks - 1) && (f->nbytes % f->chunksize)) {
  ------------------
  |  Branch (4735:9): [True: 276k, False: 1.24M]
  |  Branch (4735:39): [True: 0, False: 276k]
  ------------------
 4736|       |      // Last chunk is incomplete.  Compute its actual size.
 4737|      0|      chunksize = (int32_t) (f->nbytes % f->chunksize);
 4738|      0|    }
 4739|  1.52M|    return special_chunk_into(*offset, chunksize, f->typesize, f->blocksize, header,
 4740|  1.52M|                              BLOSC_EXTENDED_HEADER_LENGTH);
 4741|  1.52M|  }
 4742|       |
 4743|   769k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (4743:7): [True: 769k, False: 0]
  ------------------
 4744|       |    // get_coffset() checked that the header is inside the frame
 4745|   769k|    memcpy(header, frame->cframe + f->header_len + *offset, BLOSC_EXTENDED_HEADER_LENGTH);
 4746|   769k|  }
 4747|      0|  else {
 4748|      0|    blosc2_io_cb* io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 4749|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (4749:9): [True: 0, False: 0]
  ------------------
 4750|      0|      BLOSC_TRACE_ERROR("Error getting the input/output API");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4751|      0|      return BLOSC2_ERROR_PLUGIN_IO;
 4752|      0|    }
 4753|      0|    void* chunk_fp = fp;
 4754|      0|    int64_t io_pos = frame->file_offset + f->header_len + *offset;
 4755|      0|    if (frame->sframe) {
  ------------------
  |  Branch (4755:9): [True: 0, False: 0]
  ------------------
 4756|      0|      chunk_fp = sframe_open_chunk(frame->urlpath, *offset, "rb", frame->schunk->storage->io);
 4757|      0|      io_pos = 0;
 4758|      0|    }
 4759|      0|    else if (fp == NULL) {
  ------------------
  |  Branch (4759:14): [True: 0, False: 0]
  ------------------
 4760|      0|      chunk_fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 4761|      0|    }
 4762|      0|    if (chunk_fp == NULL) {
  ------------------
  |  Branch (4762:9): [True: 0, False: 0]
  ------------------
 4763|      0|      BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4764|      0|      return BLOSC2_ERROR_FILE_OPEN;
 4765|      0|    }
 4766|      0|    uint8_t* header_ptr = header;
 4767|      0|    int64_t rbytes = io_cb->read((void**)&header_ptr, 1, BLOSC_EXTENDED_HEADER_LENGTH, io_pos, chunk_fp);
 4768|      0|    if (rbytes == BLOSC_EXTENDED_HEADER_LENGTH && header_ptr != header) {
  ------------------
  |  Branch (4768:9): [True: 0, False: 0]
  |  Branch (4768:51): [True: 0, False: 0]
  ------------------
 4769|      0|      memcpy(header, header_ptr, BLOSC_EXTENDED_HEADER_LENGTH);
 4770|      0|    }
 4771|      0|    if (frame->sframe) {
  ------------------
  |  Branch (4771:9): [True: 0, False: 0]
  ------------------
 4772|      0|      io_cb->close(chunk_fp);
 4773|      0|    }
 4774|      0|    else if (fp == NULL) {
  ------------------
  |  Branch (4774:14): [True: 0, False: 0]
  ------------------
 4775|      0|      frame_reader_release(frame, io_cb, chunk_fp);
 4776|      0|    }
 4777|      0|    if (rbytes != BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (4777:9): [True: 0, False: 0]
  ------------------
 4778|      0|      BLOSC_TRACE_ERROR("Cannot read the header for chunk in the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4779|      0|      return BLOSC2_ERROR_FILE_READ;
 4780|      0|    }
 4781|      0|  }
 4782|   769k|  int32_t chunk_cbytes;
 4783|   769k|  rc = blosc2_cbuffer_sizes(header, NULL, &chunk_cbytes, NULL);
 4784|   769k|  if (rc < 0) {
  ------------------
  |  Branch (4784:7): [True: 0, False: 769k]
  ------------------
 4785|      0|    return rc;
 4786|      0|  }
 4787|   769k|  int64_t chunk_end;
 4788|   769k|  if (chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (4788:7): [True: 0, False: 769k]
  ------------------
 4789|   769k|      (!frame->sframe && (!blosc2_checked_add_i64_nonneg(*offset, chunk_cbytes, &chunk_end) ||
  ------------------
  |  Branch (4789:8): [True: 769k, False: 0]
  |  Branch (4789:27): [True: 0, False: 769k]
  ------------------
 4790|   769k|                          chunk_end > f->cbytes))) {
  ------------------
  |  Branch (4790:27): [True: 0, False: 769k]
  ------------------
 4791|      0|    BLOSC_TRACE_ERROR("Invalid chunk size in frame for chunk %" PRId64 ".", nchunk);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4792|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 4793|      0|  }
 4794|   769k|  return chunk_cbytes;
 4795|   769k|}
frame.c:compress_offsets:
 5006|  1.14M|                                uint8_t** off_chunk) {
 5007|  1.14M|  *off_chunk = NULL;
 5008|  1.14M|  blosc2_cparams cparams = BLOSC2_CPARAMS_DEFAULTS;
 5009|  1.14M|  cparams.splitmode = BLOSC_NEVER_SPLIT;
 5010|  1.14M|  cparams.typesize = sizeof(int64_t);
 5011|  1.14M|  cparams.blocksize = 16 * 1024;  // based on experiments with create_frame.c bench
 5012|  1.14M|  cparams.nthreads = 4;  // 4 threads seems a decent default for nowadays CPUs
 5013|  1.14M|  cparams.compcode = BLOSC_BLOSCLZ;
 5014|  1.14M|  blosc2_context* cctx = blosc2_create_cctx(cparams);
 5015|  1.14M|  if (cctx == NULL) {
  ------------------
  |  Branch (5015:7): [True: 0, False: 1.14M]
  ------------------
 5016|      0|    BLOSC_TRACE_ERROR("Error while creating the compression context");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5017|      0|    return BLOSC2_ERROR_NULL_POINTER;
 5018|      0|  }
 5019|  1.14M|  cctx->typesize = sizeof(int64_t);  // override a possible BLOSC_TYPESIZE env variable (or chaos may appear)
 5020|  1.14M|  uint8_t* chunk = malloc((size_t)dest_nbytes);
 5021|  1.14M|  if (chunk == NULL) {
  ------------------
  |  Branch (5021:7): [True: 0, False: 1.14M]
  ------------------
 5022|      0|    blosc2_free_ctx(cctx);
 5023|      0|    BLOSC_TRACE_ERROR("Cannot allocate memory for the offsets chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5024|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 5025|      0|  }
 5026|  1.14M|  int32_t off_cbytes = blosc2_compress_ctx(cctx, offsets, off_nbytes, chunk, dest_nbytes);
 5027|  1.14M|  blosc2_free_ctx(cctx);
 5028|  1.14M|  if (off_cbytes < 0) {
  ------------------
  |  Branch (5028:7): [True: 0, False: 1.14M]
  ------------------
 5029|      0|    free(chunk);
 5030|      0|    return off_cbytes;
 5031|      0|  }
 5032|  1.14M|  *off_chunk = chunk;
 5033|  1.14M|  return off_cbytes;
 5034|  1.14M|}
frame.c:frame_needs_last_nbytes:
 5046|     16|static bool frame_needs_last_nbytes(int32_t chunksize, int64_t nchunks, int32_t chunk_nbytes) {
 5047|     16|  return chunksize > 0 && nchunks > 0 && chunk_nbytes < chunksize;
  ------------------
  |  Branch (5047:10): [True: 16, False: 0]
  |  Branch (5047:27): [True: 14, False: 2]
  |  Branch (5047:42): [True: 0, False: 14]
  ------------------
 5048|     16|}
frame.c:frame_takes_chunk:
 5054|      8|                              int32_t chunk_nbytes) {
 5055|      8|  if (frame_needs_last_nbytes(chunksize, nchunks, chunk_nbytes) && last_nbytes < chunksize &&
  ------------------
  |  Branch (5055:7): [True: 0, False: 8]
  |  Branch (5055:68): [True: 0, False: 0]
  ------------------
 5056|      0|      nbytes < chunksize) {
  ------------------
  |  Branch (5056:7): [True: 0, False: 0]
  ------------------
 5057|      0|    BLOSC_TRACE_ERROR("Appending two consecutive chunks with a chunksize smaller "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5058|      0|                      "than the frame chunksize is not allowed yet: %d != %d.",
 5059|      0|                      chunk_nbytes, chunksize);
 5060|      0|    return false;
 5061|      0|  }
 5062|      8|  return true;
 5063|      8|}
frame.c:special_offset:
 5038|   639k|static void special_offset(int64_t* offset, int special_value) {
 5039|   639k|  uint64_t offset_value = ((uint64_t)1 << 63) + ((uint64_t)special_value << (8 * 7));
 5040|       |  to_little(offset, &offset_value, sizeof(uint64_t));
  ------------------
  |  |   35|   639k|#define to_little(dest, src, itemsize)    endian_handler(true, dest, src, itemsize)
  ------------------
 5041|   639k|}
frame.c:holes_place:
 6194|   500k|                           int64_t* payload_end) {
 6195|   500k|  int64_t start = *payload_end;
 6196|   500k|  int64_t len = 0;
 6197|   500k|  if (old_offset >= 0) {
  ------------------
  |  Branch (6197:7): [True: 17.4k, False: 483k]
  ------------------
 6198|  17.4k|    holes_take_run(frame, old_offset, old_len, &start, &len);
 6199|  17.4k|  }
 6200|   500k|  if (start + len == *payload_end) {
  ------------------
  |  Branch (6200:7): [True: 484k, False: 16.6k]
  ------------------
 6201|   484k|    *payload_end = start + new_len;
 6202|   484k|    return start;
 6203|   484k|  }
 6204|  16.6k|  if (new_len <= len) {
  ------------------
  |  Branch (6204:7): [True: 15.3k, False: 1.29k]
  ------------------
 6205|  15.3k|    holes_add(frame, start + new_len, len - new_len);
 6206|  15.3k|    return start;
 6207|  15.3k|  }
 6208|  1.29k|  holes_add(frame, start, len);
 6209|  1.29k|  int64_t offset = *payload_end;
 6210|  1.29k|  *payload_end += new_len;
 6211|  1.29k|  return offset;
 6212|  16.6k|}
frame.c:holes_take_run:
 6165|  17.4k|                           int64_t* run_len) {
 6166|  17.4k|  int64_t start = offset;
 6167|  17.4k|  int64_t end = offset + len;
 6168|  40.9k|  for (int64_t i = 0; i < frame->nholes;) {
  ------------------
  |  Branch (6168:23): [True: 23.4k, False: 17.4k]
  ------------------
 6169|  23.4k|    int64_t hole_start = frame->holes[2 * i];
 6170|  23.4k|    int64_t hole_end = hole_start + frame->holes[2 * i + 1];
 6171|  23.4k|    if (hole_end == start || hole_start == end) {
  ------------------
  |  Branch (6171:9): [True: 9.08k, False: 14.3k]
  |  Branch (6171:30): [True: 491, False: 13.8k]
  ------------------
 6172|  9.57k|      start = (hole_end == start) ? hole_start : start;
  ------------------
  |  Branch (6172:15): [True: 9.08k, False: 491]
  ------------------
 6173|  9.57k|      end = (hole_start == end) ? hole_end : end;
  ------------------
  |  Branch (6173:13): [True: 491, False: 9.08k]
  ------------------
 6174|  9.57k|      frame->nholes--;
 6175|  9.57k|      frame->holes[2 * i] = frame->holes[2 * frame->nholes];
 6176|  9.57k|      frame->holes[2 * i + 1] = frame->holes[2 * frame->nholes + 1];
 6177|  9.57k|      i = 0;  // the longer run may touch a hole seen already
 6178|  9.57k|      continue;
 6179|  9.57k|    }
 6180|  13.8k|    i++;
 6181|  13.8k|  }
 6182|  17.4k|  *run_start = start;
 6183|  17.4k|  *run_len = end - start;
 6184|  17.4k|}
frame.c:holes_add:
 6142|  16.6k|static void holes_add(blosc2_frame_s* frame, int64_t offset, int64_t len) {
 6143|  16.6k|  if (len <= 0) {
  ------------------
  |  Branch (6143:7): [True: 6.80k, False: 9.83k]
  ------------------
 6144|  6.80k|    return;
 6145|  6.80k|  }
 6146|  9.83k|  if (frame->nholes == frame->holes_cap) {
  ------------------
  |  Branch (6146:7): [True: 234, False: 9.59k]
  ------------------
 6147|    234|    int64_t cap = frame->holes_cap > 0 ? 2 * frame->holes_cap : 64;
  ------------------
  |  Branch (6147:19): [True: 0, False: 234]
  ------------------
 6148|    234|    int64_t* holes = realloc(frame->holes, (size_t)cap * 2 * sizeof(int64_t));
 6149|    234|    if (holes == NULL) {
  ------------------
  |  Branch (6149:9): [True: 0, False: 234]
  ------------------
 6150|      0|      frame->holes_lost = true;  // the frame stays valid, just with some dead space
 6151|      0|      return;
 6152|      0|    }
 6153|    234|    frame->holes = holes;
 6154|    234|    frame->holes_cap = cap;
 6155|    234|  }
 6156|  9.83k|  frame->holes[2 * frame->nholes] = offset;
 6157|  9.83k|  frame->holes[2 * frame->nholes + 1] = len;
 6158|  9.83k|  frame->nholes++;
 6159|  9.83k|}
frame.c:frame_compact:
 6544|    243|static int frame_compact(blosc2_frame_s* frame, blosc2_schunk* schunk) {
 6545|    243|  int32_t header_len;
 6546|    243|  int64_t frame_len;
 6547|    243|  int64_t nbytes;
 6548|    243|  int64_t cbytes;
 6549|    243|  int32_t blocksize;
 6550|    243|  int32_t chunksize;
 6551|    243|  int64_t nchunks;
 6552|    243|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes, &blocksize, &chunksize,
 6553|    243|                           &nchunks, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 6554|    243|                           frame->schunk->storage->io);
 6555|    243|  if (rc < 0) {
  ------------------
  |  Branch (6555:7): [True: 0, False: 243]
  ------------------
 6556|      0|    return rc;
 6557|      0|  }
 6558|    243|  int64_t nholes = frame->nholes;
 6559|    243|  int64_t* holes = frame->holes;  // (offset, length) pairs
 6560|    243|  qsort(holes, (size_t)nholes, 2 * sizeof(int64_t), compare_holes);
 6561|    499|  for (int64_t k = 0; k < nholes; k++) {
  ------------------
  |  Branch (6561:23): [True: 256, False: 243]
  ------------------
 6562|    256|    int64_t next = (k + 1 < nholes) ? holes[2 * (k + 1)] : cbytes;
  ------------------
  |  Branch (6562:20): [True: 13, False: 243]
  ------------------
 6563|    256|    if (holes[2 * k] < 0 || holes[2 * k + 1] <= 0 || holes[2 * k] + holes[2 * k + 1] > next) {
  ------------------
  |  Branch (6563:9): [True: 0, False: 256]
  |  Branch (6563:29): [True: 0, False: 256]
  |  Branch (6563:54): [True: 0, False: 256]
  ------------------
 6564|      0|      BLOSC_TRACE_ERROR("Inconsistent holes in the payload of the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6565|      0|      return BLOSC2_ERROR_DATA;
 6566|      0|    }
 6567|    256|  }
 6568|    243|  if (nchunks == 0) {
  ------------------
  |  Branch (6568:7): [True: 0, False: 243]
  ------------------
 6569|      0|    return BLOSC2_ERROR_SUCCESS;  // all chunks got deleted: no offsets to rewrite, the payload stays
 6570|      0|  }
 6571|       |
 6572|    243|  int32_t off_nbytes;
 6573|    243|  if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &off_nbytes)) {
  ------------------
  |  Branch (6573:7): [True: 0, False: 243]
  ------------------
 6574|      0|    BLOSC_TRACE_ERROR("Too many chunks for offsets representation.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6575|      0|    return BLOSC2_ERROR_DATA;
 6576|      0|  }
 6577|    243|  int64_t* offsets = malloc((size_t)off_nbytes);
 6578|    243|  int64_t* shifts = malloc((size_t)(nholes + 1) * sizeof(int64_t));  // shifts[k]: length of the first k holes
 6579|    243|  uint8_t* off_chunk = NULL;
 6580|    243|  blosc2_io_cb* io_cb = NULL;
 6581|    243|  void* fp = NULL;
 6582|    243|  if (offsets == NULL || shifts == NULL) {
  ------------------
  |  Branch (6582:7): [True: 0, False: 243]
  |  Branch (6582:26): [True: 0, False: 243]
  ------------------
 6583|      0|    rc = BLOSC2_ERROR_MEMORY_ALLOC;
 6584|      0|    goto out;
 6585|      0|  }
 6586|    243|  shifts[0] = 0;
 6587|    499|  for (int64_t k = 0; k < nholes; k++) {
  ------------------
  |  Branch (6587:23): [True: 256, False: 243]
  ------------------
 6588|    256|    shifts[k + 1] = shifts[k] + holes[2 * k + 1];
 6589|    256|  }
 6590|    243|  int32_t coffsets_cbytes = 0;
 6591|    243|  uint8_t* coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &coffsets_cbytes);
 6592|    243|  if (coffsets == NULL) {
  ------------------
  |  Branch (6592:7): [True: 0, False: 243]
  ------------------
 6593|      0|    BLOSC_TRACE_ERROR("Cannot get the offsets for the frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6594|      0|    rc = BLOSC2_ERROR_DATA;
 6595|      0|    goto out;
 6596|      0|  }
 6597|    243|  blosc2_dparams off_dparams = BLOSC2_DPARAMS_DEFAULTS;
 6598|    243|  blosc2_context* dctx = blosc2_create_dctx(off_dparams);
 6599|    243|  if (dctx == NULL) {
  ------------------
  |  Branch (6599:7): [True: 0, False: 243]
  ------------------
 6600|      0|    rc = BLOSC2_ERROR_MEMORY_ALLOC;
 6601|      0|    goto out;
 6602|      0|  }
 6603|    243|  rc = blosc2_decompress_ctx(dctx, coffsets, coffsets_cbytes, offsets, off_nbytes);
 6604|    243|  blosc2_free_ctx(dctx);
 6605|    243|  if (rc < 0) {
  ------------------
  |  Branch (6605:7): [True: 0, False: 243]
  ------------------
 6606|      0|    BLOSC_TRACE_ERROR("Cannot decompress the offsets chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6607|      0|    goto out;
 6608|      0|  }
 6609|       |
 6610|       |  // A stored chunk moves by the length of the holes before it
 6611|  46.4k|  for (int64_t i = 0; i < nchunks; i++) {
  ------------------
  |  Branch (6611:23): [True: 46.1k, False: 243]
  ------------------
 6612|  46.1k|    if (offsets[i] < 0) {
  ------------------
  |  Branch (6612:9): [True: 515, False: 45.6k]
  ------------------
 6613|    515|      continue;  // stored in its offset
 6614|    515|    }
 6615|  45.6k|    int64_t lo = 0;
 6616|  45.6k|    int64_t hi = nholes;  // the holes [0, lo) start before the chunk, [hi, nholes) after it
 6617|  91.6k|    while (lo < hi) {
  ------------------
  |  Branch (6617:12): [True: 46.0k, False: 45.6k]
  ------------------
 6618|  46.0k|      int64_t mid = lo + (hi - lo) / 2;
 6619|  46.0k|      if (holes[2 * mid] < offsets[i]) {
  ------------------
  |  Branch (6619:11): [True: 41.5k, False: 4.41k]
  ------------------
 6620|  41.5k|        lo = mid + 1;
 6621|  41.5k|      }
 6622|  4.41k|      else {
 6623|  4.41k|        hi = mid;
 6624|  4.41k|      }
 6625|  46.0k|    }
 6626|  45.6k|    if ((lo > 0 && offsets[i] < holes[2 * (lo - 1)] + holes[2 * (lo - 1) + 1]) ||
  ------------------
  |  Branch (6626:10): [True: 41.5k, False: 4.07k]
  |  Branch (6626:20): [True: 0, False: 41.5k]
  ------------------
 6627|  45.6k|        (lo < nholes && offsets[i] == holes[2 * lo])) {
  ------------------
  |  Branch (6627:10): [True: 4.36k, False: 41.3k]
  |  Branch (6627:25): [True: 0, False: 4.36k]
  ------------------
 6628|      0|      BLOSC_TRACE_ERROR("Chunk %" PRId64 " lies in a hole of the frame.", i);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6629|      0|      rc = BLOSC2_ERROR_DATA;
 6630|      0|      goto out;
 6631|      0|    }
 6632|  45.6k|    offsets[i] -= shifts[lo];
 6633|  45.6k|  }
 6634|       |
 6635|    243|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (6635:7): [True: 0, False: 243]
  ------------------
 6636|      0|    io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 6637|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (6637:9): [True: 0, False: 0]
  ------------------
 6638|      0|      rc = BLOSC2_ERROR_PLUGIN_IO;
 6639|      0|      goto out;
 6640|      0|    }
 6641|      0|    fp = frame_writer_acquire(frame, io_cb);
 6642|      0|    if (fp == NULL) {
  ------------------
  |  Branch (6642:9): [True: 0, False: 0]
  ------------------
 6643|      0|      BLOSC_TRACE_ERROR("Error opening file in: %s", frame->urlpath);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6644|      0|      rc = BLOSC2_ERROR_FILE_OPEN;
 6645|      0|      goto out;
 6646|      0|    }
 6647|      0|  }
 6648|       |  // The stretch behind each hole moves down by the length of all holes up to it
 6649|    499|  for (int64_t k = 0; k < nholes; k++) {
  ------------------
  |  Branch (6649:23): [True: 256, False: 243]
  ------------------
 6650|    256|    int64_t shift = shifts[k + 1];
 6651|    256|    int64_t src = holes[2 * k] + holes[2 * k + 1];
 6652|    256|    int64_t len = ((k + 1 < nholes) ? holes[2 * (k + 1)] : cbytes) - src;
  ------------------
  |  Branch (6652:20): [True: 13, False: 243]
  ------------------
 6653|    256|    if (len == 0) {
  ------------------
  |  Branch (6653:9): [True: 0, False: 256]
  ------------------
 6654|      0|      continue;
 6655|      0|    }
 6656|    256|    if (frame->cframe != NULL) {
  ------------------
  |  Branch (6656:9): [True: 256, False: 0]
  ------------------
 6657|    256|      memmove(frame->cframe + header_len + src - shift, frame->cframe + header_len + src, (size_t)len);
 6658|    256|    }
 6659|      0|    else {
 6660|      0|      rc = frame_move_range(io_cb, fp, frame->file_offset + header_len + src,
 6661|      0|                            frame->file_offset + header_len + src - shift, len, 0);
 6662|      0|      if (rc < 0) {
  ------------------
  |  Branch (6662:11): [True: 0, False: 0]
  ------------------
 6663|      0|        BLOSC_TRACE_ERROR("Cannot move chunks in the frame to close its holes.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6664|      0|        frame->file_end = 0;
 6665|      0|        goto out;
 6666|      0|      }
 6667|      0|    }
 6668|    256|  }
 6669|    243|  int64_t new_cbytes = cbytes - shifts[nholes];
 6670|       |
 6671|    243|  int32_t off_cbytes = compress_offsets(offsets, off_nbytes, off_nbytes + BLOSC2_MAX_OVERHEAD, &off_chunk);
 6672|    243|  if (off_cbytes < 0) {
  ------------------
  |  Branch (6672:7): [True: 0, False: 243]
  ------------------
 6673|      0|    rc = off_cbytes;
 6674|      0|    goto out;
 6675|      0|  }
 6676|    243|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (6676:7): [True: 243, False: 0]
  ------------------
 6677|       |    // The payload got shorter: the offsets fit into the frame
 6678|    243|    memcpy(frame->cframe + header_len + new_cbytes, off_chunk, (size_t)off_cbytes);
 6679|    243|  }
 6680|      0|  else {
 6681|      0|    int64_t wbytes = io_cb->write(off_chunk, 1, off_cbytes, frame->file_offset + header_len + new_cbytes, fp);
 6682|      0|    if (wbytes != off_cbytes) {
  ------------------
  |  Branch (6682:9): [True: 0, False: 0]
  ------------------
 6683|      0|      BLOSC_TRACE_ERROR("Cannot write the offsets to frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6684|      0|      frame->file_end = 0;
 6685|      0|      rc = BLOSC2_ERROR_FILE_WRITE;
 6686|      0|      goto out;
 6687|      0|    }
 6688|      0|  }
 6689|    243|  if (frame->coffsets != NULL) {
  ------------------
  |  Branch (6689:7): [True: 0, False: 243]
  ------------------
 6690|      0|    if (frame->coffsets_needs_free) {
  ------------------
  |  Branch (6690:9): [True: 0, False: 0]
  ------------------
 6691|      0|      free(frame->coffsets);
 6692|      0|    }
 6693|      0|    frame->coffsets = NULL;
 6694|      0|  }
 6695|    243|  schunk->cbytes = new_cbytes;
 6696|    243|  frame->len = header_len + new_cbytes + off_cbytes + frame->trailer_len;
 6697|    243|  rc = frame_update_header(frame, schunk, false);
 6698|    243|  if (rc >= 0) {
  ------------------
  |  Branch (6698:7): [True: 243, False: 0]
  ------------------
 6699|    243|    rc = frame_update_trailer(frame, schunk);  // cuts the file too
 6700|    243|  }
 6701|       |
 6702|    243|  out:
 6703|    243|  if (fp != NULL) {
  ------------------
  |  Branch (6703:7): [True: 0, False: 243]
  ------------------
 6704|      0|    int close_rc = frame_writer_release(frame, io_cb, fp);
 6705|      0|    if (rc >= 0 && close_rc < 0) {
  ------------------
  |  Branch (6705:9): [True: 0, False: 0]
  |  Branch (6705:20): [True: 0, False: 0]
  ------------------
 6706|      0|      rc = close_rc;
 6707|      0|    }
 6708|      0|  }
 6709|    243|  free(off_chunk);
 6710|    243|  free(offsets);
 6711|    243|  free(shifts);
 6712|    243|  return rc < 0 ? rc : BLOSC2_ERROR_SUCCESS;
  ------------------
  |  Branch (6712:10): [True: 0, False: 243]
  ------------------
 6713|    243|}
frame.c:compare_holes:
 6533|     14|static int compare_holes(const void* a, const void* b) {
 6534|     14|  int64_t x = *(const int64_t*)a;
 6535|     14|  int64_t y = *(const int64_t*)b;
 6536|     14|  return (x > y) - (x < y);
 6537|     14|}

prefetch_set_populate:
   85|  3.39k|void prefetch_set_populate(int mode) {
   86|  3.39k|  g_populate = mode < 0 ? -1 : (mode > 0);
  ------------------
  |  Branch (86:16): [True: 3.39k, False: 0]
  ------------------
   87|  3.39k|}
prefetch_applies:
  133|  23.3k|bool prefetch_applies(const blosc2_frame_s *frame) {
  134|  23.3k|  return prefetch_enabled() && frame != NULL && frame->cframe == NULL && !frame->sframe && frame->urlpath != NULL &&
  ------------------
  |  Branch (134:10): [True: 0, False: 23.3k]
  |  Branch (134:32): [True: 0, False: 0]
  |  Branch (134:49): [True: 0, False: 0]
  |  Branch (134:74): [True: 0, False: 0]
  |  Branch (134:92): [True: 0, False: 0]
  ------------------
  135|      0|         frame->schunk != NULL;
  ------------------
  |  Branch (135:10): [True: 0, False: 0]
  ------------------
  136|  23.3k|}
prefetch_destroy:
  356|  3.39k|void prefetch_destroy(void) {
  357|  3.39k|  pthread_mutex_lock(&destroy_mutex);
  358|  3.39k|  pthread_mutex_lock(&pool.mutex);
  359|  3.39k|  if (pool.threads == NULL) {
  ------------------
  |  Branch (359:7): [True: 3.39k, False: 0]
  ------------------
  360|  3.39k|    pthread_mutex_unlock(&pool.mutex);
  361|  3.39k|    pthread_mutex_unlock(&destroy_mutex);
  362|  3.39k|    return;
  363|  3.39k|  }
  364|      0|  pool.stop = true;
  365|      0|  pthread_cond_broadcast(&pool.work);
  366|      0|  int nthreads = pool.nthreads;
  367|      0|  pthread_t *threads = pool.threads;
  368|      0|  pool.threads = NULL;
  369|      0|  pool.nthreads = 0;
  370|      0|  pthread_mutex_unlock(&pool.mutex);
  371|       |
  372|      0|  for (int i = 0; i < nthreads; ++i) {
  ------------------
  |  Branch (372:19): [True: 0, False: 0]
  ------------------
  373|      0|    pthread_join(threads[i], NULL);
  374|      0|  }
  375|      0|  free(threads);
  376|       |
  377|      0|  pthread_mutex_lock(&pool.mutex);
  378|       |  pool.stop = false;
  379|      0|  pthread_mutex_unlock(&pool.mutex);
  380|      0|  pthread_mutex_unlock(&destroy_mutex);
  381|      0|}
prefetch_batch_wait:
  926|  1.14M|void prefetch_batch_wait(prefetch_batch *batch, int64_t nchunk) {
  927|  1.14M|  if (batch == NULL) {
  ------------------
  |  Branch (927:7): [True: 1.14M, False: 0]
  ------------------
  928|  1.14M|    return;
  929|  1.14M|  }
  930|      0|  pthread_mutex_lock(&pool.mutex);
  931|       |  // The slice reads the chunks in the order given, so this is mostly the next one
  932|      0|  for (int64_t k = 0; k < batch->nchunks; ++k) {
  ------------------
  |  Branch (932:23): [True: 0, False: 0]
  ------------------
  933|      0|    int64_t i = (batch->cursor + k) % batch->nchunks;
  934|      0|    if (batch->chunks[i] == nchunk) {
  ------------------
  |  Branch (934:9): [True: 0, False: 0]
  ------------------
  935|      0|      batch->cursor = i + 1;
  936|      0|      raise_limit(batch, batch->end_piece[i], batch->end_piece[i]);
  937|      0|      wait_pieces(batch, batch->end_piece[i]);
  938|      0|      break;
  939|      0|    }
  940|      0|  }
  941|      0|  pthread_mutex_unlock(&pool.mutex);
  942|      0|}
prefetch_batch_free:
  945|  70.8k|void prefetch_batch_free(prefetch_batch *batch) {
  946|  70.8k|  if (batch == NULL) {
  ------------------
  |  Branch (946:7): [True: 70.8k, False: 0]
  ------------------
  947|  70.8k|    return;
  948|  70.8k|  }
  949|      0|  pthread_mutex_lock(&pool.mutex);
  950|      0|  batch->limit = batch->next;
  951|      0|  wait_pieces(batch, batch->next);
  952|      0|  prefetch_batch **link = &pool.batches;
  953|      0|  while (*link != batch) {
  ------------------
  |  Branch (953:10): [True: 0, False: 0]
  ------------------
  954|      0|    link = &(*link)->next_batch;
  955|      0|  }
  956|      0|  *link = batch->next_batch;
  957|      0|  pool.nbatches--;
  958|      0|  pthread_mutex_unlock(&pool.mutex);
  959|      0|  pthread_cond_destroy(&batch->progress);
  960|      0|  close(batch->fd);
  961|      0|  free(batch);
  962|      0|}
prefetch.c:prefetch_enabled:
  128|  23.3k|static bool prefetch_enabled(void) {
  129|  23.3k|  return g_nthreads > 0 && blosc2_is_initialized();
  ------------------
  |  Branch (129:10): [True: 0, False: 23.3k]
  |  Branch (129:28): [True: 0, False: 0]
  ------------------
  130|  23.3k|}

blosc2_schunk_get_cparams:
   73|  12.1k|int blosc2_schunk_get_cparams(blosc2_schunk *schunk, blosc2_cparams **cparams) {
   74|  12.1k|  *cparams = calloc(1, sizeof(blosc2_cparams));
   75|  12.1k|  (*cparams)->schunk = schunk;
   76|  85.1k|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (76:19): [True: 72.9k, False: 12.1k]
  ------------------
   77|  72.9k|    (*cparams)->filters[i] = schunk->filters[i];
   78|  72.9k|    (*cparams)->filters_meta[i] = schunk->filters_meta[i];
   79|  72.9k|  }
   80|  12.1k|  (*cparams)->compcode = schunk->compcode;
   81|  12.1k|  (*cparams)->compcode_meta = schunk->compcode_meta;
   82|  12.1k|  (*cparams)->clevel = schunk->clevel;
   83|  12.1k|  (*cparams)->typesize = schunk->typesize;
   84|  12.1k|  (*cparams)->blocksize = schunk->blocksize;
   85|  12.1k|  (*cparams)->splitmode = schunk->splitmode;
   86|  12.1k|  (*cparams)->use_dict = schunk->use_dict;
   87|  12.1k|  if (schunk->cctx == NULL) {
  ------------------
  |  Branch (87:7): [True: 2.97k, False: 9.19k]
  ------------------
   88|  2.97k|    (*cparams)->nthreads = blosc2_get_nthreads();
   89|  2.97k|  }
   90|  9.19k|  else {
   91|  9.19k|    (*cparams)->nthreads = (int16_t)schunk->cctx->nthreads;
   92|  9.19k|  }
   93|  12.1k|  return 0;
   94|  12.1k|}
blosc2_schunk_get_dparams:
   98|  2.95k|int blosc2_schunk_get_dparams(blosc2_schunk *schunk, blosc2_dparams **dparams) {
   99|  2.95k|  *dparams = calloc(1, sizeof(blosc2_dparams));
  100|  2.95k|  (*dparams)->schunk = schunk;
  101|  2.95k|  if (schunk->dctx == NULL) {
  ------------------
  |  Branch (101:7): [True: 2.95k, False: 0]
  ------------------
  102|  2.95k|    (*dparams)->nthreads = blosc2_get_nthreads();
  103|  2.95k|  }
  104|      0|  else {
  105|      0|    (*dparams)->nthreads = schunk->dctx->nthreads;
  106|      0|  }
  107|  2.95k|  return 0;
  108|  2.95k|}
update_schunk_properties:
  111|  7.20k|int update_schunk_properties(struct blosc2_schunk* schunk) {
  112|  7.20k|  blosc2_cparams* cparams = schunk->storage->cparams;
  113|  7.20k|  blosc2_dparams* dparams = schunk->storage->dparams;
  114|       |
  115|  50.4k|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (115:19): [True: 43.2k, False: 7.20k]
  ------------------
  116|  43.2k|    schunk->filters[i] = cparams->filters[i];
  117|  43.2k|    schunk->filters_meta[i] = cparams->filters_meta[i];
  118|  43.2k|  }
  119|  7.20k|  schunk->compcode = cparams->compcode;
  120|  7.20k|  schunk->compcode_meta = cparams->compcode_meta;
  121|  7.20k|  schunk->clevel = cparams->clevel;
  122|  7.20k|  schunk->splitmode = cparams->splitmode;
  123|  7.20k|  schunk->use_dict = (uint8_t)cparams->use_dict;
  124|  7.20k|  schunk->typesize = cparams->typesize;
  125|  7.20k|  schunk->blocksize = cparams->blocksize;
  126|  7.20k|  schunk->chunksize = -1;
  127|  7.20k|  schunk->flags2 = 0;
  128|  7.20k|  schunk->tuner_params = cparams->tuner_params;
  129|  7.20k|  schunk->tuner_id = cparams->tuner_id;
  130|  7.20k|  if (cparams->tuner_id == BLOSC_BTUNE) {
  ------------------
  |  Branch (130:7): [True: 0, False: 7.20k]
  ------------------
  131|      0|    cparams->use_dict = 0;
  132|      0|  }
  133|       |  /* The compression context */
  134|  7.20k|  if (schunk->cctx != NULL) {
  ------------------
  |  Branch (134:7): [True: 0, False: 7.20k]
  ------------------
  135|      0|    blosc2_free_ctx(schunk->cctx);
  136|      0|  }
  137|  7.20k|  cparams->schunk = schunk;
  138|  7.20k|  schunk->cctx = blosc2_create_cctx(*cparams);
  139|  7.20k|  if (schunk->cctx == NULL) {
  ------------------
  |  Branch (139:7): [True: 0, False: 7.20k]
  ------------------
  140|      0|    BLOSC_TRACE_ERROR("Could not create compression ctx");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|      0|    return BLOSC2_ERROR_NULL_POINTER;
  142|      0|  }
  143|       |
  144|       |  /* The decompression context */
  145|  7.20k|  if (schunk->dctx != NULL) {
  ------------------
  |  Branch (145:7): [True: 0, False: 7.20k]
  ------------------
  146|      0|    blosc2_free_ctx(schunk->dctx);
  147|      0|  }
  148|  7.20k|  dparams->schunk = schunk;
  149|  7.20k|  schunk->dctx = blosc2_create_dctx(*dparams);
  150|  7.20k|  if (schunk->dctx == NULL) {
  ------------------
  |  Branch (150:7): [True: 0, False: 7.20k]
  ------------------
  151|      0|    BLOSC_TRACE_ERROR("Could not create decompression ctx");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  152|      0|    return BLOSC2_ERROR_NULL_POINTER;
  153|      0|  }
  154|       |
  155|  7.20k|  return BLOSC2_ERROR_SUCCESS;
  156|  7.20k|}
blosc2_schunk_new:
  166|  7.20k|blosc2_schunk* blosc2_schunk_new(blosc2_storage *storage) {
  167|  7.20k|  blosc2_schunk* schunk = calloc(1, sizeof(blosc2_schunk));
  168|  7.20k|  schunk->version = 0;     /* pre-first version */
  169|  7.20k|  schunk->view = false;  /* not a view by default */
  170|       |
  171|       |  // Get the storage with proper defaults
  172|  7.20k|  schunk->storage = get_new_storage(storage, &BLOSC2_CPARAMS_DEFAULTS, &BLOSC2_DPARAMS_DEFAULTS, &BLOSC2_IO_DEFAULTS);
  173|       |  // Update the (local variable) storage
  174|  7.20k|  storage = schunk->storage;
  175|       |
  176|  7.20k|  char* tradeoff = getenv("BTUNE_TRADEOFF");
  177|  7.20k|  if (tradeoff != NULL) {
  ------------------
  |  Branch (177:7): [True: 0, False: 7.20k]
  ------------------
  178|       |    // If BTUNE_TRADEOFF passed, automatically use btune
  179|      0|    storage->cparams->tuner_id = BLOSC_BTUNE;
  180|      0|  }
  181|       |
  182|       |  // ...and update internal properties
  183|  7.20k|  if (update_schunk_properties(schunk) < 0) {
  ------------------
  |  Branch (183:7): [True: 0, False: 7.20k]
  ------------------
  184|      0|    BLOSC_TRACE_ERROR("Error when updating schunk properties");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  185|      0|    blosc2_schunk_free(schunk);
  186|      0|    return NULL;
  187|      0|  }
  188|       |
  189|  7.20k|  if (!storage->contiguous && storage->urlpath != NULL){
  ------------------
  |  Branch (189:7): [True: 4.25k, False: 2.94k]
  |  Branch (189:31): [True: 0, False: 4.25k]
  ------------------
  190|      0|    char* urlpath;
  191|      0|    char last_char = storage->urlpath[strlen(storage->urlpath) - 1];
  192|      0|    urlpath = malloc(strlen(storage->urlpath) + 1);
  193|      0|    strcpy(urlpath, storage->urlpath);
  194|      0|    if (last_char == '\\' || last_char == '/') {
  ------------------
  |  Branch (194:9): [True: 0, False: 0]
  |  Branch (194:30): [True: 0, False: 0]
  ------------------
  195|      0|      urlpath[strlen(storage->urlpath) - 1] = '\0';
  196|      0|    }
  197|       |    // Create directory
  198|      0|    if (mkdir(urlpath, 0777) == -1) {
  ------------------
  |  Branch (198:9): [True: 0, False: 0]
  ------------------
  199|      0|      BLOSC_TRACE_ERROR("Error during the creation of the directory, maybe it already exists.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  200|      0|      free(urlpath);
  201|      0|      blosc2_schunk_free(schunk);
  202|      0|      return NULL;
  203|      0|    }
  204|       |    // We want a sparse (directory) frame as storage
  205|      0|    blosc2_frame_s* frame = frame_new(urlpath);
  206|      0|    free(urlpath);
  207|      0|    if (frame == NULL) {
  ------------------
  |  Branch (207:9): [True: 0, False: 0]
  ------------------
  208|      0|      BLOSC_TRACE_ERROR("Error creating sparse frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  209|      0|      blosc2_schunk_free(schunk);
  210|      0|      return NULL;
  211|      0|    }
  212|      0|    frame->sframe = true;
  213|      0|    frame_set_locking(frame, schunk->storage->io);
  214|       |    // Initialize frame (basically, encode the header)
  215|      0|    frame->schunk = schunk;
  216|      0|    int64_t frame_len = frame_from_schunk(schunk, frame);
  217|      0|    if (frame_len < 0) {
  ------------------
  |  Branch (217:9): [True: 0, False: 0]
  ------------------
  218|      0|      BLOSC_TRACE_ERROR("Error during the conversion of schunk to frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  219|      0|      frame_free(frame);
  220|      0|      blosc2_schunk_free(schunk);
  221|      0|      return NULL;
  222|      0|    }
  223|      0|    schunk->frame = (blosc2_frame*)frame;
  224|      0|  }
  225|  7.20k|  if (storage->contiguous){
  ------------------
  |  Branch (225:7): [True: 2.94k, False: 4.25k]
  ------------------
  226|       |    // We want a contiguous frame as storage
  227|  2.94k|    if (storage->urlpath != NULL) {
  ------------------
  |  Branch (227:9): [True: 0, False: 2.94k]
  ------------------
  228|      0|      if (file_exists(storage->urlpath)) {
  ------------------
  |  Branch (228:11): [True: 0, False: 0]
  ------------------
  229|      0|        BLOSC_TRACE_ERROR("You are trying to overwrite an existing frame.  Remove it first!");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  230|      0|        blosc2_schunk_free(schunk);
  231|      0|        return NULL;
  232|      0|      }
  233|      0|    }
  234|  2.94k|    blosc2_frame_s* frame = frame_new(storage->urlpath);
  235|  2.94k|    if (frame == NULL) {
  ------------------
  |  Branch (235:9): [True: 0, False: 2.94k]
  ------------------
  236|      0|      BLOSC_TRACE_ERROR("Error creating contiguous frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  237|      0|      blosc2_schunk_free(schunk);
  238|      0|      return NULL;
  239|      0|    }
  240|  2.94k|    frame->sframe = false;
  241|  2.94k|    frame_set_locking(frame, schunk->storage->io);
  242|       |    // Initialize frame (basically, encode the header)
  243|  2.94k|    frame->schunk = schunk;
  244|  2.94k|    int64_t frame_len = frame_from_schunk(schunk, frame);
  245|  2.94k|    if (frame_len < 0) {
  ------------------
  |  Branch (245:9): [True: 0, False: 2.94k]
  ------------------
  246|      0|      BLOSC_TRACE_ERROR("Error during the conversion of schunk to frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  247|      0|      frame_free(frame);
  248|      0|      blosc2_schunk_free(schunk);
  249|      0|      return NULL;
  250|      0|    }
  251|  2.94k|    schunk->frame = (blosc2_frame*)frame;
  252|  2.94k|  }
  253|       |
  254|  7.20k|  return schunk;
  255|  7.20k|}
blosc2_schunk_to_buffer:
  567|  1.47k|int64_t blosc2_schunk_to_buffer(blosc2_schunk* schunk, uint8_t** dest, bool* needs_free) {
  568|  1.47k|  blosc2_frame_s* frame;
  569|  1.47k|  int64_t cframe_len;
  570|       |
  571|       |  // Initialize defaults in case of errors
  572|  1.47k|  *dest = NULL;
  573|  1.47k|  *needs_free = false;
  574|       |
  575|  1.47k|  if ((schunk->storage->contiguous == true) && (schunk->storage->urlpath == NULL)) {
  ------------------
  |  Branch (575:7): [True: 1.47k, False: 0]
  |  Branch (575:48): [True: 1.47k, False: 0]
  ------------------
  576|  1.47k|    frame =  (blosc2_frame_s*)(schunk->frame);
  577|  1.47k|    *dest = frame->cframe;
  578|  1.47k|    cframe_len = frame->len;
  579|  1.47k|    *needs_free = false;
  580|  1.47k|  }
  581|      0|  else {
  582|       |    // Copy to a contiguous storage
  583|      0|    blosc2_storage frame_storage = {.contiguous=true};
  584|      0|    blosc2_schunk* schunk_copy = schunk_copy_as_stored(schunk, &frame_storage);
  585|      0|    if (schunk_copy == NULL) {
  ------------------
  |  Branch (585:9): [True: 0, False: 0]
  ------------------
  586|      0|      BLOSC_TRACE_ERROR("Error during the conversion of schunk to buffer.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  587|      0|      return BLOSC2_ERROR_SCHUNK_COPY;
  588|      0|    }
  589|      0|    frame = (blosc2_frame_s*)(schunk_copy->frame);
  590|      0|    *dest = frame->cframe;
  591|      0|    cframe_len = frame->len;
  592|      0|    *needs_free = true;
  593|      0|    frame->avoid_cframe_free = true;
  594|      0|    blosc2_schunk_free(schunk_copy);
  595|      0|  }
  596|       |
  597|  1.47k|  return cframe_len;
  598|       |
  599|  1.47k|}
schunk_free_metalayers:
  790|  10.5k|void schunk_free_metalayers(blosc2_schunk *schunk) {
  791|  19.4k|  for (int i = 0; i < schunk->nmetalayers; i++) {
  ------------------
  |  Branch (791:19): [True: 8.92k, False: 10.5k]
  ------------------
  792|  8.92k|    if (schunk->metalayers[i] != NULL) {
  ------------------
  |  Branch (792:9): [True: 8.72k, False: 203]
  ------------------
  793|  8.72k|      free(schunk->metalayers[i]->name);
  794|  8.72k|      free(schunk->metalayers[i]->content);
  795|  8.72k|      free(schunk->metalayers[i]);
  796|       |      schunk->metalayers[i] = NULL;
  797|  8.72k|    }
  798|  8.92k|  }
  799|  10.5k|  schunk->nmetalayers = 0;
  800|  10.5k|}
schunk_free_vlmetalayers:
  803|  10.5k|void schunk_free_vlmetalayers(blosc2_schunk *schunk) {
  804|  35.2k|  for (int i = 0; i < schunk->nvlmetalayers; i++) {
  ------------------
  |  Branch (804:19): [True: 24.7k, False: 10.5k]
  ------------------
  805|  24.7k|    if (schunk->vlmetalayers[i] != NULL) {
  ------------------
  |  Branch (805:9): [True: 66, False: 24.6k]
  ------------------
  806|     66|      free(schunk->vlmetalayers[i]->name);
  807|     66|      free(schunk->vlmetalayers[i]->content);
  808|     66|      free(schunk->vlmetalayers[i]);
  809|       |      schunk->vlmetalayers[i] = NULL;
  810|     66|    }
  811|  24.7k|  }
  812|  10.5k|  schunk->nvlmetalayers = 0;
  813|  10.5k|}
blosc2_schunk_free:
  816|  10.5k|int blosc2_schunk_free(blosc2_schunk *schunk) {
  817|  10.5k|  int err = 0;
  818|       |
  819|       |  // If it is a view, the data belongs to original array and should not be freed
  820|  10.5k|  if (schunk->data != NULL && !schunk->view) {
  ------------------
  |  Branch (820:7): [True: 0, False: 10.5k]
  |  Branch (820:31): [True: 0, False: 0]
  ------------------
  821|      0|    for (int i = 0; i < schunk->nchunks; i++) {
  ------------------
  |  Branch (821:21): [True: 0, False: 0]
  ------------------
  822|      0|      free(schunk->data[i]);
  823|      0|    }
  824|      0|    free(schunk->data);
  825|      0|  }
  826|  10.5k|  if (schunk->cctx != NULL)
  ------------------
  |  Branch (826:7): [True: 10.1k, False: 420]
  ------------------
  827|  10.1k|    blosc2_free_ctx(schunk->cctx);
  828|  10.5k|  if (schunk->dctx != NULL)
  ------------------
  |  Branch (828:7): [True: 10.1k, False: 420]
  ------------------
  829|  10.1k|    blosc2_free_ctx(schunk->dctx);
  830|  10.5k|  if (schunk->blockshape != NULL)
  ------------------
  |  Branch (830:7): [True: 0, False: 10.5k]
  ------------------
  831|      0|    free(schunk->blockshape);
  832|       |
  833|  10.5k|  schunk_free_metalayers(schunk);
  834|       |
  835|  10.5k|  if (schunk->storage != NULL) {
  ------------------
  |  Branch (835:7): [True: 10.1k, False: 420]
  ------------------
  836|  10.1k|    blosc2_io_cb *io_cb = blosc2_get_io_cb(schunk->storage->io->id);
  837|  10.1k|    if (io_cb != NULL) {
  ------------------
  |  Branch (837:9): [True: 10.1k, False: 0]
  ------------------
  838|  10.1k|      int rc = io_cb->destroy(schunk->storage->io->params);
  839|  10.1k|      if (rc < 0) {
  ------------------
  |  Branch (839:11): [True: 0, False: 10.1k]
  ------------------
  840|      0|        BLOSC_TRACE_ERROR("Could not free the I/O resources.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  841|      0|        err = 1;
  842|      0|      }
  843|  10.1k|    }
  844|       |
  845|  10.1k|    if (schunk->storage->urlpath != NULL) {
  ------------------
  |  Branch (845:9): [True: 0, False: 10.1k]
  ------------------
  846|      0|      free(schunk->storage->urlpath);
  847|      0|    }
  848|  10.1k|    free(schunk->storage->cparams);
  849|  10.1k|    free(schunk->storage->dparams);
  850|  10.1k|    free(schunk->storage->io);
  851|  10.1k|    free(schunk->storage);
  852|  10.1k|  }
  853|       |
  854|       |  // If it is a view, the frame belongs to original array and should not be freed
  855|  10.5k|  if (schunk->frame != NULL && !schunk->view) {
  ------------------
  |  Branch (855:7): [True: 10.5k, False: 0]
  |  Branch (855:32): [True: 6.31k, False: 4.25k]
  ------------------
  856|  6.31k|    int rc = frame_free((blosc2_frame_s *) schunk->frame);
  857|  6.31k|    if (rc < 0 && err == 0) {
  ------------------
  |  Branch (857:9): [True: 0, False: 6.31k]
  |  Branch (857:19): [True: 0, False: 0]
  ------------------
  858|      0|      err = rc;
  859|      0|    }
  860|  6.31k|  }
  861|       |
  862|  10.5k|  schunk_free_vlmetalayers(schunk);
  863|       |
  864|  10.5k|  free(schunk);
  865|       |
  866|  10.5k|  return err;
  867|  10.5k|}
blosc2_schunk_from_buffer:
  880|  3.39k|blosc2_schunk* blosc2_schunk_from_buffer(uint8_t *cframe, int64_t len, bool copy) {
  881|       |  // Check that the buffer actually comes from a cframe
  882|  3.39k|  if (cframe == NULL || len < FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  3.39k|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  3.39k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  3.39k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  3.39k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  3.39k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  3.39k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  3.39k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  3.39k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  3.39k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  3.39k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  3.39k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  3.39k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  3.39k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  3.39k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (882:7): [True: 0, False: 3.39k]
  |  Branch (882:25): [True: 0, False: 3.39k]
  ------------------
  883|      0|    return NULL;
  884|      0|  }
  885|  3.39k|  char *magic_number = (char *)cframe + FRAME_HEADER_MAGIC;
  ------------------
  |  |   29|  3.39k|#define FRAME_HEADER_MAGIC 2
  ------------------
  886|  3.39k|  if (memcmp(magic_number, "b2frame", sizeof("b2frame")) != 0) {
  ------------------
  |  Branch (886:7): [True: 0, False: 3.39k]
  ------------------
  887|      0|    return NULL;
  888|      0|  }
  889|  3.39k|  blosc2_frame_s* frame = frame_from_cframe(cframe, len, false);
  890|  3.39k|  if (frame == NULL) {
  ------------------
  |  Branch (890:7): [True: 20, False: 3.37k]
  ------------------
  891|     20|    return NULL;
  892|     20|  }
  893|  3.37k|  blosc2_schunk* schunk = frame_to_schunk(frame, copy, &BLOSC2_IO_DEFAULTS);
  894|  3.37k|  if (schunk && copy) {
  ------------------
  |  Branch (894:7): [True: 1.47k, False: 1.90k]
  |  Branch (894:17): [True: 0, False: 1.47k]
  ------------------
  895|       |    // Super-chunk has its own copy of frame
  896|      0|    frame_free(frame);
  897|      0|  }
  898|  3.37k|  return schunk;
  899|  3.39k|}
blosc2_schunk_fill_special:
  954|  6.08k|                               int32_t chunksize) {
  955|  6.08k|  if (nitems == 0) {
  ------------------
  |  Branch (955:7): [True: 0, False: 6.08k]
  ------------------
  956|      0|    return 0;
  957|      0|  }
  958|       |
  959|  6.08k|  int32_t typesize = schunk->typesize;
  960|  6.08k|  if (nitems < 0 || chunksize <= 0 || typesize <= 0) {
  ------------------
  |  Branch (960:7): [True: 0, False: 6.08k]
  |  Branch (960:21): [True: 0, False: 6.08k]
  |  Branch (960:39): [True: 0, False: 6.08k]
  ------------------
  961|      0|    BLOSC_TRACE_ERROR("Invalid special fill parameters.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  962|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  963|      0|  }
  964|       |
  965|  6.08k|  if ((schunk->nbytes > 0) || (schunk->cbytes > 0)) {
  ------------------
  |  Branch (965:7): [True: 0, False: 6.08k]
  |  Branch (965:31): [True: 0, False: 6.08k]
  ------------------
  966|      0|    BLOSC_TRACE_ERROR("Filling with special values only works on empty super-chunks");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  967|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
  968|      0|  }
  969|       |
  970|       |  // Compute the number of chunks and the length of the offsets chunk
  971|  6.08k|  int32_t chunkitems = chunksize / typesize;
  972|  6.08k|  if (chunkitems <= 0) {
  ------------------
  |  Branch (972:7): [True: 0, False: 6.08k]
  ------------------
  973|      0|    BLOSC_TRACE_ERROR("chunksize must be >= typesize for special fill.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  974|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  975|      0|  }
  976|  6.08k|  int64_t nchunks = nitems / chunkitems;
  977|  6.08k|  if (nchunks > INT_MAX) {
  ------------------
  |  Branch (977:7): [True: 0, False: 6.08k]
  ------------------
  978|      0|    BLOSC_TRACE_ERROR("nitems is too large.  Try increasing the chunksize.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  979|      0|    return BLOSC2_ERROR_SCHUNK_SPECIAL;
  980|      0|  }
  981|  6.08k|  if (!blosc2_checked_mul_i64_nonneg(nitems, typesize, NULL)) {
  ------------------
  |  Branch (981:7): [True: 0, False: 6.08k]
  ------------------
  982|      0|    BLOSC_TRACE_ERROR("nitems is too large for nbytes accounting.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  983|      0|    return BLOSC2_ERROR_SCHUNK_SPECIAL;
  984|      0|  }
  985|  6.08k|  int32_t leftover_items = (int32_t)(nitems % chunkitems);
  986|       |
  987|  6.08k|  if (schunk->frame == NULL) {
  ------------------
  |  Branch (987:7): [True: 4.23k, False: 1.84k]
  ------------------
  988|       |    // Build the special chunks
  989|  4.23k|    int32_t leftover_size = leftover_items * typesize;
  990|  4.23k|    void* chunk = malloc(BLOSC_EXTENDED_HEADER_LENGTH);
  991|  4.23k|    void* chunk2 = malloc(BLOSC_EXTENDED_HEADER_LENGTH);
  992|  4.23k|    blosc2_cparams* cparams;
  993|  4.23k|    blosc2_schunk_get_cparams(schunk, &cparams);
  994|  4.23k|    int csize, csize2;
  995|  4.23k|    switch (special_value) {
  996|  4.23k|      case BLOSC2_SPECIAL_ZERO:
  ------------------
  |  Branch (996:7): [True: 4.23k, False: 0]
  ------------------
  997|  4.23k|        csize = blosc2_chunk_zeros(*cparams, chunksize, chunk, BLOSC_EXTENDED_HEADER_LENGTH);
  998|  4.23k|        csize2 = blosc2_chunk_zeros(*cparams, leftover_size, chunk2, BLOSC_EXTENDED_HEADER_LENGTH);
  999|  4.23k|        break;
 1000|      0|      case BLOSC2_SPECIAL_UNINIT:
  ------------------
  |  Branch (1000:7): [True: 0, False: 4.23k]
  ------------------
 1001|      0|        csize = blosc2_chunk_uninit(*cparams, chunksize, chunk, BLOSC_EXTENDED_HEADER_LENGTH);
 1002|      0|        csize2 = blosc2_chunk_uninit(*cparams, leftover_size, chunk2, BLOSC_EXTENDED_HEADER_LENGTH);
 1003|      0|        break;
 1004|      0|      case BLOSC2_SPECIAL_NAN:
  ------------------
  |  Branch (1004:7): [True: 0, False: 4.23k]
  ------------------
 1005|      0|        csize = blosc2_chunk_nans(*cparams, chunksize, chunk, BLOSC_EXTENDED_HEADER_LENGTH);
 1006|      0|        csize2 = blosc2_chunk_nans(*cparams, leftover_size, chunk2, BLOSC_EXTENDED_HEADER_LENGTH);
 1007|      0|        break;
 1008|      0|      default:
  ------------------
  |  Branch (1008:7): [True: 0, False: 4.23k]
  ------------------
 1009|      0|        BLOSC_TRACE_ERROR("Only zeros, NaNs or non-initialized values are supported.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1010|      0|        return BLOSC2_ERROR_SCHUNK_SPECIAL;
 1011|  4.23k|    }
 1012|  4.23k|    free(cparams);
 1013|  4.23k|    if (csize < 0 || csize2 < 0) {
  ------------------
  |  Branch (1013:9): [True: 0, False: 4.23k]
  |  Branch (1013:22): [True: 0, False: 4.23k]
  ------------------
 1014|      0|      BLOSC_TRACE_ERROR("Error creating special chunks.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1015|      0|      return BLOSC2_ERROR_SCHUNK_SPECIAL;
 1016|      0|    }
 1017|       |
 1018|  1.55M|    for (int nchunk = 0; nchunk < nchunks; nchunk++) {
  ------------------
  |  Branch (1018:26): [True: 1.55M, False: 4.23k]
  ------------------
 1019|  1.55M|      int64_t nchunk_ = blosc2_schunk_append_chunk(schunk, chunk, true);
 1020|  1.55M|      if (nchunk_ != nchunk + 1) {
  ------------------
  |  Branch (1020:11): [True: 0, False: 1.55M]
  ------------------
 1021|      0|        BLOSC_TRACE_ERROR("Error appending special chunks.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1022|      0|        return BLOSC2_ERROR_SCHUNK_SPECIAL;
 1023|      0|      }
 1024|  1.55M|    }
 1025|       |
 1026|  4.23k|    if (leftover_items) {
  ------------------
  |  Branch (1026:9): [True: 0, False: 4.23k]
  ------------------
 1027|      0|      int64_t nchunk_ = blosc2_schunk_append_chunk(schunk, chunk2, true);
 1028|      0|      if (nchunk_ != nchunks + 1) {
  ------------------
  |  Branch (1028:11): [True: 0, False: 0]
  ------------------
 1029|      0|        BLOSC_TRACE_ERROR("Error appending last special chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1030|      0|        return BLOSC2_ERROR_SCHUNK_SPECIAL;
 1031|      0|      }
 1032|      0|    }
 1033|  4.23k|    free(chunk);
 1034|  4.23k|    free(chunk2);
 1035|  4.23k|  }
 1036|  1.84k|  else {
 1037|       |    /* Fill an empty frame with special values (fast path). */
 1038|  1.84k|    blosc2_frame_s *frame = (blosc2_frame_s *) schunk->frame;
 1039|  1.84k|    int64_t total_chunks = nchunks + (leftover_items ? 1 : 0);
  ------------------
  |  Branch (1039:39): [True: 0, False: 1.84k]
  ------------------
 1040|  1.84k|    if (!blosc2_nchunks_to_offsets_nbytes(total_chunks, NULL)) {
  ------------------
  |  Branch (1040:9): [True: 0, False: 1.84k]
  ------------------
 1041|      0|      BLOSC_TRACE_ERROR("Too many chunks for frame offsets representation.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1042|      0|      return BLOSC2_ERROR_FRAME_SPECIAL;
 1043|      0|    }
 1044|       |
 1045|  1.84k|    int64_t old_nchunks = schunk->nchunks;
 1046|  1.84k|    int64_t old_nbytes = schunk->nbytes;
 1047|  1.84k|    int32_t old_chunksize = schunk->chunksize;
 1048|       |
 1049|       |    /* Update counters (necessary for the frame_fill_special() logic) */
 1050|  1.84k|    if (leftover_items) {
  ------------------
  |  Branch (1050:9): [True: 0, False: 1.84k]
  ------------------
 1051|      0|      nchunks += 1;
 1052|      0|    }
 1053|  1.84k|    schunk->chunksize = chunksize;
 1054|  1.84k|    schunk->nchunks = nchunks;
 1055|  1.84k|    schunk->nbytes = nitems * typesize;
 1056|  1.84k|    int rc = frame_lock(frame, true);
 1057|  1.84k|    if (rc < 0) {
  ------------------
  |  Branch (1057:9): [True: 0, False: 1.84k]
  ------------------
 1058|      0|      schunk->chunksize = old_chunksize;
 1059|      0|      schunk->nchunks = old_nchunks;
 1060|      0|      schunk->nbytes = old_nbytes;
 1061|      0|      return rc;
 1062|      0|    }
 1063|  1.84k|    int64_t frame_len = frame_fill_special(frame, nitems, special_value, chunksize, schunk);
 1064|  1.84k|    frame_unlock(frame);
 1065|  1.84k|    if (frame_len < 0) {
  ------------------
  |  Branch (1065:9): [True: 0, False: 1.84k]
  ------------------
 1066|      0|      schunk->chunksize = old_chunksize;
 1067|      0|      schunk->nchunks = old_nchunks;
 1068|      0|      schunk->nbytes = old_nbytes;
 1069|      0|      BLOSC_TRACE_ERROR("Error creating special frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1070|      0|      return frame_len;
 1071|      0|    }
 1072|  1.84k|  }
 1073|       |
 1074|  6.08k|  return schunk->nchunks;
 1075|  6.08k|}
blosc2_schunk_append_chunk:
 1294|  1.55M|int64_t blosc2_schunk_append_chunk(blosc2_schunk *schunk, uint8_t *chunk, bool copy) {
 1295|  1.55M|  return schunk_append_chunk_locked(schunk, chunk, copy ? CHUNK_COPIED : CHUNK_GIVEN);
  ------------------
  |  Branch (1295:52): [True: 1.55M, False: 0]
  ------------------
 1296|  1.55M|}
blosc2_schunk_insert_chunk:
 1431|   532k|int64_t blosc2_schunk_insert_chunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t *chunk, bool copy) {
 1432|   532k|  return schunk_insert_chunk_locked(schunk, nchunk, chunk, copy ? CHUNK_COPIED : CHUNK_GIVEN);
  ------------------
  |  Branch (1432:60): [True: 0, False: 532k]
  ------------------
 1433|   532k|}
blosc2_schunk_update_chunk:
 1570|  7.94k|int64_t blosc2_schunk_update_chunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t *chunk, bool copy) {
 1571|  7.94k|  return schunk_update_chunk_locked(schunk, nchunk, chunk, copy ? CHUNK_COPIED : CHUNK_GIVEN);
  ------------------
  |  Branch (1571:60): [True: 7.94k, False: 0]
  ------------------
 1572|  7.94k|}
schunk_update_chunk_lent:
 1575|   608k|int64_t schunk_update_chunk_lent(blosc2_schunk *schunk, int64_t nchunk, uint8_t *chunk) {
 1576|   608k|  return schunk_update_chunk_locked(schunk, nchunk, chunk, CHUNK_LENT);
 1577|   608k|}
schunk_scratch_malloc:
 1650|   634k|uint8_t *schunk_scratch_malloc(const blosc2_schunk *schunk, int32_t nbytes, size_t *capacity) {
 1651|   634k|  if (schunk->frame != NULL) {
  ------------------
  |  Branch (1651:7): [True: 634k, False: 0]
  ------------------
 1652|   634k|    return blosc2_tmp_malloc((size_t) nbytes, capacity);
 1653|   634k|  }
 1654|      0|  *capacity = 0;
 1655|      0|  return malloc((size_t) nbytes);
 1656|   634k|}
blosc2_schunk_append_buffer:
 1723|      8|int64_t blosc2_schunk_append_buffer(blosc2_schunk *schunk, const void *src, int32_t nbytes) {
 1724|      8|  return schunk_compress_store(schunk, schunk->nchunks, src, nbytes, WRITE_APPEND,
 1725|      8|                               "blosc2_schunk_append_buffer");
 1726|      8|}
blosc2_schunk_decompress_chunk:
 1747|   490k|                                   void *dest, int32_t nbytes) {
 1748|   490k|  int rc = validate_nchunk(schunk, nchunk, false, "blosc2_schunk_decompress_chunk");
 1749|   490k|  if (rc < 0) {
  ------------------
  |  Branch (1749:7): [True: 189, False: 490k]
  ------------------
 1750|    189|    return rc;
 1751|    189|  }
 1752|       |
 1753|   490k|  int32_t chunk_nbytes;
 1754|   490k|  int32_t chunk_cbytes;
 1755|   490k|  int chunksize;
 1756|   490k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1757|       |
 1758|   490k|  schunk->current_nchunk = nchunk;
 1759|   490k|  if (frame == NULL) {
  ------------------
  |  Branch (1759:7): [True: 0, False: 490k]
  ------------------
 1760|      0|    uint8_t* src = schunk->data[nchunk];
 1761|      0|    if (src == 0) {
  ------------------
  |  Branch (1761:9): [True: 0, False: 0]
  ------------------
 1762|      0|      return 0;
 1763|      0|    }
 1764|       |
 1765|      0|    rc = blosc2_cbuffer_sizes(src, &chunk_nbytes, &chunk_cbytes, NULL);
 1766|      0|    if (rc < 0) {
  ------------------
  |  Branch (1766:9): [True: 0, False: 0]
  ------------------
 1767|      0|      return rc;
 1768|      0|    }
 1769|       |
 1770|      0|    if (nbytes < chunk_nbytes) {
  ------------------
  |  Branch (1770:9): [True: 0, False: 0]
  ------------------
 1771|      0|      BLOSC_TRACE_ERROR("Buffer size is too small for the decompressed buffer "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1772|      0|                        "('%d' bytes, but '%d' are needed).", nbytes, chunk_nbytes);
 1773|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 1774|      0|    }
 1775|       |
 1776|      0|    chunksize = blosc2_decompress_ctx(schunk->dctx, src, chunk_cbytes, dest, nbytes);
 1777|      0|    if (chunksize < 0 || chunksize != chunk_nbytes) {
  ------------------
  |  Branch (1777:9): [True: 0, False: 0]
  |  Branch (1777:26): [True: 0, False: 0]
  ------------------
 1778|      0|      BLOSC_TRACE_ERROR("Error in decompressing chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1779|      0|      if (chunksize < 0)
  ------------------
  |  Branch (1779:11): [True: 0, False: 0]
  ------------------
 1780|      0|        return chunksize;
 1781|      0|      return BLOSC2_ERROR_FAILURE;
 1782|      0|    }
 1783|   490k|  } else {
 1784|   490k|    rc = frame_lock(frame, false);
 1785|   490k|    if (rc < 0) {
  ------------------
  |  Branch (1785:9): [True: 0, False: 490k]
  ------------------
 1786|      0|      return rc;
 1787|      0|    }
 1788|   490k|    chunksize = frame_decompress_chunk(schunk->dctx, frame, nchunk, dest, nbytes);
 1789|   490k|    frame_unlock(frame);
 1790|   490k|    if (chunksize < 0) {
  ------------------
  |  Branch (1790:9): [True: 0, False: 490k]
  ------------------
 1791|      0|      return chunksize;
 1792|      0|    }
 1793|   490k|  }
 1794|   490k|  return chunksize;
 1795|   490k|}
blosc2_schunk_get_lazychunk:
 1884|  60.4k|int blosc2_schunk_get_lazychunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t **chunk, bool *needs_free) {
 1885|  60.4k|  int rc = validate_nchunk(schunk, nchunk, false, "blosc2_schunk_get_lazychunk");
 1886|  60.4k|  if (rc < 0) {
  ------------------
  |  Branch (1886:7): [True: 327, False: 60.1k]
  ------------------
 1887|    327|    return rc;
 1888|    327|  }
 1889|       |
 1890|  60.1k|  if (ctx_uses_parallel_backend(schunk->dctx)) {
  ------------------
  |  Branch (1890:7): [True: 0, False: 60.1k]
  ------------------
 1891|      0|    blosc2_pthread_mutex_lock(&schunk->dctx->nchunk_mutex);
  ------------------
  |  |   92|      0|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 1892|      0|    schunk->current_nchunk = nchunk;
 1893|      0|    blosc2_pthread_mutex_unlock(&schunk->dctx->nchunk_mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 1894|      0|  }
 1895|  60.1k|  else {
 1896|  60.1k|    schunk->current_nchunk = nchunk;
 1897|  60.1k|  }
 1898|  60.1k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1899|  60.1k|  if (schunk->frame != NULL) {
  ------------------
  |  Branch (1899:7): [True: 60.1k, False: 0]
  ------------------
 1900|  60.1k|    rc = frame_lock(frame, false);
 1901|  60.1k|    if (rc < 0) {
  ------------------
  |  Branch (1901:9): [True: 0, False: 60.1k]
  ------------------
 1902|      0|      return rc;
 1903|      0|    }
 1904|  60.1k|    rc = frame_get_lazychunk(frame, nchunk, chunk, needs_free);
 1905|  60.1k|    frame_unlock(frame);
 1906|  60.1k|    return rc;
 1907|  60.1k|  }
 1908|       |
 1909|      0|  *chunk = schunk->data[nchunk];
 1910|      0|  if (*chunk == 0) {
  ------------------
  |  Branch (1910:7): [True: 0, False: 0]
  ------------------
 1911|      0|    *needs_free = 0;
 1912|      0|    return 0;
 1913|      0|  }
 1914|       |
 1915|      0|  *needs_free = false;
 1916|      0|  int32_t chunk_cbytes;
 1917|      0|  rc = blosc2_cbuffer_sizes(*chunk, NULL, &chunk_cbytes, NULL);
 1918|      0|  if (rc < 0) {
  ------------------
  |  Branch (1918:7): [True: 0, False: 0]
  ------------------
 1919|      0|    return rc;
 1920|      0|  }
 1921|      0|  return (int)chunk_cbytes;
 1922|      0|}
schunk_decompress_masked:
 2007|   446k|                             void *user_data, void *dest, int32_t destsize) {
 2008|   446k|  blosc2_context *dctx = schunk->dctx;
 2009|   446k|  int rc = blosc2_set_maskout(dctx, (bool *) maskout, nblocks);
 2010|   446k|  if (rc < 0) {
  ------------------
  |  Branch (2010:7): [True: 0, False: 446k]
  ------------------
 2011|      0|    return rc;
 2012|      0|  }
 2013|   446k|  blosc2_postfilter_fn saved_postfilter = dctx->postfilter;
 2014|   446k|  blosc2_postfilter_params *saved_postparams = dctx->postparams;
 2015|   446k|  blosc2_postfilter_params params;
 2016|   446k|  if (postfilter != NULL) {
  ------------------
  |  Branch (2016:7): [True: 445k, False: 1.06k]
  ------------------
 2017|   445k|    memset(&params, 0, sizeof(params));
 2018|   445k|    params.user_data = user_data;
 2019|   445k|    dctx->postfilter = postfilter;
 2020|   445k|    dctx->postparams = &params;
 2021|   445k|  }
 2022|   446k|  if (chunk != NULL) {
  ------------------
  |  Branch (2022:7): [True: 0, False: 446k]
  ------------------
 2023|      0|    rc = blosc2_decompress_ctx(dctx, chunk, cbytes, dest, destsize);
 2024|      0|  }
 2025|   446k|  else {
 2026|   446k|    rc = blosc2_schunk_decompress_chunk(schunk, nchunk, dest, destsize);
 2027|   446k|  }
 2028|   446k|  dctx->postfilter = saved_postfilter;
 2029|   446k|  dctx->postparams = saved_postparams;
 2030|       |  // A decompression that failed early, or a missing chunk, leaves the mask set
 2031|   446k|  ctx_clear_maskout(dctx);
 2032|   446k|  return rc;
 2033|   446k|}
metalayer_flush:
 2815|  7.20k|int metalayer_flush(blosc2_schunk* schunk) {
 2816|  7.20k|  int rc = BLOSC2_ERROR_SUCCESS;
 2817|  7.20k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 2818|  7.20k|  if (frame == NULL) {
  ------------------
  |  Branch (2818:7): [True: 4.25k, False: 2.94k]
  ------------------
 2819|  4.25k|    return rc;
 2820|  4.25k|  }
 2821|  2.94k|  rc = frame_lock(frame, true);
 2822|  2.94k|  if (rc < 0) {
  ------------------
  |  Branch (2822:7): [True: 0, False: 2.94k]
  ------------------
 2823|      0|    return rc;
 2824|      0|  }
 2825|  2.94k|  rc = frame_update_header(frame, schunk, true);
 2826|  2.94k|  if (rc < 0) {
  ------------------
  |  Branch (2826:7): [True: 0, False: 2.94k]
  ------------------
 2827|      0|    BLOSC_TRACE_ERROR("Unable to update metalayers into frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2828|      0|    frame_unlock(frame);
 2829|      0|    return rc;
 2830|      0|  }
 2831|  2.94k|  rc = frame_update_trailer(frame, schunk);
 2832|  2.94k|  if (rc < 0) {
  ------------------
  |  Branch (2832:7): [True: 0, False: 2.94k]
  ------------------
 2833|      0|    BLOSC_TRACE_ERROR("Unable to update trailer into frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2834|      0|    frame_unlock(frame);
 2835|      0|    return rc;
 2836|      0|  }
 2837|  2.94k|  frame_unlock(frame);
 2838|  2.94k|  return rc;
 2839|  2.94k|}
blosc2_meta_add:
 2846|  7.20k|int blosc2_meta_add(blosc2_schunk *schunk, const char *name, uint8_t *content, int32_t content_len) {
 2847|  7.20k|  if (schunk == NULL || name == NULL) {
  ------------------
  |  Branch (2847:7): [True: 0, False: 7.20k]
  |  Branch (2847:25): [True: 0, False: 7.20k]
  ------------------
 2848|      0|    BLOSC_TRACE_ERROR("Invalid parameters.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2849|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2850|      0|  }
 2851|  7.20k|  int nmetalayer = blosc2_meta_exists(schunk, name);
 2852|  7.20k|  if (nmetalayer >= 0) {
  ------------------
  |  Branch (2852:7): [True: 0, False: 7.20k]
  ------------------
 2853|      0|    BLOSC_TRACE_ERROR("Metalayer \"%s\" already exists.", name);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2854|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2855|      0|  }
 2856|  7.20k|  if (content_len < 0) {
  ------------------
  |  Branch (2856:7): [True: 0, False: 7.20k]
  ------------------
 2857|      0|    BLOSC_TRACE_ERROR("Metalayer content length must not be negative.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2858|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2859|      0|  }
 2860|  7.20k|  if (content_len > 0 && content == NULL) {
  ------------------
  |  Branch (2860:7): [True: 7.20k, False: 0]
  |  Branch (2860:26): [True: 0, False: 7.20k]
  ------------------
 2861|      0|    BLOSC_TRACE_ERROR("Metalayer content pointer must not be NULL when content length is positive.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2862|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2863|      0|  }
 2864|       |
 2865|       |  // Add the metalayer
 2866|  7.20k|  blosc2_metalayer *metalayer = malloc(sizeof(blosc2_metalayer));
 2867|  7.20k|  BLOSC_ERROR_NULL(metalayer, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  7.20k|    do {                                            \
  |  |  105|  7.20k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.20k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  7.20k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.20k]
  |  |  ------------------
  ------------------
 2868|       |
 2869|  7.20k|  char* name_ = malloc(strlen(name) + 1);
 2870|  7.20k|  if (name_ == NULL) {
  ------------------
  |  Branch (2870:7): [True: 0, False: 7.20k]
  ------------------
 2871|      0|    free(metalayer);
 2872|      0|    BLOSC_TRACE_ERROR("Unable to allocate metalayer name buffer.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2873|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2874|      0|  }
 2875|  7.20k|  strcpy(name_, name);
 2876|  7.20k|  metalayer->name = name_;
 2877|       |
 2878|  7.20k|  uint8_t* content_buf = malloc((size_t)content_len);
 2879|  7.20k|  if (content_buf == NULL && content_len > 0) {
  ------------------
  |  Branch (2879:7): [True: 0, False: 7.20k]
  |  Branch (2879:30): [True: 0, False: 0]
  ------------------
 2880|      0|    free(name_);
 2881|      0|    free(metalayer);
 2882|      0|    BLOSC_TRACE_ERROR("Unable to allocate metalayer content buffer.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2883|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2884|      0|  }
 2885|  7.20k|  if (content_len > 0) {
  ------------------
  |  Branch (2885:7): [True: 7.20k, False: 0]
  ------------------
 2886|  7.20k|    memcpy(content_buf, content, content_len);
 2887|  7.20k|  }
 2888|  7.20k|  metalayer->content = content_buf;
 2889|  7.20k|  metalayer->content_len = content_len;
 2890|  7.20k|  schunk->metalayers[schunk->nmetalayers] = metalayer;
 2891|  7.20k|  schunk->nmetalayers += 1;
 2892|       |
 2893|  7.20k|  int rc = metalayer_flush(schunk);
 2894|  7.20k|  if (rc < 0) {
  ------------------
  |  Branch (2894:7): [True: 0, False: 7.20k]
  ------------------
 2895|      0|    return rc;
 2896|      0|  }
 2897|  7.20k|  schunk->change_tick++;
 2898|       |
 2899|  7.20k|  return schunk->nmetalayers - 1;
 2900|  7.20k|}
blosc2_meta_update:
 2907|  1.33k|int blosc2_meta_update(blosc2_schunk *schunk, const char *name, uint8_t *content, int32_t content_len) {
 2908|  1.33k|  if (schunk == NULL || name == NULL) {
  ------------------
  |  Branch (2908:7): [True: 0, False: 1.33k]
  |  Branch (2908:25): [True: 0, False: 1.33k]
  ------------------
 2909|      0|    BLOSC_TRACE_ERROR("Invalid parameters.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2910|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2911|      0|  }
 2912|  1.33k|  int nmetalayer = blosc2_meta_exists(schunk, name);
 2913|  1.33k|  if (nmetalayer < 0) {
  ------------------
  |  Branch (2913:7): [True: 0, False: 1.33k]
  ------------------
 2914|      0|    BLOSC_TRACE_ERROR("Metalayer \"%s\" not found.", name);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2915|      0|    return nmetalayer;
 2916|      0|  }
 2917|  1.33k|  if (content_len < 0) {
  ------------------
  |  Branch (2917:7): [True: 0, False: 1.33k]
  ------------------
 2918|      0|    BLOSC_TRACE_ERROR("Metalayer content length must not be negative.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2919|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2920|      0|  }
 2921|  1.33k|  if (content_len > 0 && content == NULL) {
  ------------------
  |  Branch (2921:7): [True: 1.33k, False: 0]
  |  Branch (2921:26): [True: 0, False: 1.33k]
  ------------------
 2922|      0|    BLOSC_TRACE_ERROR("Metalayer content pointer must not be NULL when content length is positive.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2923|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2924|      0|  }
 2925|       |
 2926|  1.33k|  blosc2_metalayer *metalayer = schunk->metalayers[nmetalayer];
 2927|  1.33k|  if (content_len > metalayer->content_len) {
  ------------------
  |  Branch (2927:7): [True: 0, False: 1.33k]
  ------------------
 2928|      0|    BLOSC_TRACE_ERROR("`content_len` cannot exceed the existing size of %d bytes.", metalayer->content_len);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2929|      0|    return nmetalayer;
 2930|      0|  }
 2931|       |
 2932|       |  // Update the contents of the metalayer
 2933|  1.33k|  if (content_len > 0) {
  ------------------
  |  Branch (2933:7): [True: 1.33k, False: 0]
  ------------------
 2934|  1.33k|    memmove(metalayer->content, content, content_len);
 2935|  1.33k|  }
 2936|       |
 2937|       |  // Update the metalayers in frame (as size has not changed, we don't need to update the trailer)
 2938|  1.33k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 2939|  1.33k|  if (frame != NULL) {
  ------------------
  |  Branch (2939:7): [True: 1.33k, False: 0]
  ------------------
 2940|  1.33k|    int rc = frame_lock(frame, true);
 2941|  1.33k|    if (rc < 0) {
  ------------------
  |  Branch (2941:9): [True: 0, False: 1.33k]
  ------------------
 2942|      0|      return rc;
 2943|      0|    }
 2944|  1.33k|    rc = frame_update_header(frame, schunk, false);
 2945|  1.33k|    frame_unlock(frame);
 2946|  1.33k|    if (rc < 0) {
  ------------------
  |  Branch (2946:9): [True: 0, False: 1.33k]
  ------------------
 2947|      0|      BLOSC_TRACE_ERROR("Unable to update meta info from frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2948|      0|      return rc;
 2949|      0|    }
 2950|  1.33k|  }
 2951|  1.33k|  schunk->change_tick++;
 2952|       |
 2953|  1.33k|  return nmetalayer;
 2954|  1.33k|}
schunk.c:schunk_append_chunk_locked:
 1273|  1.55M|static int64_t schunk_append_chunk_locked(blosc2_schunk *schunk, uint8_t *chunk, chunk_handover how) {
 1274|  1.55M|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1275|  1.55M|  int rc = frame_lock(frame, true);
 1276|  1.55M|  if (rc < 0) {
  ------------------
  |  Branch (1276:7): [True: 0, False: 1.55M]
  ------------------
 1277|      0|    return rc;
 1278|      0|  }
 1279|       |  // Sync the cached counters before the delta below is applied to them, so a
 1280|       |  // handle whose lock acquisition just flagged staleness does not persist
 1281|       |  // wrong nbytes/cbytes/nchunks (see plans/todo-locking-swmr.md item 1).
 1282|  1.55M|  rc = frame_check_stale(frame);
 1283|  1.55M|  if (rc < 0) {
  ------------------
  |  Branch (1283:7): [True: 0, False: 1.55M]
  ------------------
 1284|      0|    frame_unlock(frame);
 1285|      0|    return rc;
 1286|      0|  }
 1287|  1.55M|  int64_t nchunks = schunk_append_chunk_unlocked(schunk, chunk, how);
 1288|  1.55M|  frame_unlock(frame);
 1289|  1.55M|  return nchunks;
 1290|  1.55M|}
schunk.c:schunk_append_chunk_unlocked:
 1175|  1.55M|static int64_t schunk_append_chunk_unlocked(blosc2_schunk *schunk, uint8_t *chunk, chunk_handover how) {
 1176|  1.55M|  int32_t chunk_nbytes;
 1177|  1.55M|  int32_t chunk_cbytes;
 1178|  1.55M|  int64_t nchunks = schunk->nchunks;
 1179|       |
 1180|  1.55M|  int rc = blosc2_cbuffer_sizes(chunk, &chunk_nbytes, &chunk_cbytes, NULL);
 1181|  1.55M|  if (rc < 0) {
  ------------------
  |  Branch (1181:7): [True: 0, False: 1.55M]
  ------------------
 1182|      0|    return rc;
 1183|      0|  }
 1184|       |  // Saved, so that the super-chunk is left unchanged if appending to the frame fails
 1185|  1.55M|  uint8_t old_flags2 = schunk->flags2;
 1186|  1.55M|  int32_t old_chunksize = schunk->chunksize;
 1187|  1.55M|  int64_t old_current_nchunk = schunk->current_nchunk;
 1188|  1.55M|  int64_t old_nbytes = schunk->nbytes;
 1189|  1.55M|  int64_t old_cbytes = schunk->cbytes;
 1190|       |
 1191|  1.55M|  uint8_t flags2 = get_chunk_flags2(chunk, chunk_cbytes);
 1192|  1.55M|  bool chunk_vlblocks = (flags2 & BLOSC2_VL_BLOCKS) != 0;
 1193|  1.55M|  if (nchunks > 0) {
  ------------------
  |  Branch (1193:7): [True: 1.55M, False: 4.23k]
  ------------------
 1194|  1.55M|    uint8_t first_flags2;
 1195|  1.55M|    rc = schunk_get_chunk_flags2(schunk, 0, &first_flags2);
 1196|  1.55M|    if (rc < 0) {
  ------------------
  |  Branch (1196:9): [True: 0, False: 1.55M]
  ------------------
 1197|      0|      return rc;
 1198|      0|    }
 1199|  1.55M|    if (((first_flags2 & BLOSC2_VL_BLOCKS) != 0) != chunk_vlblocks) {
  ------------------
  |  Branch (1199:9): [True: 0, False: 1.55M]
  ------------------
 1200|      0|      BLOSC_TRACE_ERROR("schunks cannot mix regular chunks and VL-block chunks.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1201|      0|      return BLOSC2_ERROR_CHUNK_APPEND;
 1202|      0|    }
 1203|  1.55M|  }
 1204|  4.23k|  else {
 1205|  4.23k|    schunk->flags2 = flags2;
 1206|  4.23k|  }
 1207|       |
 1208|  1.55M|  int32_t last_nbytes = 0;
 1209|  1.55M|  if (schunk->chunksize != 0 && nchunks > 0) {
  ------------------
  |  Branch (1209:7): [True: 1.55M, False: 0]
  |  Branch (1209:33): [True: 1.55M, False: 4.23k]
  ------------------
 1210|  1.55M|    rc = schunk_get_chunk_nbytes(schunk, nchunks - 1, &last_nbytes);
 1211|  1.55M|    if (rc < 0) {
  ------------------
  |  Branch (1211:9): [True: 0, False: 1.55M]
  ------------------
 1212|      0|      return rc;
 1213|      0|    }
 1214|  1.55M|  }
 1215|  1.55M|  int32_t chunksize = schunk->chunksize;
 1216|  1.55M|  if (!chunksize_after_adding(&schunk->chunksize, nchunks, last_nbytes, chunk_nbytes, true)) {
  ------------------
  |  Branch (1216:7): [True: 0, False: 1.55M]
  ------------------
 1217|      0|    BLOSC_TRACE_ERROR("Appending chunks that have different lengths in the same schunk "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1218|      0|                      "is not supported yet: %d > %d.", chunk_nbytes, chunksize);
 1219|      0|    return BLOSC2_ERROR_CHUNK_APPEND;
 1220|      0|  }
 1221|       |
 1222|       |  /* Update counters */
 1223|  1.55M|  schunk->current_nchunk = nchunks;
 1224|  1.55M|  schunk->nchunks = nchunks + 1;
 1225|  1.55M|  schunk->nbytes += chunk_nbytes;
 1226|       |  // A frame codes special chunks in their offsets
 1227|  1.55M|  if (schunk->frame == NULL || !chunk_special_in_offset(chunk, chunk_cbytes)) {
  ------------------
  |  Branch (1227:7): [True: 1.55M, False: 8]
  |  Branch (1227:32): [True: 7, False: 1]
  ------------------
 1228|  1.55M|    schunk->cbytes += chunk_cbytes;
 1229|  1.55M|  }
 1230|       |
 1231|  1.55M|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1232|  1.55M|  bool private_copy = chunk_needs_private_copy(frame, how);
 1233|  1.55M|  if (private_copy) {
  ------------------
  |  Branch (1233:7): [True: 1.55M, False: 8]
  ------------------
 1234|       |    // Make a copy of the chunk
 1235|  1.55M|    uint8_t *chunk_copy = malloc(chunk_cbytes);
 1236|  1.55M|    memcpy(chunk_copy, chunk, chunk_cbytes);
 1237|  1.55M|    chunk = chunk_copy;
 1238|  1.55M|  }
 1239|       |
 1240|       |  // Update super-chunk or frame
 1241|  1.55M|  if (frame == NULL) {
  ------------------
  |  Branch (1241:7): [True: 1.55M, False: 8]
  ------------------
 1242|  1.55M|    if (how == CHUNK_GIVEN && (chunk_cbytes < chunk_nbytes)) {
  ------------------
  |  Branch (1242:9): [True: 0, False: 1.55M]
  |  Branch (1242:31): [True: 0, False: 0]
  ------------------
 1243|       |      // We still want to do a shrink of the chunk
 1244|      0|      chunk = realloc(chunk, chunk_cbytes);
 1245|      0|    }
 1246|       |
 1247|       |    /* Make space for appending the copy of the chunk and do it */
 1248|  1.55M|    if ((nchunks + 1) * sizeof(void *) > schunk->data_len) {
  ------------------
  |  Branch (1248:9): [True: 6.74k, False: 1.54M]
  ------------------
 1249|       |      // Extend the data pointer by one memory page (4k)
 1250|  6.74k|      schunk->data_len += 4096;  // must be a multiple of sizeof(void*)
 1251|  6.74k|      schunk->data = realloc(schunk->data, schunk->data_len);
 1252|  6.74k|    }
 1253|  1.55M|    schunk->data[nchunks] = chunk;
 1254|  1.55M|  }
 1255|      8|  else {
 1256|      8|    bool written = frame_append_chunk(frame, chunk, schunk) != NULL;
 1257|      8|    frame_write_done(chunk, how, private_copy, written);
 1258|      8|    if (!written) {
  ------------------
  |  Branch (1258:9): [True: 0, False: 8]
  ------------------
 1259|      0|      BLOSC_TRACE_ERROR("Problems appending a chunk.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1260|      0|      schunk->flags2 = old_flags2;
 1261|      0|      schunk->chunksize = old_chunksize;
 1262|      0|      schunk->current_nchunk = old_current_nchunk;
 1263|      0|      schunk->nchunks = nchunks;
 1264|      0|      schunk->nbytes = old_nbytes;
 1265|      0|      schunk->cbytes = old_cbytes;
 1266|      0|      return BLOSC2_ERROR_CHUNK_APPEND;
 1267|      0|    }
 1268|      8|  }
 1269|  1.55M|  return schunk->nchunks;
 1270|  1.55M|}
schunk.c:schunk_get_chunk_flags2:
 1109|  2.69M|static int schunk_get_chunk_flags2(blosc2_schunk *schunk, int64_t nchunk, uint8_t *chunk_flags2) {
 1110|  2.69M|  uint8_t header[BLOSC_EXTENDED_HEADER_LENGTH];
 1111|  2.69M|  const uint8_t *chunk;
 1112|  2.69M|  int rc = schunk_get_chunk_header(schunk, nchunk, header, &chunk);
 1113|  2.69M|  if (rc < 0) {
  ------------------
  |  Branch (1113:7): [True: 0, False: 2.69M]
  ------------------
 1114|      0|    return rc;
 1115|      0|  }
 1116|  2.69M|  if (chunk == NULL) {
  ------------------
  |  Branch (1116:7): [True: 0, False: 2.69M]
  ------------------
 1117|      0|    return BLOSC2_ERROR_DATA;
 1118|      0|  }
 1119|  2.69M|  *chunk_flags2 = get_chunk_flags2(chunk, rc);
 1120|  2.69M|  return 0;
 1121|  2.69M|}
schunk.c:schunk_get_chunk_header:
 1082|  5.39M|                                   const uint8_t **chunk) {
 1083|  5.39M|  if (schunk->frame != NULL) {
  ------------------
  |  Branch (1083:7): [True: 2.29M, False: 3.10M]
  ------------------
 1084|  2.29M|    *chunk = header;
 1085|  2.29M|    return frame_get_chunk_header((blosc2_frame_s *)schunk->frame, nchunk, header);
 1086|  2.29M|  }
 1087|  3.10M|  *chunk = schunk->data[nchunk];
 1088|  3.10M|  if (*chunk == NULL) {
  ------------------
  |  Branch (1088:7): [True: 0, False: 3.10M]
  ------------------
 1089|      0|    return 0;
 1090|      0|  }
 1091|  3.10M|  int32_t chunk_cbytes;
 1092|  3.10M|  int rc = blosc2_cbuffer_sizes(*chunk, NULL, &chunk_cbytes, NULL);
 1093|  3.10M|  return rc < 0 ? rc : chunk_cbytes;
  ------------------
  |  Branch (1093:10): [True: 0, False: 3.10M]
  ------------------
 1094|  3.10M|}
schunk.c:schunk_get_chunk_nbytes:
 1096|  2.08M|static int schunk_get_chunk_nbytes(blosc2_schunk *schunk, int64_t nchunk, int32_t *chunk_nbytes) {
 1097|  2.08M|  uint8_t header[BLOSC_EXTENDED_HEADER_LENGTH];
 1098|  2.08M|  const uint8_t *chunk;
 1099|  2.08M|  int rc = schunk_get_chunk_header(schunk, nchunk, header, &chunk);
 1100|  2.08M|  if (rc < 0) {
  ------------------
  |  Branch (1100:7): [True: 0, False: 2.08M]
  ------------------
 1101|      0|    return rc;
 1102|      0|  }
 1103|  2.08M|  if (chunk == NULL) {
  ------------------
  |  Branch (1103:7): [True: 0, False: 2.08M]
  ------------------
 1104|      0|    return BLOSC2_ERROR_DATA;
 1105|      0|  }
 1106|  2.08M|  return blosc2_cbuffer_sizes(chunk, chunk_nbytes, NULL, NULL);
 1107|  2.08M|}
schunk.c:chunk_needs_private_copy:
 1159|  2.70M|static bool chunk_needs_private_copy(const blosc2_frame_s *frame, chunk_handover how) {
 1160|  2.70M|  return how == CHUNK_COPIED || (how == CHUNK_LENT && frame == NULL);
  ------------------
  |  Branch (1160:10): [True: 1.56M, False: 1.14M]
  |  Branch (1160:34): [True: 608k, False: 532k]
  |  Branch (1160:55): [True: 0, False: 608k]
  ------------------
 1161|  2.70M|}
schunk.c:frame_write_done:
 1167|  1.14M|static void frame_write_done(uint8_t *chunk, chunk_handover how, bool private_copy, bool written) {
 1168|  1.14M|  if (private_copy || (written && how == CHUNK_GIVEN)) {
  ------------------
  |  Branch (1168:7): [True: 7.94k, False: 1.14M]
  |  Branch (1168:24): [True: 1.14M, False: 0]
  |  Branch (1168:35): [True: 532k, False: 608k]
  ------------------
 1169|   540k|    free(chunk);
 1170|   540k|  }
 1171|  1.14M|}
schunk.c:schunk_insert_chunk_locked:
 1411|   532k|                                          chunk_handover how) {
 1412|   532k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1413|   532k|  int rc = frame_lock(frame, true);
 1414|   532k|  if (rc < 0) {
  ------------------
  |  Branch (1414:7): [True: 0, False: 532k]
  ------------------
 1415|      0|    return rc;
 1416|      0|  }
 1417|       |  // See schunk_append_chunk_locked() for why this must happen before the
 1418|       |  // counter deltas below are applied.
 1419|   532k|  rc = frame_check_stale(frame);
 1420|   532k|  if (rc < 0) {
  ------------------
  |  Branch (1420:7): [True: 0, False: 532k]
  ------------------
 1421|      0|    frame_unlock(frame);
 1422|      0|    return rc;
 1423|      0|  }
 1424|   532k|  int64_t nchunks = schunk_insert_chunk_unlocked(schunk, nchunk, chunk, how);
 1425|   532k|  frame_unlock(frame);
 1426|   532k|  return nchunks;
 1427|   532k|}
schunk.c:schunk_insert_chunk_unlocked:
 1301|   532k|                                            chunk_handover how) {
 1302|   532k|  int rc = validate_nchunk(schunk, nchunk, true, "blosc2_schunk_insert_chunk");
 1303|   532k|  if (rc < 0) {
  ------------------
  |  Branch (1303:7): [True: 0, False: 532k]
  ------------------
 1304|      0|    return rc;
 1305|      0|  }
 1306|       |
 1307|   532k|  int32_t chunk_nbytes;
 1308|   532k|  int32_t chunk_cbytes;
 1309|   532k|  int64_t nchunks = schunk->nchunks;
 1310|       |
 1311|   532k|  rc = blosc2_cbuffer_sizes(chunk, &chunk_nbytes, &chunk_cbytes, NULL);
 1312|   532k|  if (rc < 0) {
  ------------------
  |  Branch (1312:7): [True: 0, False: 532k]
  ------------------
 1313|      0|    return rc;
 1314|      0|  }
 1315|       |  // Saved, so that the super-chunk is left unchanged if inserting into the frame fails
 1316|   532k|  uint8_t old_flags2 = schunk->flags2;
 1317|   532k|  int32_t old_chunksize = schunk->chunksize;
 1318|   532k|  int64_t old_current_nchunk = schunk->current_nchunk;
 1319|   532k|  int64_t old_nbytes = schunk->nbytes;
 1320|   532k|  int64_t old_cbytes = schunk->cbytes;
 1321|   532k|  uint8_t flags2 = get_chunk_flags2(chunk, chunk_cbytes);
 1322|   532k|  bool chunk_vlblocks = (flags2 & BLOSC2_VL_BLOCKS) != 0;
 1323|   532k|  if (nchunks > 0) {
  ------------------
  |  Branch (1323:7): [True: 532k, False: 37]
  ------------------
 1324|   532k|    uint8_t first_flags2;
 1325|   532k|    rc = schunk_get_chunk_flags2(schunk, 0, &first_flags2);
 1326|   532k|    if (rc < 0) {
  ------------------
  |  Branch (1326:9): [True: 0, False: 532k]
  ------------------
 1327|      0|      return rc;
 1328|      0|    }
 1329|   532k|    if (((first_flags2 & BLOSC2_VL_BLOCKS) != 0) != chunk_vlblocks) {
  ------------------
  |  Branch (1329:9): [True: 0, False: 532k]
  ------------------
 1330|      0|      BLOSC_TRACE_ERROR("schunks cannot mix regular chunks and VL-block chunks.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1331|      0|      return BLOSC2_ERROR_CHUNK_INSERT;
 1332|      0|    }
 1333|   532k|  }
 1334|     37|  else {
 1335|     37|    schunk->flags2 = flags2;
 1336|     37|  }
 1337|       |
 1338|   532k|  int32_t last_nbytes = 0;
 1339|   532k|  if (schunk->chunksize != 0 && nchunks > 0) {
  ------------------
  |  Branch (1339:7): [True: 532k, False: 0]
  |  Branch (1339:33): [True: 532k, False: 37]
  ------------------
 1340|   532k|    rc = schunk_get_chunk_nbytes(schunk, nchunks - 1, &last_nbytes);
 1341|   532k|    if (rc < 0) {
  ------------------
  |  Branch (1341:9): [True: 0, False: 532k]
  ------------------
 1342|      0|      return rc;
 1343|      0|    }
 1344|   532k|  }
 1345|   532k|  int32_t chunksize = schunk->chunksize;
 1346|   532k|  if (!chunksize_after_adding(&schunk->chunksize, nchunks, last_nbytes, chunk_nbytes,
  ------------------
  |  Branch (1346:7): [True: 0, False: 532k]
  ------------------
 1347|   532k|                              nchunk == nchunks)) {
 1348|      0|    BLOSC_TRACE_ERROR("Inserting chunks that have different lengths in the same schunk "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1349|      0|                      "is not supported yet: %d > %d.", chunk_nbytes, chunksize);
 1350|      0|    return BLOSC2_ERROR_CHUNK_INSERT;
 1351|      0|  }
 1352|       |
 1353|       |  /* Update counters */
 1354|   532k|  schunk->current_nchunk = nchunk;
 1355|   532k|  schunk->nchunks = nchunks + 1;
 1356|   532k|  schunk->nbytes += chunk_nbytes;
 1357|       |  // A frame codes special chunks in their offsets
 1358|   532k|  if (schunk->frame == NULL || !chunk_special_in_offset(chunk, chunk_cbytes)) {
  ------------------
  |  Branch (1358:7): [True: 0, False: 532k]
  |  Branch (1358:32): [True: 0, False: 532k]
  ------------------
 1359|      0|    schunk->cbytes += chunk_cbytes;
 1360|      0|  }
 1361|       |
 1362|   532k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1363|   532k|  bool private_copy = chunk_needs_private_copy(frame, how);
 1364|   532k|  if (private_copy) {
  ------------------
  |  Branch (1364:7): [True: 0, False: 532k]
  ------------------
 1365|       |    // Make a copy of the chunk
 1366|      0|    uint8_t *chunk_copy = malloc(chunk_cbytes);
 1367|      0|    memcpy(chunk_copy, chunk, chunk_cbytes);
 1368|      0|    chunk = chunk_copy;
 1369|      0|  }
 1370|       |
 1371|       |  // Update super-chunk or frame
 1372|   532k|  if (frame == NULL) {
  ------------------
  |  Branch (1372:7): [True: 0, False: 532k]
  ------------------
 1373|      0|    if (how == CHUNK_GIVEN && (chunk_cbytes < chunk_nbytes)) {
  ------------------
  |  Branch (1373:9): [True: 0, False: 0]
  |  Branch (1373:31): [True: 0, False: 0]
  ------------------
 1374|       |      // We still want to do a shrink of the chunk
 1375|      0|      chunk = realloc(chunk, chunk_cbytes);
 1376|      0|    }
 1377|       |
 1378|       |    // Make space for appending the copy of the chunk and do it
 1379|      0|    if ((nchunks + 1) * sizeof(void *) > schunk->data_len) {
  ------------------
  |  Branch (1379:9): [True: 0, False: 0]
  ------------------
 1380|       |      // Extend the data pointer by one memory page (4k)
 1381|      0|      schunk->data_len += 4096;  // must be a multiple of sizeof(void*)
 1382|      0|      schunk->data = realloc(schunk->data, schunk->data_len);
 1383|      0|    }
 1384|       |
 1385|       |    // Reorder the offsets and insert the new chunk
 1386|      0|    for (int64_t i = nchunks; i > nchunk; --i) {
  ------------------
  |  Branch (1386:31): [True: 0, False: 0]
  ------------------
 1387|      0|      schunk->data[i] = schunk->data[i-1];
 1388|      0|    }
 1389|      0|    schunk->data[nchunk] = chunk;
 1390|      0|  }
 1391|       |
 1392|   532k|  else {
 1393|   532k|    bool written = frame_insert_chunk(frame, nchunk, chunk, schunk) != NULL;
 1394|   532k|    frame_write_done(chunk, how, private_copy, written);
 1395|   532k|    if (!written) {
  ------------------
  |  Branch (1395:9): [True: 0, False: 532k]
  ------------------
 1396|      0|      BLOSC_TRACE_ERROR("Problems inserting a chunk in a frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1397|      0|      schunk->flags2 = old_flags2;
 1398|      0|      schunk->chunksize = old_chunksize;
 1399|      0|      schunk->current_nchunk = old_current_nchunk;
 1400|      0|      schunk->nchunks = nchunks;
 1401|      0|      schunk->nbytes = old_nbytes;
 1402|      0|      schunk->cbytes = old_cbytes;
 1403|      0|      return BLOSC2_ERROR_CHUNK_INSERT;
 1404|      0|    }
 1405|   532k|  }
 1406|   532k|  return schunk->nchunks;
 1407|   532k|}
schunk.c:schunk_update_chunk_locked:
 1558|   616k|                                          chunk_handover how) {
 1559|   616k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1560|   616k|  int rc = frame_lock(frame, true);
 1561|   616k|  if (rc < 0) {
  ------------------
  |  Branch (1561:7): [True: 0, False: 616k]
  ------------------
 1562|      0|    return rc;
 1563|      0|  }
 1564|   616k|  int64_t nchunks = schunk_update_chunk_unlocked(schunk, nchunk, chunk, how);
 1565|   616k|  frame_unlock(frame);
 1566|   616k|  return nchunks;
 1567|   616k|}
schunk.c:schunk_update_chunk_unlocked:
 1437|   616k|                                            chunk_handover how) {
 1438|   616k|  int rc = validate_nchunk(schunk, nchunk, false, "blosc2_schunk_update_chunk");
 1439|   616k|  if (rc < 0) {
  ------------------
  |  Branch (1439:7): [True: 20, False: 615k]
  ------------------
 1440|     20|    return rc;
 1441|     20|  }
 1442|       |
 1443|   615k|  uint8_t old_flags2 = schunk->flags2;
 1444|   615k|  int32_t old_chunksize = schunk->chunksize;
 1445|   615k|  int64_t old_current_nchunk = schunk->current_nchunk;
 1446|   615k|  int64_t old_nbytes = schunk->nbytes;
 1447|   615k|  int64_t old_cbytes = schunk->cbytes;
 1448|       |
 1449|   615k|  int32_t chunk_nbytes;
 1450|   615k|  int32_t chunk_cbytes;
 1451|       |
 1452|   615k|  rc = blosc2_cbuffer_sizes(chunk, &chunk_nbytes, &chunk_cbytes, NULL);
 1453|   615k|  if (rc < 0) {
  ------------------
  |  Branch (1453:7): [True: 0, False: 615k]
  ------------------
 1454|      0|    return rc;
 1455|      0|  }
 1456|   615k|  uint8_t flags2 = get_chunk_flags2(chunk, chunk_cbytes);
 1457|   615k|  bool chunk_vlblocks = (flags2 & BLOSC2_VL_BLOCKS) != 0;
 1458|   615k|  if (schunk->nchunks > 1 || (schunk->nchunks == 1 && nchunk != 0)) {
  ------------------
  |  Branch (1458:7): [True: 614k, False: 1.04k]
  |  Branch (1458:31): [True: 1.04k, False: 0]
  |  Branch (1458:55): [True: 0, False: 1.04k]
  ------------------
 1459|   614k|    int64_t ref_nchunk = (nchunk == 0) ? 1 : 0;
  ------------------
  |  Branch (1459:26): [True: 1.99k, False: 612k]
  ------------------
 1460|   614k|    uint8_t ref_flags2;
 1461|   614k|    rc = schunk_get_chunk_flags2(schunk, ref_nchunk, &ref_flags2);
 1462|   614k|    if (rc < 0) {
  ------------------
  |  Branch (1462:9): [True: 0, False: 614k]
  ------------------
 1463|      0|      return rc;
 1464|      0|    }
 1465|   614k|    if (((ref_flags2 & BLOSC2_VL_BLOCKS) != 0) != chunk_vlblocks) {
  ------------------
  |  Branch (1465:9): [True: 0, False: 614k]
  ------------------
 1466|      0|      BLOSC_TRACE_ERROR("schunks cannot mix regular chunks and VL-block chunks.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1467|      0|      return BLOSC2_ERROR_CHUNK_UPDATE;
 1468|      0|    }
 1469|   614k|  }
 1470|  1.04k|  else {
 1471|  1.04k|    schunk->flags2 = flags2;
 1472|  1.04k|  }
 1473|       |
 1474|   615k|  int32_t chunksize = schunk->chunksize;
 1475|   615k|  bool variable_chunksize = (chunksize == 0);
 1476|   615k|  if (chunksize == -1) {
  ------------------
  |  Branch (1476:7): [True: 0, False: 615k]
  ------------------
 1477|      0|    schunk->chunksize = chunk_nbytes;  // The super-chunk is initialized now
 1478|      0|    chunksize = schunk->chunksize;
 1479|      0|  }
 1480|       |
 1481|   615k|  if (!variable_chunksize && (chunk_nbytes > chunksize ||
  ------------------
  |  Branch (1481:7): [True: 615k, False: 0]
  |  Branch (1481:31): [True: 0, False: 615k]
  ------------------
 1482|   615k|      (nchunk != schunk->nchunks - 1 && chunk_nbytes != chunksize))) {
  ------------------
  |  Branch (1482:8): [True: 612k, False: 3.10k]
  |  Branch (1482:41): [True: 0, False: 612k]
  ------------------
 1483|      0|    variable_chunksize = true;
 1484|      0|    schunk->chunksize = 0;
 1485|      0|  }
 1486|   615k|  if (!variable_chunksize && chunksize > 0 && chunk_nbytes > chunksize) {
  ------------------
  |  Branch (1486:7): [True: 615k, False: 0]
  |  Branch (1486:30): [True: 615k, False: 0]
  |  Branch (1486:47): [True: 0, False: 615k]
  ------------------
 1487|      0|    BLOSC_TRACE_ERROR("Updating chunks having different lengths in the same schunk "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1488|      0|                      "is not supported yet: %d > %d.", chunk_nbytes, chunksize);
 1489|      0|    return BLOSC2_ERROR_CHUNK_UPDATE;
 1490|      0|  }
 1491|       |
 1492|       |  // Only the sizes of the old chunk are needed, so do not read all of it from disk
 1493|   615k|  int32_t chunk_nbytes_old;
 1494|   615k|  int32_t chunk_cbytes_old;
 1495|   615k|  rc = schunk_get_counted_sizes(schunk, nchunk, &chunk_nbytes_old, &chunk_cbytes_old);
 1496|   615k|  if (rc < 0) {
  ------------------
  |  Branch (1496:7): [True: 0, False: 615k]
  ------------------
 1497|      0|    BLOSC_TRACE_ERROR("%" PRId64 " chunk can not be obtained from schunk.", nchunk);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1498|      0|    return rc;
 1499|      0|  }
 1500|   615k|  schunk->current_nchunk = nchunk;
 1501|       |
 1502|   615k|  blosc2_frame_s* frame = (blosc2_frame_s*)(schunk->frame);
 1503|   615k|  bool private_copy = chunk_needs_private_copy(frame, how);
 1504|   615k|  if (private_copy) {
  ------------------
  |  Branch (1504:7): [True: 7.94k, False: 608k]
  ------------------
 1505|       |    // Make a copy of the chunk
 1506|  7.94k|    uint8_t *chunk_copy = malloc(chunk_cbytes);
 1507|  7.94k|    memcpy(chunk_copy, chunk, chunk_cbytes);
 1508|  7.94k|    chunk = chunk_copy;
 1509|  7.94k|  }
 1510|       |
 1511|   615k|  if (schunk->frame == NULL) {
  ------------------
  |  Branch (1511:7): [True: 0, False: 615k]
  ------------------
 1512|       |    /* Update counters */
 1513|      0|    schunk->nbytes += chunk_nbytes;
 1514|      0|    schunk->nbytes -= chunk_nbytes_old;
 1515|      0|    schunk->cbytes += chunk_cbytes;
 1516|      0|    schunk->cbytes -= chunk_cbytes_old;
 1517|   615k|  } else {
 1518|       |    // A frame codes special chunks in their offsets
 1519|   615k|    schunk->nbytes += chunk_nbytes;
 1520|   615k|    schunk->nbytes -= chunk_nbytes_old;
 1521|   615k|    if (!chunk_special_in_offset(chunk, chunk_cbytes)) {
  ------------------
  |  Branch (1521:9): [True: 508k, False: 107k]
  ------------------
 1522|   508k|      schunk->cbytes += chunk_cbytes;
 1523|   508k|    }
 1524|   615k|    schunk->cbytes -= chunk_cbytes_old;
 1525|   615k|  }
 1526|       |
 1527|       |  // Update super-chunk or frame
 1528|   615k|  if (schunk->frame == NULL) {
  ------------------
  |  Branch (1528:7): [True: 0, False: 615k]
  ------------------
 1529|      0|    if (how == CHUNK_GIVEN && (chunk_cbytes < chunk_nbytes)) {
  ------------------
  |  Branch (1529:9): [True: 0, False: 0]
  |  Branch (1529:31): [True: 0, False: 0]
  ------------------
 1530|       |      // We still want to do a shrink of the chunk
 1531|      0|      chunk = realloc(chunk, chunk_cbytes);
 1532|      0|    }
 1533|       |
 1534|       |    // Free old chunk and add reference to new chunk
 1535|      0|    if (schunk->data[nchunk] != 0) {
  ------------------
  |  Branch (1535:9): [True: 0, False: 0]
  ------------------
 1536|      0|      free(schunk->data[nchunk]);
 1537|      0|    }
 1538|      0|    schunk->data[nchunk] = chunk;
 1539|      0|  }
 1540|   615k|  else {
 1541|   615k|    bool written = frame_update_chunk(frame, nchunk, chunk, schunk, chunk_cbytes_old) != NULL;
 1542|   615k|    frame_write_done(chunk, how, private_copy, written);
 1543|   615k|    if (!written) {
  ------------------
  |  Branch (1543:9): [True: 0, False: 615k]
  ------------------
 1544|      0|      BLOSC_TRACE_ERROR("Problems updating a chunk in a frame.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1545|      0|      schunk->flags2 = old_flags2;
 1546|      0|      schunk->chunksize = old_chunksize;
 1547|      0|      schunk->current_nchunk = old_current_nchunk;
 1548|      0|      schunk->nbytes = old_nbytes;
 1549|      0|      schunk->cbytes = old_cbytes;
 1550|      0|      return BLOSC2_ERROR_CHUNK_UPDATE;
 1551|      0|    }
 1552|   615k|  }
 1553|       |
 1554|   615k|  return schunk->nchunks;
 1555|   615k|}
schunk.c:schunk_get_counted_sizes:
 1126|   615k|                                    int32_t *chunk_cbytes) {
 1127|   615k|  *chunk_nbytes = 0;
 1128|   615k|  *chunk_cbytes = 0;
 1129|   615k|  uint8_t header[BLOSC_EXTENDED_HEADER_LENGTH];
 1130|   615k|  const uint8_t *chunk;
 1131|   615k|  int rc = schunk_get_chunk_header(schunk, nchunk, header, &chunk);
 1132|   615k|  if (rc < 0 || chunk == NULL) {
  ------------------
  |  Branch (1132:7): [True: 0, False: 615k]
  |  Branch (1132:17): [True: 0, False: 615k]
  ------------------
 1133|      0|    return rc;
 1134|      0|  }
 1135|   615k|  rc = blosc2_cbuffer_sizes(chunk, chunk_nbytes, chunk_cbytes, NULL);
 1136|   615k|  if (rc < 0) {
  ------------------
  |  Branch (1136:7): [True: 0, False: 615k]
  ------------------
 1137|      0|    return rc;
 1138|      0|  }
 1139|   615k|  if (*chunk_cbytes == BLOSC2_MAX_OVERHEAD) {
  ------------------
  |  Branch (1139:7): [True: 598k, False: 17.4k]
  ------------------
 1140|   598k|    *chunk_cbytes = 0;
 1141|   598k|  }
 1142|   615k|  return BLOSC2_ERROR_SUCCESS;
 1143|   615k|}
schunk.c:schunk_compress_store:
 1673|      8|                                     int32_t nbytes, chunk_write_op op, const char *func_name) {
 1674|      8|  if (nbytes < 0 || nbytes > BLOSC2_MAX_BUFFERSIZE) {
  ------------------
  |  Branch (1674:7): [True: 0, False: 8]
  |  Branch (1674:21): [True: 0, False: 8]
  ------------------
 1675|      0|    BLOSC_TRACE_ERROR("nbytes ('%d') is out of range [0, %d] in %s.", nbytes,
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1676|      0|                      BLOSC2_MAX_BUFFERSIZE, func_name);
 1677|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 1678|      0|  }
 1679|       |  // `nchunk` is left to the store below, which checks it under the frame lock (inserts and
 1680|       |  // appends after refreshing a handle that another one made stale).
 1681|      8|  bool in_frame = schunk->frame != NULL;
 1682|      8|  int32_t dest_nbytes = nbytes + BLOSC2_MAX_OVERHEAD;
 1683|      8|  size_t capacity;
 1684|      8|  uint8_t *chunk = blosc2_tmp_malloc((size_t)dest_nbytes, &capacity);
 1685|      8|  BLOSC_ERROR_NULL(chunk, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|      8|    do {                                            \
  |  |  105|      8|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 8]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|      8|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8]
  |  |  ------------------
  ------------------
 1686|       |  // Prefilters read the number of the chunk being compressed
 1687|      8|  int64_t old_current_nchunk = schunk->current_nchunk;
 1688|      8|  schunk->current_nchunk = nchunk;
 1689|      8|  int cbytes = blosc2_compress_ctx(schunk->cctx, src, nbytes, chunk, dest_nbytes);
 1690|      8|  if (cbytes <= 0) {
  ------------------
  |  Branch (1690:7): [True: 0, False: 8]
  ------------------
 1691|      0|    blosc2_tmp_free(chunk, capacity);
 1692|      0|    schunk->current_nchunk = old_current_nchunk;
 1693|      0|    BLOSC_TRACE_ERROR("Cannot compress the buffer in %s.", func_name);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1694|      0|    return cbytes < 0 ? cbytes : BLOSC2_ERROR_WRITE_BUFFER;
  ------------------
  |  Branch (1694:12): [True: 0, False: 0]
  ------------------
 1695|      0|  }
 1696|      8|  bool lend = in_frame || (cbytes < nbytes / 2);
  ------------------
  |  Branch (1696:15): [True: 8, False: 0]
  |  Branch (1696:27): [True: 0, False: 0]
  ------------------
 1697|      8|  chunk_handover how = lend ? CHUNK_LENT : CHUNK_GIVEN;
  ------------------
  |  Branch (1697:24): [True: 8, False: 0]
  ------------------
 1698|      8|  int64_t nchunks;
 1699|      8|  switch (op) {
 1700|      8|    case WRITE_APPEND:
  ------------------
  |  Branch (1700:5): [True: 8, False: 0]
  ------------------
 1701|      8|      nchunks = schunk_append_chunk_locked(schunk, chunk, how);
 1702|      8|      break;
 1703|      0|    case WRITE_INSERT:
  ------------------
  |  Branch (1703:5): [True: 0, False: 8]
  ------------------
 1704|      0|      nchunks = schunk_insert_chunk_locked(schunk, nchunk, chunk, how);
 1705|      0|      break;
 1706|      0|    default:
  ------------------
  |  Branch (1706:5): [True: 0, False: 8]
  ------------------
 1707|      0|      nchunks = schunk_update_chunk_locked(schunk, nchunk, chunk, how);
 1708|      0|      break;
 1709|      8|  }
 1710|       |  // A lent buffer stays in the thread-local cache; a failed store leaves it to us
 1711|      8|  if (lend || nchunks < 0) {
  ------------------
  |  Branch (1711:7): [True: 8, False: 0]
  |  Branch (1711:15): [True: 0, False: 0]
  ------------------
 1712|      8|    blosc2_tmp_free(chunk, capacity);
 1713|      8|  }
 1714|      8|  if (nchunks < 0) {
  ------------------
  |  Branch (1714:7): [True: 0, False: 8]
  ------------------
 1715|      0|    schunk->current_nchunk = old_current_nchunk;
 1716|       |    BLOSC_TRACE_ERROR("Cannot store the compressed buffer in %s.", func_name);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1717|      0|  }
 1718|      8|  return nchunks;
 1719|      8|}
schunk.c:validate_nchunk:
   47|  1.69M|static int validate_nchunk(blosc2_schunk *schunk, int64_t nchunk, bool allow_end, const char *func_name) {
   48|  1.69M|  if (nchunk < 0) {
  ------------------
  |  Branch (48:7): [True: 0, False: 1.69M]
  ------------------
   49|      0|    BLOSC_TRACE_ERROR("nchunk ('%" PRId64 "') is negative in %s.", nchunk, func_name);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   50|      0|    return BLOSC2_ERROR_INVALID_PARAM;
   51|      0|  }
   52|       |
   53|  1.69M|  if (allow_end) {
  ------------------
  |  Branch (53:7): [True: 532k, False: 1.16M]
  ------------------
   54|   532k|    if (nchunk > schunk->nchunks) {
  ------------------
  |  Branch (54:9): [True: 0, False: 532k]
  ------------------
   55|      0|      BLOSC_TRACE_ERROR("nchunk ('%" PRId64 "') is out of range [0, %" PRId64 "] in %s.",
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|      0|                        nchunk, schunk->nchunks, func_name);
   57|      0|      return BLOSC2_ERROR_INVALID_PARAM;
   58|      0|    }
   59|   532k|  }
   60|  1.16M|  else {
   61|  1.16M|    if (nchunk >= schunk->nchunks) {
  ------------------
  |  Branch (61:9): [True: 536, False: 1.16M]
  ------------------
   62|    536|      BLOSC_TRACE_ERROR("nchunk ('%" PRId64 "') exceeds the number of chunks "
  ------------------
  |  |   93|    536|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    536|    do {                                            \
  |  |  |  |   98|    536|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    536|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 536, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    536|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   63|    536|                        "('%" PRId64 "') in %s.", nchunk, schunk->nchunks, func_name);
   64|    536|      return BLOSC2_ERROR_INVALID_PARAM;
   65|    536|    }
   66|  1.16M|  }
   67|       |
   68|  1.69M|  return BLOSC2_ERROR_SUCCESS;
   69|  1.69M|}

shuffle_avx2:
  718|  2.14M|             const uint8_t *_src, uint8_t *_dest) {
  719|  2.14M|  const int32_t vectorized_chunk_size = bytesoftype * (int32_t)sizeof(__m256i);
  720|       |
  721|       |  /* If the block size is too small to be vectorized,
  722|       |     use the generic implementation. */
  723|  2.14M|  if (blocksize < vectorized_chunk_size) {
  ------------------
  |  Branch (723:7): [True: 845k, False: 1.29M]
  ------------------
  724|   845k|    shuffle_generic(bytesoftype, blocksize, _src, _dest);
  725|   845k|    return;
  726|   845k|  }
  727|       |
  728|       |  /* If the blocksize is not a multiple of both the typesize and
  729|       |     the vector size, round the blocksize down to the next value
  730|       |     which is a multiple of both. The vectorized shuffle can be
  731|       |     used for that portion of the data, and the naive implementation
  732|       |     can be used for the remaining portion. */
  733|  1.29M|  const int32_t vectorizable_bytes = blocksize - (blocksize % vectorized_chunk_size);
  734|       |
  735|  1.29M|  const int32_t vectorizable_elements = vectorizable_bytes / bytesoftype;
  736|  1.29M|  const int32_t total_elements = blocksize / bytesoftype;
  737|       |
  738|       |  /* Optimized shuffle implementations */
  739|  1.29M|  switch (bytesoftype) {
  740|    393|    case 2:
  ------------------
  |  Branch (740:5): [True: 393, False: 1.29M]
  ------------------
  741|    393|      shuffle2_avx2(_dest, _src, vectorizable_elements, total_elements);
  742|    393|      break;
  743|    644|    case 4:
  ------------------
  |  Branch (743:5): [True: 644, False: 1.29M]
  ------------------
  744|    644|      shuffle4_avx2(_dest, _src, vectorizable_elements, total_elements);
  745|    644|      break;
  746|  1.29M|    case 8:
  ------------------
  |  Branch (746:5): [True: 1.29M, False: 1.35k]
  ------------------
  747|  1.29M|      shuffle8_avx2(_dest, _src, vectorizable_elements, total_elements);
  748|  1.29M|      break;
  749|      0|    case 16:
  ------------------
  |  Branch (749:5): [True: 0, False: 1.29M]
  ------------------
  750|      0|      shuffle16_avx2(_dest, _src, vectorizable_elements, total_elements);
  751|      0|      break;
  752|    653|    default:
  ------------------
  |  Branch (752:5): [True: 653, False: 1.29M]
  ------------------
  753|       |      /* For types larger than 16 bytes, use the AVX2 tiled shuffle. */
  754|    653|      if (bytesoftype > (int32_t)sizeof(__m128i)) {
  ------------------
  |  Branch (754:11): [True: 0, False: 653]
  ------------------
  755|      0|        shuffle16_tiled_avx2(_dest, _src, vectorizable_elements, total_elements, bytesoftype);
  756|      0|      }
  757|    653|      else {
  758|       |        /* Non-optimized shuffle */
  759|    653|        shuffle_generic(bytesoftype, blocksize, _src, _dest);
  760|       |        /* The non-optimized function covers the whole buffer,
  761|       |           so we're done processing here. */
  762|    653|        return;
  763|    653|      }
  764|  1.29M|  }
  765|       |
  766|       |  /* If the buffer had any bytes at the end which couldn't be handled
  767|       |     by the vectorized implementations, use the non-optimized version
  768|       |     to finish them up. */
  769|  1.29M|  if (vectorizable_bytes < blocksize) {
  ------------------
  |  Branch (769:7): [True: 1.01M, False: 282k]
  ------------------
  770|  1.01M|    shuffle_generic_inline(bytesoftype, vectorizable_bytes, blocksize, _src, _dest);
  771|  1.01M|  }
  772|  1.29M|}
unshuffle_avx2:
  777|  4.21M|               const uint8_t *_src, uint8_t *_dest) {
  778|  4.21M|  const int32_t vectorized_chunk_size = bytesoftype * (int32_t)sizeof(__m256i);
  779|       |
  780|       |  /* If the block size is too small to be vectorized,
  781|       |     use the generic implementation. */
  782|  4.21M|  if (blocksize < vectorized_chunk_size) {
  ------------------
  |  Branch (782:7): [True: 152k, False: 4.06M]
  ------------------
  783|   152k|    unshuffle_generic(bytesoftype, blocksize, _src, _dest);
  784|   152k|    return;
  785|   152k|  }
  786|       |
  787|       |  /* If the blocksize is not a multiple of both the typesize and
  788|       |     the vector size, round the blocksize down to the next value
  789|       |     which is a multiple of both. The vectorized unshuffle can be
  790|       |     used for that portion of the data, and the naive implementation
  791|       |     can be used for the remaining portion. */
  792|  4.06M|  const int32_t vectorizable_bytes = blocksize - (blocksize % vectorized_chunk_size);
  793|       |
  794|  4.06M|  const int32_t vectorizable_elements = vectorizable_bytes / bytesoftype;
  795|  4.06M|  const int32_t total_elements = blocksize / bytesoftype;
  796|       |
  797|       |  /* Optimized unshuffle implementations */
  798|  4.06M|  switch (bytesoftype) {
  799|    512|    case 2:
  ------------------
  |  Branch (799:5): [True: 512, False: 4.06M]
  ------------------
  800|    512|      unshuffle2_avx2(_dest, _src, vectorizable_elements, total_elements);
  801|    512|      break;
  802|    624|    case 4:
  ------------------
  |  Branch (802:5): [True: 624, False: 4.06M]
  ------------------
  803|    624|      unshuffle4_avx2(_dest, _src, vectorizable_elements, total_elements);
  804|    624|      break;
  805|  4.06M|    case 8:
  ------------------
  |  Branch (805:5): [True: 4.06M, False: 1.63k]
  ------------------
  806|  4.06M|      unshuffle8_avx2(_dest, _src, vectorizable_elements, total_elements);
  807|  4.06M|      break;
  808|     23|    case 12:
  ------------------
  |  Branch (808:5): [True: 23, False: 4.06M]
  ------------------
  809|     23|      unshuffle12_avx2(_dest, _src, vectorizable_elements, total_elements);
  810|     23|      break;
  811|     44|    case 16:
  ------------------
  |  Branch (811:5): [True: 44, False: 4.06M]
  ------------------
  812|     44|      unshuffle16_avx2(_dest, _src, vectorizable_elements, total_elements);
  813|     44|      break;
  814|    433|    default:
  ------------------
  |  Branch (814:5): [True: 433, False: 4.06M]
  ------------------
  815|       |      /* For types larger than 16 bytes, use the AVX2 tiled unshuffle. */
  816|    433|      if (bytesoftype > (int32_t)sizeof(__m128i)) {
  ------------------
  |  Branch (816:11): [True: 91, False: 342]
  ------------------
  817|     91|        unshuffle16_tiled_avx2(_dest, _src, vectorizable_elements, total_elements, bytesoftype);
  818|     91|      }
  819|    342|      else {
  820|       |        /* Non-optimized unshuffle */
  821|    342|        unshuffle_generic(bytesoftype, blocksize, _src, _dest);
  822|       |        /* The non-optimized function covers the whole buffer,
  823|       |           so we're done processing here. */
  824|    342|        return;
  825|    342|      }
  826|  4.06M|  }
  827|       |
  828|       |  /* If the buffer had any bytes at the end which couldn't be handled
  829|       |     by the vectorized implementations, use the non-optimized version
  830|       |     to finish them up. */
  831|  4.06M|  if (vectorizable_bytes < blocksize) {
  ------------------
  |  Branch (831:7): [True: 3.25M, False: 808k]
  ------------------
  832|  3.25M|    unshuffle_generic_inline(bytesoftype, vectorizable_bytes, blocksize, _src, _dest);
  833|  3.25M|  }
  834|  4.06M|}
shuffle-avx2.c:shuffle2_avx2:
   75|    393|              const int32_t vectorizable_elements, const int32_t total_elements) {
   76|    393|  static const int32_t bytesoftype = 2;
   77|    393|  int32_t j;
   78|    393|  const __m256i mask = _mm256_set1_epi16(0x00ff);
   79|       |
   80|  31.9k|  for (j = 0; j < vectorizable_elements; j += sizeof(__m256i)) {
  ------------------
  |  Branch (80:15): [True: 31.5k, False: 393]
  ------------------
   81|       |    /* Fetch 32 elements (64 bytes), pack low/high bytes, and fix cross-lane order. */
   82|  31.5k|    __m256i y0 = _mm256_loadu_si256((__m256i*)(src + (j * bytesoftype)));
   83|  31.5k|    __m256i y1 = _mm256_loadu_si256((__m256i*)(src + (j * bytesoftype) + sizeof(__m256i)));
   84|  31.5k|    __m256i lo = _mm256_permute4x64_epi64(
   85|  31.5k|        _mm256_packus_epi16(_mm256_and_si256(y0, mask), _mm256_and_si256(y1, mask)), 0xd8);
   86|  31.5k|    __m256i hi = _mm256_permute4x64_epi64(
   87|  31.5k|        _mm256_packus_epi16(_mm256_srli_epi16(y0, 8), _mm256_srli_epi16(y1, 8)), 0xd8);
   88|       |
   89|       |    /* Store the result vectors */
   90|  31.5k|    _mm256_storeu_si256((__m256i*)(dest + j), lo);
   91|  31.5k|    _mm256_storeu_si256((__m256i*)(dest + j + total_elements), hi);
   92|  31.5k|  }
   93|    393|}
shuffle-avx2.c:shuffle4_avx2:
   98|    644|              const int32_t vectorizable_elements, const int32_t total_elements) {
   99|    644|  static const int32_t bytesoftype = 4;
  100|    644|  int32_t i;
  101|    644|  int j;
  102|    644|  __m256i ymm0[4], ymm1[4];
  103|       |
  104|       |  /* Create the shuffle mask.
  105|       |     NOTE: The XMM/YMM 'set' intrinsics require the arguments to be ordered from
  106|       |     most to least significant (i.e., their order is reversed when compared to
  107|       |     loading the mask from an array). */
  108|    644|  const __m256i shmask = _mm256_set_epi8(
  109|    644|      0x0f, 0x0b, 0x07, 0x03, 0x0e, 0x0a, 0x06, 0x02,
  110|    644|      0x0d, 0x09, 0x05, 0x01, 0x0c, 0x08, 0x04, 0x00,
  111|    644|      0x0f, 0x0b, 0x07, 0x03, 0x0e, 0x0a, 0x06, 0x02,
  112|    644|      0x0d, 0x09, 0x05, 0x01, 0x0c, 0x08, 0x04, 0x00);
  113|    644|  const __m256i mask = _mm256_set_epi32(
  114|    644|      0x07, 0x03, 0x06, 0x02, 0x05, 0x01, 0x04, 0x00);
  115|       |
  116|  16.8M|  for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (116:15): [True: 16.8M, False: 644]
  ------------------
  117|       |    /* Fetch 32 elements (128 bytes) then transpose bytes and words within 128-bit lanes. */
  118|  84.4M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (118:17): [True: 67.5M, False: 16.8M]
  ------------------
  119|  67.5M|      ymm0[j] = _mm256_shuffle_epi8(
  120|  67.5M|          _mm256_loadu_si256((__m256i*)(src + (i * bytesoftype) + (j * sizeof(__m256i)))),
  121|  67.5M|          shmask);
  122|  67.5M|    }
  123|       |    /* Transpose double words */
  124|  50.6M|    for (j = 0; j < 2; j++) {
  ------------------
  |  Branch (124:17): [True: 33.7M, False: 16.8M]
  ------------------
  125|  33.7M|      ymm1[j * 2] = _mm256_unpacklo_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  126|  33.7M|      ymm1[j * 2 + 1] = _mm256_unpackhi_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  127|  33.7M|    }
  128|       |    /* Transpose quad words */
  129|  50.6M|    for (j = 0; j < 2; j++) {
  ------------------
  |  Branch (129:17): [True: 33.7M, False: 16.8M]
  ------------------
  130|  33.7M|      ymm0[j * 2] = _mm256_unpacklo_epi64(ymm1[j], ymm1[j + 2]);
  131|  33.7M|      ymm0[j * 2 + 1] = _mm256_unpackhi_epi64(ymm1[j], ymm1[j + 2]);
  132|  33.7M|    }
  133|  84.4M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (133:17): [True: 67.5M, False: 16.8M]
  ------------------
  134|  67.5M|      ymm0[j] = _mm256_permutevar8x32_epi32(ymm0[j], mask);
  135|  67.5M|    }
  136|       |    /* Store the result vectors */
  137|  16.8M|    uint8_t* const dest_for_ith_element = dest + i;
  138|  84.4M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (138:17): [True: 67.5M, False: 16.8M]
  ------------------
  139|  67.5M|      _mm256_storeu_si256((__m256i*)(dest_for_ith_element + (j * total_elements)), ymm0[j]);
  140|  67.5M|    }
  141|  16.8M|  }
  142|    644|}
shuffle-avx2.c:shuffle8_avx2:
  147|  1.29M|              const int32_t vectorizable_elements, const int32_t total_elements) {
  148|  1.29M|  static const int32_t bytesoftype = 8;
  149|  1.29M|  int32_t j;
  150|  1.29M|  int k, l;
  151|  1.29M|  __m256i ymm0[8], ymm1[8];
  152|  1.29M|  const __m256i shmask_in = _mm256_set_epi8(
  153|  1.29M|      0x0f, 0x07, 0x0e, 0x06, 0x0d, 0x05, 0x0c, 0x04,
  154|  1.29M|      0x0b, 0x03, 0x0a, 0x02, 0x09, 0x01, 0x08, 0x00,
  155|  1.29M|      0x0f, 0x07, 0x0e, 0x06, 0x0d, 0x05, 0x0c, 0x04,
  156|  1.29M|      0x0b, 0x03, 0x0a, 0x02, 0x09, 0x01, 0x08, 0x00);
  157|  1.29M|  const __m256i shmask_out = _mm256_set_epi8(
  158|  1.29M|      0x0f, 0x0e, 0x07, 0x06, 0x0d, 0x0c, 0x05, 0x04,
  159|  1.29M|      0x0b, 0x0a, 0x03, 0x02, 0x09, 0x08, 0x01, 0x00,
  160|  1.29M|      0x0f, 0x0e, 0x07, 0x06, 0x0d, 0x0c, 0x05, 0x04,
  161|  1.29M|      0x0b, 0x0a, 0x03, 0x02, 0x09, 0x08, 0x01, 0x00);
  162|       |
  163|  42.8M|  for (j = 0; j < vectorizable_elements; j += sizeof(__m256i)) {
  ------------------
  |  Branch (163:15): [True: 41.5M, False: 1.29M]
  ------------------
  164|       |    /* Fetch 32 elements (256 bytes) then transpose bytes. */
  165|   373M|    for (k = 0; k < 8; k++) {
  ------------------
  |  Branch (165:17): [True: 332M, False: 41.5M]
  ------------------
  166|   332M|      ymm1[k] = _mm256_shuffle_epi8(
  167|   332M|          _mm256_loadu_si256((__m256i*)(src + (j * bytesoftype) + (k * sizeof(__m256i)))),
  168|   332M|          shmask_in);
  169|   332M|    }
  170|       |    /* Transpose words */
  171|   207M|    for (k = 0, l = 0; k < 4; k++, l += 2) {
  ------------------
  |  Branch (171:24): [True: 166M, False: 41.5M]
  ------------------
  172|   166M|      ymm0[k * 2] = _mm256_unpacklo_epi16(ymm1[l], ymm1[l + 1]);
  173|   166M|      ymm0[k * 2 + 1] = _mm256_unpackhi_epi16(ymm1[l], ymm1[l + 1]);
  174|   166M|    }
  175|       |    /* Transpose double words */
  176|   207M|    for (k = 0, l = 0; k < 4; k++, l++) {
  ------------------
  |  Branch (176:24): [True: 166M, False: 41.5M]
  ------------------
  177|   166M|      if (k == 2) l += 2;
  ------------------
  |  Branch (177:11): [True: 41.5M, False: 124M]
  ------------------
  178|   166M|      ymm1[k * 2] = _mm256_unpacklo_epi32(ymm0[l], ymm0[l + 2]);
  179|   166M|      ymm1[k * 2 + 1] = _mm256_unpackhi_epi32(ymm0[l], ymm0[l + 2]);
  180|   166M|    }
  181|       |    /* Transpose quad words */
  182|   207M|    for (k = 0; k < 4; k++) {
  ------------------
  |  Branch (182:17): [True: 166M, False: 41.5M]
  ------------------
  183|   166M|      ymm0[k * 2] = _mm256_unpacklo_epi64(ymm1[k], ymm1[k + 4]);
  184|   166M|      ymm0[k * 2 + 1] = _mm256_unpackhi_epi64(ymm1[k], ymm1[k + 4]);
  185|   166M|    }
  186|   373M|    for (k = 0; k < 8; k++) {
  ------------------
  |  Branch (186:17): [True: 331M, False: 41.5M]
  ------------------
  187|   331M|      ymm0[k] = _mm256_shuffle_epi8(
  188|   331M|          _mm256_permute4x64_epi64(ymm0[k], 0xD8), shmask_out);
  189|   331M|    }
  190|       |    /* Store the result vectors */
  191|  41.5M|    uint8_t* const dest_for_jth_element = dest + j;
  192|   369M|    for (k = 0; k < 8; k++) {
  ------------------
  |  Branch (192:17): [True: 328M, False: 41.5M]
  ------------------
  193|   328M|      _mm256_storeu_si256((__m256i*)(dest_for_jth_element + (k * total_elements)), ymm0[k]);
  194|   328M|    }
  195|  41.5M|  }
  196|  1.29M|}
shuffle-avx2.c:unshuffle2_avx2:
  331|    512|                const int32_t vectorizable_elements, const int32_t total_elements) {
  332|    512|  static const int32_t bytesoftype = 2;
  333|    512|  int32_t i;
  334|    512|  int j;
  335|    512|  __m256i ymm0[2], ymm1[2];
  336|       |
  337|   502k|  for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (337:15): [True: 501k, False: 512]
  ------------------
  338|       |    /* Load 32 elements (64 bytes) into 2 YMM registers. */
  339|   501k|    const uint8_t* const src_for_ith_element = src + i;
  340|  1.50M|    for (j = 0; j < 2; j++) {
  ------------------
  |  Branch (340:17): [True: 1.00M, False: 501k]
  ------------------
  341|  1.00M|      ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (j * total_elements)));
  342|  1.00M|    }
  343|       |    /* Shuffle bytes */
  344|  1.50M|    for (j = 0; j < 2; j++) {
  ------------------
  |  Branch (344:17): [True: 1.00M, False: 501k]
  ------------------
  345|  1.00M|      ymm0[j] = _mm256_permute4x64_epi64(ymm0[j], 0xd8);
  346|  1.00M|    }
  347|       |    /* Compute the low 64 bytes */
  348|   501k|    ymm1[0] = _mm256_unpacklo_epi8(ymm0[0], ymm0[1]);
  349|       |    /* Compute the hi 64 bytes */
  350|   501k|    ymm1[1] = _mm256_unpackhi_epi8(ymm0[0], ymm0[1]);
  351|       |    /* Store the result vectors in proper order */
  352|   501k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (0 * sizeof(__m256i))), ymm1[0]);
  353|   501k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (1 * sizeof(__m256i))), ymm1[1]);
  354|   501k|  }
  355|    512|}
shuffle-avx2.c:unshuffle4_avx2:
  360|    624|                const int32_t vectorizable_elements, const int32_t total_elements) {
  361|    624|  static const int32_t bytesoftype = 4;
  362|    624|  int32_t i;
  363|    624|  int j;
  364|    624|  __m256i ymm0[4], ymm1[4];
  365|       |
  366|  23.2M|  for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (366:15): [True: 23.2M, False: 624]
  ------------------
  367|       |    /* Load 32 elements (128 bytes) into 4 YMM registers. */
  368|  23.2M|    const uint8_t* const src_for_ith_element = src + i;
  369|   116M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (369:17): [True: 92.9M, False: 23.2M]
  ------------------
  370|  92.9M|      ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (j * total_elements)));
  371|  92.9M|    }
  372|       |    /* Shuffle bytes */
  373|  69.7M|    for (j = 0; j < 2; j++) {
  ------------------
  |  Branch (373:17): [True: 46.4M, False: 23.2M]
  ------------------
  374|       |      /* Compute the low 64 bytes */
  375|  46.4M|      ymm1[j] = _mm256_unpacklo_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  376|       |      /* Compute the hi 64 bytes */
  377|  46.4M|      ymm1[2 + j] = _mm256_unpackhi_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  378|  46.4M|    }
  379|       |    /* Shuffle 2-byte words */
  380|  69.7M|    for (j = 0; j < 2; j++) {
  ------------------
  |  Branch (380:17): [True: 46.4M, False: 23.2M]
  ------------------
  381|       |      /* Compute the low 64 bytes */
  382|  46.4M|      ymm0[j] = _mm256_unpacklo_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  383|       |      /* Compute the hi 64 bytes */
  384|  46.4M|      ymm0[2 + j] = _mm256_unpackhi_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  385|  46.4M|    }
  386|  23.2M|    ymm1[0] = _mm256_permute2x128_si256(ymm0[0], ymm0[2], 0x20);
  387|  23.2M|    ymm1[1] = _mm256_permute2x128_si256(ymm0[1], ymm0[3], 0x20);
  388|  23.2M|    ymm1[2] = _mm256_permute2x128_si256(ymm0[0], ymm0[2], 0x31);
  389|  23.2M|    ymm1[3] = _mm256_permute2x128_si256(ymm0[1], ymm0[3], 0x31);
  390|       |
  391|       |    /* Store the result vectors in proper order */
  392|   116M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (392:17): [True: 92.9M, False: 23.2M]
  ------------------
  393|  92.9M|      _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (j * sizeof(__m256i))), ymm1[j]);
  394|  92.9M|    }
  395|  23.2M|  }
  396|    624|}
shuffle-avx2.c:unshuffle8_avx2:
  401|  4.06M|                const int32_t vectorizable_elements, const int32_t total_elements) {
  402|  4.06M|  static const int32_t bytesoftype = 8;
  403|  4.06M|  int32_t i;
  404|  4.06M|  int j;
  405|  4.06M|  __m256i ymm0[8], ymm1[8];
  406|       |
  407|   138M|  for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (407:15): [True: 134M, False: 4.06M]
  ------------------
  408|       |    /* Fetch 32 elements (256 bytes) into 8 YMM registers. */
  409|   134M|    const uint8_t* const src_for_ith_element = src + i;
  410|  1.21G|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (410:17): [True: 1.07G, False: 134M]
  ------------------
  411|  1.07G|      ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (j * total_elements)));
  412|  1.07G|    }
  413|       |    /* Shuffle bytes */
  414|   672M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (414:17): [True: 537M, False: 134M]
  ------------------
  415|       |      /* Compute the low 32 bytes */
  416|   537M|      ymm1[j] = _mm256_unpacklo_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  417|       |      /* Compute the hi 32 bytes */
  418|   537M|      ymm1[4 + j] = _mm256_unpackhi_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  419|   537M|    }
  420|       |    /* Shuffle words */
  421|   672M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (421:17): [True: 537M, False: 134M]
  ------------------
  422|       |      /* Compute the low 32 bytes */
  423|   537M|      ymm0[j] = _mm256_unpacklo_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  424|       |      /* Compute the hi 32 bytes */
  425|   537M|      ymm0[4 + j] = _mm256_unpackhi_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  426|   537M|    }
  427|  1.21G|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (427:17): [True: 1.07G, False: 134M]
  ------------------
  428|  1.07G|      ymm0[j] = _mm256_permute4x64_epi64(ymm0[j], 0xd8);
  429|  1.07G|    }
  430|       |
  431|       |    /* Shuffle 4-byte dwords */
  432|   672M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (432:17): [True: 537M, False: 134M]
  ------------------
  433|       |      /* Compute the low 32 bytes */
  434|   537M|      ymm1[j] = _mm256_unpacklo_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  435|       |      /* Compute the hi 32 bytes */
  436|   537M|      ymm1[4 + j] = _mm256_unpackhi_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  437|   537M|    }
  438|       |
  439|       |    /* Store the result vectors in proper order */
  440|   134M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (0 * sizeof(__m256i))), ymm1[0]);
  441|   134M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (1 * sizeof(__m256i))), ymm1[2]);
  442|   134M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (2 * sizeof(__m256i))), ymm1[1]);
  443|   134M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (3 * sizeof(__m256i))), ymm1[3]);
  444|   134M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (4 * sizeof(__m256i))), ymm1[4]);
  445|   134M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (5 * sizeof(__m256i))), ymm1[6]);
  446|   134M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (6 * sizeof(__m256i))), ymm1[5]);
  447|   134M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (7 * sizeof(__m256i))), ymm1[7]);
  448|   134M|  }
  449|  4.06M|}
shuffle-avx2.c:unshuffle12_avx2:
  526|     23|    const int32_t vectorizable_elements, const int32_t total_elements) {
  527|     23|  static const int32_t bytesoftype = 12;
  528|     23|  int32_t i;
  529|     23|  int j;
  530|     23|  __m256i ymm0[16], ymm1[16];
  531|       |
  532|     23|  __m256i permute = _mm256_set_epi32(0,0,6,5,4,2,1,0);
  533|     23|  __m256i store_mask = _mm256_set_epi32(0x0, 0x0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
  534|     23|  int32_t jump = 2*bytesoftype;
  535|  8.49k|  for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (535:15): [True: 8.46k, False: 23]
  ------------------
  536|       |    /* Fetch 24 elements (384 bytes) into 12 YMM registers. */
  537|  8.46k|    const uint8_t* const src_for_ith_element = src + i;
  538|   110k|    for (j = 0; j < bytesoftype; j++) {
  ------------------
  |  Branch (538:17): [True: 101k, False: 8.46k]
  ------------------
  539|   101k|      ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (j * total_elements)));
  540|   101k|    }
  541|       |    /* Initialize the last 4 registers (128 bytes) to null */
  542|  42.3k|    for (j = bytesoftype; j < 16; j++) {
  ------------------
  |  Branch (542:27): [True: 33.8k, False: 8.46k]
  ------------------
  543|  33.8k|      ymm0[j] = _mm256_setzero_si256();
  544|  33.8k|    }
  545|       |
  546|       |    /* Shuffle bytes */
  547|  76.2k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (547:17): [True: 67.7k, False: 8.46k]
  ------------------
  548|       |      /* Compute the low 32 bytes */
  549|  67.7k|      ymm1[j] = _mm256_unpacklo_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  550|       |      /* Compute the hi 32 bytes */
  551|  67.7k|      ymm1[8 + j] = _mm256_unpackhi_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  552|  67.7k|    }
  553|       |    /* Shuffle 2-byte words */
  554|  76.2k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (554:17): [True: 67.7k, False: 8.46k]
  ------------------
  555|       |      /* Compute the low 32 bytes */
  556|  67.7k|      ymm0[j] = _mm256_unpacklo_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  557|       |      /* Compute the hi 32 bytes */
  558|  67.7k|      ymm0[8 + j] = _mm256_unpackhi_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  559|  67.7k|    }
  560|       |    /* Shuffle 4-byte dwords */
  561|  76.2k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (561:17): [True: 67.7k, False: 8.46k]
  ------------------
  562|       |      /* Compute the low 32 bytes */
  563|  67.7k|      ymm1[j] = _mm256_unpacklo_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  564|       |      /* Compute the hi 32 bytes */
  565|  67.7k|      ymm1[8 + j] = _mm256_unpackhi_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  566|  67.7k|    }
  567|       |
  568|       |    /* Shuffle 8-byte qwords */
  569|  76.2k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (569:17): [True: 67.7k, False: 8.46k]
  ------------------
  570|       |      /* Compute the low 32 bytes */
  571|  67.7k|      ymm0[j] = _mm256_unpacklo_epi64(ymm1[j * 2], ymm1[j * 2 + 1]);
  572|       |      /* Compute the hi 32 bytes */
  573|  67.7k|      ymm0[8 + j] = _mm256_unpackhi_epi64(ymm1[j * 2], ymm1[j * 2 + 1]);
  574|  67.7k|    }
  575|       |
  576|       |
  577|  76.2k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (577:17): [True: 67.7k, False: 8.46k]
  ------------------
  578|  67.7k|      ymm1[j] = _mm256_permute2x128_si256(ymm0[j], ymm0[j + 8], 0x20);
  579|  67.7k|      ymm1[j + 8] = _mm256_permute2x128_si256(ymm0[j], ymm0[j + 8], 0x31);
  580|  67.7k|      ymm1[j] = _mm256_permutevar8x32_epi32(ymm1[j], permute);
  581|  67.7k|      ymm1[j+8] = _mm256_permutevar8x32_epi32(ymm1[j+8], permute);
  582|       |
  583|       |
  584|  67.7k|    }
  585|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (0 * jump)), ymm1[0]);
  586|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (1 * jump)), ymm1[4]);
  587|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (2 * jump)), ymm1[2]);
  588|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (3 * jump)), ymm1[6]);
  589|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (4 * jump)), ymm1[1]);
  590|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (5 * jump)), ymm1[5]);
  591|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (6 * jump)), ymm1[3]);
  592|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (7 * jump)), ymm1[7]);
  593|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (8 * jump)), ymm1[8]);
  594|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (9 * jump)), ymm1[12]);
  595|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (10 * jump)), ymm1[10]);
  596|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (11 * jump)), ymm1[14]);
  597|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (12 * jump)), ymm1[9]);
  598|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (13 * jump)), ymm1[13]);
  599|  8.46k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (14 * jump)), ymm1[11]);
  600|  8.46k|    _mm256_maskstore_epi32((int *)(dest + (i * bytesoftype) + (15 * jump)), store_mask, ymm1[15]);
  601|  8.46k|  }
  602|     23|}
shuffle-avx2.c:unshuffle16_avx2:
  454|     44|                 const int32_t vectorizable_elements, const int32_t total_elements) {
  455|     44|  static const int32_t bytesoftype = 16;
  456|     44|  int32_t i;
  457|     44|  int j;
  458|     44|  __m256i ymm0[16], ymm1[16];
  459|       |
  460|   153k|  for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (460:15): [True: 153k, False: 44]
  ------------------
  461|       |    /* Fetch 32 elements (512 bytes) into 16 YMM registers. */
  462|   153k|    const uint8_t* const src_for_ith_element = src + i;
  463|  2.60M|    for (j = 0; j < 16; j++) {
  ------------------
  |  Branch (463:17): [True: 2.44M, False: 153k]
  ------------------
  464|  2.44M|      ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (j * total_elements)));
  465|  2.44M|    }
  466|       |
  467|       |    /* Shuffle bytes */
  468|  1.37M|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (468:17): [True: 1.22M, False: 153k]
  ------------------
  469|       |      /* Compute the low 32 bytes */
  470|  1.22M|      ymm1[j] = _mm256_unpacklo_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  471|       |      /* Compute the hi 32 bytes */
  472|  1.22M|      ymm1[8 + j] = _mm256_unpackhi_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  473|  1.22M|    }
  474|       |    /* Shuffle 2-byte words */
  475|  1.37M|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (475:17): [True: 1.22M, False: 153k]
  ------------------
  476|       |      /* Compute the low 32 bytes */
  477|  1.22M|      ymm0[j] = _mm256_unpacklo_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  478|       |      /* Compute the hi 32 bytes */
  479|  1.22M|      ymm0[8 + j] = _mm256_unpackhi_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  480|  1.22M|    }
  481|       |    /* Shuffle 4-byte dwords */
  482|  1.37M|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (482:17): [True: 1.22M, False: 153k]
  ------------------
  483|       |      /* Compute the low 32 bytes */
  484|  1.22M|      ymm1[j] = _mm256_unpacklo_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  485|       |      /* Compute the hi 32 bytes */
  486|  1.22M|      ymm1[8 + j] = _mm256_unpackhi_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  487|  1.22M|    }
  488|       |
  489|       |    /* Shuffle 8-byte qwords */
  490|  1.37M|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (490:17): [True: 1.22M, False: 153k]
  ------------------
  491|       |      /* Compute the low 32 bytes */
  492|  1.22M|      ymm0[j] = _mm256_unpacklo_epi64(ymm1[j * 2], ymm1[j * 2 + 1]);
  493|       |      /* Compute the hi 32 bytes */
  494|  1.22M|      ymm0[8 + j] = _mm256_unpackhi_epi64(ymm1[j * 2], ymm1[j * 2 + 1]);
  495|  1.22M|    }
  496|       |
  497|  1.37M|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (497:17): [True: 1.22M, False: 153k]
  ------------------
  498|  1.22M|      ymm1[j] = _mm256_permute2x128_si256(ymm0[j], ymm0[j + 8], 0x20);
  499|  1.22M|      ymm1[j + 8] = _mm256_permute2x128_si256(ymm0[j], ymm0[j + 8], 0x31);
  500|  1.22M|    }
  501|       |
  502|       |    /* Store the result vectors in proper order */
  503|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (0 * sizeof(__m256i))), ymm1[0]);
  504|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (1 * sizeof(__m256i))), ymm1[4]);
  505|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (2 * sizeof(__m256i))), ymm1[2]);
  506|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (3 * sizeof(__m256i))), ymm1[6]);
  507|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (4 * sizeof(__m256i))), ymm1[1]);
  508|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (5 * sizeof(__m256i))), ymm1[5]);
  509|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (6 * sizeof(__m256i))), ymm1[3]);
  510|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (7 * sizeof(__m256i))), ymm1[7]);
  511|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (8 * sizeof(__m256i))), ymm1[8]);
  512|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (9 * sizeof(__m256i))), ymm1[12]);
  513|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (10 * sizeof(__m256i))), ymm1[10]);
  514|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (11 * sizeof(__m256i))), ymm1[14]);
  515|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (12 * sizeof(__m256i))), ymm1[9]);
  516|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (13 * sizeof(__m256i))), ymm1[13]);
  517|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (14 * sizeof(__m256i))), ymm1[11]);
  518|   153k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (15 * sizeof(__m256i))), ymm1[15]);
  519|   153k|  }
  520|     44|}
shuffle-avx2.c:unshuffle16_tiled_avx2:
  606|     91|                       const int32_t vectorizable_elements, const int32_t total_elements, const int32_t bytesoftype) {
  607|     91|  int32_t i;
  608|     91|  int j;
  609|     91|  __m256i ymm0[16], ymm1[16];
  610|       |
  611|     91|  const lldiv_t vecs_per_el = lldiv(bytesoftype, sizeof(__m128i));
  612|     91|  const int32_t vecs_rem = (int32_t)vecs_per_el.rem;
  613|       |
  614|       |  /* The unshuffle loops are inverted (compared to shuffle_tiled16_avx2)
  615|       |     to optimize cache utilization. */
  616|     91|  int32_t offset_into_type;
  617|    851|  for (offset_into_type = 0; offset_into_type < bytesoftype;
  ------------------
  |  Branch (617:30): [True: 760, False: 91]
  ------------------
  618|    760|       offset_into_type += (offset_into_type == 0 && vecs_rem > 0 ? vecs_rem : (int32_t)sizeof(__m128i))) {
  ------------------
  |  Branch (618:29): [True: 91, False: 669]
  |  Branch (618:54): [True: 66, False: 25]
  ------------------
  619|  81.1k|    for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (619:17): [True: 80.4k, False: 760]
  ------------------
  620|       |      /* Load the first 16 bytes of 32 adjacent elements (512 bytes) into 16 YMM registers */
  621|  80.4k|      const uint8_t* const src_for_ith_element = src + i;
  622|  1.36M|      for (j = 0; j < 16; j++) {
  ------------------
  |  Branch (622:19): [True: 1.28M, False: 80.4k]
  ------------------
  623|  1.28M|        ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (total_elements * (offset_into_type + j))));
  624|  1.28M|      }
  625|       |
  626|       |      /* Shuffle bytes */
  627|   723k|      for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (627:19): [True: 643k, False: 80.4k]
  ------------------
  628|       |        /* Compute the low 32 bytes */
  629|   643k|        ymm1[j] = _mm256_unpacklo_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  630|       |        /* Compute the hi 32 bytes */
  631|   643k|        ymm1[8 + j] = _mm256_unpackhi_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  632|   643k|      }
  633|       |      /* Shuffle 2-byte words */
  634|   723k|      for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (634:19): [True: 643k, False: 80.4k]
  ------------------
  635|       |        /* Compute the low 32 bytes */
  636|   643k|        ymm0[j] = _mm256_unpacklo_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  637|       |        /* Compute the hi 32 bytes */
  638|   643k|        ymm0[8 + j] = _mm256_unpackhi_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  639|   643k|      }
  640|       |      /* Shuffle 4-byte dwords */
  641|   723k|      for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (641:19): [True: 643k, False: 80.4k]
  ------------------
  642|       |        /* Compute the low 32 bytes */
  643|   643k|        ymm1[j] = _mm256_unpacklo_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  644|       |        /* Compute the hi 32 bytes */
  645|   643k|        ymm1[8 + j] = _mm256_unpackhi_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  646|   643k|      }
  647|       |
  648|       |      /* Shuffle 8-byte qwords */
  649|   723k|      for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (649:19): [True: 643k, False: 80.4k]
  ------------------
  650|       |        /* Compute the low 32 bytes */
  651|   643k|        ymm0[j] = _mm256_unpacklo_epi64(ymm1[j * 2], ymm1[j * 2 + 1]);
  652|       |        /* Compute the hi 32 bytes */
  653|   643k|        ymm0[8 + j] = _mm256_unpackhi_epi64(ymm1[j * 2], ymm1[j * 2 + 1]);
  654|   643k|      }
  655|       |
  656|   723k|      for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (656:19): [True: 643k, False: 80.4k]
  ------------------
  657|   643k|        ymm1[j] = _mm256_permute2x128_si256(ymm0[j], ymm0[j + 8], 0x20);
  658|   643k|        ymm1[j + 8] = _mm256_permute2x128_si256(ymm0[j], ymm0[j + 8], 0x31);
  659|   643k|      }
  660|       |
  661|       |      /* Store the result vectors in proper order */
  662|  80.4k|      const uint8_t* const dest_with_offset = dest + offset_into_type;
  663|  80.4k|      _mm256_storeu2_m128i(
  664|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x01) * bytesoftype),
  665|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x00) * bytesoftype), ymm1[0]);
  666|  80.4k|      _mm256_storeu2_m128i(
  667|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x03) * bytesoftype),
  668|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x02) * bytesoftype), ymm1[4]);
  669|  80.4k|      _mm256_storeu2_m128i(
  670|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x05) * bytesoftype),
  671|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x04) * bytesoftype), ymm1[2]);
  672|  80.4k|      _mm256_storeu2_m128i(
  673|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x07) * bytesoftype),
  674|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x06) * bytesoftype), ymm1[6]);
  675|  80.4k|      _mm256_storeu2_m128i(
  676|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x09) * bytesoftype),
  677|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x08) * bytesoftype), ymm1[1]);
  678|  80.4k|      _mm256_storeu2_m128i(
  679|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x0b) * bytesoftype),
  680|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x0a) * bytesoftype), ymm1[5]);
  681|  80.4k|      _mm256_storeu2_m128i(
  682|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x0d) * bytesoftype),
  683|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x0c) * bytesoftype), ymm1[3]);
  684|  80.4k|      _mm256_storeu2_m128i(
  685|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x0f) * bytesoftype),
  686|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x0e) * bytesoftype), ymm1[7]);
  687|  80.4k|      _mm256_storeu2_m128i(
  688|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x11) * bytesoftype),
  689|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x10) * bytesoftype), ymm1[8]);
  690|  80.4k|      _mm256_storeu2_m128i(
  691|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x13) * bytesoftype),
  692|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x12) * bytesoftype), ymm1[12]);
  693|  80.4k|      _mm256_storeu2_m128i(
  694|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x15) * bytesoftype),
  695|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x14) * bytesoftype), ymm1[10]);
  696|  80.4k|      _mm256_storeu2_m128i(
  697|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x17) * bytesoftype),
  698|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x16) * bytesoftype), ymm1[14]);
  699|  80.4k|      _mm256_storeu2_m128i(
  700|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x19) * bytesoftype),
  701|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x18) * bytesoftype), ymm1[9]);
  702|  80.4k|      _mm256_storeu2_m128i(
  703|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x1b) * bytesoftype),
  704|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x1a) * bytesoftype), ymm1[13]);
  705|  80.4k|      _mm256_storeu2_m128i(
  706|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x1d) * bytesoftype),
  707|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x1c) * bytesoftype), ymm1[11]);
  708|  80.4k|      _mm256_storeu2_m128i(
  709|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x1f) * bytesoftype),
  710|  80.4k|          (__m128i*)(dest_with_offset + (i + 0x1e) * bytesoftype), ymm1[15]);
  711|  80.4k|    }
  712|    760|  }
  713|     91|}

shuffle_bytedelta_avx2_backward:
  537|    100|int shuffle_bytedelta_avx2_backward(const uint8_t *input, uint8_t *output, int32_t length, int typesize) {
  538|    100|  switch (typesize) {
  539|     40|    case 2: return backward2_avx2(input, output, length);
  ------------------
  |  Branch (539:5): [True: 40, False: 60]
  ------------------
  540|     13|    case 4: return backward4_avx2(input, output, length);
  ------------------
  |  Branch (540:5): [True: 13, False: 87]
  ------------------
  541|     47|    case 8: return backward8_avx2(input, output, length);
  ------------------
  |  Branch (541:5): [True: 47, False: 53]
  ------------------
  542|      0|    default: return 0;
  ------------------
  |  Branch (542:5): [True: 0, False: 100]
  ------------------
  543|    100|  }
  544|    100|}
shuffle-bytedelta-avx2.c:backward2_avx2:
  204|     40|static int backward2_avx2(const uint8_t *input, uint8_t *output, int32_t length) {
  205|     40|  int count = length / 2, vector_count = count / 32 * 32;
  206|       |  /* Shuffle mask broadcasting the 8th 16-bit record (bytes 14..15) in each 128-bit lane. */
  207|     40|  const __m256i mask_hi16 = _mm256_setr_epi8(
  208|     40|      14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15,
  209|     40|      14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 15);
  210|     40|  const __m128i mask_hi16_128 = _mm256_castsi256_si128(mask_hi16);
  211|     40|  __m128i carry128 = _mm_setzero_si128();
  212|  54.2k|  for (int i = 0; i < vector_count; i += 32) {
  ------------------
  |  Branch (212:19): [True: 54.2k, False: 40]
  ------------------
  213|       |    /* Load 32 delta bytes from each of the 2 byte planes. */
  214|  54.2k|    __m256i p0 = _mm256_loadu_si256((const __m256i *)(input + i));
  215|  54.2k|    __m256i p1 = _mm256_loadu_si256((const __m256i *)(input + count + i));
  216|       |
  217|       |    /* Interleave into 2-byte records: lo lanes hold 0..7 and 8..15, hi lanes 16..23 and 24..31. */
  218|  54.2k|    __m256i r0 = _mm256_unpacklo_epi8(p0, p1);
  219|  54.2k|    __m256i r1 = _mm256_unpackhi_epi8(p0, p1);
  220|       |
  221|       |    /* Kogge-Stone prefix sum across the 8 interleaved 2-byte records in each 128-bit lane. */
  222|  54.2k|    r0 = _mm256_add_epi8(r0, _mm256_slli_si256(r0, 2));
  223|  54.2k|    r1 = _mm256_add_epi8(r1, _mm256_slli_si256(r1, 2));
  224|  54.2k|    r0 = _mm256_add_epi8(r0, _mm256_slli_si256(r0, 4));
  225|  54.2k|    r1 = _mm256_add_epi8(r1, _mm256_slli_si256(r1, 4));
  226|  54.2k|    r0 = _mm256_add_epi8(r0, _mm256_slli_si256(r0, 8));
  227|  54.2k|    r1 = _mm256_add_epi8(r1, _mm256_slli_si256(r1, 8));
  228|       |
  229|       |    /* Propagate each 8-record half-lane total from r0 into r1. */
  230|  54.2k|    r1 = _mm256_add_epi8(r1, _mm256_shuffle_epi8(r0, mask_hi16));
  231|       |
  232|       |    /* Build per-lane tile carry [carry, carry + sum_lo] and advance running carry128. */
  233|  54.2k|    __m128i sum_lo = _mm_shuffle_epi8(_mm256_castsi256_si128(r1), mask_hi16_128);
  234|  54.2k|    __m128i sum_hi = _mm_shuffle_epi8(_mm256_extracti128_si256(r1, 1), mask_hi16_128);
  235|  54.2k|    __m128i carry_hi = _mm_add_epi8(carry128, sum_lo);
  236|  54.2k|    __m256i tile_carry = _mm256_inserti128_si256(_mm256_castsi128_si256(carry128), carry_hi, 1);
  237|  54.2k|    carry128 = _mm_add_epi8(carry128, _mm_add_epi8(sum_lo, sum_hi));
  238|       |
  239|       |    /* Apply incoming cross-tile and cross-lane carry to all 32 records. */
  240|  54.2k|    r0 = _mm256_add_epi8(r0, tile_carry);
  241|  54.2k|    r1 = _mm256_add_epi8(r1, tile_carry);
  242|       |
  243|       |    /* Reorder lanes into two contiguous 32-byte stores (records 0..15, then 16..31). */
  244|  54.2k|    uint8_t *dst = output + i * 2;
  245|  54.2k|    _mm256_storeu_si256((__m256i *)dst, _mm256_permute2x128_si256(r0, r1, 0x20));
  246|  54.2k|    _mm256_storeu_si256((__m256i *)(dst + 32), _mm256_permute2x128_si256(r0, r1, 0x31));
  247|  54.2k|  }
  248|       |  /* Scalar tail for remaining <32 records and any incomplete trailing bytes. */
  249|     40|  uint8_t tail_carry[16];
  250|     40|  _mm_storeu_si128((__m128i *)tail_carry, carry128);
  251|    120|  for (int p = 0; p < 2; p++) {
  ------------------
  |  Branch (251:19): [True: 80, False: 40]
  ------------------
  252|     80|    uint8_t carry = tail_carry[p];
  253|  1.32k|    for (int i = vector_count; i < count; i++) {
  ------------------
  |  Branch (253:32): [True: 1.24k, False: 80]
  ------------------
  254|  1.24k|      carry = (uint8_t)(carry + input[p * count + i]);
  255|  1.24k|      output[i * 2 + p] = carry;
  256|  1.24k|    }
  257|     80|  }
  258|     40|  memcpy(output + count * 2, input + count * 2, (size_t)(length % 2));
  259|     40|  return 1;
  260|     40|}
shuffle-bytedelta-avx2.c:backward4_avx2:
  262|     13|static int backward4_avx2(const uint8_t *input, uint8_t *output, int32_t length) {
  263|     13|  int count = length / 4, vector_count = count / 32 * 32;
  264|     13|  __m128i carry128 = _mm_setzero_si128();
  265|  10.9k|  for (int i = 0; i < vector_count; i += 32) {
  ------------------
  |  Branch (265:19): [True: 10.9k, False: 13]
  ------------------
  266|       |    /* Load 32 delta bytes from each of the 4 byte planes. */
  267|  10.9k|    __m256i p0 = _mm256_loadu_si256((const __m256i *)(input + 0 * count + i));
  268|  10.9k|    __m256i p1 = _mm256_loadu_si256((const __m256i *)(input + 1 * count + i));
  269|  10.9k|    __m256i p2 = _mm256_loadu_si256((const __m256i *)(input + 2 * count + i));
  270|  10.9k|    __m256i p3 = _mm256_loadu_si256((const __m256i *)(input + 3 * count + i));
  271|       |
  272|       |    /* Stage 1 & 2 in-lane transpose: interleave 4 planes into 4-byte records in r0..r3. */
  273|  10.9k|    __m256i a0 = _mm256_unpacklo_epi8(p0, p1);
  274|  10.9k|    __m256i a1 = _mm256_unpackhi_epi8(p0, p1);
  275|  10.9k|    __m256i a2 = _mm256_unpacklo_epi8(p2, p3);
  276|  10.9k|    __m256i a3 = _mm256_unpackhi_epi8(p2, p3);
  277|       |
  278|  10.9k|    __m256i r0 = _mm256_unpacklo_epi16(a0, a2);
  279|  10.9k|    __m256i r1 = _mm256_unpackhi_epi16(a0, a2);
  280|  10.9k|    __m256i r2 = _mm256_unpacklo_epi16(a1, a3);
  281|  10.9k|    __m256i r3 = _mm256_unpackhi_epi16(a1, a3);
  282|       |
  283|       |    /* Prefix sum across the 4 interleaved 4-byte records within each 128-bit lane. */
  284|  10.9k|    r0 = _mm256_add_epi8(r0, _mm256_slli_si256(r0, 4));
  285|  10.9k|    r1 = _mm256_add_epi8(r1, _mm256_slli_si256(r1, 4));
  286|  10.9k|    r2 = _mm256_add_epi8(r2, _mm256_slli_si256(r2, 4));
  287|  10.9k|    r3 = _mm256_add_epi8(r3, _mm256_slli_si256(r3, 4));
  288|       |
  289|  10.9k|    r0 = _mm256_add_epi8(r0, _mm256_slli_si256(r0, 8));
  290|  10.9k|    r1 = _mm256_add_epi8(r1, _mm256_slli_si256(r1, 8));
  291|  10.9k|    r2 = _mm256_add_epi8(r2, _mm256_slli_si256(r2, 8));
  292|  10.9k|    r3 = _mm256_add_epi8(r3, _mm256_slli_si256(r3, 8));
  293|       |
  294|       |    /* Tree-reduce quad totals across r0..r3 to get full 16-record local sums per lane. */
  295|  10.9k|    r1 = _mm256_add_epi8(r1, dup_hi32_256(r0));
  296|  10.9k|    r3 = _mm256_add_epi8(r3, dup_hi32_256(r2));
  297|  10.9k|    __m256i d1 = dup_hi32_256(r1);
  298|  10.9k|    __m256i r3_local = _mm256_add_epi8(r3, d1);
  299|       |
  300|       |    /* Build per-lane tile carry [carry, carry + sum_lo] and advance running carry128. */
  301|  10.9k|    __m128i sum_lo = _mm_shuffle_epi32(_mm256_castsi256_si128(r3_local), 0xff);
  302|  10.9k|    __m128i sum_hi = _mm_shuffle_epi32(_mm256_extracti128_si256(r3_local, 1), 0xff);
  303|  10.9k|    __m128i carry_hi = _mm_add_epi8(carry128, sum_lo);
  304|  10.9k|    __m256i tile_carry = _mm256_inserti128_si256(_mm256_castsi128_si256(carry128), carry_hi, 1);
  305|  10.9k|    carry128 = _mm_add_epi8(carry128, _mm_add_epi8(sum_lo, sum_hi));
  306|       |
  307|       |    /* Fold tile_carry with d1 for r2 and apply carries to all 4 vectors. */
  308|  10.9k|    __m256i d1c = _mm256_add_epi8(d1, tile_carry);
  309|  10.9k|    r0 = _mm256_add_epi8(r0, tile_carry);
  310|  10.9k|    r1 = _mm256_add_epi8(r1, tile_carry);
  311|  10.9k|    r2 = _mm256_add_epi8(r2, d1c);
  312|  10.9k|    r3 = _mm256_add_epi8(r3_local, tile_carry);
  313|       |
  314|       |    /* Reorder lanes into four contiguous 32-byte stores (records 0..31). */
  315|  10.9k|    uint8_t *dst = output + i * 4;
  316|  10.9k|    _mm256_storeu_si256((__m256i *)(dst + 0), _mm256_permute2x128_si256(r0, r1, 0x20));
  317|  10.9k|    _mm256_storeu_si256((__m256i *)(dst + 32), _mm256_permute2x128_si256(r2, r3, 0x20));
  318|  10.9k|    _mm256_storeu_si256((__m256i *)(dst + 64), _mm256_permute2x128_si256(r0, r1, 0x31));
  319|  10.9k|    _mm256_storeu_si256((__m256i *)(dst + 96), _mm256_permute2x128_si256(r2, r3, 0x31));
  320|  10.9k|  }
  321|       |  /* Scalar tail for remaining <32 records and any incomplete trailing bytes. */
  322|     13|  uint8_t tail_carry[16];
  323|     13|  _mm_storeu_si128((__m128i *)tail_carry, carry128);
  324|     65|  for (int p = 0; p < 4; p++) {
  ------------------
  |  Branch (324:19): [True: 52, False: 13]
  ------------------
  325|     52|    uint8_t carry = tail_carry[p];
  326|    328|    for (int i = vector_count; i < count; i++) {
  ------------------
  |  Branch (326:32): [True: 276, False: 52]
  ------------------
  327|    276|      carry = (uint8_t)(carry + input[p * count + i]);
  328|    276|      output[i * 4 + p] = carry;
  329|    276|    }
  330|     52|  }
  331|     13|  memcpy(output + count * 4, input + count * 4, (size_t)(length % 4));
  332|     13|  return 1;
  333|     13|}
shuffle-bytedelta-avx2.c:dup_hi32_256:
   95|  37.8k|static inline __m256i dup_hi32_256(__m256i v) {
   96|       |  /* Broadcast the top 32-bit record of each 128-bit lane across that lane. */
   97|       |  return _mm256_shuffle_epi32(v, 0xff);
   98|  37.8k|}
shuffle-bytedelta-avx2.c:backward8_avx2:
  335|     47|static int backward8_avx2(const uint8_t *input, uint8_t *output, int32_t length) {
  336|     47|  int count = length / 8, vector_count = count / 32 * 32;
  337|     47|  __m128i carry128 = _mm_setzero_si128();
  338|  3.05k|  for (int i = 0; i < vector_count; i += 32) {
  ------------------
  |  Branch (338:19): [True: 3.00k, False: 47]
  ------------------
  339|       |    /* Load 32 delta bytes from each of the 8 byte planes. */
  340|  3.00k|    __m256i p0 = _mm256_loadu_si256((const __m256i *)(input + 0 * count + i));
  341|  3.00k|    __m256i p1 = _mm256_loadu_si256((const __m256i *)(input + 1 * count + i));
  342|  3.00k|    __m256i p2 = _mm256_loadu_si256((const __m256i *)(input + 2 * count + i));
  343|  3.00k|    __m256i p3 = _mm256_loadu_si256((const __m256i *)(input + 3 * count + i));
  344|  3.00k|    __m256i p4 = _mm256_loadu_si256((const __m256i *)(input + 4 * count + i));
  345|  3.00k|    __m256i p5 = _mm256_loadu_si256((const __m256i *)(input + 5 * count + i));
  346|  3.00k|    __m256i p6 = _mm256_loadu_si256((const __m256i *)(input + 6 * count + i));
  347|  3.00k|    __m256i p7 = _mm256_loadu_si256((const __m256i *)(input + 7 * count + i));
  348|       |
  349|       |    /* Stage 1 (8-bit) transpose of low 4 planes; skip upper 4 planes when all zero. */
  350|  3.00k|    __m256i a0 = _mm256_unpacklo_epi8(p0, p1);
  351|  3.00k|    __m256i a1 = _mm256_unpackhi_epi8(p0, p1);
  352|  3.00k|    __m256i a2 = _mm256_unpacklo_epi8(p2, p3);
  353|  3.00k|    __m256i a3 = _mm256_unpackhi_epi8(p2, p3);
  354|       |
  355|  3.00k|    __m256i hi = _mm256_or_si256(_mm256_or_si256(p4, p5), _mm256_or_si256(p6, p7));
  356|  3.00k|    if (_mm256_testz_si256(hi, hi)) {
  ------------------
  |  Branch (356:9): [True: 1.62k, False: 1.38k]
  ------------------
  357|  1.62k|      __m256i b0 = _mm256_unpacklo_epi16(a0, a2);
  358|  1.62k|      __m256i b1 = _mm256_unpackhi_epi16(a0, a2);
  359|  1.62k|      __m256i b2 = _mm256_unpacklo_epi16(a1, a3);
  360|  1.62k|      __m256i b3 = _mm256_unpackhi_epi16(a1, a3);
  361|       |
  362|  1.62k|      b0 = _mm256_add_epi8(b0, _mm256_slli_si256(b0, 4));
  363|  1.62k|      b1 = _mm256_add_epi8(b1, _mm256_slli_si256(b1, 4));
  364|  1.62k|      b2 = _mm256_add_epi8(b2, _mm256_slli_si256(b2, 4));
  365|  1.62k|      b3 = _mm256_add_epi8(b3, _mm256_slli_si256(b3, 4));
  366|       |
  367|  1.62k|      b0 = _mm256_add_epi8(b0, _mm256_slli_si256(b0, 8));
  368|  1.62k|      b1 = _mm256_add_epi8(b1, _mm256_slli_si256(b1, 8));
  369|  1.62k|      b2 = _mm256_add_epi8(b2, _mm256_slli_si256(b2, 8));
  370|  1.62k|      b3 = _mm256_add_epi8(b3, _mm256_slli_si256(b3, 8));
  371|       |
  372|  1.62k|      b1 = _mm256_add_epi8(b1, dup_hi32_256(b0));
  373|  1.62k|      b3 = _mm256_add_epi8(b3, dup_hi32_256(b2));
  374|  1.62k|      __m256i d1 = dup_hi32_256(b1);
  375|  1.62k|      __m256i b3_local = _mm256_add_epi8(b3, d1);
  376|       |
  377|  1.62k|      __m128i carry_lo128 = _mm_shuffle_epi32(carry128, 0x00);
  378|  1.62k|      __m128i carry_hi128 = _mm_shuffle_epi32(carry128, 0x55);
  379|  1.62k|      __m128i sum_lo = _mm_shuffle_epi32(_mm256_castsi256_si128(b3_local), 0xff);
  380|  1.62k|      __m128i sum_hi = _mm_shuffle_epi32(_mm256_extracti128_si256(b3_local, 1), 0xff);
  381|  1.62k|      __m128i carry_mid = _mm_add_epi8(carry_lo128, sum_lo);
  382|  1.62k|      __m256i tile_carry_lo = _mm256_inserti128_si256(
  383|  1.62k|          _mm256_castsi128_si256(carry_lo128), carry_mid, 1);
  384|  1.62k|      carry_lo128 = _mm_add_epi8(carry_mid, sum_hi);
  385|  1.62k|      carry128 = _mm_unpacklo_epi32(carry_lo128, carry_hi128);
  386|       |
  387|  1.62k|      __m256i d1c = _mm256_add_epi8(d1, tile_carry_lo);
  388|  1.62k|      b0 = _mm256_add_epi8(b0, tile_carry_lo);
  389|  1.62k|      b1 = _mm256_add_epi8(b1, tile_carry_lo);
  390|  1.62k|      b2 = _mm256_add_epi8(b2, d1c);
  391|  1.62k|      b3 = _mm256_add_epi8(b3_local, tile_carry_lo);
  392|       |
  393|  1.62k|      __m256i carry_hi256 = _mm256_inserti128_si256(
  394|  1.62k|          _mm256_castsi128_si256(carry_hi128), carry_hi128, 1);
  395|  1.62k|      __m256i r0 = _mm256_unpacklo_epi32(b0, carry_hi256);
  396|  1.62k|      __m256i r1 = _mm256_unpackhi_epi32(b0, carry_hi256);
  397|  1.62k|      __m256i r2 = _mm256_unpacklo_epi32(b1, carry_hi256);
  398|  1.62k|      __m256i r3 = _mm256_unpackhi_epi32(b1, carry_hi256);
  399|  1.62k|      __m256i r4 = _mm256_unpacklo_epi32(b2, carry_hi256);
  400|  1.62k|      __m256i r5 = _mm256_unpackhi_epi32(b2, carry_hi256);
  401|  1.62k|      __m256i r6 = _mm256_unpacklo_epi32(b3, carry_hi256);
  402|  1.62k|      __m256i r7 = _mm256_unpackhi_epi32(b3, carry_hi256);
  403|       |
  404|  1.62k|      uint8_t *dst = output + i * 8;
  405|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 0), _mm256_castsi256_si128(r0));
  406|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 16), _mm256_castsi256_si128(r1));
  407|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 32), _mm256_castsi256_si128(r2));
  408|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 48), _mm256_castsi256_si128(r3));
  409|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 64), _mm256_castsi256_si128(r4));
  410|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 80), _mm256_castsi256_si128(r5));
  411|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 96), _mm256_castsi256_si128(r6));
  412|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 112), _mm256_castsi256_si128(r7));
  413|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 128), _mm256_extracti128_si256(r0, 1));
  414|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 144), _mm256_extracti128_si256(r1, 1));
  415|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 160), _mm256_extracti128_si256(r2, 1));
  416|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 176), _mm256_extracti128_si256(r3, 1));
  417|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 192), _mm256_extracti128_si256(r4, 1));
  418|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 208), _mm256_extracti128_si256(r5, 1));
  419|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 224), _mm256_extracti128_si256(r6, 1));
  420|  1.62k|      _mm_storeu_si128((__m128i *)(dst + 240), _mm256_extracti128_si256(r7, 1));
  421|  1.62k|      continue;
  422|  1.62k|    }
  423|       |
  424|  1.38k|    __m256i a4 = _mm256_unpacklo_epi8(p4, p5);
  425|  1.38k|    __m256i a5 = _mm256_unpackhi_epi8(p4, p5);
  426|  1.38k|    __m256i a6 = _mm256_unpacklo_epi8(p6, p7);
  427|  1.38k|    __m256i a7 = _mm256_unpackhi_epi8(p6, p7);
  428|       |
  429|  1.38k|    __m256i b0 = _mm256_unpacklo_epi16(a0, a2);
  430|  1.38k|    __m256i b1 = _mm256_unpackhi_epi16(a0, a2);
  431|  1.38k|    __m256i b2 = _mm256_unpacklo_epi16(a1, a3);
  432|  1.38k|    __m256i b3 = _mm256_unpackhi_epi16(a1, a3);
  433|  1.38k|    __m256i b4 = _mm256_unpacklo_epi16(a4, a6);
  434|  1.38k|    __m256i b5 = _mm256_unpackhi_epi16(a4, a6);
  435|  1.38k|    __m256i b6 = _mm256_unpacklo_epi16(a5, a7);
  436|  1.38k|    __m256i b7 = _mm256_unpackhi_epi16(a5, a7);
  437|       |
  438|  1.38k|    __m256i r0 = _mm256_unpacklo_epi32(b0, b4);
  439|  1.38k|    __m256i r1 = _mm256_unpackhi_epi32(b0, b4);
  440|  1.38k|    __m256i r2 = _mm256_unpacklo_epi32(b1, b5);
  441|  1.38k|    __m256i r3 = _mm256_unpackhi_epi32(b1, b5);
  442|  1.38k|    __m256i r4 = _mm256_unpacklo_epi32(b2, b6);
  443|  1.38k|    __m256i r5 = _mm256_unpackhi_epi32(b2, b6);
  444|  1.38k|    __m256i r6 = _mm256_unpacklo_epi32(b3, b7);
  445|  1.38k|    __m256i r7 = _mm256_unpackhi_epi32(b3, b7);
  446|       |
  447|       |    /* Prefix sum depth 1: combine adjacent pairs of 8-byte records within each 128-bit lane. */
  448|  1.38k|    r0 = _mm256_add_epi8(r0, _mm256_slli_si256(r0, 8));
  449|  1.38k|    r1 = _mm256_add_epi8(r1, _mm256_slli_si256(r1, 8));
  450|  1.38k|    r2 = _mm256_add_epi8(r2, _mm256_slli_si256(r2, 8));
  451|  1.38k|    r3 = _mm256_add_epi8(r3, _mm256_slli_si256(r3, 8));
  452|  1.38k|    r4 = _mm256_add_epi8(r4, _mm256_slli_si256(r4, 8));
  453|  1.38k|    r5 = _mm256_add_epi8(r5, _mm256_slli_si256(r5, 8));
  454|  1.38k|    r6 = _mm256_add_epi8(r6, _mm256_slli_si256(r6, 8));
  455|  1.38k|    r7 = _mm256_add_epi8(r7, _mm256_slli_si256(r7, 8));
  456|       |
  457|       |    /* Prefix sum depth 2: combine pairs into 4-record groups. */
  458|  1.38k|    r1 = _mm256_add_epi8(r1, dup_hi64_256(r0));
  459|  1.38k|    r3 = _mm256_add_epi8(r3, dup_hi64_256(r2));
  460|  1.38k|    r5 = _mm256_add_epi8(r5, dup_hi64_256(r4));
  461|  1.38k|    r7 = _mm256_add_epi8(r7, dup_hi64_256(r6));
  462|       |
  463|       |    /* Prefix sum depth 3: combine 4-record groups into 8-record halves. */
  464|  1.38k|    __m256i d1 = dup_hi64_256(r1);
  465|  1.38k|    __m256i d5 = dup_hi64_256(r5);
  466|  1.38k|    r2 = _mm256_add_epi8(r2, d1);
  467|  1.38k|    r3 = _mm256_add_epi8(r3, d1);
  468|  1.38k|    r6 = _mm256_add_epi8(r6, d5);
  469|  1.38k|    r7 = _mm256_add_epi8(r7, d5);
  470|       |
  471|       |    /* Prefix sum depth 4: compute 16-record local totals in r7_local before applying carries. */
  472|  1.38k|    __m256i d3 = dup_hi64_256(r3);
  473|  1.38k|    __m256i r7_local = _mm256_add_epi8(r7, d3);
  474|       |
  475|       |    /* Build per-lane tile carry [carry, carry + sum_lo] and advance running carry128. */
  476|  1.38k|    __m128i r7_lo = _mm256_castsi256_si128(r7_local);
  477|  1.38k|    __m128i r7_hi = _mm256_extracti128_si256(r7_local, 1);
  478|  1.38k|    __m128i sum_lo = _mm_unpackhi_epi64(r7_lo, r7_lo);
  479|  1.38k|    __m128i sum_hi = _mm_unpackhi_epi64(r7_hi, r7_hi);
  480|  1.38k|    __m128i carry_hi = _mm_add_epi8(carry128, sum_lo);
  481|  1.38k|    __m256i tile_carry = _mm256_inserti128_si256(_mm256_castsi128_si256(carry128), carry_hi, 1);
  482|  1.38k|    carry128 = _mm_add_epi8(carry128, _mm_add_epi8(sum_lo, sum_hi));
  483|       |
  484|       |    /* Fold tile_carry with d3 for r4..r6 to save vector adds, then finalize r0..r7. */
  485|  1.38k|    __m256i d3c = _mm256_add_epi8(d3, tile_carry);
  486|  1.38k|    r0 = _mm256_add_epi8(r0, tile_carry);
  487|  1.38k|    r1 = _mm256_add_epi8(r1, tile_carry);
  488|  1.38k|    r2 = _mm256_add_epi8(r2, tile_carry);
  489|  1.38k|    r3 = _mm256_add_epi8(r3, tile_carry);
  490|  1.38k|    r4 = _mm256_add_epi8(r4, d3c);
  491|  1.38k|    r5 = _mm256_add_epi8(r5, d3c);
  492|  1.38k|    r6 = _mm256_add_epi8(r6, d3c);
  493|  1.38k|    r7 = _mm256_add_epi8(r7_local, tile_carry);
  494|       |
  495|       |    /* Split-store low 128-bit lanes (records 0..15) and high lanes (16..31) without vperm2i128. */
  496|  1.38k|    uint8_t *dst = output + i * 8;
  497|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 0), _mm256_castsi256_si128(r0));
  498|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 16), _mm256_castsi256_si128(r1));
  499|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 32), _mm256_castsi256_si128(r2));
  500|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 48), _mm256_castsi256_si128(r3));
  501|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 64), _mm256_castsi256_si128(r4));
  502|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 80), _mm256_castsi256_si128(r5));
  503|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 96), _mm256_castsi256_si128(r6));
  504|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 112), _mm256_castsi256_si128(r7));
  505|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 128), _mm256_extracti128_si256(r0, 1));
  506|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 144), _mm256_extracti128_si256(r1, 1));
  507|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 160), _mm256_extracti128_si256(r2, 1));
  508|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 176), _mm256_extracti128_si256(r3, 1));
  509|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 192), _mm256_extracti128_si256(r4, 1));
  510|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 208), _mm256_extracti128_si256(r5, 1));
  511|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 224), _mm256_extracti128_si256(r6, 1));
  512|  1.38k|    _mm_storeu_si128((__m128i *)(dst + 240), _mm256_extracti128_si256(r7, 1));
  513|  1.38k|  }
  514|       |  /* Scalar tail for remaining <32 records and any incomplete trailing bytes. */
  515|     47|  uint8_t tail_carry[16];
  516|     47|  _mm_storeu_si128((__m128i *)tail_carry, carry128);
  517|    423|  for (int p = 0; p < 8; p++) {
  ------------------
  |  Branch (517:19): [True: 376, False: 47]
  ------------------
  518|    376|    uint8_t carry = tail_carry[p];
  519|  2.73k|    for (int i = vector_count; i < count; i++) {
  ------------------
  |  Branch (519:32): [True: 2.36k, False: 376]
  ------------------
  520|  2.36k|      carry = (uint8_t)(carry + input[p * count + i]);
  521|  2.36k|      output[i * 8 + p] = carry;
  522|  2.36k|    }
  523|    376|  }
  524|     47|  memcpy(output + count * 8, input + count * 8, (size_t)(length % 8));
  525|     47|  return 1;
  526|     47|}
shuffle-bytedelta-avx2.c:dup_hi64_256:
   90|  9.69k|static inline __m256i dup_hi64_256(__m256i v) {
   91|       |  /* Broadcast the upper 64-bit record of each 128-bit lane across that lane. */
   92|  9.69k|  return _mm256_unpackhi_epi64(v, v);
   93|  9.69k|}

shuffle_generic:
   15|   845k|                     const uint8_t *_src, uint8_t *_dest) {
   16|       |  /* Non-optimized shuffle */
   17|   845k|  shuffle_generic_inline(bytesoftype, 0, blocksize, _src, _dest);
   18|   845k|}
unshuffle_generic:
   22|   152k|                       const uint8_t *_src, uint8_t *_dest) {
   23|       |  /* Non-optimized unshuffle */
   24|   152k|  unshuffle_generic_inline(bytesoftype, 0, blocksize, _src, _dest);
   25|   152k|}

shuffle-generic.c:shuffle_generic_inline:
   36|   845k|                                   const uint8_t *_src, uint8_t *_dest) {
   37|   845k|  int32_t i, j;
   38|       |  /* Calculate the number of elements in the block. */
   39|   845k|  const int32_t neblock_quot = blocksize / type_size;
   40|   845k|  const int32_t neblock_rem = blocksize % type_size;
   41|   845k|  const int32_t vectorizable_elements = vectorizable_blocksize / type_size;
   42|       |
   43|       |
   44|       |  /* Non-optimized shuffle */
   45|  6.15M|  for (j = 0; j < type_size; j++) {
  ------------------
  |  Branch (45:15): [True: 5.30M, False: 845k]
  ------------------
   46|   130M|    for (i = vectorizable_elements; i < (int32_t)neblock_quot; i++) {
  ------------------
  |  Branch (46:37): [True: 125M, False: 5.30M]
  ------------------
   47|   125M|      _dest[j * neblock_quot + i] = _src[i * type_size + j];
   48|   125M|    }
   49|  5.30M|  }
   50|       |
   51|       |  /* Copy any leftover bytes in the block without shuffling them. */
   52|   845k|  memcpy(_dest + (blocksize - neblock_rem), _src + (blocksize - neblock_rem), neblock_rem);
   53|   845k|}
shuffle-generic.c:unshuffle_generic_inline:
   64|   152k|                                     const uint8_t *_src, uint8_t *_dest) {
   65|   152k|  int32_t i, j;
   66|       |
   67|       |  /* Calculate the number of elements in the block. */
   68|   152k|  const int32_t neblock_quot = blocksize / type_size;
   69|   152k|  const int32_t neblock_rem = blocksize % type_size;
   70|   152k|  const int32_t vectorizable_elements = vectorizable_blocksize / type_size;
   71|       |
   72|       |  /* Non-optimized unshuffle */
   73|  7.11M|  for (i = vectorizable_elements; i < (int32_t)neblock_quot; i++) {
  ------------------
  |  Branch (73:35): [True: 6.95M, False: 152k]
  ------------------
   74|  50.7M|    for (j = 0; j < type_size; j++) {
  ------------------
  |  Branch (74:17): [True: 43.7M, False: 6.95M]
  ------------------
   75|  43.7M|      _dest[i * type_size + j] = _src[j * neblock_quot + i];
   76|  43.7M|    }
   77|  6.95M|  }
   78|       |
   79|       |  /* Copy any leftover bytes in the block without unshuffling them. */
   80|   152k|  memcpy(_dest + (blocksize - neblock_rem), _src + (blocksize - neblock_rem), neblock_rem);
   81|   152k|}
shuffle-avx2.c:shuffle_generic_inline:
   36|  1.01M|                                   const uint8_t *_src, uint8_t *_dest) {
   37|  1.01M|  int32_t i, j;
   38|       |  /* Calculate the number of elements in the block. */
   39|  1.01M|  const int32_t neblock_quot = blocksize / type_size;
   40|  1.01M|  const int32_t neblock_rem = blocksize % type_size;
   41|  1.01M|  const int32_t vectorizable_elements = vectorizable_blocksize / type_size;
   42|       |
   43|       |
   44|       |  /* Non-optimized shuffle */
   45|  9.14M|  for (j = 0; j < type_size; j++) {
  ------------------
  |  Branch (45:15): [True: 8.13M, False: 1.01M]
  ------------------
   46|   126M|    for (i = vectorizable_elements; i < (int32_t)neblock_quot; i++) {
  ------------------
  |  Branch (46:37): [True: 118M, False: 8.13M]
  ------------------
   47|   118M|      _dest[j * neblock_quot + i] = _src[i * type_size + j];
   48|   118M|    }
   49|  8.13M|  }
   50|       |
   51|       |  /* Copy any leftover bytes in the block without shuffling them. */
   52|  1.01M|  memcpy(_dest + (blocksize - neblock_rem), _src + (blocksize - neblock_rem), neblock_rem);
   53|  1.01M|}
shuffle-avx2.c:unshuffle_generic_inline:
   64|  3.25M|                                     const uint8_t *_src, uint8_t *_dest) {
   65|  3.25M|  int32_t i, j;
   66|       |
   67|       |  /* Calculate the number of elements in the block. */
   68|  3.25M|  const int32_t neblock_quot = blocksize / type_size;
   69|  3.25M|  const int32_t neblock_rem = blocksize % type_size;
   70|  3.25M|  const int32_t vectorizable_elements = vectorizable_blocksize / type_size;
   71|       |
   72|       |  /* Non-optimized unshuffle */
   73|  49.7M|  for (i = vectorizable_elements; i < (int32_t)neblock_quot; i++) {
  ------------------
  |  Branch (73:35): [True: 46.4M, False: 3.25M]
  ------------------
   74|   418M|    for (j = 0; j < type_size; j++) {
  ------------------
  |  Branch (74:17): [True: 371M, False: 46.4M]
  ------------------
   75|   371M|      _dest[i * type_size + j] = _src[j * neblock_quot + i];
   76|   371M|    }
   77|  46.4M|  }
   78|       |
   79|       |  /* Copy any leftover bytes in the block without unshuffling them. */
   80|  3.25M|  memcpy(_dest + (blocksize - neblock_rem), _src + (blocksize - neblock_rem), neblock_rem);
   81|  3.25M|}

shuffle_bytedelta_available:
  443|    100|int shuffle_bytedelta_available(void) {
  444|    100|  init_shuffle_implementation();
  445|       |  return host_shuffle_bytedelta_forward != NULL;
  446|    100|}
blosc_cpu_has_avx2:
  448|  8.24M|int blosc_cpu_has_avx2(void) {
  449|  8.24M|  init_shuffle_implementation();
  450|  8.24M|  return host_has_avx2;
  451|  8.24M|}
shuffle_bytedelta_backward:
  462|    100|int shuffle_bytedelta_backward(const uint8_t *input, uint8_t *output, int32_t length, int typesize) {
  463|    100|  init_shuffle_implementation();
  464|    100|  if ((typesize != 2 && typesize != 4 && typesize != 8) || length < 0 || input == output ||
  ------------------
  |  Branch (464:8): [True: 60, False: 40]
  |  Branch (464:25): [True: 47, False: 13]
  |  Branch (464:42): [True: 0, False: 47]
  |  Branch (464:60): [True: 0, False: 100]
  |  Branch (464:74): [True: 0, False: 100]
  ------------------
  465|    100|      host_shuffle_bytedelta_backward == NULL) {
  ------------------
  |  Branch (465:7): [True: 0, False: 100]
  ------------------
  466|      0|    return 0;
  467|      0|  }
  468|    100|  return host_shuffle_bytedelta_backward(input, output, length, typesize);
  469|    100|}
blosc2_shuffle:
  475|  2.14M|               const void* src, void* dest) {
  476|       |  /* Initialize the shuffle implementation if necessary. */
  477|  2.14M|  init_shuffle_implementation();
  478|       |
  479|  2.14M|  if (typesize < 1 || typesize > 256 || blocksize < 0) {
  ------------------
  |  Branch (479:7): [True: 18.4E, False: 2.14M]
  |  Branch (479:23): [True: 4, False: 2.14M]
  |  Branch (479:41): [True: 2, False: 2.14M]
  ------------------
  480|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  481|      0|  }
  482|       |
  483|       |  /* Shuffling single bytes is the identity; the generic routine would copy them one by one. */
  484|  2.14M|  if (typesize == 1) {
  ------------------
  |  Branch (484:7): [True: 0, False: 2.14M]
  ------------------
  485|      0|    if (dest != src) {
  ------------------
  |  Branch (485:9): [True: 0, False: 0]
  ------------------
  486|      0|      memcpy(dest, src, (size_t)blocksize);
  487|      0|    }
  488|      0|    return blocksize;
  489|      0|  }
  490|       |
  491|       |  /* The implementation is initialized.
  492|       |     Dispatch to its shuffle routine. */
  493|  2.14M|  (host_implementation.shuffle)(typesize, blocksize, src, dest);
  494|       |
  495|  2.14M|  return blocksize;
  496|  2.14M|}
blosc2_unshuffle:
  502|  4.21M|                 const void* src, void* dest) {
  503|       |  /* Initialize the shuffle implementation if necessary. */
  504|  4.21M|  init_shuffle_implementation();
  505|       |
  506|  4.21M|  if (typesize < 1 || typesize > 256 || blocksize < 0) {
  ------------------
  |  Branch (506:7): [True: 0, False: 4.21M]
  |  Branch (506:23): [True: 0, False: 4.21M]
  |  Branch (506:41): [True: 0, False: 4.21M]
  ------------------
  507|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  508|      0|  }
  509|       |
  510|       |  /* Unshuffling single bytes is the identity (see blosc2_shuffle). */
  511|  4.21M|  if (typesize == 1) {
  ------------------
  |  Branch (511:7): [True: 0, False: 4.21M]
  ------------------
  512|      0|    if (dest != src) {
  ------------------
  |  Branch (512:9): [True: 0, False: 0]
  ------------------
  513|      0|      memcpy(dest, src, (size_t)blocksize);
  514|      0|    }
  515|      0|    return blocksize;
  516|      0|  }
  517|       |
  518|       |  /* The implementation is initialized.
  519|       |     Dispatch to it's unshuffle routine. */
  520|  4.21M|  (host_implementation.unshuffle)(typesize, blocksize, src, dest);
  521|       |
  522|  4.21M|  return blocksize;
  523|  4.21M|}
bitunshuffle:
  582|    587|                     const uint8_t format_version) {
  583|       |  /* Initialize the shuffle implementation if necessary. */
  584|    587|  init_shuffle_implementation();
  585|    587|  size_t size = blocksize / typesize;
  586|       |
  587|    587|  if (format_version == 2) {
  ------------------
  |  Branch (587:7): [True: 166, False: 421]
  ------------------
  588|       |    /* Starting from version 3, bitshuffle() works differently */
  589|    166|    if ((size % 8) == 0) {
  ------------------
  |  Branch (589:9): [True: 102, False: 64]
  ------------------
  590|       |      /* The number of elems is a multiple of 8 which is supported by
  591|       |         bitshuffle. */
  592|    102|      int ret = (int) run_bitshuffle(host_implementation.bitunshuffle,
  593|    102|                                     src, dest, size, typesize, tmp);
  594|    102|      if (ret < 0) {
  ------------------
  |  Branch (594:11): [True: 0, False: 102]
  ------------------
  595|       |        // Some error in bitshuffle (should not happen)
  596|      0|        BLOSC_TRACE_ERROR("the impossible happened: the bitunshuffle filter failed!");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  597|      0|        return ret;
  598|      0|      }
  599|       |      /* Copy the leftovers (the bytes that do not make up a whole element), as
  600|       |         Blosc1 does when it writes them after the shuffled part. */
  601|    102|      size_t offset = size * typesize;
  602|    102|      memcpy((uint8_t *) dest + offset, (const uint8_t *) src + offset, blocksize - offset);
  603|    102|    }
  604|     64|    else {
  605|     64|      memcpy(dest, src, blocksize);
  606|     64|    }
  607|    166|  }
  608|    421|  else {
  609|       |    /* bitshuffle only supports a number of bytes that is a multiple of 8. */
  610|    421|    size -= size % 8;
  611|    421|    int ret = (int) run_bitshuffle(host_implementation.bitunshuffle, src, dest, size, typesize, tmp);
  612|    421|    if (ret < 0) {
  ------------------
  |  Branch (612:9): [True: 0, False: 421]
  ------------------
  613|      0|      BLOSC_TRACE_ERROR("the impossible happened: the bitunshuffle filter failed!");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  614|      0|      return ret;
  615|      0|    }
  616|       |
  617|       |    /* Copy the leftovers */
  618|    421|    size_t offset = size * typesize;
  619|    421|    memcpy((uint8_t *) dest + offset, (const uint8_t *) src + offset, blocksize - offset);
  620|    421|  }
  621|       |
  622|    587|  return blocksize;
  623|    587|}
shuffle.c:init_shuffle_implementation:
  436|  14.6M|static void init_shuffle_implementation(void) {
  437|  14.6M|  pthread_once(&implementation_once, set_host_implementation);
  438|  14.6M|}
shuffle.c:set_host_implementation:
  392|      1|static void set_host_implementation(void) {
  393|      1|  host_implementation = get_shuffle_implementation();
  394|      1|#if defined(SHUFFLE_AVX512_ENABLED) || defined(SHUFFLE_AVX2_ENABLED) || defined(SHUFFLE_SSE2_ENABLED)
  395|      1|  blosc_cpu_features cpu_features = blosc_get_cpu_features();
  396|      1|  host_has_avx2 = (cpu_features & BLOSC_HAVE_AVX2) != 0;
  397|      1|#if defined(SHUFFLE_BYTEDELTA_AVX2_ENABLED)
  398|      1|  if (cpu_features & BLOSC_HAVE_AVX2) {
  ------------------
  |  Branch (398:7): [True: 1, False: 0]
  ------------------
  399|      1|    host_shuffle_bytedelta_forward = shuffle_bytedelta_avx2_forward;
  400|      1|    host_shuffle_bytedelta_backward = shuffle_bytedelta_avx2_backward;
  401|      1|  }
  402|      1|#endif
  403|      1|#if defined(SHUFFLE_BYTEDELTA_SSSE3_ENABLED)
  404|       |  /* SSSE3 needs only the legacy XMM state, not AVX/XSAVE or YMM support. */
  405|      1|  if (host_shuffle_bytedelta_forward == NULL && (cpu_features & BLOSC_HAVE_SSSE3)) {
  ------------------
  |  Branch (405:7): [True: 0, False: 1]
  |  Branch (405:49): [True: 0, False: 0]
  ------------------
  406|      0|    host_shuffle_bytedelta_forward = shuffle_bytedelta_ssse3_forward;
  407|      0|    host_shuffle_bytedelta_backward = shuffle_bytedelta_ssse3_backward;
  408|      0|  }
  409|      1|#endif
  410|       |#elif defined(SHUFFLE_BYTEDELTA_NEON_ENABLED) && (defined(__aarch64__) || defined(_M_ARM64))
  411|       |  host_shuffle_bytedelta_forward = shuffle_bytedelta_neon_forward;
  412|       |  host_shuffle_bytedelta_backward = shuffle_bytedelta_neon_backward;
  413|       |#endif
  414|      1|}
shuffle.c:get_shuffle_implementation:
  303|      1|static shuffle_implementation_t get_shuffle_implementation(void) {
  304|      1|#if defined(SHUFFLE_AVX512_ENABLED) || defined(SHUFFLE_AVX2_ENABLED) || defined(SHUFFLE_SSE2_ENABLED) || defined(SHUFFLE_NEON_ENABLED) || defined(SHUFFLE_ALTIVEC_ENABLED)
  305|      1|  blosc_cpu_features cpu_features = blosc_get_cpu_features();
  306|      1|#endif
  307|      1|#if defined(SHUFFLE_AVX512_ENABLED)
  308|      1|  if (cpu_features & BLOSC_HAVE_AVX512 && is_shuffle_avx2 && is_bshuf_AVX512) {
  ------------------
  |  Branch (308:7): [True: 0, False: 1]
  |  Branch (308:43): [True: 0, False: 0]
  |  Branch (308:62): [True: 0, False: 0]
  ------------------
  309|      0|    shuffle_implementation_t impl_avx512;
  310|      0|    impl_avx512.name = "avx512";
  311|      0|    impl_avx512.shuffle = (shuffle_func)shuffle_avx2;
  312|      0|    impl_avx512.unshuffle = (unshuffle_func)unshuffle_avx2;
  313|      0|    impl_avx512.bitshuffle = (bitshuffle_func) bshuf_trans_bit_elem_AVX512;
  314|      0|    impl_avx512.bitunshuffle = (bitunshuffle_func)bshuf_untrans_bit_elem_AVX512;
  315|      0|    return impl_avx512;
  316|      0|  }
  317|      1|#endif  /* defined(SHUFFLE_AVX512_ENABLED) */
  318|       |
  319|      1|#if defined(SHUFFLE_AVX2_ENABLED)
  320|      1|  if (cpu_features & BLOSC_HAVE_AVX2 && is_shuffle_avx2 && is_bshuf_AVX) {
  ------------------
  |  Branch (320:7): [True: 1, False: 0]
  |  Branch (320:41): [True: 1, False: 0]
  |  Branch (320:60): [True: 1, False: 0]
  ------------------
  321|      1|    shuffle_implementation_t impl_avx2;
  322|      1|    impl_avx2.name = "avx2";
  323|      1|    impl_avx2.shuffle = (shuffle_func)shuffle_avx2;
  324|      1|    impl_avx2.unshuffle = (unshuffle_func)unshuffle_avx2;
  325|      1|    impl_avx2.bitshuffle = (bitshuffle_func) bshuf_trans_bit_elem_AVX;
  326|      1|    impl_avx2.bitunshuffle = (bitunshuffle_func)bshuf_untrans_bit_elem_AVX;
  327|      1|    return impl_avx2;
  328|      1|  }
  329|      0|#endif  /* defined(SHUFFLE_AVX2_ENABLED) */
  330|       |
  331|      0|#if defined(SHUFFLE_SSE2_ENABLED)
  332|      0|  if (cpu_features & BLOSC_HAVE_SSE2 && is_shuffle_sse2 && is_bshuf_SSE) {
  ------------------
  |  Branch (332:7): [True: 0, False: 0]
  |  Branch (332:41): [True: 0, False: 0]
  |  Branch (332:60): [True: 0, False: 0]
  ------------------
  333|      0|    shuffle_implementation_t impl_sse2;
  334|      0|    impl_sse2.name = "sse2";
  335|      0|    impl_sse2.shuffle = (shuffle_func)shuffle_sse2;
  336|      0|    impl_sse2.unshuffle = (unshuffle_func)unshuffle_sse2;
  337|      0|    impl_sse2.bitshuffle = (bitshuffle_func)bshuf_trans_bit_elem_SSE;
  338|      0|    impl_sse2.bitunshuffle = (bitunshuffle_func) bshuf_untrans_bit_elem_SSE;
  339|      0|    return impl_sse2;
  340|      0|  }
  341|      0|#endif  /* defined(SHUFFLE_SSE2_ENABLED) */
  342|       |
  343|       |#if defined(SHUFFLE_NEON_ENABLED)
  344|       |  if (cpu_features & BLOSC_HAVE_NEON && is_shuffle_neon) {
  345|       |    shuffle_implementation_t impl_neon;
  346|       |    impl_neon.name = "neon";
  347|       |    impl_neon.shuffle = (shuffle_func)shuffle_neon;
  348|       |    impl_neon.unshuffle = (unshuffle_func)unshuffle_neon;
  349|       |#if defined(BITSHUFFLE_NEON_ENABLED)
  350|       |    impl_neon.bitshuffle = (bitshuffle_func)bshuf_trans_bit_elem_NEON;
  351|       |    impl_neon.bitunshuffle = (bitunshuffle_func)bshuf_untrans_bit_elem_NEON;
  352|       |#else
  353|       |    // The optimized bitshuffle transpose requires AArch64; ARMv7 stays scalar.
  354|       |    impl_neon.bitshuffle = (bitshuffle_func)bshuf_trans_bit_elem_scal;
  355|       |    impl_neon.bitunshuffle = (bitunshuffle_func)bshuf_untrans_bit_elem_scal;
  356|       |#endif
  357|       |    return impl_neon;
  358|       |  }
  359|       |#endif  /* defined(SHUFFLE_NEON_ENABLED) */
  360|       |
  361|       |#if defined(SHUFFLE_ALTIVEC_ENABLED)
  362|       |  if (cpu_features & BLOSC_HAVE_ALTIVEC && is_shuffle_altivec && is_bshuf_altivec) {
  363|       |    shuffle_implementation_t impl_altivec;
  364|       |    impl_altivec.name = "altivec";
  365|       |    impl_altivec.shuffle = (shuffle_func)shuffle_altivec;
  366|       |    impl_altivec.unshuffle = (unshuffle_func)unshuffle_altivec;
  367|       |    impl_altivec.bitshuffle = (bitshuffle_func)bshuf_trans_bit_elem_altivec;
  368|       |    impl_altivec.bitunshuffle = (bitunshuffle_func)bshuf_untrans_bit_elem_altivec;
  369|       |    return impl_altivec;
  370|       |  }
  371|       |#endif  /* defined(SHUFFLE_ALTIVEC_ENABLED) */
  372|       |
  373|       |  /* Processor doesn't support any of the hardware-accelerated implementations,
  374|       |     so use the generic implementation. */
  375|      0|  shuffle_implementation_t impl_generic;
  376|      0|  impl_generic.name = "generic";
  377|      0|  impl_generic.shuffle = (shuffle_func)shuffle_generic;
  378|      0|  impl_generic.unshuffle = (unshuffle_func)unshuffle_generic;
  379|      0|  impl_generic.bitshuffle = (bitshuffle_func)bshuf_trans_bit_elem_scal;
  380|      0|  impl_generic.bitunshuffle = (bitunshuffle_func)bshuf_untrans_bit_elem_scal;
  381|      0|  return impl_generic;
  382|      0|}
shuffle.c:blosc_get_cpu_features:
  107|      2|static blosc_cpu_features blosc_get_cpu_features(void) {
  108|      2|  blosc_cpu_features cpu_features = BLOSC_HAVE_NOTHING;
  109|      2|  if (__builtin_cpu_supports("sse2")) {
  ------------------
  |  Branch (109:7): [True: 2, False: 0]
  ------------------
  110|      2|    cpu_features |= BLOSC_HAVE_SSE2;
  111|      2|  }
  112|      2|  if (__builtin_cpu_supports("ssse3")) {
  ------------------
  |  Branch (112:7): [True: 2, False: 0]
  ------------------
  113|      2|    cpu_features |= BLOSC_HAVE_SSSE3;
  114|      2|  }
  115|      2|  if (__builtin_cpu_supports("avx2")) {
  ------------------
  |  Branch (115:7): [True: 2, False: 0]
  ------------------
  116|      2|    cpu_features |= BLOSC_HAVE_AVX2;
  117|      2|  }
  118|      2|  if (__builtin_cpu_supports("avx512f") && __builtin_cpu_supports("avx512bw")) {
  ------------------
  |  Branch (118:7): [True: 0, False: 2]
  |  Branch (118:44): [True: 0, False: 0]
  ------------------
  119|      0|    cpu_features |= BLOSC_HAVE_AVX512;
  120|      0|  }
  121|      2|  return cpu_features;
  122|      2|}
shuffle.c:run_bitshuffle:
  528|    523|                              const size_t size, const size_t typesize, void* tmp) {
  529|    523|  if (size == 0) {
  ------------------
  |  Branch (529:7): [True: 115, False: 408]
  ------------------
  530|    115|    return 0;  /* fewer than 8 elements: only leftovers */
  531|    115|  }
  532|    408|  void* scratch = (tmp != NULL) ? tmp : malloc(size * typesize);
  ------------------
  |  Branch (532:19): [True: 408, False: 0]
  ------------------
  533|    408|  if (scratch == NULL) {
  ------------------
  |  Branch (533:7): [True: 0, False: 408]
  ------------------
  534|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
  535|      0|  }
  536|    408|  int64_t ret = routine(src, dest, size, typesize, scratch);
  537|    408|  if (scratch != tmp) {
  ------------------
  |  Branch (537:7): [True: 0, False: 408]
  ------------------
  538|      0|    free(scratch);
  539|      0|  }
  540|    408|  return ret;
  541|    408|}

blosc_stune_next_blocksize:
   47|  3.83M|int blosc_stune_next_blocksize(blosc2_context *context) {
   48|  3.83M|  int32_t clevel = context->clevel;
   49|  3.83M|  int32_t typesize = context->typesize;
   50|  3.83M|  int32_t nbytes = context->sourcesize;
   51|  3.83M|  int32_t user_blocksize = context->blocksize;
   52|  3.83M|  int32_t blocksize = nbytes;
   53|       |
   54|       |  // Protection against very small buffers
   55|  3.83M|  if (nbytes < typesize) {
  ------------------
  |  Branch (55:7): [True: 4.23k, False: 3.82M]
  ------------------
   56|  4.23k|    context->blocksize = 1;
   57|  4.23k|    return BLOSC2_ERROR_SUCCESS;
   58|  4.23k|  }
   59|       |
   60|  3.82M|  int splitmode = split_block(context, typesize, blocksize);
   61|  3.82M|  if (user_blocksize) {
  ------------------
  |  Branch (61:7): [True: 3.82M, False: 0]
  ------------------
   62|  3.82M|    blocksize = user_blocksize;
   63|  3.82M|    goto last;
   64|  3.82M|  }
   65|       |
   66|      0|  if (nbytes >= L1) {
  ------------------
  |  |   19|      0|#define L1 (32 * 1024)
  ------------------
  |  Branch (66:7): [True: 0, False: 0]
  ------------------
   67|      0|    blocksize = L1;
  ------------------
  |  |   19|      0|#define L1 (32 * 1024)
  ------------------
   68|       |
   69|       |    /* For HCR codecs, increase the block sizes by a factor of 2 because they
   70|       |        are meant for compressing large blocks (i.e. they show a big overhead
   71|       |        when compressing small ones). */
   72|      0|    if (is_HCR(context)) {
  ------------------
  |  Branch (72:9): [True: 0, False: 0]
  ------------------
   73|      0|      blocksize *= 2;
   74|      0|    }
   75|       |
   76|       |    // Choose a different blocksize depending on the compression level
   77|      0|    switch (clevel) {
   78|      0|      case 0:
  ------------------
  |  Branch (78:7): [True: 0, False: 0]
  ------------------
   79|       |        // Case of plain copy
   80|      0|        blocksize /= 4;
   81|      0|        break;
   82|      0|      case 1:
  ------------------
  |  Branch (82:7): [True: 0, False: 0]
  ------------------
   83|      0|        blocksize /= 2;
   84|      0|        break;
   85|      0|      case 2:
  ------------------
  |  Branch (85:7): [True: 0, False: 0]
  ------------------
   86|      0|        blocksize *= 1;
   87|      0|        break;
   88|      0|      case 3:
  ------------------
  |  Branch (88:7): [True: 0, False: 0]
  ------------------
   89|      0|        blocksize *= 2;
   90|      0|        break;
   91|      0|      case 4:
  ------------------
  |  Branch (91:7): [True: 0, False: 0]
  ------------------
   92|      0|      case 5:
  ------------------
  |  Branch (92:7): [True: 0, False: 0]
  ------------------
   93|      0|        blocksize *= 4;
   94|      0|        break;
   95|      0|      case 6:
  ------------------
  |  Branch (95:7): [True: 0, False: 0]
  ------------------
   96|      0|      case 7:
  ------------------
  |  Branch (96:7): [True: 0, False: 0]
  ------------------
   97|      0|      case 8:
  ------------------
  |  Branch (97:7): [True: 0, False: 0]
  ------------------
   98|      0|        blocksize *= 8;
   99|      0|        break;
  100|      0|      case 9:
  ------------------
  |  Branch (100:7): [True: 0, False: 0]
  ------------------
  101|       |        // Do not exceed 256 KB for non HCR codecs
  102|      0|        blocksize *= 8;
  103|      0|        if (is_HCR(context)) {
  ------------------
  |  Branch (103:13): [True: 0, False: 0]
  ------------------
  104|      0|          blocksize *= 2;
  105|      0|        }
  106|      0|        break;
  107|      0|      default:
  ------------------
  |  Branch (107:7): [True: 0, False: 0]
  ------------------
  108|      0|        break;
  109|      0|    }
  110|      0|  }
  111|       |
  112|       |  /* Now the blocksize for splittable codecs */
  113|      0|  if (clevel > 0 && splitmode) {
  ------------------
  |  Branch (113:7): [True: 0, False: 0]
  |  Branch (113:21): [True: 0, False: 0]
  ------------------
  114|       |    // For performance reasons, do not exceed 256 KB (it must fit in L2 cache)
  115|      0|    switch (clevel) {
  116|      0|      case 1:
  ------------------
  |  Branch (116:7): [True: 0, False: 0]
  ------------------
  117|      0|      case 2:
  ------------------
  |  Branch (117:7): [True: 0, False: 0]
  ------------------
  118|      0|      case 3:
  ------------------
  |  Branch (118:7): [True: 0, False: 0]
  ------------------
  119|      0|        blocksize = 32 * 1024;
  120|      0|        break;
  121|      0|      case 4:
  ------------------
  |  Branch (121:7): [True: 0, False: 0]
  ------------------
  122|      0|      case 5:
  ------------------
  |  Branch (122:7): [True: 0, False: 0]
  ------------------
  123|      0|      case 6:
  ------------------
  |  Branch (123:7): [True: 0, False: 0]
  ------------------
  124|      0|        blocksize = 64 * 1024;
  125|      0|        break;
  126|      0|      case 7:
  ------------------
  |  Branch (126:7): [True: 0, False: 0]
  ------------------
  127|      0|        blocksize = 128 * 1024;
  128|      0|        break;
  129|      0|      case 8:
  ------------------
  |  Branch (129:7): [True: 0, False: 0]
  ------------------
  130|      0|        blocksize = 256 * 1024;
  131|      0|        break;
  132|      0|      case 9:
  ------------------
  |  Branch (132:7): [True: 0, False: 0]
  ------------------
  133|      0|      default:
  ------------------
  |  Branch (133:7): [True: 0, False: 0]
  ------------------
  134|      0|        blocksize = 512 * 1024;
  135|      0|        break;
  136|      0|    }
  137|       |    // Multiply by typesize to get proper split sizes
  138|      0|    blocksize *= typesize;
  139|       |    // But do not exceed 4 MB per thread (having this capacity in L3 is normal in modern CPUs)
  140|      0|    if (blocksize > 4 * 1024 * 1024) {
  ------------------
  |  Branch (140:9): [True: 0, False: 0]
  ------------------
  141|      0|      blocksize = 4 * 1024 * 1024;
  142|      0|    }
  143|      0|    if (blocksize < 32 * 1024) {
  ------------------
  |  Branch (143:9): [True: 0, False: 0]
  ------------------
  144|       |      /* Do not use a too small blocksize (< 32 KB) when typesize is small */
  145|      0|      blocksize = 32 * 1024;
  146|      0|    }
  147|      0|  }
  148|       |
  149|  3.82M|  last:
  150|       |  /* Check that blocksize is not too large */
  151|  3.82M|  if (blocksize > nbytes) {
  ------------------
  |  Branch (151:7): [True: 979k, False: 2.84M]
  ------------------
  152|   979k|    blocksize = nbytes;
  153|   979k|  }
  154|       |
  155|       |  // blocksize *must absolutely* be a multiple of the typesize
  156|  3.82M|  if (blocksize > typesize) {
  ------------------
  |  Branch (156:7): [True: 3.77M, False: 54.9k]
  ------------------
  157|  3.77M|    blocksize = blocksize / typesize * typesize;
  158|  3.77M|  }
  159|       |
  160|  3.82M|  context->blocksize = blocksize;
  161|  3.82M|  BLOSC_INFO("compcode: %d, clevel: %d, blocksize: %d, splitmode: %d, typesize: %d",
  ------------------
  |  |  121|  3.82M|    do {                                            \
  |  |  122|  3.82M|        const char *__e = getenv("BLOSC_INFO");     \
  |  |  123|  3.82M|        if (!__e) { break; }                        \
  |  |  ------------------
  |  |  |  Branch (123:13): [True: 3.82M, False: 0]
  |  |  ------------------
  |  |  124|  3.82M|        fprintf(stderr, "[INFO] - " msg "\n", ##__VA_ARGS__); \
  |  |  125|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  162|  3.82M|             context->compcode, context->clevel, blocksize, splitmode, typesize);
  163|       |
  164|  3.82M|  return BLOSC2_ERROR_SUCCESS;
  165|      0|}
split_block:
  190|  5.55M|int split_block(blosc2_context *context, int32_t typesize, int32_t blocksize) {
  191|  5.55M|  if (context->blosc1_format &&
  ------------------
  |  Branch (191:7): [True: 0, False: 5.55M]
  ------------------
  192|      0|      (typesize > MAX_STREAMS || (blocksize / typesize) < BLOSC1_MIN_SPLIT_ELEMENTS)) {
  ------------------
  |  |   24|      0|#define MAX_STREAMS 16 /* Cannot be larger than 128 */
  ------------------
                    (typesize > MAX_STREAMS || (blocksize / typesize) < BLOSC1_MIN_SPLIT_ELEMENTS)) {
  ------------------
  |  |  188|      0|#define BLOSC1_MIN_SPLIT_ELEMENTS 128
  ------------------
  |  Branch (192:8): [True: 0, False: 0]
  |  Branch (192:34): [True: 0, False: 0]
  ------------------
  193|       |    // A C-Blosc 1.x reader would not split this block whatever the flag says
  194|      0|    return 0;
  195|      0|  }
  196|  5.55M|  switch (context->splitmode) {
  197|      0|    case BLOSC_ALWAYS_SPLIT:
  ------------------
  |  Branch (197:5): [True: 0, False: 5.55M]
  ------------------
  198|      0|      return 1;
  199|  2.29M|    case BLOSC_NEVER_SPLIT:
  ------------------
  |  Branch (199:5): [True: 2.29M, False: 3.26M]
  ------------------
  200|  2.29M|      return 0;
  201|  3.26M|    case BLOSC_FORWARD_COMPAT_SPLIT:
  ------------------
  |  Branch (201:5): [True: 3.26M, False: 2.29M]
  ------------------
  202|  3.26M|    case BLOSC_AUTO_SPLIT:
  ------------------
  |  Branch (202:5): [True: 0, False: 5.55M]
  ------------------
  203|       |      // These cases will be handled later
  204|  3.26M|      break;
  205|      0|    default:
  ------------------
  |  Branch (205:5): [True: 0, False: 5.55M]
  ------------------
  206|      0|      BLOSC_TRACE_WARNING("Unrecognized split mode.  Default to BLOSC_FORWARD_COMPAT_SPLIT");
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|  5.55M|  }
  208|       |
  209|  3.26M|  int compcode = context->compcode;
  210|  3.26M|  if (compcode == BLOSC_CODEC_OPENZL) {
  ------------------
  |  Branch (210:7): [True: 0, False: 3.26M]
  ------------------
  211|       |    // Never split blocks for OpenZL, as it has its own block mechanisms
  212|      0|    return 0;
  213|      0|  }
  214|  3.26M|  return (
  215|       |          // Fast codecs like blosclz, lz4 seems to prefer to split
  216|  3.26M|          ((compcode == BLOSC_BLOSCLZ) || (compcode == BLOSC_LZ4)
  ------------------
  |  Branch (216:12): [True: 3.26M, False: 0]
  |  Branch (216:43): [True: 0, False: 0]
  ------------------
  217|       |            // and low levels of zstd too
  218|      0|            || ((compcode == BLOSC_ZSTD) && (context->clevel <= 5))
  ------------------
  |  Branch (218:17): [True: 0, False: 0]
  |  Branch (218:45): [True: 0, False: 0]
  ------------------
  219|  3.26M|            ) &&
  220|       |          // ...but split seems to harm cratio too much when not using shuffle
  221|  3.26M|          (context->filter_flags & BLOSC_DOSHUFFLE) &&
  ------------------
  |  Branch (221:11): [True: 3.26M, False: 0]
  ------------------
  222|  3.26M|          (typesize <= MAX_STREAMS) &&
  ------------------
  |  |   24|  3.26M|#define MAX_STREAMS 16 /* Cannot be larger than 128 */
  ------------------
  |  Branch (222:11): [True: 3.26M, False: 0]
  ------------------
  223|  3.26M|          (blocksize / typesize) >= BLOSC_MIN_BUFFERSIZE);
  ------------------
  |  Branch (223:11): [True: 3.11M, False: 149k]
  ------------------
  224|  3.26M|}

b2nd.c:b2nd_deserialize_meta_inline:
  721|  4.29k|                                                int32_t *chunkshape, int32_t *blockshape, char **dtype, int8_t *dtype_format) {
  722|  4.29k|  BLOSC_ERROR_NULL(smeta, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.29k|    do {                                            \
  |  |  105|  4.29k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  723|  4.29k|  BLOSC_ERROR_NULL(ndim, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.29k|    do {                                            \
  |  |  105|  4.29k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  724|  4.29k|  BLOSC_ERROR_NULL(shape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.29k|    do {                                            \
  |  |  105|  4.29k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  725|  4.29k|  BLOSC_ERROR_NULL(chunkshape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.29k|    do {                                            \
  |  |  105|  4.29k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  726|  4.29k|  BLOSC_ERROR_NULL(blockshape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.29k|    do {                                            \
  |  |  105|  4.29k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  727|  4.29k|  if (dtype != NULL) {
  ------------------
  |  Branch (727:7): [True: 4.29k, False: 0]
  ------------------
  728|  4.29k|    *dtype = NULL;
  729|  4.29k|  }
  730|  4.29k|  if (dtype_format != NULL) {
  ------------------
  |  Branch (730:7): [True: 4.29k, False: 0]
  ------------------
  731|  4.29k|    *dtype_format = 0;
  732|  4.29k|  }
  733|  4.29k|  if (smeta_len <= 0) {
  ------------------
  |  Branch (733:7): [True: 0, False: 4.29k]
  ------------------
  734|      0|    BLOSC_TRACE_ERROR("Malformed b2nd metalayer: empty metadata");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  735|      0|    return BLOSC2_ERROR_FAILURE;
  736|      0|  }
  737|       |
  738|  4.29k|  const uint8_t *pmeta = smeta;
  739|       |
  740|  4.29k|#define B2ND_REQUIRE_META_NBYTES(nbytes)                                             \
  741|  4.29k|  do {                                                                                \
  742|  4.29k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  743|  4.29k|    size_t total = (size_t)smeta_len;                                                 \
  744|  4.29k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  745|  4.29k|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  746|  4.29k|      return BLOSC2_ERROR_FAILURE;                                                    \
  747|  4.29k|    }                                                                                 \
  748|  4.29k|  } while (0)
  749|       |
  750|       |  // Check that we have an array with 7 entries (version, ndim, shape, chunkshape, blockshape, dtype_format, dtype)
  751|  4.29k|  B2ND_REQUIRE_META_NBYTES(1);
  ------------------
  |  |  741|  4.29k|  do {                                                                                \
  |  |  742|  4.29k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  743|  4.29k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  744|  4.29k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (744:9): [True: 0, False: 4.29k]
  |  |  |  Branch (744:29): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  745|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  746|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  747|      0|    }                                                                                 \
  |  |  748|  4.29k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (748:12): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  752|  4.29k|  pmeta += 1;
  753|       |
  754|       |  // version entry
  755|       |  // int8_t version = (int8_t)pmeta[0];  // positive fixnum (7-bit positive integer) commented to avoid warning
  756|  4.29k|  B2ND_REQUIRE_META_NBYTES(1);
  ------------------
  |  |  741|  4.29k|  do {                                                                                \
  |  |  742|  4.29k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  743|  4.29k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  744|  4.29k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (744:9): [True: 0, False: 4.29k]
  |  |  |  Branch (744:29): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  745|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  746|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  747|      0|    }                                                                                 \
  |  |  748|  4.29k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (748:12): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  757|  4.29k|  pmeta += 1;
  758|       |
  759|       |  // ndim entry
  760|  4.29k|  B2ND_REQUIRE_META_NBYTES(1);
  ------------------
  |  |  741|  4.29k|  do {                                                                                \
  |  |  742|  4.29k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  743|  4.29k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  744|  4.29k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (744:9): [True: 0, False: 4.29k]
  |  |  |  Branch (744:29): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  745|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  746|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  747|      0|    }                                                                                 \
  |  |  748|  4.29k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (748:12): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  761|  4.29k|  *ndim = (int8_t) pmeta[0];
  762|  4.29k|  int8_t ndim_aux = *ndim;  // positive fixnum (7-bit positive integer)
  763|  4.29k|  if (ndim_aux < 0 || ndim_aux > B2ND_MAX_DIM) {
  ------------------
  |  |   50|  4.29k|#define B2ND_MAX_DIM 16
  ------------------
  |  Branch (763:7): [True: 0, False: 4.29k]
  |  Branch (763:23): [True: 0, False: 4.29k]
  ------------------
  764|      0|    BLOSC_TRACE_ERROR("ndim %d is out of range", ndim_aux);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  765|      0|    return BLOSC2_ERROR_FAILURE;
  766|      0|  }
  767|  4.29k|  pmeta += 1;
  768|       |
  769|       |  // shape entry
  770|       |  // Initialize to ones, as required by b2nd
  771|  20.9k|  for (int i = 0; i < ndim_aux; i++) shape[i] = 1;
  ------------------
  |  Branch (771:19): [True: 16.6k, False: 4.29k]
  ------------------
  772|  4.29k|  B2ND_REQUIRE_META_NBYTES(1);
  ------------------
  |  |  741|  4.29k|  do {                                                                                \
  |  |  742|  4.29k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  743|  4.29k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  744|  4.29k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (744:9): [True: 0, False: 4.29k]
  |  |  |  Branch (744:29): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  745|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  746|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  747|      0|    }                                                                                 \
  |  |  748|  4.29k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (748:12): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  773|  4.29k|  pmeta += 1;
  774|  20.9k|  for (int8_t i = 0; i < ndim_aux; i++) {
  ------------------
  |  Branch (774:22): [True: 16.6k, False: 4.29k]
  ------------------
  775|  16.6k|    B2ND_REQUIRE_META_NBYTES(1 + sizeof(int64_t));
  ------------------
  |  |  741|  16.6k|  do {                                                                                \
  |  |  742|  16.6k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  743|  16.6k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  744|  16.6k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (744:9): [True: 0, False: 16.6k]
  |  |  |  Branch (744:29): [True: 0, False: 16.6k]
  |  |  ------------------
  |  |  745|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  746|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  747|      0|    }                                                                                 \
  |  |  748|  16.6k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (748:12): [Folded, False: 16.6k]
  |  |  ------------------
  ------------------
  776|  16.6k|    pmeta += 1;
  777|  16.6k|    swap_store(shape + i, pmeta, sizeof(int64_t));
  778|  16.6k|    pmeta += sizeof(int64_t);
  779|  16.6k|  }
  780|       |
  781|       |  // chunkshape entry
  782|       |  // Initialize to ones, as required by b2nd
  783|  20.9k|  for (int i = 0; i < ndim_aux; i++) chunkshape[i] = 1;
  ------------------
  |  Branch (783:19): [True: 16.6k, False: 4.29k]
  ------------------
  784|  4.29k|  B2ND_REQUIRE_META_NBYTES(1);
  ------------------
  |  |  741|  4.29k|  do {                                                                                \
  |  |  742|  4.29k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  743|  4.29k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  744|  4.29k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (744:9): [True: 0, False: 4.29k]
  |  |  |  Branch (744:29): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  745|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  746|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  747|      0|    }                                                                                 \
  |  |  748|  4.29k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (748:12): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  785|  4.29k|  pmeta += 1;
  786|  20.9k|  for (int8_t i = 0; i < ndim_aux; i++) {
  ------------------
  |  Branch (786:22): [True: 16.6k, False: 4.29k]
  ------------------
  787|  16.6k|    B2ND_REQUIRE_META_NBYTES(1 + sizeof(int32_t));
  ------------------
  |  |  741|  16.6k|  do {                                                                                \
  |  |  742|  16.6k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  743|  16.6k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  744|  16.6k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (744:9): [True: 0, False: 16.6k]
  |  |  |  Branch (744:29): [True: 0, False: 16.6k]
  |  |  ------------------
  |  |  745|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  746|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  747|      0|    }                                                                                 \
  |  |  748|  16.6k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (748:12): [Folded, False: 16.6k]
  |  |  ------------------
  ------------------
  788|  16.6k|    pmeta += 1;
  789|  16.6k|    swap_store(chunkshape + i, pmeta, sizeof(int32_t));
  790|  16.6k|    pmeta += sizeof(int32_t);
  791|  16.6k|  }
  792|       |
  793|       |  // blockshape entry
  794|       |  // Initialize to ones, as required by b2nd
  795|  20.9k|  for (int i = 0; i < ndim_aux; i++) blockshape[i] = 1;
  ------------------
  |  Branch (795:19): [True: 16.6k, False: 4.29k]
  ------------------
  796|  4.29k|  B2ND_REQUIRE_META_NBYTES(1);
  ------------------
  |  |  741|  4.29k|  do {                                                                                \
  |  |  742|  4.29k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  743|  4.29k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  744|  4.29k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (744:9): [True: 0, False: 4.29k]
  |  |  |  Branch (744:29): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  745|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  746|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  747|      0|    }                                                                                 \
  |  |  748|  4.29k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (748:12): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  797|  4.29k|  pmeta += 1;
  798|  20.9k|  for (int8_t i = 0; i < ndim_aux; i++) {
  ------------------
  |  Branch (798:22): [True: 16.6k, False: 4.29k]
  ------------------
  799|  16.6k|    B2ND_REQUIRE_META_NBYTES(1 + sizeof(int32_t));
  ------------------
  |  |  741|  16.6k|  do {                                                                                \
  |  |  742|  16.6k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  743|  16.6k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  744|  16.6k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (744:9): [True: 0, False: 16.6k]
  |  |  |  Branch (744:29): [True: 0, False: 16.6k]
  |  |  ------------------
  |  |  745|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  746|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  747|      0|    }                                                                                 \
  |  |  748|  16.6k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (748:12): [Folded, False: 16.6k]
  |  |  ------------------
  ------------------
  800|  16.6k|    pmeta += 1;
  801|  16.6k|    swap_store(blockshape + i, pmeta, sizeof(int32_t));
  802|  16.6k|    pmeta += sizeof(int32_t);
  803|  16.6k|  }
  804|       |
  805|       |  // dtype entry
  806|  4.29k|  if (dtype_format == NULL || dtype == NULL) {
  ------------------
  |  Branch (806:7): [True: 0, False: 4.29k]
  |  Branch (806:31): [True: 0, False: 4.29k]
  ------------------
  807|      0|    return (int32_t)(pmeta - smeta);
  808|      0|  }
  809|  4.29k|  if (pmeta - smeta < smeta_len) {
  ------------------
  |  Branch (809:7): [True: 4.29k, False: 0]
  ------------------
  810|       |    // dtype info is here
  811|  4.29k|    B2ND_REQUIRE_META_NBYTES(1 + 1 + sizeof(int32_t));
  ------------------
  |  |  741|  4.29k|  do {                                                                                \
  |  |  742|  4.29k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  743|  4.29k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  744|  4.29k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (744:9): [True: 0, False: 4.29k]
  |  |  |  Branch (744:29): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  745|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  746|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  747|      0|    }                                                                                 \
  |  |  748|  4.29k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (748:12): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  812|  4.29k|    *dtype_format = (int8_t) *(pmeta++);
  813|  4.29k|    if (*pmeta != 0xdb) {
  ------------------
  |  Branch (813:9): [True: 0, False: 4.29k]
  ------------------
  814|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: invalid dtype MsgPack marker");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  815|      0|      return BLOSC2_ERROR_FAILURE;
  816|      0|    }
  817|  4.29k|    pmeta += 1;
  818|  4.29k|    int32_t dtype_len;
  819|  4.29k|    swap_store(&dtype_len, pmeta, sizeof(int32_t));
  820|  4.29k|    pmeta += sizeof(int32_t);
  821|  4.29k|    if (dtype_len < 0) {
  ------------------
  |  Branch (821:9): [True: 0, False: 4.29k]
  ------------------
  822|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: negative dtype length");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  823|      0|      return BLOSC2_ERROR_FAILURE;
  824|      0|    }
  825|  4.29k|    B2ND_REQUIRE_META_NBYTES(dtype_len);
  ------------------
  |  |  741|  4.29k|  do {                                                                                \
  |  |  742|  4.29k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  743|  4.29k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  744|  4.29k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (744:9): [True: 0, False: 4.29k]
  |  |  |  Branch (744:29): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  745|      0|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  746|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  747|      0|    }                                                                                 \
  |  |  748|  4.29k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (748:12): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  826|  4.29k|    size_t dtype_len_ = (size_t)dtype_len;
  827|  4.29k|    *dtype = (char*)malloc(dtype_len_ + 1);
  828|  4.29k|    BLOSC_ERROR_NULL(*dtype, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  4.29k|    do {                                            \
  |  |  105|  4.29k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.29k]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|  4.29k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.29k]
  |  |  ------------------
  ------------------
  829|  4.29k|    char* dtype_ = *dtype;
  830|  4.29k|    memcpy(dtype_, (char*)pmeta, dtype_len_);
  831|  4.29k|    dtype_[dtype_len_] = '\0';
  832|  4.29k|    pmeta += dtype_len_;
  833|  4.29k|  }
  834|      0|  else {
  835|       |    // dtype is mandatory in b2nd metalayer, but this is mainly meant as
  836|       |    // a fall-back for deprecated caterva headers
  837|      0|    *dtype = NULL;
  838|      0|    *dtype_format = 0;
  839|      0|  }
  840|       |
  841|  4.29k|#undef B2ND_REQUIRE_META_NBYTES
  842|       |
  843|  4.29k|  int32_t slen = (int32_t) (pmeta - smeta);
  844|  4.29k|  return (int)slen;
  845|  4.29k|}

blosc2.c:print_error:
  525|     11|static inline char *print_error(int rc) {
  526|       |  // TODO: remove this function, use blosc2_error_string only
  527|     11|  return (char *) blosc2_error_string(rc);
  528|     11|}
schunk.c:blosc2_meta_exists:
 2705|  8.53k|static inline int blosc2_meta_exists(blosc2_schunk *schunk, const char *name) {
 2706|  8.53k|  if (strlen(name) > BLOSC2_METALAYER_NAME_MAXLEN) {
  ------------------
  |  | 1896|  8.53k|#define BLOSC2_METALAYER_NAME_MAXLEN 31
  ------------------
  |  Branch (2706:7): [True: 0, False: 8.53k]
  ------------------
 2707|      0|    BLOSC_TRACE_ERROR("Metalayers cannot be larger than %d chars.", BLOSC2_METALAYER_NAME_MAXLEN);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 2707|      0|    BLOSC_TRACE_ERROR("Metalayers cannot be larger than %d chars.", BLOSC2_METALAYER_NAME_MAXLEN);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1896|      0|#define BLOSC2_METALAYER_NAME_MAXLEN 31
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2708|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2709|      0|  }
 2710|       |
 2711|  8.53k|  if (schunk == NULL) {
  ------------------
  |  Branch (2711:7): [True: 0, False: 8.53k]
  ------------------
 2712|      0|    BLOSC_TRACE_ERROR("Schunk must not be NUll.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2713|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2714|      0|  }
 2715|       |
 2716|  8.53k|  for (int nmetalayer = 0; nmetalayer < schunk->nmetalayers; nmetalayer++) {
  ------------------
  |  Branch (2716:28): [True: 1.33k, False: 7.20k]
  ------------------
 2717|  1.33k|    if (strcmp(name, schunk->metalayers[nmetalayer]->name) == 0) {
  ------------------
  |  Branch (2717:9): [True: 1.33k, False: 0]
  ------------------
 2718|  1.33k|      return nmetalayer;
 2719|  1.33k|    }
 2720|  1.33k|  }
 2721|  7.20k|  return BLOSC2_ERROR_NOT_FOUND;
 2722|  8.53k|}
b2nd.c:print_error:
  525|  4.03k|static inline char *print_error(int rc) {
  526|       |  // TODO: remove this function, use blosc2_error_string only
  527|  4.03k|  return (char *) blosc2_error_string(rc);
  528|  4.03k|}
b2nd.c:swap_store:
 3274|   153k|static inline void swap_store(void *dest, const void *pa, int size) {
 3275|   153k|  uint8_t *pa_ = (uint8_t *) pa;
 3276|   153k|  uint8_t *pa2_ = (uint8_t*)malloc((size_t) size);
 3277|   153k|  int i = 1; /* for big/little endian detection */
 3278|   153k|  char *p = (char *) &i;
 3279|       |
 3280|   153k|  if (p[0] == 1) {
  ------------------
  |  Branch (3280:7): [True: 153k, False: 0]
  ------------------
 3281|       |    /* little endian */
 3282|   153k|    switch (size) {
 3283|  46.9k|      case 8:
  ------------------
  |  Branch (3283:7): [True: 46.9k, False: 106k]
  ------------------
 3284|  46.9k|        pa2_[0] = pa_[7];
 3285|  46.9k|        pa2_[1] = pa_[6];
 3286|  46.9k|        pa2_[2] = pa_[5];
 3287|  46.9k|        pa2_[3] = pa_[4];
 3288|  46.9k|        pa2_[4] = pa_[3];
 3289|  46.9k|        pa2_[5] = pa_[2];
 3290|  46.9k|        pa2_[6] = pa_[1];
 3291|  46.9k|        pa2_[7] = pa_[0];
 3292|  46.9k|        break;
 3293|   106k|      case 4:
  ------------------
  |  Branch (3293:7): [True: 106k, False: 46.9k]
  ------------------
 3294|   106k|        pa2_[0] = pa_[3];
 3295|   106k|        pa2_[1] = pa_[2];
 3296|   106k|        pa2_[2] = pa_[1];
 3297|   106k|        pa2_[3] = pa_[0];
 3298|   106k|        break;
 3299|      0|      case 2:
  ------------------
  |  Branch (3299:7): [True: 0, False: 153k]
  ------------------
 3300|      0|        pa2_[0] = pa_[1];
 3301|      0|        pa2_[1] = pa_[0];
 3302|      0|        break;
 3303|      0|      case 1:
  ------------------
  |  Branch (3303:7): [True: 0, False: 153k]
  ------------------
 3304|      0|        pa2_[0] = pa_[0];
 3305|      0|        break;
 3306|      0|      default:
  ------------------
  |  Branch (3306:7): [True: 0, False: 153k]
  ------------------
 3307|      0|        fprintf(stderr, "Unhandled nitems: %d\n", size);
 3308|   153k|    }
 3309|   153k|  } else {
 3310|       |    /* big endian: native byte order is already big-endian, just copy */
 3311|      0|    memcpy(pa2_, pa_, size);
 3312|      0|  }
 3313|   153k|  memcpy(dest, pa2_, size);
 3314|   153k|  free(pa2_);
 3315|   153k|}
b2nd.c:blosc2_meta_exists:
 2705|  5.62k|static inline int blosc2_meta_exists(blosc2_schunk *schunk, const char *name) {
 2706|  5.62k|  if (strlen(name) > BLOSC2_METALAYER_NAME_MAXLEN) {
  ------------------
  |  | 1896|  5.62k|#define BLOSC2_METALAYER_NAME_MAXLEN 31
  ------------------
  |  Branch (2706:7): [True: 0, False: 5.62k]
  ------------------
 2707|      0|    BLOSC_TRACE_ERROR("Metalayers cannot be larger than %d chars.", BLOSC2_METALAYER_NAME_MAXLEN);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 2707|      0|    BLOSC_TRACE_ERROR("Metalayers cannot be larger than %d chars.", BLOSC2_METALAYER_NAME_MAXLEN);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  | 1896|      0|#define BLOSC2_METALAYER_NAME_MAXLEN 31
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2708|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2709|      0|  }
 2710|       |
 2711|  5.62k|  if (schunk == NULL) {
  ------------------
  |  Branch (2711:7): [True: 0, False: 5.62k]
  ------------------
 2712|      0|    BLOSC_TRACE_ERROR("Schunk must not be NUll.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2713|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2714|      0|  }
 2715|       |
 2716|  5.62k|  for (int nmetalayer = 0; nmetalayer < schunk->nmetalayers; nmetalayer++) {
  ------------------
  |  Branch (2716:28): [True: 5.62k, False: 2]
  ------------------
 2717|  5.62k|    if (strcmp(name, schunk->metalayers[nmetalayer]->name) == 0) {
  ------------------
  |  Branch (2717:9): [True: 5.62k, False: 0]
  ------------------
 2718|  5.62k|      return nmetalayer;
 2719|  5.62k|    }
 2720|  5.62k|  }
 2721|      2|  return BLOSC2_ERROR_NOT_FOUND;
 2722|  5.62k|}
b2nd.c:blosc2_meta_get:
 2774|  4.29k|                                  int32_t *content_len) {
 2775|  4.29k|  if (schunk == NULL || name == NULL || content == NULL || content_len == NULL) {
  ------------------
  |  Branch (2775:7): [True: 0, False: 4.29k]
  |  Branch (2775:25): [True: 0, False: 4.29k]
  |  Branch (2775:41): [True: 0, False: 4.29k]
  |  Branch (2775:60): [True: 0, False: 4.29k]
  ------------------
 2776|      0|    BLOSC_TRACE_ERROR("Invalid parameters.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2777|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2778|      0|  }
 2779|       |
 2780|  4.29k|  int nmetalayer = blosc2_meta_exists(schunk, name);
 2781|  4.29k|  if (nmetalayer < 0) {
  ------------------
  |  Branch (2781:7): [True: 2, False: 4.29k]
  ------------------
 2782|      2|    BLOSC_TRACE_WARNING("Metalayer \"%s\" not found.", name);
  ------------------
  |  |   94|      2|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2783|      2|    return nmetalayer;
 2784|      2|  }
 2785|  4.29k|  int32_t len = schunk->metalayers[nmetalayer]->content_len;
 2786|  4.29k|  if (len < 0) {
  ------------------
  |  Branch (2786:7): [True: 0, False: 4.29k]
  ------------------
 2787|      0|    BLOSC_TRACE_ERROR("Metalayer \"%s\" has corrupted content length %d.", name, len);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2788|      0|    return BLOSC2_ERROR_DATA;
 2789|      0|  }
 2790|  4.29k|  *content_len = len;
 2791|  4.29k|  if (len == 0) {
  ------------------
  |  Branch (2791:7): [True: 0, False: 4.29k]
  ------------------
 2792|      0|    *content = NULL;
 2793|      0|    return nmetalayer;
 2794|      0|  }
 2795|  4.29k|  *content = (uint8_t*)malloc((size_t)len);
 2796|  4.29k|  if (*content == NULL) {
  ------------------
  |  Branch (2796:7): [True: 0, False: 4.29k]
  ------------------
 2797|      0|    BLOSC_TRACE_ERROR("Unable to allocate metalayer content buffer.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2798|      0|    *content_len = 0;
 2799|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2800|      0|  }
 2801|  4.29k|  if (len > 0 && schunk->metalayers[nmetalayer]->content == NULL) {
  ------------------
  |  Branch (2801:7): [True: 4.29k, False: 0]
  |  Branch (2801:18): [True: 0, False: 4.29k]
  ------------------
 2802|      0|    free(*content);
 2803|      0|    *content = NULL;
 2804|      0|    *content_len = 0;
 2805|      0|    BLOSC_TRACE_ERROR("Metalayer \"%s\" has corrupted content pointer.", name);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2806|      0|    return BLOSC2_ERROR_DATA;
 2807|      0|  }
 2808|  4.29k|  memcpy(*content, schunk->metalayers[nmetalayer]->content, (size_t)len);
 2809|  4.29k|  return nmetalayer;
 2810|  4.29k|}
ndcell.c:blosc2_meta_get:
 2774|      2|                                  int32_t *content_len) {
 2775|      2|  if (schunk == NULL || name == NULL || content == NULL || content_len == NULL) {
  ------------------
  |  Branch (2775:7): [True: 2, False: 0]
  |  Branch (2775:25): [True: 0, False: 0]
  |  Branch (2775:41): [True: 0, False: 0]
  |  Branch (2775:60): [True: 0, False: 0]
  ------------------
 2776|      2|    BLOSC_TRACE_ERROR("Invalid parameters.");
  ------------------
  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2777|      2|    return BLOSC2_ERROR_INVALID_PARAM;
 2778|      2|  }
 2779|       |
 2780|      0|  int nmetalayer = blosc2_meta_exists(schunk, name);
 2781|      0|  if (nmetalayer < 0) {
  ------------------
  |  Branch (2781:7): [True: 0, False: 0]
  ------------------
 2782|      0|    BLOSC_TRACE_WARNING("Metalayer \"%s\" not found.", name);
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2783|      0|    return nmetalayer;
 2784|      0|  }
 2785|      0|  int32_t len = schunk->metalayers[nmetalayer]->content_len;
 2786|      0|  if (len < 0) {
  ------------------
  |  Branch (2786:7): [True: 0, False: 0]
  ------------------
 2787|      0|    BLOSC_TRACE_ERROR("Metalayer \"%s\" has corrupted content length %d.", name, len);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2788|      0|    return BLOSC2_ERROR_DATA;
 2789|      0|  }
 2790|      0|  *content_len = len;
 2791|      0|  if (len == 0) {
  ------------------
  |  Branch (2791:7): [True: 0, False: 0]
  ------------------
 2792|      0|    *content = NULL;
 2793|      0|    return nmetalayer;
 2794|      0|  }
 2795|      0|  *content = (uint8_t*)malloc((size_t)len);
 2796|      0|  if (*content == NULL) {
  ------------------
  |  Branch (2796:7): [True: 0, False: 0]
  ------------------
 2797|      0|    BLOSC_TRACE_ERROR("Unable to allocate metalayer content buffer.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2798|      0|    *content_len = 0;
 2799|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2800|      0|  }
 2801|      0|  if (len > 0 && schunk->metalayers[nmetalayer]->content == NULL) {
  ------------------
  |  Branch (2801:7): [True: 0, False: 0]
  |  Branch (2801:18): [True: 0, False: 0]
  ------------------
 2802|      0|    free(*content);
 2803|      0|    *content = NULL;
 2804|      0|    *content_len = 0;
 2805|      0|    BLOSC_TRACE_ERROR("Metalayer \"%s\" has corrupted content pointer.", name);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2806|      0|    return BLOSC2_ERROR_DATA;
 2807|      0|  }
 2808|      0|  memcpy(*content, schunk->metalayers[nmetalayer]->content, (size_t)len);
 2809|      0|  return nmetalayer;
 2810|      0|}
ndmean.c:blosc2_meta_get:
 2774|      2|                                  int32_t *content_len) {
 2775|      2|  if (schunk == NULL || name == NULL || content == NULL || content_len == NULL) {
  ------------------
  |  Branch (2775:7): [True: 2, False: 0]
  |  Branch (2775:25): [True: 0, False: 0]
  |  Branch (2775:41): [True: 0, False: 0]
  |  Branch (2775:60): [True: 0, False: 0]
  ------------------
 2776|      2|    BLOSC_TRACE_ERROR("Invalid parameters.");
  ------------------
  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2777|      2|    return BLOSC2_ERROR_INVALID_PARAM;
 2778|      2|  }
 2779|       |
 2780|      0|  int nmetalayer = blosc2_meta_exists(schunk, name);
 2781|      0|  if (nmetalayer < 0) {
  ------------------
  |  Branch (2781:7): [True: 0, False: 0]
  ------------------
 2782|      0|    BLOSC_TRACE_WARNING("Metalayer \"%s\" not found.", name);
  ------------------
  |  |   94|      0|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2783|      0|    return nmetalayer;
 2784|      0|  }
 2785|      0|  int32_t len = schunk->metalayers[nmetalayer]->content_len;
 2786|      0|  if (len < 0) {
  ------------------
  |  Branch (2786:7): [True: 0, False: 0]
  ------------------
 2787|      0|    BLOSC_TRACE_ERROR("Metalayer \"%s\" has corrupted content length %d.", name, len);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2788|      0|    return BLOSC2_ERROR_DATA;
 2789|      0|  }
 2790|      0|  *content_len = len;
 2791|      0|  if (len == 0) {
  ------------------
  |  Branch (2791:7): [True: 0, False: 0]
  ------------------
 2792|      0|    *content = NULL;
 2793|      0|    return nmetalayer;
 2794|      0|  }
 2795|      0|  *content = (uint8_t*)malloc((size_t)len);
 2796|      0|  if (*content == NULL) {
  ------------------
  |  Branch (2796:7): [True: 0, False: 0]
  ------------------
 2797|      0|    BLOSC_TRACE_ERROR("Unable to allocate metalayer content buffer.");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2798|      0|    *content_len = 0;
 2799|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2800|      0|  }
 2801|      0|  if (len > 0 && schunk->metalayers[nmetalayer]->content == NULL) {
  ------------------
  |  Branch (2801:7): [True: 0, False: 0]
  |  Branch (2801:18): [True: 0, False: 0]
  ------------------
 2802|      0|    free(*content);
 2803|      0|    *content = NULL;
 2804|      0|    *content_len = 0;
 2805|      0|    BLOSC_TRACE_ERROR("Metalayer \"%s\" has corrupted content pointer.", name);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2806|      0|    return BLOSC2_ERROR_DATA;
 2807|      0|  }
 2808|      0|  memcpy(*content, schunk->metalayers[nmetalayer]->content, (size_t)len);
 2809|      0|  return nmetalayer;
 2810|      0|}
bytedelta.c:print_error:
  525|      4|static inline char *print_error(int rc) {
  526|       |  // TODO: remove this function, use blosc2_error_string only
  527|      4|  return (char *) blosc2_error_string(rc);
  528|      4|}

register_codecs:
   18|  3.39k|void register_codecs(void) {
   19|       |  // May add .free func in future
   20|       |
   21|  3.39k|  blosc2_codec ndlz;
   22|  3.39k|  ndlz.compcode = BLOSC_CODEC_NDLZ;
   23|  3.39k|  ndlz.version = 1;
   24|  3.39k|  ndlz.complib = BLOSC_CODEC_NDLZ;
   25|  3.39k|  ndlz.encoder = &ndlz_compress;
   26|  3.39k|  ndlz.decoder = &ndlz_decompress;
   27|  3.39k|  ndlz.compname = "ndlz";
   28|       |  // ndlz.free = NULL; 
   29|  3.39k|  register_codec_private(&ndlz);
   30|       |
   31|  3.39k|#if defined(HAVE_ZFP)
   32|  3.39k|  blosc2_codec zfp_acc;
   33|  3.39k|  zfp_acc.compcode = BLOSC_CODEC_ZFP_FIXED_ACCURACY;
   34|  3.39k|  zfp_acc.version = 1;
   35|  3.39k|  zfp_acc.complib = BLOSC_CODEC_ZFP_FIXED_ACCURACY;
   36|  3.39k|  zfp_acc.encoder = &zfp_acc_compress;
   37|  3.39k|  zfp_acc.decoder = &zfp_acc_decompress;
   38|       |  // zfp_acc.free = NULL;
   39|  3.39k|  zfp_acc.compname = "zfp_acc";
   40|  3.39k|  register_codec_private(&zfp_acc);
   41|       |
   42|  3.39k|  blosc2_codec zfp_prec;
   43|  3.39k|  zfp_prec.compcode = BLOSC_CODEC_ZFP_FIXED_PRECISION;
   44|  3.39k|  zfp_prec.version = 1;
   45|  3.39k|  zfp_prec.complib = BLOSC_CODEC_ZFP_FIXED_PRECISION;
   46|  3.39k|  zfp_prec.encoder = &zfp_prec_compress;
   47|  3.39k|  zfp_prec.decoder = &zfp_prec_decompress;
   48|       |  // zfp_prec.free = NULL;
   49|  3.39k|  zfp_prec.compname = "zfp_prec";
   50|  3.39k|  register_codec_private(&zfp_prec);
   51|       |
   52|  3.39k|  blosc2_codec zfp_rate;
   53|  3.39k|  zfp_rate.compcode = BLOSC_CODEC_ZFP_FIXED_RATE;
   54|  3.39k|  zfp_rate.version = 1;
   55|  3.39k|  zfp_rate.complib = BLOSC_CODEC_ZFP_FIXED_RATE;
   56|  3.39k|  zfp_rate.encoder = &zfp_rate_compress;
   57|  3.39k|  zfp_rate.decoder = &zfp_rate_decompress;
   58|  3.39k|  zfp_rate.compname = "zfp_rate";
   59|       |  // zfp_rate.free = NULL;
   60|  3.39k|  register_codec_private(&zfp_rate);
   61|  3.39k|#endif
   62|       |
   63|  3.39k|  blosc2_codec openhtj2k;
   64|  3.39k|  openhtj2k.compcode = BLOSC_CODEC_OPENHTJ2K;
   65|  3.39k|  openhtj2k.version = 1;
   66|  3.39k|  openhtj2k.complib = BLOSC_CODEC_OPENHTJ2K;
   67|  3.39k|  openhtj2k.encoder = NULL;
   68|  3.39k|  openhtj2k.decoder = NULL;
   69|       |  // openhtj2k.free = NULL;
   70|  3.39k|  openhtj2k.compname = "openhtj2k";
   71|  3.39k|  register_codec_private(&openhtj2k);
   72|       |
   73|  3.39k|  blosc2_codec grok;
   74|  3.39k|  grok.compcode = BLOSC_CODEC_GROK;
   75|  3.39k|  grok.version = 1;
   76|  3.39k|  grok.complib = BLOSC_CODEC_GROK;
   77|  3.39k|  grok.encoder = NULL;
   78|  3.39k|  grok.decoder = NULL;
   79|       |  // grok.free = NULL;
   80|  3.39k|  grok.compname = "grok";
   81|  3.39k|  register_codec_private(&grok);
   82|       |
   83|  3.39k|  blosc2_codec openzl;
   84|  3.39k|  openzl.compcode = BLOSC_CODEC_OPENZL;
   85|  3.39k|  openzl.version = 1;
   86|  3.39k|  openzl.complib = BLOSC_CODEC_OPENZL;
   87|  3.39k|  openzl.encoder = NULL;
   88|  3.39k|  openzl.decoder = NULL;
   89|       |  // openzl.free = NULL;
   90|  3.39k|  openzl.compname = "openzl";
   91|  3.39k|  register_codec_private(&openzl);
   92|       |
   93|  3.39k|  blosc2_codec j2k;
   94|  3.39k|  j2k.compcode = BLOSC_CODEC_J2K;
   95|  3.39k|  j2k.version = 1;
   96|  3.39k|  j2k.complib = BLOSC_CODEC_J2K;
   97|  3.39k|  j2k.encoder = NULL;
   98|  3.39k|  j2k.decoder = NULL;
   99|       |  // j2k.free = NULL;
  100|  3.39k|  j2k.compname = "j2k";
  101|  3.39k|  register_codec_private(&j2k);
  102|       |
  103|  3.39k|  blosc2_codec htj2k;
  104|  3.39k|  htj2k.compcode = BLOSC_CODEC_HTJ2K;
  105|  3.39k|  htj2k.version = 1;
  106|  3.39k|  htj2k.complib = BLOSC_CODEC_HTJ2K;
  107|  3.39k|  htj2k.encoder = NULL;
  108|  3.39k|  htj2k.decoder = NULL;
  109|       |  // htj2k.free = NULL;
  110|  3.39k|  htj2k.compname = "htj2k";
  111|  3.39k|  register_codec_private(&htj2k);
  112|  3.39k|}

ndlz_decompress:
   42|     88|                    uint8_t meta, blosc2_dparams *dparams, const void *chunk) {
   43|     88|  NDLZ_ERROR_NULL(input);
  ------------------
  |  |   19|     88|  do {                           \
  |  |   20|     88|    if ((pointer) == NULL) {     \
  |  |  ------------------
  |  |  |  Branch (20:9): [True: 0, False: 88]
  |  |  ------------------
  |  |   21|      0|      return 0;                  \
  |  |   22|      0|    }                            \
  |  |   23|     88|  } while (0)
  |  |  ------------------
  |  |  |  Branch (23:12): [Folded, False: 88]
  |  |  ------------------
  ------------------
   44|     88|  NDLZ_ERROR_NULL(output);
  ------------------
  |  |   19|     88|  do {                           \
  |  |   20|     88|    if ((pointer) == NULL) {     \
  |  |  ------------------
  |  |  |  Branch (20:9): [True: 0, False: 88]
  |  |  ------------------
  |  |   21|      0|      return 0;                  \
  |  |   22|      0|    }                            \
  |  |   23|     88|  } while (0)
  |  |  ------------------
  |  |  |  Branch (23:12): [Folded, False: 88]
  |  |  ------------------
  ------------------
   45|     88|  NDLZ_ERROR_NULL(dparams);
  ------------------
  |  |   19|     88|  do {                           \
  |  |   20|     88|    if ((pointer) == NULL) {     \
  |  |  ------------------
  |  |  |  Branch (20:9): [True: 0, False: 88]
  |  |  ------------------
  |  |   21|      0|      return 0;                  \
  |  |   22|      0|    }                            \
  |  |   23|     88|  } while (0)
  |  |  ------------------
  |  |  |  Branch (23:12): [Folded, False: 88]
  |  |  ------------------
  ------------------
   46|     88|  BLOSC_UNUSED_PARAM(chunk);
  ------------------
  |  |   28|     88|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
   47|       |
   48|     88|  switch (meta) {
   49|     43|    case 4:
  ------------------
  |  Branch (49:5): [True: 43, False: 45]
  ------------------
   50|     43|      return ndlz4_decompress(input, input_len, output, output_len, meta, dparams);
   51|     44|    case 8:
  ------------------
  |  Branch (51:5): [True: 44, False: 44]
  ------------------
   52|     44|      return ndlz8_decompress(input, input_len, output, output_len, meta, dparams);
   53|      1|    default:
  ------------------
  |  Branch (53:5): [True: 1, False: 87]
  ------------------
   54|      1|      BLOSC_TRACE_ERROR("NDLZ is not available for this cellsize: %d", meta);
  ------------------
  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|     88|  }
   56|      1|  return BLOSC2_ERROR_FAILURE;
   57|     88|}

ndlz4_decompress:
  526|     43|                     uint8_t meta, blosc2_dparams *dparams) {
  527|     43|  BLOSC_UNUSED_PARAM(meta);
  ------------------
  |  |   28|     43|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  528|     43|  BLOSC_UNUSED_PARAM(dparams);
  ------------------
  |  |   28|     43|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  529|     43|  BLOSC_ERROR_NULL(input, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|     43|    do {                                            \
  |  |  105|     43|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 43]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|     43|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 43]
  |  |  ------------------
  ------------------
  530|     43|  BLOSC_ERROR_NULL(output, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|     43|    do {                                            \
  |  |  105|     43|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 43]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|     43|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 43]
  |  |  ------------------
  ------------------
  531|       |
  532|     43|  uint8_t *ip = (uint8_t *) input;
  533|     43|  uint8_t *op = (uint8_t *) output;
  534|     43|  uint8_t ndim;
  535|     43|  int32_t blockshape[2];
  536|     43|  int32_t eshape[2];
  537|     43|  uint8_t *buffercpy;
  538|     43|  uint8_t local_buffer[16];
  539|     43|  uint8_t token;
  540|       |  // The fixed header is 1 (ndim) + 2 * int32 (blockshape) = 9 bytes.  Reject any
  541|       |  // input too short to hold it -- the previous `< 8` check let an 8-byte input
  542|       |  // through and the header parse below then read a 9th byte.  The cast keeps the
  543|       |  // comparison signed so a negative `input_len` is rejected here, before the
  544|       |  // `ip + input_len` pointer arithmetic (which would otherwise be UB) is reached.
  545|     43|  if (NDLZ_UNEXPECT_CONDITIONAL(input_len < (int32_t) (1 + 2 * sizeof(int32_t)))) {
  ------------------
  |  |   30|     43|#define NDLZ_UNEXPECT_CONDITIONAL(c)  (__builtin_expect((c), 0))
  |  |  ------------------
  |  |  |  Branch (30:39): [True: 1, False: 42]
  |  |  ------------------
  ------------------
  546|      1|    return 0;
  547|      1|  }
  548|     42|  uint8_t *ip_limit = ip + input_len;
  549|       |
  550|       |  // Validate that a read of `len` bytes starting at byte offset `pos` (measured
  551|       |  // from the start of `input`) lies fully within the compressed buffer.  A
  552|       |  // crafted token `offset` otherwise makes a back-reference point before
  553|       |  // `input`, and the cell-fill memcpy then leaks out-of-bounds heap memory into
  554|       |  // the (attacker-visible) output buffer -- CWE-125.  The per-cell `ip > ip_limit`
  555|       |  // check is not enough because each cell reads a 2-byte offset and literal bytes
  556|       |  // past that point.  All arithmetic is done on integer offsets so we never form
  557|       |  // an out-of-bounds pointer (which is undefined behaviour in C, even when the
  558|       |  // pointer is only compared and not dereferenced).
  559|     42|#define NDLZ4_CHECK_RANGE(pos, len)                                              \
  560|     42|  do {                                                                           \
  561|     42|    int64_t _pos = (int64_t) (pos);                                              \
  562|     42|    int64_t _len = (int64_t) (len);                                              \
  563|     42|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  564|     42|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  565|     42|      return BLOSC2_ERROR_FAILURE;                                               \
  566|     42|    }                                                                            \
  567|     42|  } while (0)
  568|       |
  569|       |  /* we start with literal copy */
  570|     42|  ndim = *ip;
  571|     42|  ip++;
  572|     42|  if (ndim != 2) {
  ------------------
  |  Branch (572:7): [True: 2, False: 40]
  ------------------
  573|      2|    BLOSC_TRACE_ERROR("This codec only works for ndim = 2");
  ------------------
  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  574|      2|    return BLOSC2_ERROR_FAILURE;
  575|      2|  }
  576|     40|  memcpy(&blockshape[0], ip, 4);
  577|     40|  ip += 4;
  578|     40|  memcpy(&blockshape[1], ip, 4);
  579|     40|  ip += 4;
  580|       |
  581|       |  // Sanity check.  See https://www.cve.org/CVERecord?id=CVE-2024-3204
  582|     40|  if (output_len < 0 || blockshape[0] < 0 || blockshape[1] < 0) {
  ------------------
  |  Branch (582:7): [True: 0, False: 40]
  |  Branch (582:25): [True: 3, False: 37]
  |  Branch (582:46): [True: 7, False: 30]
  ------------------
  583|     10|    BLOSC_TRACE_ERROR("Output length or blockshape is negative");
  ------------------
  |  |   93|     10|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     10|    do {                                            \
  |  |  |  |   98|     10|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     10|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     10|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|     10|    return BLOSC2_ERROR_FAILURE;
  585|     10|  }
  586|       |
  587|     30|  eshape[0] = ((blockshape[0] + 3) / 4) * 4;
  588|     30|  eshape[1] = ((blockshape[1] + 3) / 4) * 4;
  589|       |
  590|     30|  if (NDLZ_UNEXPECT_CONDITIONAL((int64_t)output_len < (int64_t)blockshape[0] * (int64_t)blockshape[1])) {
  ------------------
  |  |   30|     30|#define NDLZ_UNEXPECT_CONDITIONAL(c)  (__builtin_expect((c), 0))
  |  |  ------------------
  |  |  |  Branch (30:39): [True: 28, False: 2]
  |  |  ------------------
  ------------------
  591|     28|    BLOSC_TRACE_ERROR("The blockshape is bigger than the output buffer");
  ------------------
  |  |   93|     28|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     28|    do {                                            \
  |  |  |  |   98|     28|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     28|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 28, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     28|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  592|     28|    return 0;
  593|     28|  }
  594|      2|  memset(op, 0, blockshape[0] * blockshape[1]);
  595|       |
  596|      2|  uint32_t i_stop[2];
  597|      6|  for (int i = 0; i < 2; ++i) {
  ------------------
  |  Branch (597:19): [True: 4, False: 2]
  ------------------
  598|      4|    i_stop[i] = eshape[i] / 4;
  599|      4|  }
  600|       |
  601|       |  /* main loop */
  602|      2|  uint32_t ii[2];
  603|      2|  uint32_t padding[2] = {0};
  604|      2|  uint32_t ind = 0;
  605|      2|  uint8_t cell_aux[16];
  606|  42.0M|  for (ii[0] = 0; ii[0] < i_stop[0]; ++ii[0]) {
  ------------------
  |  Branch (606:19): [True: 42.0M, False: 2]
  ------------------
  607|  42.0M|    for (ii[1] = 0; ii[1] < i_stop[1]; ++ii[1]) {      // for each cell
  ------------------
  |  Branch (607:21): [True: 0, False: 42.0M]
  ------------------
  608|      0|      if (NDLZ_UNEXPECT_CONDITIONAL(ip > ip_limit)) {
  ------------------
  |  |   30|      0|#define NDLZ_UNEXPECT_CONDITIONAL(c)  (__builtin_expect((c), 0))
  |  |  ------------------
  |  |  |  Branch (30:39): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  609|      0|        BLOSC_TRACE_ERROR("Exceeding input length");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  610|      0|        return BLOSC2_ERROR_FAILURE;
  611|      0|      }
  612|      0|      if (ii[0] == i_stop[0] - 1) {
  ------------------
  |  Branch (612:11): [True: 0, False: 0]
  ------------------
  613|      0|        padding[0] = (blockshape[0] % 4 == 0) ? 4 : blockshape[0] % 4;
  ------------------
  |  Branch (613:22): [True: 0, False: 0]
  ------------------
  614|      0|      } else {
  615|      0|        padding[0] = 4;
  616|      0|      }
  617|      0|      if (ii[1] == i_stop[1] - 1) {
  ------------------
  |  Branch (617:11): [True: 0, False: 0]
  ------------------
  618|      0|        padding[1] = (blockshape[1] % 4 == 0) ? 4 : blockshape[1] % 4;
  ------------------
  |  Branch (618:22): [True: 0, False: 0]
  ------------------
  619|      0|      } else {
  620|      0|        padding[1] = 4;
  621|      0|      }
  622|      0|      int64_t cur = ip - (const uint8_t *) input;   // in-range: ip is within [input, ip_limit]
  623|      0|      NDLZ4_CHECK_RANGE(cur, 1);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  624|      0|      token = *ip++;
  625|      0|      if (token == 0) {    // no match
  ------------------
  |  Branch (625:11): [True: 0, False: 0]
  ------------------
  626|      0|        NDLZ4_CHECK_RANGE(cur + 1, (int64_t) padding[0] * padding[1]);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  627|      0|        buffercpy = ip;
  628|      0|        ip += padding[0] * padding[1];
  629|      0|      } else if (token == (uint8_t) ((1U << 7U) | (1U << 6U))) {  // cell match
  ------------------
  |  Branch (629:18): [True: 0, False: 0]
  ------------------
  630|      0|        NDLZ4_CHECK_RANGE(cur + 1, 2);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  631|      0|        uint16_t offset;
  632|      0|        memcpy(&offset, ip, sizeof(offset));
  633|      0|        int64_t bpos = (cur + 1) - (int64_t) offset - 1;   // back-reference start offset
  634|      0|        NDLZ4_CHECK_RANGE(bpos, (int64_t) padding[0] * padding[1]);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  635|      0|        buffercpy = (uint8_t *) input + bpos;
  636|      0|        ip += 2;
  637|      0|      } else if (token == (uint8_t) (1U << 6U)) { // whole cell of same element
  ------------------
  |  Branch (637:18): [True: 0, False: 0]
  ------------------
  638|      0|        NDLZ4_CHECK_RANGE(cur + 1, 1);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  639|      0|        buffercpy = cell_aux;
  640|      0|        memset(buffercpy, *ip, 16);
  641|      0|        ip++;
  642|      0|      } else if (token >= 224) { // three rows match
  ------------------
  |  Branch (642:18): [True: 0, False: 0]
  ------------------
  643|      0|        buffercpy = local_buffer;
  644|      0|        NDLZ4_CHECK_RANGE(cur + 1, 2);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  645|      0|        uint16_t offset;
  646|      0|        memcpy(&offset, ip, sizeof(offset));
  647|      0|        offset += 3;
  648|      0|        ip += 2;
  649|      0|        int i, j, k;
  650|      0|        if ((token >> 3U) == 28) {
  ------------------
  |  Branch (650:13): [True: 0, False: 0]
  ------------------
  651|      0|          i = 1;
  652|      0|          j = 2;
  653|      0|          k = 3;
  654|      0|        } else {
  655|      0|          i = 0;
  656|      0|          if ((token >> 3U) < 30) {
  ------------------
  |  Branch (656:15): [True: 0, False: 0]
  ------------------
  657|      0|            j = 1;
  658|      0|            k = 2;
  659|      0|          } else {
  660|      0|            k = 3;
  661|      0|            if ((token >> 3U) == 30) {
  ------------------
  |  Branch (661:17): [True: 0, False: 0]
  ------------------
  662|      0|              j = 1;
  663|      0|            } else {
  664|      0|              j = 2;
  665|      0|            }
  666|      0|          }
  667|      0|        }
  668|      0|        int64_t bpos = (cur + 3) - (int64_t) offset;   // == (ip - offset) as an offset
  669|      0|        NDLZ4_CHECK_RANGE(bpos, 12);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  670|      0|        const uint8_t *ref = (const uint8_t *) input + bpos;
  671|      0|        memcpy(&buffercpy[i * 4], ref, 4);
  672|      0|        memcpy(&buffercpy[j * 4], ref + 4, 4);
  673|      0|        memcpy(&buffercpy[k * 4], ref + 8, 4);
  674|      0|        for (int l = 0; l < 4; l++) {
  ------------------
  |  Branch (674:25): [True: 0, False: 0]
  ------------------
  675|      0|          if ((l != i) && (l != j) && (l != k)) {
  ------------------
  |  Branch (675:15): [True: 0, False: 0]
  |  Branch (675:27): [True: 0, False: 0]
  |  Branch (675:39): [True: 0, False: 0]
  ------------------
  676|      0|            NDLZ4_CHECK_RANGE(ip - (const uint8_t *) input, 4);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  677|      0|            memcpy(&buffercpy[l * 4], ip, 4);
  678|      0|            ip += 4;
  679|      0|            break;
  680|      0|          }
  681|      0|        }
  682|       |
  683|      0|      } else if ((token >= 128) && (token <= 191)) { // rows pair match
  ------------------
  |  Branch (683:18): [True: 0, False: 0]
  |  Branch (683:36): [True: 0, False: 0]
  ------------------
  684|      0|        buffercpy = local_buffer;
  685|      0|        NDLZ4_CHECK_RANGE(cur + 1, 2);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  686|      0|        uint16_t offset;
  687|      0|        memcpy(&offset, ip, sizeof(offset));
  688|      0|        offset += 3;
  689|      0|        ip += 2;
  690|      0|        int i, j;
  691|      0|        if (token == 128) {
  ------------------
  |  Branch (691:13): [True: 0, False: 0]
  ------------------
  692|      0|          i = 2;
  693|      0|          j = 3;
  694|      0|        } else {
  695|      0|          i = (token - 128) >> 5U;
  696|      0|          j = ((token - 128) >> 3U) - (i << 2U);
  697|      0|        }
  698|      0|        int64_t bpos = (cur + 3) - (int64_t) offset;
  699|      0|        NDLZ4_CHECK_RANGE(bpos, 8);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  700|      0|        const uint8_t *ref = (const uint8_t *) input + bpos;
  701|      0|        memcpy(&buffercpy[i * 4], ref, 4);
  702|      0|        memcpy(&buffercpy[j * 4], ref + 4, 4);
  703|      0|        for (int k = 0; k < 4; k++) {
  ------------------
  |  Branch (703:25): [True: 0, False: 0]
  ------------------
  704|      0|          if ((k != i) && (k != j)) {
  ------------------
  |  Branch (704:15): [True: 0, False: 0]
  |  Branch (704:27): [True: 0, False: 0]
  ------------------
  705|      0|            NDLZ4_CHECK_RANGE(ip - (const uint8_t *) input, 4);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  706|      0|            memcpy(&buffercpy[k * 4], ip, 4);
  707|      0|            ip += 4;
  708|      0|          }
  709|      0|        }
  710|      0|      } else if ((token >= 40) && (token <= 63)) {  // 2 rows pair matches
  ------------------
  |  Branch (710:18): [True: 0, False: 0]
  |  Branch (710:35): [True: 0, False: 0]
  ------------------
  711|      0|        buffercpy = local_buffer;
  712|      0|        NDLZ4_CHECK_RANGE(cur + 1, 2);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  713|      0|        uint16_t offset_1;
  714|      0|        memcpy(&offset_1, ip, sizeof(offset_1));
  715|      0|        offset_1 += 5;
  716|      0|        ip += 2;
  717|      0|        NDLZ4_CHECK_RANGE(cur + 3, 2);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  718|      0|        uint16_t offset_2;
  719|      0|        memcpy(&offset_2, ip, sizeof(offset_2));
  720|      0|        offset_2 += 5;
  721|      0|        ip += 2;
  722|      0|        int i, j, k, l, m;
  723|      0|        i = 0;
  724|      0|        j = ((token - 32) >> 3U);
  725|      0|        l = -1;
  726|      0|        for (k = 1; k < 4; k++) {
  ------------------
  |  Branch (726:21): [True: 0, False: 0]
  ------------------
  727|      0|          if ((k != i) && (k != j)) {
  ------------------
  |  Branch (727:15): [True: 0, False: 0]
  |  Branch (727:27): [True: 0, False: 0]
  ------------------
  728|      0|            if (l == -1) {
  ------------------
  |  Branch (728:17): [True: 0, False: 0]
  ------------------
  729|      0|              l = k;
  730|      0|            } else {
  731|      0|              m = k;
  732|      0|            }
  733|      0|          }
  734|      0|        }
  735|      0|        int64_t bpos1 = (cur + 5) - (int64_t) offset_1;
  736|      0|        NDLZ4_CHECK_RANGE(bpos1, 8);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  737|      0|        const uint8_t *ref1 = (const uint8_t *) input + bpos1;
  738|      0|        memcpy(&buffercpy[i * 4], ref1, 4);
  739|      0|        memcpy(&buffercpy[j * 4], ref1 + 4, 4);
  740|      0|        int64_t bpos2 = (cur + 5) - (int64_t) offset_2;
  741|      0|        NDLZ4_CHECK_RANGE(bpos2, 8);
  ------------------
  |  |  560|      0|  do {                                                                           \
  |  |  561|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  562|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  563|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (563:9): [True: 0, False: 0]
  |  |  |  Branch (563:21): [True: 0, False: 0]
  |  |  |  Branch (563:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  564|      0|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  565|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  566|      0|    }                                                                            \
  |  |  567|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (567:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  742|      0|        const uint8_t *ref2 = (const uint8_t *) input + bpos2;
  743|      0|        memcpy(&buffercpy[l * 4], ref2, 4);
  744|      0|        memcpy(&buffercpy[m * 4], ref2 + 4, 4);
  745|       |
  746|      0|      } else {
  747|      0|        BLOSC_TRACE_ERROR("Invalid token: %u at cell [%d, %d]\n", token, ii[0], ii[1]);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  748|      0|        return BLOSC2_ERROR_FAILURE;
  749|      0|      }
  750|       |      // fill op with buffercpy
  751|      0|      uint32_t orig = ii[0] * 4 * blockshape[1] + ii[1] * 4;
  752|      0|      for (uint32_t i = 0; i < 4; i++) {
  ------------------
  |  Branch (752:28): [True: 0, False: 0]
  ------------------
  753|      0|        if (i < padding[0]) {
  ------------------
  |  Branch (753:13): [True: 0, False: 0]
  ------------------
  754|      0|          ind = orig + i * blockshape[1];
  755|      0|          memcpy(&op[ind], buffercpy, padding[1]);
  756|       |          // Only advance over rows we actually consume.  For a literal cell
  757|       |          // (token == 0) buffercpy points into the input and only holds
  758|       |          // padding[0] * padding[1] bytes; advancing unconditionally for the
  759|       |          // trailing padding rows would form an out-of-bounds pointer (UB)
  760|       |          // for the block's last cell.  The skipped rows are never read.
  761|      0|          buffercpy += padding[1];
  762|      0|        }
  763|      0|      }
  764|      0|      if (ind > (uint32_t) output_len) {
  ------------------
  |  Branch (764:11): [True: 0, False: 0]
  ------------------
  765|      0|        BLOSC_TRACE_ERROR("Exceeding output size");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  766|      0|        return BLOSC2_ERROR_FAILURE;
  767|      0|      }
  768|      0|    }
  769|  42.0M|  }
  770|      2|  ind += padding[1];
  771|       |
  772|      2|  if ((int32_t)ind != (blockshape[0] * blockshape[1])) {
  ------------------
  |  Branch (772:7): [True: 0, False: 2]
  ------------------
  773|      0|    BLOSC_TRACE_ERROR("Output size is not compatible with embedded blockshape");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  774|      0|    return BLOSC2_ERROR_FAILURE;
  775|      0|  }
  776|      2|  if (ind > (uint32_t) output_len) {
  ------------------
  |  Branch (776:7): [True: 0, False: 2]
  ------------------
  777|      0|    BLOSC_TRACE_ERROR("Exceeding output size");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|      0|    return BLOSC2_ERROR_FAILURE;
  779|      0|  }
  780|       |
  781|      2|  return (int) ind;
  782|      2|#undef NDLZ4_CHECK_RANGE
  783|      2|}

ndlz8_decompress:
  444|     44|                     uint8_t meta, blosc2_dparams *dparams) {
  445|     44|  BLOSC_UNUSED_PARAM(meta);
  ------------------
  |  |   28|     44|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  446|     44|  BLOSC_UNUSED_PARAM(dparams);
  ------------------
  |  |   28|     44|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  447|     44|  BLOSC_ERROR_NULL(input, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|     44|    do {                                            \
  |  |  105|     44|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 44]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|     44|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 44]
  |  |  ------------------
  ------------------
  448|     44|  BLOSC_ERROR_NULL(output, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|     44|    do {                                            \
  |  |  105|     44|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 44]
  |  |  ------------------
  |  |  106|      0|            BLOSC_TRACE_ERROR("Pointer is null");   \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  107|      0|            return (rc);                            \
  |  |  108|      0|        }                                           \
  |  |  109|     44|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 44]
  |  |  ------------------
  ------------------
  449|       |
  450|     44|  const int cell_shape = 8;
  451|     44|  const int cell_size = 64;
  452|     44|  uint8_t *ip = (uint8_t *) input;
  453|     44|  uint8_t *op = (uint8_t *) output;
  454|     44|  uint8_t ndim;
  455|     44|  int32_t blockshape[2];
  456|     44|  int32_t eshape[2];
  457|     44|  uint8_t *buffercpy;
  458|     44|  uint8_t token;
  459|       |  // The fixed header is 1 (ndim) + 2 * int32 (blockshape) = 9 bytes.  Reject any
  460|       |  // input too short to hold it -- the previous `< 8` check let an 8-byte input
  461|       |  // through and the header parse below then read a 9th byte.  The cast keeps the
  462|       |  // comparison signed so a negative `input_len` is rejected here, before the
  463|       |  // `ip + input_len` pointer arithmetic (which would otherwise be UB) is reached.
  464|     44|  if (NDLZ_UNEXPECT_CONDITIONAL(input_len < (int32_t) (1 + 2 * sizeof(int32_t)))) {
  ------------------
  |  |   30|     44|#define NDLZ_UNEXPECT_CONDITIONAL(c)  (__builtin_expect((c), 0))
  |  |  ------------------
  |  |  |  Branch (30:39): [True: 1, False: 43]
  |  |  ------------------
  ------------------
  465|      1|    return 0;
  466|      1|  }
  467|     43|  uint8_t *ip_limit = ip + input_len;
  468|       |
  469|       |  /* we start with literal copy */
  470|     43|  ndim = *ip;
  471|     43|  ip++;
  472|     43|  if (ndim != 2) {
  ------------------
  |  Branch (472:7): [True: 0, False: 43]
  ------------------
  473|      0|    BLOSC_TRACE_ERROR("This codec only works for ndim = 2");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  474|      0|    return BLOSC2_ERROR_FAILURE;
  475|      0|  }
  476|     43|  memcpy(&blockshape[0], ip, 4);
  477|     43|  ip += 4;
  478|     43|  memcpy(&blockshape[1], ip, 4);
  479|     43|  ip += 4;
  480|       |
  481|       |  // Sanity check.  See https://www.cve.org/CVERecord?id=CVE-2024-3203
  482|     43|  if (output_len < 0 || blockshape[0] < 0 || blockshape[1] < 0) {
  ------------------
  |  Branch (482:7): [True: 0, False: 43]
  |  Branch (482:25): [True: 1, False: 42]
  |  Branch (482:46): [True: 7, False: 35]
  ------------------
  483|      8|    BLOSC_TRACE_ERROR("Output length or blockshape is negative");
  ------------------
  |  |   93|      8|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      8|    do {                                            \
  |  |  |  |   98|      8|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      8|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      8|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  484|      8|    return BLOSC2_ERROR_FAILURE;
  485|      8|  }
  486|       |
  487|     35|  eshape[0] = ((blockshape[0] + 7) / cell_shape) * cell_shape;
  488|     35|  eshape[1] = ((blockshape[1] + 7) / cell_shape) * cell_shape;
  489|       |
  490|     35|  if (NDLZ_UNEXPECT_CONDITIONAL((int64_t)output_len < (int64_t)blockshape[0] * (int64_t)blockshape[1])) {
  ------------------
  |  |   30|     35|#define NDLZ_UNEXPECT_CONDITIONAL(c)  (__builtin_expect((c), 0))
  |  |  ------------------
  |  |  |  Branch (30:39): [True: 34, False: 1]
  |  |  ------------------
  ------------------
  491|     34|    BLOSC_TRACE_ERROR("The blockshape is bigger than the output buffer");
  ------------------
  |  |   93|     34|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     34|    do {                                            \
  |  |  |  |   98|     34|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     34|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 34, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     34|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  492|     34|    return 0;
  493|     34|  }
  494|      1|  memset(op, 0, blockshape[0] * blockshape[1]);
  495|       |
  496|      1|  int32_t i_stop[2];
  497|      3|  for (int i = 0; i < 2; ++i) {
  ------------------
  |  Branch (497:19): [True: 2, False: 1]
  ------------------
  498|      2|    i_stop[i] = eshape[i] / cell_shape;
  499|      2|  }
  500|       |
  501|       |  /* main loop */
  502|      1|  int32_t ii[2];
  503|      1|  int32_t padding[2] = {0};
  504|      1|  int32_t ind = 0;
  505|      1|  uint8_t *local_buffer = malloc(cell_size);
  506|      1|  uint8_t *cell_aux = malloc(cell_size);
  507|       |
  508|       |  // Validate that a read of `len` bytes starting at byte offset `pos` (measured
  509|       |  // from the start of `input`) lies fully within the compressed buffer.  A
  510|       |  // crafted token `offset` otherwise makes a back-reference point before
  511|       |  // `input`, and the cell-fill memcpy then leaks out-of-bounds heap memory into
  512|       |  // the (attacker-visible) output -- CWE-125.  The per-cell `ip > ip_limit`
  513|       |  // check is not enough because each cell reads a 2-byte offset and literal
  514|       |  // bytes past that point.  All arithmetic is done on integer offsets so we
  515|       |  // never form an out-of-bounds pointer (undefined behaviour in C, even when the
  516|       |  // pointer is only compared and not dereferenced).
  517|      1|#define NDLZ8_CHECK_RANGE(pos, len)                                              \
  518|      1|  do {                                                                           \
  519|      1|    int64_t _pos = (int64_t) (pos);                                              \
  520|      1|    int64_t _len = (int64_t) (len);                                              \
  521|      1|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  522|      1|      free(local_buffer);                                                        \
  523|      1|      free(cell_aux);                                                            \
  524|      1|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  525|      1|      return BLOSC2_ERROR_FAILURE;                                               \
  526|      1|    }                                                                            \
  527|      1|  } while (0)
  528|       |
  529|   111M|  for (ii[0] = 0; ii[0] < i_stop[0]; ++ii[0]) {
  ------------------
  |  Branch (529:19): [True: 111M, False: 1]
  ------------------
  530|   111M|    for (ii[1] = 0; ii[1] < i_stop[1]; ++ii[1]) {      // for each cell
  ------------------
  |  Branch (530:21): [True: 0, False: 111M]
  ------------------
  531|      0|      if (NDLZ_UNEXPECT_CONDITIONAL(ip > ip_limit)) {
  ------------------
  |  |   30|      0|#define NDLZ_UNEXPECT_CONDITIONAL(c)  (__builtin_expect((c), 0))
  |  |  ------------------
  |  |  |  Branch (30:39): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  532|      0|        free(local_buffer);
  533|      0|        free(cell_aux);
  534|      0|        BLOSC_TRACE_ERROR("Exceeding input length");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  535|      0|        return BLOSC2_ERROR_FAILURE;
  536|      0|      }
  537|      0|      if (ii[0] == i_stop[0] - 1) {
  ------------------
  |  Branch (537:11): [True: 0, False: 0]
  ------------------
  538|      0|        padding[0] = (blockshape[0] % cell_shape == 0) ? cell_shape : blockshape[0] % cell_shape;
  ------------------
  |  Branch (538:22): [True: 0, False: 0]
  ------------------
  539|      0|      } else {
  540|      0|        padding[0] = cell_shape;
  541|      0|      }
  542|      0|      if (ii[1] == i_stop[1] - 1) {
  ------------------
  |  Branch (542:11): [True: 0, False: 0]
  ------------------
  543|      0|        padding[1] = (blockshape[1] % cell_shape == 0) ? cell_shape : blockshape[1] % cell_shape;
  ------------------
  |  Branch (543:22): [True: 0, False: 0]
  ------------------
  544|      0|      } else {
  545|      0|        padding[1] = cell_shape;
  546|      0|      }
  547|      0|      int64_t cur = ip - (const uint8_t *) input;   // in-range: ip is within [input, ip_limit]
  548|      0|      NDLZ8_CHECK_RANGE(cur, 1);
  ------------------
  |  |  518|      0|  do {                                                                           \
  |  |  519|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  520|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  521|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (521:9): [True: 0, False: 0]
  |  |  |  Branch (521:21): [True: 0, False: 0]
  |  |  |  Branch (521:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  522|      0|      free(local_buffer);                                                        \
  |  |  523|      0|      free(cell_aux);                                                            \
  |  |  524|      0|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  525|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  526|      0|    }                                                                            \
  |  |  527|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (527:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  549|      0|      token = *ip++;
  550|      0|      uint8_t match_type = (token >> 3U);
  551|      0|      if (token == 0) {    // no match
  ------------------
  |  Branch (551:11): [True: 0, False: 0]
  ------------------
  552|      0|        NDLZ8_CHECK_RANGE(cur + 1, (int64_t) padding[0] * padding[1]);
  ------------------
  |  |  518|      0|  do {                                                                           \
  |  |  519|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  520|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  521|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (521:9): [True: 0, False: 0]
  |  |  |  Branch (521:21): [True: 0, False: 0]
  |  |  |  Branch (521:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  522|      0|      free(local_buffer);                                                        \
  |  |  523|      0|      free(cell_aux);                                                            \
  |  |  524|      0|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  525|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  526|      0|    }                                                                            \
  |  |  527|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (527:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  553|      0|        buffercpy = ip;
  554|      0|        ip += padding[0] * padding[1];
  555|      0|      } else if (token == (uint8_t) ((1U << 7U) | (1U << 6U))) {  // cell match
  ------------------
  |  Branch (555:18): [True: 0, False: 0]
  ------------------
  556|      0|        NDLZ8_CHECK_RANGE(cur + 1, 2);
  ------------------
  |  |  518|      0|  do {                                                                           \
  |  |  519|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  520|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  521|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (521:9): [True: 0, False: 0]
  |  |  |  Branch (521:21): [True: 0, False: 0]
  |  |  |  Branch (521:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  522|      0|      free(local_buffer);                                                        \
  |  |  523|      0|      free(cell_aux);                                                            \
  |  |  524|      0|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  525|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  526|      0|    }                                                                            \
  |  |  527|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (527:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  557|      0|        uint16_t offset;
  558|      0|        memcpy(&offset, ip, sizeof(offset));
  559|      0|        int64_t bpos = (cur + 1) - (int64_t) offset - 1;
  560|      0|        NDLZ8_CHECK_RANGE(bpos, (int64_t) padding[0] * padding[1]);
  ------------------
  |  |  518|      0|  do {                                                                           \
  |  |  519|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  520|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  521|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (521:9): [True: 0, False: 0]
  |  |  |  Branch (521:21): [True: 0, False: 0]
  |  |  |  Branch (521:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  522|      0|      free(local_buffer);                                                        \
  |  |  523|      0|      free(cell_aux);                                                            \
  |  |  524|      0|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  525|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  526|      0|    }                                                                            \
  |  |  527|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (527:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  561|      0|        buffercpy = (uint8_t *) input + bpos;
  562|      0|        ip += 2;
  563|      0|      } else if (token == (uint8_t) (1U << 6U)) { // whole cell of same element
  ------------------
  |  Branch (563:18): [True: 0, False: 0]
  ------------------
  564|      0|        NDLZ8_CHECK_RANGE(cur + 1, 1);
  ------------------
  |  |  518|      0|  do {                                                                           \
  |  |  519|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  520|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  521|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (521:9): [True: 0, False: 0]
  |  |  |  Branch (521:21): [True: 0, False: 0]
  |  |  |  Branch (521:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  522|      0|      free(local_buffer);                                                        \
  |  |  523|      0|      free(cell_aux);                                                            \
  |  |  524|      0|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  525|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  526|      0|    }                                                                            \
  |  |  527|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (527:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  565|      0|        buffercpy = cell_aux;
  566|      0|        memset(buffercpy, *ip, cell_size);
  567|      0|        ip++;
  568|      0|      } else if (match_type == 21) {    // triple match
  ------------------
  |  Branch (568:18): [True: 0, False: 0]
  ------------------
  569|      0|        buffercpy = local_buffer;
  570|      0|        int row = (int) (token & 7);
  571|      0|        if (row + 2 >= cell_shape) {
  ------------------
  |  Branch (571:13): [True: 0, False: 0]
  ------------------
  572|      0|          free(local_buffer);
  573|      0|          free(cell_aux);
  574|      0|          BLOSC_TRACE_ERROR("Triple match row out of bounds");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|      0|          return BLOSC2_ERROR_FAILURE;
  576|      0|        }
  577|      0|        NDLZ8_CHECK_RANGE(cur + 1, 2);
  ------------------
  |  |  518|      0|  do {                                                                           \
  |  |  519|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  520|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  521|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (521:9): [True: 0, False: 0]
  |  |  |  Branch (521:21): [True: 0, False: 0]
  |  |  |  Branch (521:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  522|      0|      free(local_buffer);                                                        \
  |  |  523|      0|      free(cell_aux);                                                            \
  |  |  524|      0|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  525|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  526|      0|    }                                                                            \
  |  |  527|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (527:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  578|      0|        uint16_t offset;
  579|      0|        memcpy(&offset, ip, sizeof(offset));
  580|      0|        ip += 2;
  581|       |        // back-reference base == ip - sizeof(token) - sizeof(offset) - offset,
  582|       |        // i.e. (cur + 3) - 3 - offset == cur - offset, expressed as an offset.
  583|      0|        int64_t bpos = cur - (int64_t) offset;
  584|      0|        NDLZ8_CHECK_RANGE(bpos, 3 * cell_shape);
  ------------------
  |  |  518|      0|  do {                                                                           \
  |  |  519|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  520|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  521|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (521:9): [True: 0, False: 0]
  |  |  |  Branch (521:21): [True: 0, False: 0]
  |  |  |  Branch (521:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  522|      0|      free(local_buffer);                                                        \
  |  |  523|      0|      free(cell_aux);                                                            \
  |  |  524|      0|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  525|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  526|      0|    }                                                                            \
  |  |  527|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (527:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  585|      0|        const uint8_t *ref = (const uint8_t *) input + bpos;
  586|      0|        for (int l = 0; l < 3; l++) {
  ------------------
  |  Branch (586:25): [True: 0, False: 0]
  ------------------
  587|      0|          memcpy(&buffercpy[(row + l) * cell_shape], ref + l * cell_shape, cell_shape);
  588|      0|        }
  589|      0|        for (int l = 0; l < cell_shape; l++) {
  ------------------
  |  Branch (589:25): [True: 0, False: 0]
  ------------------
  590|      0|          if ((l < row) || (l > row + 2)) {
  ------------------
  |  Branch (590:15): [True: 0, False: 0]
  |  Branch (590:28): [True: 0, False: 0]
  ------------------
  591|      0|            NDLZ8_CHECK_RANGE(ip - (const uint8_t *) input, cell_shape);
  ------------------
  |  |  518|      0|  do {                                                                           \
  |  |  519|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  520|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  521|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (521:9): [True: 0, False: 0]
  |  |  |  Branch (521:21): [True: 0, False: 0]
  |  |  |  Branch (521:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  522|      0|      free(local_buffer);                                                        \
  |  |  523|      0|      free(cell_aux);                                                            \
  |  |  524|      0|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  525|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  526|      0|    }                                                                            \
  |  |  527|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (527:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  592|      0|            memcpy(&buffercpy[l * cell_shape], ip, cell_shape);
  593|      0|            ip += cell_shape;
  594|      0|          }
  595|      0|        }
  596|      0|      } else if (match_type == 17) {    // pair match
  ------------------
  |  Branch (596:18): [True: 0, False: 0]
  ------------------
  597|      0|        buffercpy = local_buffer;
  598|      0|        int row = (int) (token & 7);
  599|      0|        if (row + 1 >= cell_shape) {
  ------------------
  |  Branch (599:13): [True: 0, False: 0]
  ------------------
  600|      0|          free(local_buffer);
  601|      0|          free(cell_aux);
  602|      0|          BLOSC_TRACE_ERROR("Pair match row out of bounds");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  603|      0|          return BLOSC2_ERROR_FAILURE;
  604|      0|        }
  605|      0|        NDLZ8_CHECK_RANGE(cur + 1, 2);
  ------------------
  |  |  518|      0|  do {                                                                           \
  |  |  519|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  520|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  521|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (521:9): [True: 0, False: 0]
  |  |  |  Branch (521:21): [True: 0, False: 0]
  |  |  |  Branch (521:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  522|      0|      free(local_buffer);                                                        \
  |  |  523|      0|      free(cell_aux);                                                            \
  |  |  524|      0|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  525|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  526|      0|    }                                                                            \
  |  |  527|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (527:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  606|      0|        uint16_t offset;
  607|      0|        memcpy(&offset, ip, sizeof(offset));
  608|      0|        ip += 2;
  609|       |        // back-reference base == cur - offset (see triple-match note above).
  610|      0|        int64_t bpos = cur - (int64_t) offset;
  611|      0|        NDLZ8_CHECK_RANGE(bpos, 2 * cell_shape);
  ------------------
  |  |  518|      0|  do {                                                                           \
  |  |  519|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  520|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  521|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (521:9): [True: 0, False: 0]
  |  |  |  Branch (521:21): [True: 0, False: 0]
  |  |  |  Branch (521:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  522|      0|      free(local_buffer);                                                        \
  |  |  523|      0|      free(cell_aux);                                                            \
  |  |  524|      0|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  525|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  526|      0|    }                                                                            \
  |  |  527|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (527:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  612|      0|        const uint8_t *ref = (const uint8_t *) input + bpos;
  613|      0|        for (int l = 0; l < 2; l++) {
  ------------------
  |  Branch (613:25): [True: 0, False: 0]
  ------------------
  614|      0|          memcpy(&buffercpy[(row + l) * cell_shape], ref + l * cell_shape, cell_shape);
  615|      0|        }
  616|      0|        for (int l = 0; l < cell_shape; l++) {
  ------------------
  |  Branch (616:25): [True: 0, False: 0]
  ------------------
  617|      0|          if ((l < row) || (l > row + 1)) {
  ------------------
  |  Branch (617:15): [True: 0, False: 0]
  |  Branch (617:28): [True: 0, False: 0]
  ------------------
  618|      0|            NDLZ8_CHECK_RANGE(ip - (const uint8_t *) input, cell_shape);
  ------------------
  |  |  518|      0|  do {                                                                           \
  |  |  519|      0|    int64_t _pos = (int64_t) (pos);                                              \
  |  |  520|      0|    int64_t _len = (int64_t) (len);                                              \
  |  |  521|      0|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  |  |  ------------------
  |  |  |  Branch (521:9): [True: 0, False: 0]
  |  |  |  Branch (521:21): [True: 0, False: 0]
  |  |  |  Branch (521:33): [True: 0, False: 0]
  |  |  ------------------
  |  |  522|      0|      free(local_buffer);                                                        \
  |  |  523|      0|      free(cell_aux);                                                            \
  |  |  524|      0|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  |  |  ------------------
  |  |  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  525|      0|      return BLOSC2_ERROR_FAILURE;                                               \
  |  |  526|      0|    }                                                                            \
  |  |  527|      0|  } while (0)
  |  |  ------------------
  |  |  |  Branch (527:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  619|      0|            memcpy(&buffercpy[l * cell_shape], ip, cell_shape);
  620|      0|            ip += cell_shape;
  621|      0|          }
  622|      0|        }
  623|      0|      } else {
  624|      0|        free(local_buffer);
  625|      0|        free(cell_aux);
  626|      0|        BLOSC_TRACE_ERROR("Invalid token: %u at cell [%d, %d]\n", token, ii[0], ii[1]);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  627|      0|        return BLOSC2_ERROR_FAILURE;
  628|      0|      }
  629|       |
  630|      0|      int32_t orig = ii[0] * cell_shape * blockshape[1] + ii[1] * cell_shape;
  631|      0|      for (int32_t i = 0; i < (int32_t) cell_shape; i++) {
  ------------------
  |  Branch (631:27): [True: 0, False: 0]
  ------------------
  632|      0|        if (i < padding[0]) {
  ------------------
  |  Branch (632:13): [True: 0, False: 0]
  ------------------
  633|      0|          ind = orig + i * blockshape[1];
  634|      0|          memcpy(&op[ind], buffercpy, padding[1]);
  635|       |          // Only advance over rows we actually consume.  For a literal cell
  636|       |          // (token == 0) buffercpy points into the input and only holds
  637|       |          // padding[0] * padding[1] bytes; advancing unconditionally for the
  638|       |          // trailing padding rows would form an out-of-bounds pointer (UB)
  639|       |          // for the block's last cell.  The skipped rows are never read.
  640|      0|          buffercpy += padding[1];
  641|      0|        }
  642|      0|      }
  643|      0|      if (ind > output_len) {
  ------------------
  |  Branch (643:11): [True: 0, False: 0]
  ------------------
  644|      0|        free(local_buffer);
  645|      0|        free(cell_aux);
  646|      0|        BLOSC_TRACE_ERROR("Exceeding output size");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  647|      0|        return BLOSC2_ERROR_FAILURE;
  648|      0|      }
  649|      0|    }
  650|   111M|  }
  651|      1|  ind += padding[1];
  652|       |
  653|      1|  free(cell_aux);
  654|      1|  free(local_buffer);
  655|       |
  656|      1|  if (ind != (blockshape[0] * blockshape[1])) {
  ------------------
  |  Branch (656:7): [True: 0, False: 1]
  ------------------
  657|      0|    BLOSC_TRACE_ERROR("Output size is not compatible with embedded blockshape");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  658|      0|    return BLOSC2_ERROR_FAILURE;
  659|      0|  }
  660|      1|  if (ind > output_len) {
  ------------------
  |  Branch (660:7): [True: 0, False: 1]
  ------------------
  661|      0|    BLOSC_TRACE_ERROR("Exceeding output size");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  662|      0|    return BLOSC2_ERROR_FAILURE;
  663|      0|  }
  664|       |
  665|      1|  return (int) ind;
  666|      1|#undef NDLZ8_CHECK_RANGE
  667|      1|}

zfp_prec_decompress:
  607|      1|                        int32_t output_len, uint8_t meta, blosc2_dparams *dparams, const void *chunk) {
  608|      1|  ZFP_ERROR_NULL(input);
  ------------------
  |  |   22|      1|  do {                          \
  |  |   23|      1|    if ((pointer) == NULL) {    \
  |  |  ------------------
  |  |  |  Branch (23:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   24|      0|      return 0;                 \
  |  |   25|      0|    }                           \
  |  |   26|      1|  } while (0)
  |  |  ------------------
  |  |  |  Branch (26:12): [Folded, False: 1]
  |  |  ------------------
  ------------------
  609|      1|  ZFP_ERROR_NULL(output);
  ------------------
  |  |   22|      1|  do {                          \
  |  |   23|      1|    if ((pointer) == NULL) {    \
  |  |  ------------------
  |  |  |  Branch (23:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   24|      0|      return 0;                 \
  |  |   25|      0|    }                           \
  |  |   26|      1|  } while (0)
  |  |  ------------------
  |  |  |  Branch (26:12): [Folded, False: 1]
  |  |  ------------------
  ------------------
  610|      1|  ZFP_ERROR_NULL(dparams);
  ------------------
  |  |   22|      1|  do {                          \
  |  |   23|      1|    if ((pointer) == NULL) {    \
  |  |  ------------------
  |  |  |  Branch (23:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   24|      0|      return 0;                 \
  |  |   25|      0|    }                           \
  |  |   26|      1|  } while (0)
  |  |  ------------------
  |  |  |  Branch (26:12): [Folded, False: 1]
  |  |  ------------------
  ------------------
  611|      1|  ZFP_ERROR_NULL(dparams->schunk);
  ------------------
  |  |   22|      1|  do {                          \
  |  |   23|      1|    if ((pointer) == NULL) {    \
  |  |  ------------------
  |  |  |  Branch (23:9): [True: 1, False: 0]
  |  |  ------------------
  |  |   24|      1|      return 0;                 \
  |  |   25|      1|    }                           \
  |  |   26|      1|  } while (0)
  |  |  ------------------
  |  |  |  Branch (26:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  612|      0|  BLOSC_UNUSED_PARAM(chunk);
  ------------------
  |  |   28|      0|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  613|       |
  614|      0|  blosc2_schunk *sc = dparams->schunk;
  615|      0|  int32_t typesize = sc->typesize;
  616|      0|  int8_t ndim;
  617|      0|  int64_t *shape = malloc(B2ND_MAX_DIM * sizeof(int64_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  618|      0|  int32_t *chunkshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  619|      0|  int32_t *blockshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  620|      0|  uint8_t *smeta;
  621|      0|  int32_t smeta_len;
  622|      0|  if (blosc2_meta_get(sc, "b2nd", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (622:7): [True: 0, False: 0]
  ------------------
  623|      0|    BLOSC_TRACE_ERROR("Cannot access b2nd meta info");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  624|      0|    free(shape);
  625|      0|    free(chunkshape);
  626|      0|    free(blockshape);
  627|      0|    return BLOSC2_ERROR_FAILURE;
  628|      0|  }
  629|      0|  int deserialize_rc = b2nd_deserialize_meta(smeta, smeta_len, &ndim, shape, chunkshape, blockshape, NULL, NULL);
  630|      0|  free(smeta);
  631|       |
  632|      0|  if (zfp_check_output_size(deserialize_rc, ndim, blockshape, typesize, output_len) < 0) {
  ------------------
  |  Branch (632:7): [True: 0, False: 0]
  ------------------
  633|      0|    free(shape);
  634|      0|    free(chunkshape);
  635|      0|    free(blockshape);
  636|      0|    return BLOSC2_ERROR_FAILURE;
  637|      0|  }
  638|       |
  639|      0|  zfp_type type;     /* array scalar type */
  640|      0|  zfp_field *field;  /* array meta data */
  641|      0|  zfp_stream *zfp;   /* compressed stream */
  642|      0|  bitstream *stream = NULL; /* bit stream to write to or read from */
  643|      0|  uint8_t *padded_input = NULL;
  644|      0|  size_t zfpsize;    /* byte size of compressed stream */
  645|       |
  646|      0|  uint prec;
  647|      0|  switch (ndim) {
  648|      0|    case 1:
  ------------------
  |  Branch (648:5): [True: 0, False: 0]
  ------------------
  649|      0|      prec = meta + 5;
  650|      0|      break;
  651|      0|    case 2:
  ------------------
  |  Branch (651:5): [True: 0, False: 0]
  ------------------
  652|      0|      prec = meta + 7;
  653|      0|      break;
  654|      0|    case 3:
  ------------------
  |  Branch (654:5): [True: 0, False: 0]
  ------------------
  655|      0|      prec = meta + 9;
  656|      0|      break;
  657|      0|    case 4:
  ------------------
  |  Branch (657:5): [True: 0, False: 0]
  ------------------
  658|      0|      prec = meta + 11;
  659|      0|      break;
  660|      0|    default:
  ------------------
  |  Branch (660:5): [True: 0, False: 0]
  ------------------
  661|      0|      free(shape);
  662|      0|      free(chunkshape);
  663|      0|      free(blockshape);
  664|      0|      BLOSC_TRACE_ERROR("ZFP is not available for ndims: %d", ndim);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  665|      0|      return BLOSC2_ERROR_FAILURE;
  666|      0|  }
  667|       |
  668|      0|  if (prec > ZFP_MAX_PREC) {
  ------------------
  |  |   20|      0|#define ZFP_MAX_PREC    64 /* maximum precision supported */
  ------------------
  |  Branch (668:7): [True: 0, False: 0]
  ------------------
  669|      0|    BLOSC_TRACE_ERROR("Max precision for this codecs is %d", ZFP_MAX_PREC);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  669|      0|    BLOSC_TRACE_ERROR("Max precision for this codecs is %d", ZFP_MAX_PREC);
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   20|      0|#define ZFP_MAX_PREC    64 /* maximum precision supported */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  670|      0|    prec = ZFP_MAX_PREC;
  ------------------
  |  |   20|      0|#define ZFP_MAX_PREC    64 /* maximum precision supported */
  ------------------
  671|      0|  }
  672|       |
  673|      0|  switch (typesize) {
  674|      0|    case sizeof(float):
  ------------------
  |  Branch (674:5): [True: 0, False: 0]
  ------------------
  675|      0|      type = zfp_type_float;
  676|      0|      break;
  677|      0|    case sizeof(double):
  ------------------
  |  Branch (677:5): [True: 0, False: 0]
  ------------------
  678|      0|      type = zfp_type_double;
  679|      0|      break;
  680|      0|    default:
  ------------------
  |  Branch (680:5): [True: 0, False: 0]
  ------------------
  681|      0|      free(shape);
  682|      0|      free(chunkshape);
  683|      0|      free(blockshape);
  684|      0|      BLOSC_TRACE_ERROR("ZFP is not available for typesize: %d", typesize);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  685|      0|      return BLOSC2_ERROR_FAILURE;
  686|      0|  }
  687|       |
  688|      0|  zfp = zfp_stream_open(NULL);
  689|      0|  zfp_stream_set_precision(zfp, prec);
  690|       |
  691|      0|  switch (ndim) {
  692|      0|    case 1:
  ------------------
  |  Branch (692:5): [True: 0, False: 0]
  ------------------
  693|      0|      field = zfp_field_1d((void *) output, type, blockshape[0]);
  694|      0|      break;
  695|      0|    case 2:
  ------------------
  |  Branch (695:5): [True: 0, False: 0]
  ------------------
  696|      0|      field = zfp_field_2d((void *) output, type, blockshape[1], blockshape[0]);
  697|      0|      break;
  698|      0|    case 3:
  ------------------
  |  Branch (698:5): [True: 0, False: 0]
  ------------------
  699|      0|      field = zfp_field_3d((void *) output, type, blockshape[2], blockshape[1], blockshape[0]);
  700|      0|      break;
  701|      0|    case 4:
  ------------------
  |  Branch (701:5): [True: 0, False: 0]
  ------------------
  702|      0|      field = zfp_field_4d((void *) output, type, blockshape[3], blockshape[2], blockshape[1], blockshape[0]);
  703|      0|      break;
  704|      0|    default:
  ------------------
  |  Branch (704:5): [True: 0, False: 0]
  ------------------
  705|      0|      free(shape);
  706|      0|      free(chunkshape);
  707|      0|      free(blockshape);
  708|      0|      BLOSC_TRACE_ERROR("ZFP is not available for ndims: %d", ndim);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  709|      0|      return BLOSC2_ERROR_FAILURE;
  710|      0|  }
  711|       |
  712|      0|  size_t blocks = zfp_field_blocks(field);
  713|      0|  size_t min_bytes = (blocks + CHAR_BIT - 1) / CHAR_BIT;
  714|      0|  if (min_bytes < 1) {
  ------------------
  |  Branch (714:7): [True: 0, False: 0]
  ------------------
  715|      0|    min_bytes = 1;
  716|      0|  }
  717|      0|  if (input_len < 0 || (size_t) input_len < min_bytes) {
  ------------------
  |  Branch (717:7): [True: 0, False: 0]
  |  Branch (717:24): [True: 0, False: 0]
  ------------------
  718|      0|    BLOSC_TRACE_ERROR("ZFP prec: input too small (%d bytes) for the required "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  719|      0|                      "bitstream size (%zu bytes)", input_len, min_bytes);
  720|      0|    zfp_field_free(field);
  721|      0|    zfp_stream_close(zfp);
  722|      0|    free(shape);
  723|      0|    free(chunkshape);
  724|      0|    free(blockshape);
  725|      0|    return BLOSC2_ERROR_FAILURE;
  726|      0|  }
  727|       |
  728|      0|  if (zfp_open_padded_stream(input, input_len, zfp, field, &stream, &padded_input) != BLOSC2_ERROR_SUCCESS) {
  ------------------
  |  Branch (728:7): [True: 0, False: 0]
  ------------------
  729|      0|    zfp_field_free(field);
  730|      0|    zfp_stream_close(zfp);
  731|      0|    free(shape);
  732|      0|    free(chunkshape);
  733|      0|    free(blockshape);
  734|      0|    return BLOSC2_ERROR_FAILURE;
  735|      0|  }
  736|       |
  737|      0|  zfpsize = zfp_decompress(zfp, field);
  738|       |
  739|       |  /* clean up */
  740|      0|  zfp_field_free(field);
  741|      0|  zfp_stream_close(zfp);
  742|      0|  zfp_close_padded_stream(stream, padded_input);
  743|      0|  free(shape);
  744|      0|  free(chunkshape);
  745|      0|  free(blockshape);
  746|       |
  747|      0|  if (zfpsize == 0) {
  ------------------
  |  Branch (747:7): [True: 0, False: 0]
  ------------------
  748|      0|    BLOSC_TRACE_ERROR("\n ZFP: Decompression failed\n");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  749|      0|    return (int) zfpsize;
  750|      0|  }
  751|       |
  752|      0|  return (int) output_len;
  753|      0|}
zfp_rate_decompress:
  920|      1|                        int32_t output_len, uint8_t meta, blosc2_dparams *dparams, const void *chunk) {
  921|      1|  ZFP_ERROR_NULL(input);
  ------------------
  |  |   22|      1|  do {                          \
  |  |   23|      1|    if ((pointer) == NULL) {    \
  |  |  ------------------
  |  |  |  Branch (23:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   24|      0|      return 0;                 \
  |  |   25|      0|    }                           \
  |  |   26|      1|  } while (0)
  |  |  ------------------
  |  |  |  Branch (26:12): [Folded, False: 1]
  |  |  ------------------
  ------------------
  922|      1|  ZFP_ERROR_NULL(output);
  ------------------
  |  |   22|      1|  do {                          \
  |  |   23|      1|    if ((pointer) == NULL) {    \
  |  |  ------------------
  |  |  |  Branch (23:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   24|      0|      return 0;                 \
  |  |   25|      0|    }                           \
  |  |   26|      1|  } while (0)
  |  |  ------------------
  |  |  |  Branch (26:12): [Folded, False: 1]
  |  |  ------------------
  ------------------
  923|      1|  ZFP_ERROR_NULL(dparams);
  ------------------
  |  |   22|      1|  do {                          \
  |  |   23|      1|    if ((pointer) == NULL) {    \
  |  |  ------------------
  |  |  |  Branch (23:9): [True: 0, False: 1]
  |  |  ------------------
  |  |   24|      0|      return 0;                 \
  |  |   25|      0|    }                           \
  |  |   26|      1|  } while (0)
  |  |  ------------------
  |  |  |  Branch (26:12): [Folded, False: 1]
  |  |  ------------------
  ------------------
  924|      1|  ZFP_ERROR_NULL(dparams->schunk);
  ------------------
  |  |   22|      1|  do {                          \
  |  |   23|      1|    if ((pointer) == NULL) {    \
  |  |  ------------------
  |  |  |  Branch (23:9): [True: 1, False: 0]
  |  |  ------------------
  |  |   24|      1|      return 0;                 \
  |  |   25|      1|    }                           \
  |  |   26|      1|  } while (0)
  |  |  ------------------
  |  |  |  Branch (26:12): [Folded, False: 0]
  |  |  ------------------
  ------------------
  925|      0|  BLOSC_UNUSED_PARAM(chunk);
  ------------------
  |  |   28|      0|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  926|       |
  927|      0|  blosc2_schunk *sc = dparams->schunk;
  928|      0|  int32_t typesize = sc->typesize;
  929|       |
  930|      0|  double ratio = (double) meta / 100.0;
  931|      0|  int8_t ndim;
  932|      0|  int64_t *shape = malloc(B2ND_MAX_DIM * sizeof(int64_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  933|      0|  int32_t *chunkshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  934|      0|  int32_t *blockshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  935|      0|  uint8_t *smeta;
  936|      0|  int32_t smeta_len;
  937|      0|  if (blosc2_meta_get(sc, "b2nd", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (937:7): [True: 0, False: 0]
  ------------------
  938|      0|    BLOSC_TRACE_ERROR("Cannot access b2nd meta info");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  939|      0|    free(shape);
  940|      0|    free(chunkshape);
  941|      0|    free(blockshape);
  942|      0|    return BLOSC2_ERROR_FAILURE;
  943|      0|  }
  944|      0|  int deserialize_rc = b2nd_deserialize_meta(smeta, smeta_len, &ndim, shape, chunkshape, blockshape, NULL, NULL);
  945|      0|  free(smeta);
  946|       |
  947|      0|  if (zfp_check_output_size(deserialize_rc, ndim, blockshape, typesize, output_len) < 0) {
  ------------------
  |  Branch (947:7): [True: 0, False: 0]
  ------------------
  948|      0|    free(shape);
  949|      0|    free(chunkshape);
  950|      0|    free(blockshape);
  951|      0|    return BLOSC2_ERROR_FAILURE;
  952|      0|  }
  953|       |
  954|      0|  zfp_type type;     /* array scalar type */
  955|      0|  zfp_field *field;  /* array meta data */
  956|      0|  zfp_stream *zfp;   /* compressed stream */
  957|      0|  bitstream *stream = NULL; /* bit stream to write to or read from */
  958|      0|  uint8_t *padded_input = NULL;
  959|      0|  size_t zfpsize;    /* byte size of compressed stream */
  960|       |
  961|      0|  switch (typesize) {
  962|      0|    case sizeof(float):
  ------------------
  |  Branch (962:5): [True: 0, False: 0]
  ------------------
  963|      0|      type = zfp_type_float;
  964|      0|      break;
  965|      0|    case sizeof(double):
  ------------------
  |  Branch (965:5): [True: 0, False: 0]
  ------------------
  966|      0|      type = zfp_type_double;
  967|      0|      break;
  968|      0|    default:
  ------------------
  |  Branch (968:5): [True: 0, False: 0]
  ------------------
  969|      0|      free(shape);
  970|      0|      free(chunkshape);
  971|      0|      free(blockshape);
  972|      0|      BLOSC_TRACE_ERROR("ZFP is not available for typesize: %d", typesize);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  973|      0|      return BLOSC2_ERROR_FAILURE;
  974|      0|  }
  975|      0|  double rate =
  976|      0|      ratio * (double) typesize * 8;     // convert from output size / input size to output bits per input value
  977|      0|  zfp = zfp_stream_open(NULL);
  978|      0|  zfp_stream_set_rate(zfp, rate, type, ndim, zfp_false);
  979|       |
  980|      0|  switch (ndim) {
  981|      0|    case 1:
  ------------------
  |  Branch (981:5): [True: 0, False: 0]
  ------------------
  982|      0|      field = zfp_field_1d((void *) output, type, blockshape[0]);
  983|      0|      break;
  984|      0|    case 2:
  ------------------
  |  Branch (984:5): [True: 0, False: 0]
  ------------------
  985|      0|      field = zfp_field_2d((void *) output, type, blockshape[1], blockshape[0]);
  986|      0|      break;
  987|      0|    case 3:
  ------------------
  |  Branch (987:5): [True: 0, False: 0]
  ------------------
  988|      0|      field = zfp_field_3d((void *) output, type, blockshape[2], blockshape[1], blockshape[0]);
  989|      0|      break;
  990|      0|    case 4:
  ------------------
  |  Branch (990:5): [True: 0, False: 0]
  ------------------
  991|      0|      field = zfp_field_4d((void *) output, type, blockshape[3], blockshape[2], blockshape[1], blockshape[0]);
  992|      0|      break;
  993|      0|    default:
  ------------------
  |  Branch (993:5): [True: 0, False: 0]
  ------------------
  994|      0|      free(shape);
  995|      0|      free(chunkshape);
  996|      0|      free(blockshape);
  997|      0|      BLOSC_TRACE_ERROR("ZFP is not available for ndims: %d", ndim);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  998|      0|      return BLOSC2_ERROR_FAILURE;
  999|      0|  }
 1000|       |
 1001|      0|  size_t blocks = zfp_field_blocks(field);
 1002|      0|  uint n = 1u << (2 * ndim);
 1003|      0|  uint bits = (uint) floor(n * rate + 0.5);
 1004|      0|  switch (type) {
 1005|      0|    case zfp_type_float:
  ------------------
  |  Branch (1005:5): [True: 0, False: 0]
  ------------------
 1006|      0|      if (bits < 1 + 8u) {
  ------------------
  |  Branch (1006:11): [True: 0, False: 0]
  ------------------
 1007|      0|        bits = 1 + 8u;
 1008|      0|      }
 1009|      0|      break;
 1010|      0|    case zfp_type_double:
  ------------------
  |  Branch (1010:5): [True: 0, False: 0]
  ------------------
 1011|      0|      if (bits < 1 + 11u) {
  ------------------
  |  Branch (1011:11): [True: 0, False: 0]
  ------------------
 1012|      0|        bits = 1 + 11u;
 1013|      0|      }
 1014|      0|      break;
 1015|      0|    default:
  ------------------
  |  Branch (1015:5): [True: 0, False: 0]
  ------------------
 1016|      0|      break;
 1017|      0|  }
 1018|      0|  if (bits > 0 && blocks > SIZE_MAX / bits) {
  ------------------
  |  Branch (1018:7): [True: 0, False: 0]
  |  Branch (1018:19): [True: 0, False: 0]
  ------------------
 1019|      0|    BLOSC_TRACE_ERROR("ZFP rate: required bits overflow size_t");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1020|      0|    zfp_field_free(field);
 1021|      0|    zfp_stream_close(zfp);
 1022|      0|    free(shape);
 1023|      0|    free(chunkshape);
 1024|      0|    free(blockshape);
 1025|      0|    return BLOSC2_ERROR_FAILURE;
 1026|      0|  }
 1027|      0|  size_t required_bits = blocks * (size_t) bits;
 1028|      0|  size_t required_bytes = (required_bits + CHAR_BIT - 1) / CHAR_BIT;
 1029|      0|  if (required_bytes < 1) {
  ------------------
  |  Branch (1029:7): [True: 0, False: 0]
  ------------------
 1030|      0|    required_bytes = 1;
 1031|      0|  }
 1032|      0|  if (input_len < 0 || (size_t) input_len < required_bytes) {
  ------------------
  |  Branch (1032:7): [True: 0, False: 0]
  |  Branch (1032:24): [True: 0, False: 0]
  ------------------
 1033|      0|    BLOSC_TRACE_ERROR("ZFP rate: input too small (%d bytes) for the required "
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1034|      0|                      "bitstream size (%zu bytes)", input_len, required_bytes);
 1035|      0|    zfp_field_free(field);
 1036|      0|    zfp_stream_close(zfp);
 1037|      0|    free(shape);
 1038|      0|    free(chunkshape);
 1039|      0|    free(blockshape);
 1040|      0|    return BLOSC2_ERROR_FAILURE;
 1041|      0|  }
 1042|       |
 1043|      0|  if (zfp_open_padded_stream(input, input_len, zfp, field, &stream, &padded_input) != BLOSC2_ERROR_SUCCESS) {
  ------------------
  |  Branch (1043:7): [True: 0, False: 0]
  ------------------
 1044|      0|    zfp_field_free(field);
 1045|      0|    zfp_stream_close(zfp);
 1046|      0|    free(shape);
 1047|      0|    free(chunkshape);
 1048|      0|    free(blockshape);
 1049|      0|    return BLOSC2_ERROR_FAILURE;
 1050|      0|  }
 1051|       |
 1052|      0|  zfpsize = zfp_decompress(zfp, field);
 1053|       |
 1054|       |  /* clean up */
 1055|      0|  zfp_field_free(field);
 1056|      0|  zfp_stream_close(zfp);
 1057|      0|  zfp_close_padded_stream(stream, padded_input);
 1058|      0|  free(shape);
 1059|      0|  free(chunkshape);
 1060|      0|  free(blockshape);
 1061|       |
 1062|      0|  if (zfpsize == 0) {
  ------------------
  |  Branch (1062:7): [True: 0, False: 0]
  ------------------
 1063|      0|    BLOSC_TRACE_ERROR("\n ZFP: Decompression failed\n");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1064|      0|    return (int) zfpsize;
 1065|      0|  }
 1066|       |
 1067|      0|  return (int) output_len;
 1068|      0|}

simd_load:
   34|  2.58M|bytes16 simd_load(const void* ptr) { return _mm_loadu_si128((const __m128i*)ptr); }
simd_store:
   35|  2.58M|void simd_store(void* ptr, bytes16 x) { _mm_storeu_si128((__m128i*)ptr, x); }
simd_add:
   38|  2.58M|bytes16 simd_add(bytes16 a, bytes16 b) { return _mm_add_epi8(a, b); }
simd_duplane15:
   40|  2.58M|bytes16 simd_duplane15(bytes16 x) { return _mm_shuffle_epi8(x, _mm_set1_epi8(15)); }
simd_prefix_sum:
   43|  2.58M|{
   44|       |  // Sklansky-style sum from https://gist.github.com/rygorous/4212be0cd009584e4184e641ca210528
   45|  2.58M|  x = _mm_add_epi8(x, _mm_slli_epi64(x, 8));
   46|  2.58M|  x = _mm_add_epi8(x, _mm_slli_epi64(x, 16));
   47|  2.58M|  x = _mm_add_epi8(x, _mm_slli_epi64(x, 32));
   48|  2.58M|  x = _mm_add_epi8(x, _mm_shuffle_epi8(x, _mm_setr_epi8(-1,-1,-1,-1,-1,-1,-1,-1,7,7,7,7,7,7,7,7)));
   49|  2.58M|  return x;
   50|  2.58M|}
simd_get_last:
   52|  1.85k|uint8_t simd_get_last(bytes16 x) { return (_mm_extract_epi16(x, 7) >> 8) & 0xFF; }
bytedelta_backward:
  515|    137|                       blosc2_dparams *dparams, uint8_t id) {
  516|    137|  BLOSC_UNUSED_PARAM(id);
  ------------------
  |  |   28|    137|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  517|       |
  518|    137|  int typesize = meta;
  519|    137|  if (typesize == 0) {
  ------------------
  |  Branch (519:7): [True: 1, False: 136]
  ------------------
  520|      1|    if (dparams->schunk == NULL) {
  ------------------
  |  Branch (520:9): [True: 1, False: 0]
  ------------------
  521|      1|      BLOSC_TRACE_ERROR("When meta is 0, you need to be on a schunk!");
  ------------------
  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  522|      1|      BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      1|    do {                                            \
  |  |  112|      1|        int rc_ = (rc);                             \
  |  |  113|      1|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 1, False: 0]
  |  |  ------------------
  |  |  114|      1|            char *error_msg = print_error(rc_);     \
  |  |  115|      1|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      1|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      1|    do {                                            \
  |  |  |  |  |  |   98|      1|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      1|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 1, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      1|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      1|            return rc_;                             \
  |  |  117|      1|        }                                           \
  |  |  118|      1|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  523|      1|    }
  524|      0|    blosc2_schunk* schunk = (blosc2_schunk*)(dparams->schunk);
  525|      0|    typesize = schunk->typesize;
  526|      0|  }
  527|       |
  528|    136|  const int stream_len = length / typesize;
  529|  8.60k|  for (int ich = 0; ich < typesize; ++ich) {
  ------------------
  |  Branch (529:21): [True: 8.47k, False: 136]
  ------------------
  530|  8.47k|    int ip = 0;
  531|  8.47k|    uint8_t _v2 = 0;
  532|       |    // SIMD fetch 16 bytes from each channel, prefix-sum un-delta
  533|  8.47k|#if defined(CPU_HAS_SIMD)
  534|  8.47k|    bytes16 v2 = {0};
  535|  1.38M|    for (; ip < stream_len - 15; ip += 16) {
  ------------------
  |  Branch (535:12): [True: 1.37M, False: 8.47k]
  ------------------
  536|  1.37M|      bytes16 v = simd_load(input);
  537|  1.37M|      input += 16;
  538|       |      // un-delta via prefix sum
  539|  1.37M|      v2 = simd_add(simd_prefix_sum(v), simd_duplane15(v2));
  540|  1.37M|      simd_store(output, v2);
  541|  1.37M|      output += 16;
  542|  1.37M|    }
  543|  8.47k|    if (stream_len > 15) {
  ------------------
  |  Branch (543:9): [True: 1.85k, False: 6.61k]
  ------------------
  544|  1.85k|      _v2 = simd_get_last(v2);
  545|  1.85k|    }
  546|  8.47k|#endif // #if defined(CPU_HAS_SIMD)
  547|       |    // scalar leftover
  548|  27.9k|    for (; ip < stream_len; ip++) {
  ------------------
  |  Branch (548:12): [True: 19.5k, False: 8.47k]
  ------------------
  549|  19.5k|      uint8_t v = *input + _v2;
  550|  19.5k|      input++;
  551|  19.5k|      *output = v;
  552|  19.5k|      output++;
  553|  19.5k|      _v2 = v;
  554|  19.5k|    }
  555|  8.47k|  }
  556|       |
  557|       |  // Mirror of the forward pass: restore the trailing bytes verbatim.
  558|    136|  memcpy(output, input, (size_t)(length - stream_len * typesize));
  559|       |
  560|    136|  return BLOSC2_ERROR_SUCCESS;
  561|    137|}
bytedelta_backward_buggy:
  611|    156|                             uint8_t meta, blosc2_dparams *dparams, uint8_t id) {
  612|    156|  BLOSC_UNUSED_PARAM(id);
  ------------------
  |  |   28|    156|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  613|       |
  614|    156|  int typesize = meta;
  615|    156|  if (typesize == 0) {
  ------------------
  |  Branch (615:7): [True: 3, False: 153]
  ------------------
  616|      3|    if (dparams->schunk == NULL) {
  ------------------
  |  Branch (616:9): [True: 3, False: 0]
  ------------------
  617|      3|      BLOSC_TRACE_ERROR("When meta is 0, you need to be on a schunk!");
  ------------------
  |  |   93|      3|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      3|    do {                                            \
  |  |  |  |   98|      3|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      3|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      3|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  618|      3|      BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      3|    do {                                            \
  |  |  112|      3|        int rc_ = (rc);                             \
  |  |  113|      3|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 3, False: 0]
  |  |  ------------------
  |  |  114|      3|            char *error_msg = print_error(rc_);     \
  |  |  115|      3|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|      3|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|      3|    do {                                            \
  |  |  |  |  |  |   98|      3|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|      3|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 3, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|      3|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      3|            return rc_;                             \
  |  |  117|      3|        }                                           \
  |  |  118|      3|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  619|      3|    }
  620|      0|    blosc2_schunk* schunk = (blosc2_schunk*)(dparams->schunk);
  621|      0|    typesize = schunk->typesize;
  622|      0|  }
  623|       |
  624|    153|  const int stream_len = length / typesize;
  625|  14.2k|  for (int ich = 0; ich < typesize; ++ich) {
  ------------------
  |  Branch (625:21): [True: 14.0k, False: 153]
  ------------------
  626|  14.0k|    int ip = 0;
  627|       |    // SIMD fetch 16 bytes from each channel, prefix-sum un-delta
  628|  14.0k|#if defined(CPU_HAS_SIMD)
  629|  14.0k|    bytes16 v2 = {0};
  630|  1.21M|    for (; ip < stream_len - 15; ip += 16) {
  ------------------
  |  Branch (630:12): [True: 1.20M, False: 14.0k]
  ------------------
  631|  1.20M|      bytes16 v = simd_load(input);
  632|  1.20M|      input += 16;
  633|       |      // un-delta via prefix sum
  634|  1.20M|      v2 = simd_add(simd_prefix_sum(v), simd_duplane15(v2));
  635|  1.20M|      simd_store(output, v2);
  636|  1.20M|      output += 16;
  637|  1.20M|    }
  638|  14.0k|#endif // #if defined(CPU_HAS_SIMD)
  639|       |    // scalar leftover
  640|  14.0k|    uint8_t _v2 = 0;
  641|  51.9k|    for (; ip < stream_len; ip++) {
  ------------------
  |  Branch (641:12): [True: 37.9k, False: 14.0k]
  ------------------
  642|  37.9k|      uint8_t v = *input + _v2;
  643|  37.9k|      input++;
  644|  37.9k|      *output = v;
  645|  37.9k|      output++;
  646|  37.9k|      _v2 = v;
  647|  37.9k|    }
  648|  14.0k|  }
  649|       |
  650|    153|  return BLOSC2_ERROR_SUCCESS;
  651|    156|}

register_filters:
   15|  3.39k|void register_filters(void) {
   16|       |
   17|  3.39k|  blosc2_filter ndcell;
   18|  3.39k|  ndcell.id = BLOSC_FILTER_NDCELL;
   19|  3.39k|  ndcell.name = "ndcell";
   20|  3.39k|  ndcell.version = 1;
   21|  3.39k|  ndcell.forward = &ndcell_forward;
   22|  3.39k|  ndcell.backward = &ndcell_backward;
   23|  3.39k|  register_filter_private(&ndcell);
   24|       |
   25|  3.39k|  blosc2_filter ndmean;
   26|  3.39k|  ndmean.id = BLOSC_FILTER_NDMEAN;
   27|  3.39k|  ndmean.name = "ndmean";
   28|  3.39k|  ndmean.version = 1;
   29|  3.39k|  ndmean.forward = &ndmean_forward;
   30|  3.39k|  ndmean.backward = &ndmean_backward;
   31|  3.39k|  register_filter_private(&ndmean);
   32|       |
   33|       |  // Buggy version. See #524
   34|  3.39k|  blosc2_filter bytedelta_buggy;
   35|  3.39k|  bytedelta_buggy.id = BLOSC_FILTER_BYTEDELTA_BUGGY;
   36|  3.39k|  bytedelta_buggy.name = "bytedelta_buggy";
   37|  3.39k|  bytedelta_buggy.version = 1;
   38|  3.39k|  bytedelta_buggy.forward = &bytedelta_forward_buggy;
   39|  3.39k|  bytedelta_buggy.backward = &bytedelta_backward_buggy;
   40|  3.39k|  register_filter_private(&bytedelta_buggy);
   41|       |
   42|       |  // Fixed version. See #524
   43|  3.39k|  blosc2_filter bytedelta;
   44|  3.39k|  bytedelta.id = BLOSC_FILTER_BYTEDELTA;
   45|  3.39k|  bytedelta.name = "bytedelta";
   46|  3.39k|  bytedelta.version = 1;
   47|  3.39k|  bytedelta.forward = &bytedelta_forward;
   48|  3.39k|  bytedelta.backward = &bytedelta_backward;
   49|  3.39k|  register_filter_private(&bytedelta);
   50|       |
   51|  3.39k|  blosc2_filter int_trunc;
   52|  3.39k|  int_trunc.id = BLOSC_FILTER_INT_TRUNC;
   53|  3.39k|  int_trunc.name = "int_trunc";
   54|  3.39k|  int_trunc.version = 1;
   55|  3.39k|  int_trunc.forward = &int_trunc_forward;
   56|  3.39k|  int_trunc.backward = &int_trunc_backward;
   57|  3.39k|  register_filter_private(&int_trunc);
   58|       |
   59|  3.39k|}

int_trunc_backward:
  117|     25|                       blosc2_dparams *dparams, uint8_t id) {
  118|     25|  BLOSC_UNUSED_PARAM(id);
  ------------------
  |  |   28|     25|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  119|     25|  BLOSC_UNUSED_PARAM(dparams);
  ------------------
  |  |   28|     25|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  120|     25|  BLOSC_UNUSED_PARAM(meta);
  ------------------
  |  |   28|     25|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  121|       |
  122|       |  // Do a copy of the input buffer (truncation is lossy and cannot be reversed)
  123|     25|  memcpy(output, input, length);
  124|     25|  return BLOSC2_ERROR_SUCCESS;
  125|     25|}

ndcell_backward:
  205|      2|                   uint8_t id) {
  206|      2|  BLOSC_UNUSED_PARAM(id);
  ------------------
  |  |   28|      2|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  207|      2|  blosc2_schunk *schunk = dparams->schunk;
  208|      2|  int8_t ndim;
  209|      2|  int64_t *shape = malloc(B2ND_MAX_DIM * sizeof(int64_t));
  ------------------
  |  |   50|      2|#define B2ND_MAX_DIM 16
  ------------------
  210|      2|  int32_t *chunkshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      2|#define B2ND_MAX_DIM 16
  ------------------
  211|      2|  int32_t *blockshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      2|#define B2ND_MAX_DIM 16
  ------------------
  212|      2|  uint8_t *smeta;
  213|      2|  int32_t smeta_len;
  214|      2|  if (blosc2_meta_get(schunk, "b2nd", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (214:7): [True: 2, False: 0]
  ------------------
  215|      2|    free(shape);
  216|      2|    free(chunkshape);
  217|      2|    free(blockshape);
  218|      2|    BLOSC_TRACE_ERROR("b2nd layer not found!");
  ------------------
  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  219|      2|    return BLOSC2_ERROR_FAILURE;
  220|      2|  }
  221|      0|  if (b2nd_deserialize_meta(smeta, smeta_len, &ndim, shape, chunkshape, blockshape, NULL, NULL) < 0) {
  ------------------
  |  Branch (221:7): [True: 0, False: 0]
  ------------------
  222|      0|    free(smeta);
  223|      0|    free(shape);
  224|      0|    free(chunkshape);
  225|      0|    free(blockshape);
  226|      0|    return BLOSC2_ERROR_FAILURE;
  227|      0|  }
  228|      0|  free(smeta);
  229|      0|  if (ndim <= 0 || ndim > NDCELL_MAX_DIM) {
  ------------------
  |  |   16|      0|#define NDCELL_MAX_DIM 8
  ------------------
  |  Branch (229:7): [True: 0, False: 0]
  |  Branch (229:20): [True: 0, False: 0]
  ------------------
  230|      0|    free(shape);
  231|      0|    free(chunkshape);
  232|      0|    free(blockshape);
  233|      0|    BLOSC_TRACE_ERROR("ndim %d is out of range", ndim);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|      0|    return BLOSC2_ERROR_FAILURE;
  235|      0|  }
  236|       |
  237|       |  // `meta` is attacker-controlled in a crafted frame.  Interpret it as unsigned
  238|       |  // and reject 0: an (int8_t) cast would turn 128..255 into negative values and
  239|       |  // 0 would later divide by zero in `(blockshape[i] + cell_shape - 1) / cell_shape`.
  240|      0|  int cell_shape = (int) meta;
  241|      0|  if (cell_shape <= 0) {
  ------------------
  |  Branch (241:7): [True: 0, False: 0]
  ------------------
  242|      0|    free(shape);
  243|      0|    free(chunkshape);
  244|      0|    free(blockshape);
  245|      0|    BLOSC_TRACE_ERROR("Invalid cell_shape %d", cell_shape);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|      0|    return BLOSC2_ERROR_FAILURE;
  247|      0|  }
  248|       |  // See ndcell_forward(): compute cell_shape^ndim with checked 64-bit
  249|       |  // multiplication so an overflowing (int) pow() cannot bypass the
  250|       |  // "buffer smaller than cell" check below.
  251|      0|  int64_t cell_size = 1;
  252|      0|  for (int i = 0; i < ndim; i++) {
  ------------------
  |  Branch (252:19): [True: 0, False: 0]
  ------------------
  253|      0|    if (cell_size > INT64_MAX / cell_shape) {
  ------------------
  |  Branch (253:9): [True: 0, False: 0]
  ------------------
  254|      0|      free(shape);
  255|      0|      free(chunkshape);
  256|      0|      free(blockshape);
  257|      0|      BLOSC_TRACE_ERROR("cell_shape %d too large for ndim %d", cell_shape, ndim);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  258|      0|      return BLOSC2_ERROR_FAILURE;
  259|      0|    }
  260|      0|    cell_size *= cell_shape;
  261|      0|  }
  262|      0|  int32_t typesize = schunk->typesize;
  263|      0|  uint8_t *ip = (uint8_t *) input;
  264|      0|  uint8_t *ip_limit = ip + length;
  265|      0|  uint8_t *op = (uint8_t *) output;
  266|      0|  if (typesize <= 0) {
  ------------------
  |  Branch (266:7): [True: 0, False: 0]
  ------------------
  267|      0|    free(shape);
  268|      0|    free(chunkshape);
  269|      0|    free(blockshape);
  270|      0|    BLOSC_TRACE_ERROR("Invalid typesize %d", typesize);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  271|      0|    return BLOSC2_ERROR_FAILURE;
  272|      0|  }
  273|       |  // The block geometry (blockshape) comes from the attacker-controlled "b2nd"
  274|       |  // metalayer and is NOT validated by b2nd_deserialize_meta().  Compute the
  275|       |  // block size in 64-bit and reject non-positive dimensions.  Otherwise a
  276|       |  // crafted blockshape whose 32-bit product wraps back onto `length` would pass
  277|       |  // the check below, while the scatter-write index arithmetic further down uses
  278|       |  // the true (huge) dimensions, writing past the `length`-sized output buffer
  279|       |  // (heap overflow).  Bailing as soon as the running product exceeds `length`
  280|       |  // also keeps the 64-bit multiply from overflowing (it stays
  281|       |  // <= length * INT32_MAX < INT64_MAX).
  282|      0|  int64_t blocksize = (int64_t) typesize;
  283|      0|  for (int i = 0; i < ndim; i++) {
  ------------------
  |  Branch (283:19): [True: 0, False: 0]
  ------------------
  284|      0|    if (blockshape[i] <= 0) {
  ------------------
  |  Branch (284:9): [True: 0, False: 0]
  ------------------
  285|      0|      free(shape);
  286|      0|      free(chunkshape);
  287|      0|      free(blockshape);
  288|      0|      BLOSC_TRACE_ERROR("Invalid blockshape[%d] = %d", i, blockshape[i]);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  289|      0|      return BLOSC2_ERROR_FAILURE;
  290|      0|    }
  291|      0|    blocksize *= blockshape[i];
  292|      0|    if (blocksize > (int64_t) length) {
  ------------------
  |  Branch (292:9): [True: 0, False: 0]
  ------------------
  293|      0|      free(shape);
  294|      0|      free(chunkshape);
  295|      0|      free(blockshape);
  296|      0|      BLOSC_TRACE_ERROR("blockshape too large for block of %d bytes", length);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|      0|      return BLOSC2_ERROR_FAILURE;
  298|      0|    }
  299|      0|  }
  300|       |
  301|      0|  if ((int64_t) length != blocksize) {
  ------------------
  |  Branch (301:7): [True: 0, False: 0]
  ------------------
  302|      0|    free(shape);
  303|      0|    free(chunkshape);
  304|      0|    free(blockshape);
  305|      0|    BLOSC_TRACE_ERROR("Length not equal to blocksize %d %lld", length, (long long) blocksize);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  306|      0|    return BLOSC2_ERROR_FAILURE;
  307|      0|  }
  308|       |
  309|       |  // length is a multiple of typesize here (length == blocksize, checked above),
  310|       |  // so the division is exact; phrasing the check this way avoids overflowing the
  311|       |  // cell_size * typesize product.
  312|      0|  if (cell_size > (int64_t) length / typesize) {
  ------------------
  |  Branch (312:7): [True: 0, False: 0]
  ------------------
  313|      0|    free(shape);
  314|      0|    free(chunkshape);
  315|      0|    free(blockshape);
  316|      0|    BLOSC_TRACE_ERROR("input and output buffer cannot be smaller than cell size");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  317|      0|    return BLOSC2_ERROR_FAILURE;
  318|      0|  }
  319|       |
  320|      0|  int64_t i_shape[NDCELL_MAX_DIM];
  321|      0|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (321:19): [True: 0, False: 0]
  ------------------
  322|      0|    i_shape[i] = (blockshape[i] + cell_shape - 1) / cell_shape;
  323|      0|  }
  324|       |
  325|      0|  int64_t ncells = 1;
  326|      0|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (326:19): [True: 0, False: 0]
  ------------------
  327|      0|    ncells *= i_shape[i];
  328|      0|  }
  329|       |
  330|       |  /* main loop */
  331|      0|  int64_t pad_shape[NDCELL_MAX_DIM] = {0};
  332|      0|  int64_t ii[NDCELL_MAX_DIM];
  333|      0|  int32_t ind = 0;
  334|      0|  for (int cell_ind = 0; cell_ind < ncells; cell_ind++) {      // for each cell
  ------------------
  |  Branch (334:26): [True: 0, False: 0]
  ------------------
  335|       |
  336|      0|    if (ip > ip_limit) {
  ------------------
  |  Branch (336:9): [True: 0, False: 0]
  ------------------
  337|      0|      free(shape);
  338|      0|      free(chunkshape);
  339|      0|      free(blockshape);
  340|      0|      BLOSC_TRACE_ERROR("Exceeding input length!");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|      0|      return BLOSC2_ERROR_FAILURE;
  342|      0|    }
  343|      0|    blosc2_unidim_to_multidim(ndim, i_shape, cell_ind, ii);
  344|      0|    uint32_t orig = 0;
  345|      0|    int64_t nd_aux = (int64_t) cell_shape;
  346|      0|    for (int i = ndim - 1; i >= 0; i--) {
  ------------------
  |  Branch (346:28): [True: 0, False: 0]
  ------------------
  347|      0|      orig += ii[i] * nd_aux;
  348|      0|      nd_aux *= blockshape[i];
  349|      0|    }
  350|       |
  351|      0|    for (int dim_ind = 0; dim_ind < ndim; dim_ind++) {
  ------------------
  |  Branch (351:27): [True: 0, False: 0]
  ------------------
  352|      0|      if ((blockshape[dim_ind] % cell_shape != 0) && (ii[dim_ind] == i_shape[dim_ind] - 1)) {
  ------------------
  |  Branch (352:11): [True: 0, False: 0]
  |  Branch (352:54): [True: 0, False: 0]
  ------------------
  353|      0|        pad_shape[dim_ind] = blockshape[dim_ind] % cell_shape;
  354|      0|      } else {
  355|      0|        pad_shape[dim_ind] = (int64_t) cell_shape;
  356|      0|      }
  357|      0|    }
  358|       |
  359|      0|    int64_t ncopies = 1;
  360|      0|    for (int i = 0; i < ndim - 1; ++i) {
  ------------------
  |  Branch (360:21): [True: 0, False: 0]
  ------------------
  361|      0|      ncopies *= pad_shape[i];
  362|      0|    }
  363|      0|    int64_t kk[NDCELL_MAX_DIM];
  364|      0|    for (int copy_ind = 0; copy_ind < ncopies; ++copy_ind) {
  ------------------
  |  Branch (364:28): [True: 0, False: 0]
  ------------------
  365|      0|      blosc2_unidim_to_multidim(ndim - 1, pad_shape, copy_ind, kk);
  366|      0|      nd_aux = blockshape[ndim - 1];
  367|      0|      ind = (int32_t) orig;
  368|      0|      for (int i = ndim - 2; i >= 0; i--) {
  ------------------
  |  Branch (368:30): [True: 0, False: 0]
  ------------------
  369|      0|        ind += (int32_t) (kk[i] * nd_aux);
  370|      0|        nd_aux *= blockshape[i];
  371|      0|      }
  372|      0|      memcpy(&op[ind * typesize], ip, pad_shape[ndim - 1] * typesize);
  373|      0|      ip += pad_shape[ndim - 1] * typesize;
  374|      0|    }
  375|      0|  }
  376|      0|  ind += (int32_t) pad_shape[ndim - 1];
  377|       |
  378|       |
  379|      0|  if (ind != (int32_t) (blocksize / typesize)) {
  ------------------
  |  Branch (379:7): [True: 0, False: 0]
  ------------------
  380|      0|    free(shape);
  381|      0|    free(chunkshape);
  382|      0|    free(blockshape);
  383|      0|    BLOSC_TRACE_ERROR("Output size is not compatible with embedded blockshape ind %d %lld \n",
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  384|      0|                      ind, (long long) (blocksize / typesize));
  385|      0|    return BLOSC2_ERROR_FAILURE;
  386|      0|  }
  387|       |
  388|      0|  free(shape);
  389|      0|  free(chunkshape);
  390|      0|  free(blockshape);
  391|       |
  392|      0|  return BLOSC2_ERROR_SUCCESS;
  393|      0|}

ndmean_backward:
  243|      2|                   uint8_t id) {
  244|      2|  BLOSC_UNUSED_PARAM(id);
  ------------------
  |  |   28|      2|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  245|      2|  blosc2_schunk *schunk = dparams->schunk;
  246|      2|  int8_t ndim;
  247|       |  // b2nd_deserialize_meta() writes up to B2ND_MAX_DIM entries (it only validates
  248|       |  // ndim <= B2ND_MAX_DIM), so the destination buffers must be sized accordingly,
  249|       |  // not for NDMEAN_MAX_DIM.  Otherwise a crafted b2nd metalayer with
  250|       |  // NDMEAN_MAX_DIM < ndim <= B2ND_MAX_DIM overflows these allocations.
  251|      2|  int64_t *shape = malloc(B2ND_MAX_DIM * sizeof(int64_t));
  ------------------
  |  |   50|      2|#define B2ND_MAX_DIM 16
  ------------------
  252|      2|  int32_t *chunkshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      2|#define B2ND_MAX_DIM 16
  ------------------
  253|      2|  int32_t *blockshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      2|#define B2ND_MAX_DIM 16
  ------------------
  254|      2|  uint8_t *smeta;
  255|      2|  int32_t smeta_len;
  256|      2|  if (blosc2_meta_get(schunk, "b2nd", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (256:7): [True: 2, False: 0]
  ------------------
  257|      2|    free(shape);
  258|      2|    free(chunkshape);
  259|      2|    free(blockshape);
  260|      2|    BLOSC_TRACE_ERROR("b2nd layer not found!");
  ------------------
  |  |   93|      2|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      2|    do {                                            \
  |  |  |  |   98|      2|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      2|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      2|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  261|      2|    return BLOSC2_ERROR_FAILURE;
  262|      2|  }
  263|      0|  if (b2nd_deserialize_meta(smeta, smeta_len, &ndim, shape, chunkshape, blockshape, NULL, NULL) < 0) {
  ------------------
  |  Branch (263:7): [True: 0, False: 0]
  ------------------
  264|      0|    free(smeta);
  265|      0|    free(shape);
  266|      0|    free(chunkshape);
  267|      0|    free(blockshape);
  268|      0|    BLOSC_TRACE_ERROR("Cannot deserialize b2nd metalayer");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  269|      0|    return BLOSC2_ERROR_FAILURE;
  270|      0|  }
  271|      0|  free(smeta);
  272|       |  // Guard the fixed-size (NDMEAN_MAX_DIM) stack arrays used below.
  273|      0|  if (ndim <= 0 || ndim > NDMEAN_MAX_DIM) {
  ------------------
  |  |   16|      0|#define NDMEAN_MAX_DIM 8
  ------------------
  |  Branch (273:7): [True: 0, False: 0]
  |  Branch (273:20): [True: 0, False: 0]
  ------------------
  274|      0|    free(shape);
  275|      0|    free(chunkshape);
  276|      0|    free(blockshape);
  277|      0|    BLOSC_TRACE_ERROR("ndim %d is out of range", ndim);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  278|      0|    return BLOSC2_ERROR_FAILURE;
  279|      0|  }
  280|       |
  281|       |  // `meta` carries the NDMEAN cell shape and is attacker-controlled (it is the
  282|       |  // chunk-header filters_meta byte).  It is cast to int8_t and used as the
  283|       |  // divisor when building i_shape[] below, so a value of 0 (divide-by-zero) or
  284|       |  // one that becomes negative after the cast (meta > INT8_MAX) would crash or
  285|       |  // produce bogus, out-of-range geometry (e.g. a negative pad_shape feeding a
  286|       |  // huge memcpy).  Require a positive cell shape.
  287|      0|  if ((int8_t) meta <= 0) {
  ------------------
  |  Branch (287:7): [True: 0, False: 0]
  ------------------
  288|      0|    free(shape);
  289|      0|    free(chunkshape);
  290|      0|    free(blockshape);
  291|      0|    BLOSC_TRACE_ERROR("Invalid cell shape (meta) %d", (int) meta);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  292|      0|    return BLOSC2_ERROR_FAILURE;
  293|      0|  }
  294|       |
  295|      0|  int8_t cellshape[8];
  296|      0|  int64_t cell_size = 1;  // 64-bit: prod(cellshape) can reach 127^ndim, which overflows int
  297|      0|  for (int i = 0; i < 8; ++i) {
  ------------------
  |  Branch (297:19): [True: 0, False: 0]
  ------------------
  298|      0|    if (i < ndim) {
  ------------------
  |  Branch (298:9): [True: 0, False: 0]
  ------------------
  299|      0|      cellshape[i] = (int8_t) meta;
  300|      0|      if (cellshape[i] > blockshape[i]) {
  ------------------
  |  Branch (300:11): [True: 0, False: 0]
  ------------------
  301|      0|        cellshape[i] = (int8_t) blockshape[i];
  302|      0|      }
  303|      0|      cell_size *= cellshape[i];
  304|      0|    } else {
  305|      0|      cellshape[i] = 1;
  306|      0|    }
  307|      0|  }
  308|       |
  309|      0|  int8_t typesize = (int8_t) schunk->typesize;
  310|      0|  uint8_t *ip = (uint8_t *) input;
  311|      0|  uint8_t *ip_limit = ip + length;
  312|      0|  uint8_t *op = (uint8_t *) output;
  313|      0|  if (typesize <= 0) {
  ------------------
  |  Branch (313:7): [True: 0, False: 0]
  ------------------
  314|      0|    free(shape);
  315|      0|    free(chunkshape);
  316|      0|    free(blockshape);
  317|      0|    BLOSC_TRACE_ERROR("Invalid typesize %d", typesize);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  318|      0|    return BLOSC2_ERROR_FAILURE;
  319|      0|  }
  320|       |  // The block geometry (blockshape) comes from the attacker-controlled "b2nd"
  321|       |  // metalayer and is NOT validated by b2nd_deserialize_meta().  Compute the
  322|       |  // block size in 64-bit and reject non-positive dimensions.  Otherwise a
  323|       |  // crafted blockshape whose 32-bit product wraps back onto `length` would pass
  324|       |  // the check below, while the scatter-write index arithmetic further down uses
  325|       |  // the true (huge) dimensions, writing past the `length`-sized output buffer
  326|       |  // (heap overflow).  Bailing as soon as the running product exceeds `length`
  327|       |  // also keeps the 64-bit multiply from overflowing.
  328|      0|  int64_t blocksize = (int64_t) typesize;
  329|      0|  for (int i = 0; i < ndim; i++) {
  ------------------
  |  Branch (329:19): [True: 0, False: 0]
  ------------------
  330|      0|    if (blockshape[i] <= 0) {
  ------------------
  |  Branch (330:9): [True: 0, False: 0]
  ------------------
  331|      0|      free(shape);
  332|      0|      free(chunkshape);
  333|      0|      free(blockshape);
  334|      0|      BLOSC_TRACE_ERROR("Invalid blockshape[%d] = %d", i, blockshape[i]);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  335|      0|      return BLOSC2_ERROR_FAILURE;
  336|      0|    }
  337|      0|    blocksize *= blockshape[i];
  338|      0|    if (blocksize > (int64_t) length) {
  ------------------
  |  Branch (338:9): [True: 0, False: 0]
  ------------------
  339|      0|      free(shape);
  340|      0|      free(chunkshape);
  341|      0|      free(blockshape);
  342|      0|      BLOSC_TRACE_ERROR("blockshape too large for block of %d bytes", length);
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  343|      0|      return BLOSC2_ERROR_FAILURE;
  344|      0|    }
  345|      0|  }
  346|       |
  347|      0|  if ((int64_t) length != blocksize) {
  ------------------
  |  Branch (347:7): [True: 0, False: 0]
  ------------------
  348|      0|    free(shape);
  349|      0|    free(chunkshape);
  350|      0|    free(blockshape);
  351|      0|    BLOSC_TRACE_ERROR("Length not equal to blocksize");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  352|      0|    return BLOSC2_ERROR_FAILURE;
  353|      0|  }
  354|       |
  355|      0|  if (length < cell_size * typesize) {
  ------------------
  |  Branch (355:7): [True: 0, False: 0]
  ------------------
  356|      0|    free(shape);
  357|      0|    free(chunkshape);
  358|      0|    free(blockshape);
  359|      0|    BLOSC_TRACE_ERROR("input and output buffer cannot be smaller than cell size");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  360|      0|    return BLOSC2_ERROR_FAILURE;
  361|      0|  }
  362|       |
  363|      0|  int64_t i_shape[NDMEAN_MAX_DIM];
  364|      0|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (364:19): [True: 0, False: 0]
  ------------------
  365|      0|    i_shape[i] = (blockshape[i] + cellshape[i] - 1) / cellshape[i];
  366|      0|  }
  367|       |
  368|      0|  int64_t ncells = 1;
  369|      0|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (369:19): [True: 0, False: 0]
  ------------------
  370|      0|    ncells *= i_shape[i];
  371|      0|  }
  372|       |
  373|       |  /* main loop */
  374|      0|  int64_t pad_shape[NDMEAN_MAX_DIM] = {0};
  375|      0|  int64_t ii[NDMEAN_MAX_DIM];
  376|      0|  int32_t ind = 0;
  377|      0|  for (int cell_ind = 0; cell_ind < ncells; cell_ind++) {      // for each cell
  ------------------
  |  Branch (377:26): [True: 0, False: 0]
  ------------------
  378|       |
  379|      0|    if (ip > ip_limit) {
  ------------------
  |  Branch (379:9): [True: 0, False: 0]
  ------------------
  380|      0|      free(shape);
  381|      0|      free(chunkshape);
  382|      0|      free(blockshape);
  383|      0|      BLOSC_TRACE_ERROR("Exceeding input length!");
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  384|      0|      return BLOSC2_ERROR_FAILURE;
  385|      0|    }
  386|      0|    blosc2_unidim_to_multidim(ndim, i_shape, cell_ind, ii);
  387|      0|    uint32_t orig = 0;
  388|      0|    int64_t nd_aux = (int64_t) (cellshape[0]);
  389|      0|    for (int i = ndim - 1; i >= 0; i--) {
  ------------------
  |  Branch (389:28): [True: 0, False: 0]
  ------------------
  390|      0|      orig += ii[i] * nd_aux;
  391|      0|      nd_aux *= blockshape[i];
  392|      0|    }
  393|       |
  394|      0|    for (int dim_ind = 0; dim_ind < ndim; dim_ind++) {
  ------------------
  |  Branch (394:27): [True: 0, False: 0]
  ------------------
  395|      0|      if ((blockshape[dim_ind] % cellshape[dim_ind] != 0) && (ii[dim_ind] == i_shape[dim_ind] - 1)) {
  ------------------
  |  Branch (395:11): [True: 0, False: 0]
  |  Branch (395:62): [True: 0, False: 0]
  ------------------
  396|      0|        pad_shape[dim_ind] = blockshape[dim_ind] % cellshape[dim_ind];
  397|      0|      } else {
  398|      0|        pad_shape[dim_ind] = (int64_t) cellshape[dim_ind];
  399|      0|      }
  400|      0|    }
  401|       |
  402|      0|    int64_t ncopies = 1;
  403|      0|    for (int i = 0; i < ndim - 1; ++i) {
  ------------------
  |  Branch (403:21): [True: 0, False: 0]
  ------------------
  404|      0|      ncopies *= pad_shape[i];
  405|      0|    }
  406|      0|    int64_t kk[NDMEAN_MAX_DIM];
  407|      0|    for (int copy_ind = 0; copy_ind < ncopies; ++copy_ind) {
  ------------------
  |  Branch (407:28): [True: 0, False: 0]
  ------------------
  408|      0|      blosc2_unidim_to_multidim((int8_t) (ndim - 1), pad_shape, copy_ind, kk);
  409|      0|      nd_aux = blockshape[ndim - 1];
  410|      0|      ind = (int32_t) orig;
  411|      0|      for (int i = ndim - 2; i >= 0; i--) {
  ------------------
  |  Branch (411:30): [True: 0, False: 0]
  ------------------
  412|      0|        ind += (int32_t) (kk[i] * nd_aux);
  413|      0|        nd_aux *= blockshape[i];
  414|      0|      }
  415|      0|      memcpy(&op[ind * typesize], ip, pad_shape[ndim - 1] * typesize);
  416|      0|      ip += pad_shape[ndim - 1] * typesize;
  417|      0|    }
  418|      0|  }
  419|      0|  ind += (int32_t) pad_shape[ndim - 1];
  420|       |
  421|      0|  free(shape);
  422|      0|  free(chunkshape);
  423|      0|  free(blockshape);
  424|       |
  425|      0|  if (ind != (int32_t) (blocksize / typesize)) {
  ------------------
  |  Branch (425:7): [True: 0, False: 0]
  ------------------
  426|      0|    BLOSC_TRACE_ERROR("Output size is not compatible with embedded blockshape ind %d %lld \n",
  ------------------
  |  |   93|      0|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      0|    do {                                            \
  |  |  |  |   98|      0|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      0|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  427|      0|                      ind, (long long) (blocksize / typesize));
  428|      0|    return BLOSC2_ERROR_FAILURE;
  429|      0|  }
  430|       |
  431|      0|  return BLOSC2_ERROR_SUCCESS;
  432|      0|}

register_tuners:
   13|  3.39k|void register_tuners(void) {
   14|       |
   15|  3.39k|  blosc2_tuner btune;
   16|  3.39k|  btune.id = BLOSC_BTUNE;
   17|  3.39k|  btune.name = "btune";
   18|  3.39k|  btune.init = NULL;
   19|  3.39k|  btune.next_cparams = NULL;
   20|  3.39k|  btune.next_blocksize = NULL;
   21|  3.39k|  btune.update = NULL;
   22|  3.39k|  btune.free = NULL;
   23|       |
   24|  3.39k|  register_tuner_private(&btune);
   25|  3.39k|}

LLVMFuzzerTestOneInput:
   50|  3.39k|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   51|  3.39k|  tail_reader r = {data, size};
   52|       |
   53|  3.39k|  if (size < 16) {
  ------------------
  |  Branch (53:7): [True: 0, False: 3.39k]
  ------------------
   54|      0|    return 0;
   55|      0|  }
   56|       |
   57|  3.39k|  uint8_t mode = (uint8_t)(tail_u8(&r) % 5);
   58|  3.39k|  int8_t ndim = (int8_t)(tail_u8(&r) % FUZZ_MAX_DIM + 1);
  ------------------
  |  |   29|  3.39k|#define FUZZ_MAX_DIM 16        /* B2ND_MAX_DIM */
  ------------------
   59|  3.39k|  uint8_t typesize = (uint8_t)(tail_u8(&r) % 8 + 1);
   60|       |
   61|  3.39k|  int64_t shape[FUZZ_MAX_DIM] = {0};
   62|  3.39k|  int32_t chunkshape[FUZZ_MAX_DIM] = {0};
   63|  3.39k|  int32_t blockshape[FUZZ_MAX_DIM] = {0};
   64|  3.39k|  int64_t start[FUZZ_MAX_DIM] = {0};
   65|  3.39k|  int64_t stop[FUZZ_MAX_DIM] = {0};
   66|  3.39k|  int64_t diff[FUZZ_MAX_DIM] = {0};
   67|  3.39k|  int64_t shape_items = 1;
   68|  3.39k|  int64_t chunk_items = 1;
   69|  3.39k|  int64_t nchunks_est = 1;
   70|  3.39k|  int64_t req = 1;
   71|  3.39k|  int8_t d;
   72|       |
   73|  16.6k|  for (d = 0; d < ndim; d++) {
  ------------------
  |  Branch (73:15): [True: 13.2k, False: 3.39k]
  ------------------
   74|  13.2k|    int64_t ext = tail_dim(&r);
   75|  13.2k|    if (ext > 0 && shape_items * ext > FUZZ_MAX_ITEMS) {
  ------------------
  |  |   31|  12.8k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  |  Branch (75:9): [True: 12.8k, False: 482]
  |  Branch (75:20): [True: 2.97k, False: 9.82k]
  ------------------
   76|  2.97k|      ext = 1;
   77|  2.97k|    }
   78|  13.2k|    shape[d] = ext;
   79|  13.2k|    if (ext > 0) {
  ------------------
  |  Branch (79:9): [True: 12.8k, False: 482]
  ------------------
   80|  12.8k|      shape_items *= ext;
   81|  12.8k|    }
   82|       |
   83|  13.2k|    int32_t c_ext = (int32_t)(tail_u8(&r) % FUZZ_MAX_EXTENT + 1);
  ------------------
  |  |   30|  13.2k|#define FUZZ_MAX_EXTENT 64     /* per-dimension bound */
  ------------------
   84|  13.2k|    if (chunk_items * c_ext > FUZZ_MAX_ITEMS) {
  ------------------
  |  |   31|  13.2k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  |  Branch (84:9): [True: 3.34k, False: 9.93k]
  ------------------
   85|  3.34k|      c_ext = 1;
   86|  3.34k|    }
   87|  13.2k|    int64_t dim_chunks = ext > 0 ? (ext + c_ext - 1) / c_ext : 1;
  ------------------
  |  Branch (87:26): [True: 12.8k, False: 482]
  ------------------
   88|  13.2k|    if (nchunks_est * dim_chunks > 64 && ext > 0) {
  ------------------
  |  Branch (88:9): [True: 518, False: 12.7k]
  |  Branch (88:42): [True: 518, False: 0]
  ------------------
   89|    518|      c_ext = (int32_t)ext;
   90|    518|      dim_chunks = 1;
   91|    518|    }
   92|  13.2k|    chunkshape[d] = c_ext;
   93|  13.2k|    chunk_items *= c_ext;
   94|  13.2k|    nchunks_est *= dim_chunks;
   95|       |
   96|  13.2k|    blockshape[d] = (int32_t)(tail_u8(&r) % c_ext + 1);
   97|  13.2k|  }
   98|  16.6k|  for (d = 0; d < ndim; d++) {
  ------------------
  |  Branch (98:15): [True: 13.2k, False: 3.39k]
  ------------------
   99|  13.2k|    start[d] = tail_dim(&r);
  100|  13.2k|    stop[d] = tail_dim(&r);
  101|  13.2k|    diff[d] = stop[d] - start[d];
  102|  13.2k|    if (diff[d] < 0) {
  ------------------
  |  Branch (102:9): [True: 2.17k, False: 11.1k]
  ------------------
  103|  2.17k|      diff[d] = 0;
  104|  2.17k|      stop[d] = start[d];
  105|  2.17k|    }
  106|  13.2k|    if (diff[d] > 0 && req * diff[d] > FUZZ_MAX_ITEMS) {
  ------------------
  |  |   31|  3.64k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  |  Branch (106:9): [True: 3.64k, False: 9.63k]
  |  Branch (106:24): [True: 456, False: 3.19k]
  ------------------
  107|    456|      diff[d] = 1;
  108|    456|      stop[d] = start[d] + 1;
  109|    456|    }
  110|  13.2k|    if (diff[d] > 0) {
  ------------------
  |  Branch (110:9): [True: 3.64k, False: 9.63k]
  ------------------
  111|  3.64k|      req *= diff[d];
  112|  3.64k|    }
  113|  13.2k|  }
  114|  5.22k|  for (d = 0; d < ndim; d++) {
  ------------------
  |  Branch (114:15): [True: 4.80k, False: 426]
  ------------------
  115|  4.80k|    if (diff[d] == 0) {
  ------------------
  |  Branch (115:9): [True: 2.96k, False: 1.83k]
  ------------------
  116|  2.96k|      req = 0;
  117|  2.96k|      break;
  118|  2.96k|    }
  119|  4.80k|  }
  120|       |
  121|       |  /* The head bytes that were not consumed as control bytes are the payload. */
  122|  3.39k|  const uint8_t *payload = data;
  123|  3.39k|  size_t payload_len = r.size;
  124|       |
  125|  3.39k|  blosc2_init();
  126|  3.39k|  blosc2_set_nthreads(1);
  127|       |
  128|  3.39k|  if (mode == 4) {
  ------------------
  |  Branch (128:7): [True: 1.92k, False: 1.47k]
  ------------------
  129|       |    /* Parser mode: the whole input is an untrusted b2nd frame. */
  130|  1.92k|    b2nd_array_t *parsed = NULL;
  131|  1.92k|    if (b2nd_from_cframe((uint8_t *)data, (int64_t)size, false, &parsed) >= 0 &&
  ------------------
  |  Branch (131:9): [True: 0, False: 1.92k]
  ------------------
  132|      0|        parsed != NULL) {
  ------------------
  |  Branch (132:9): [True: 0, False: 0]
  ------------------
  133|      0|      if (parsed->nitems >= 0 && parsed->nitems <= FUZZ_MAX_ITEMS &&
  ------------------
  |  |   31|      0|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  |  Branch (133:11): [True: 0, False: 0]
  |  Branch (133:34): [True: 0, False: 0]
  ------------------
  134|      0|          parsed->extchunknitems >= 0 && parsed->extchunknitems <= FUZZ_MAX_ITEMS * 8 &&
  ------------------
  |  |   31|      0|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  |  Branch (134:11): [True: 0, False: 0]
  |  Branch (134:42): [True: 0, False: 0]
  ------------------
  135|      0|          parsed->sc != NULL && parsed->sc->typesize > 0 && parsed->sc->typesize <= 8) {
  ------------------
  |  Branch (135:11): [True: 0, False: 0]
  |  Branch (135:33): [True: 0, False: 0]
  |  Branch (135:61): [True: 0, False: 0]
  ------------------
  136|      0|        uint8_t *buf = (uint8_t *)malloc(FUZZ_MAX_ITEMS * 8);
  ------------------
  |  |   31|      0|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  137|      0|        if (buf != NULL) {
  ------------------
  |  Branch (137:13): [True: 0, False: 0]
  ------------------
  138|      0|          b2nd_to_cbuffer(parsed, buf, FUZZ_MAX_ITEMS * 8);
  ------------------
  |  |   31|      0|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  139|      0|          free(buf);
  140|      0|        }
  141|      0|      }
  142|      0|      b2nd_free(parsed);
  143|      0|    }
  144|  1.92k|    blosc2_destroy();
  145|  1.92k|    return 0;
  146|  1.92k|  }
  147|       |
  148|  1.47k|  blosc2_cparams cparams = BLOSC2_CPARAMS_DEFAULTS;
  149|  1.47k|  cparams.typesize = typesize;
  150|  1.47k|  cparams.clevel = tail_u8(&r) % 10;
  151|  1.47k|  cparams.nthreads = 1;
  152|  1.47k|  blosc2_dparams dparams = BLOSC2_DPARAMS_DEFAULTS;
  153|  1.47k|  dparams.nthreads = 1;
  154|  1.47k|  blosc2_storage storage = {.cparams = &cparams, .dparams = &dparams,
  155|  1.47k|                            .contiguous = true};
  156|       |
  157|  1.47k|  b2nd_context_t *ctx = b2nd_create_ctx(&storage, ndim, shape, chunkshape,
  158|  1.47k|                                        blockshape, NULL, 0, NULL, 0);
  159|  1.47k|  if (ctx == NULL) {
  ------------------
  |  Branch (159:7): [True: 0, False: 1.47k]
  ------------------
  160|      0|    blosc2_destroy();
  161|      0|    return 0;
  162|      0|  }
  163|       |
  164|  1.47k|  b2nd_array_t *arr = NULL;
  165|  1.47k|  int rc = BLOSC2_ERROR_DATA;
  166|  1.47k|  switch (mode) {
  167|    879|    case 0:
  ------------------
  |  Branch (167:5): [True: 879, False: 592]
  ------------------
  168|    879|      rc = b2nd_from_cbuffer(ctx, &arr, payload, (int64_t)payload_len);
  169|    879|      break;
  170|    178|    case 1:
  ------------------
  |  Branch (170:5): [True: 178, False: 1.29k]
  ------------------
  171|    178|      rc = b2nd_zeros(ctx, &arr);
  172|    178|      break;
  173|    105|    case 2:
  ------------------
  |  Branch (173:5): [True: 105, False: 1.36k]
  ------------------
  174|    105|      rc = b2nd_empty(ctx, &arr);
  175|    105|      break;
  176|    309|    default: {
  ------------------
  |  Branch (176:5): [True: 309, False: 1.16k]
  ------------------
  177|    309|      uint8_t fill_value[8] = {0};
  178|    309|      if (payload_len > 0) {
  ------------------
  |  Branch (178:11): [True: 309, False: 0]
  ------------------
  179|    309|        memcpy(fill_value, payload,
  180|    309|               payload_len < typesize ? payload_len : typesize);
  ------------------
  |  Branch (180:16): [True: 0, False: 309]
  ------------------
  181|    309|      }
  182|    309|      rc = b2nd_full(ctx, &arr, fill_value);
  183|    309|      break;
  184|      0|    }
  185|  1.47k|  }
  186|  1.47k|  if (rc < 0 || arr == NULL) {
  ------------------
  |  Branch (186:7): [True: 0, False: 1.47k]
  |  Branch (186:17): [True: 0, False: 1.47k]
  ------------------
  187|       |    /* b2nd_empty inside b2nd_from_cbuffer may have assigned *array even on
  188|       |     * error; free it whenever it is set. */
  189|      0|    if (arr != NULL) {
  ------------------
  |  Branch (189:9): [True: 0, False: 0]
  ------------------
  190|      0|      b2nd_free(arr);
  191|      0|    }
  192|      0|    b2nd_free_ctx(ctx);
  193|      0|    blosc2_destroy();
  194|      0|    return 0;
  195|      0|  }
  196|       |
  197|  1.47k|  uint8_t *buf = (uint8_t *)malloc((size_t)FUZZ_MAX_ITEMS * 8);
  ------------------
  |  |   31|  1.47k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  198|  1.47k|  if (buf != NULL) {
  ------------------
  |  Branch (198:7): [True: 1.47k, False: 0]
  ------------------
  199|       |    /* Get a slice into a plain buffer. */
  200|  1.47k|    b2nd_get_slice_cbuffer(arr, start, stop, buf, diff, req * typesize);
  201|       |
  202|       |    /* Get a slice as a new array and read it back. */
  203|  1.47k|    b2nd_array_t *slice = NULL;
  204|  1.47k|    if (b2nd_get_slice(ctx, &slice, arr, start, stop) >= 0 && slice != NULL) {
  ------------------
  |  Branch (204:9): [True: 1.35k, False: 118]
  |  Branch (204:63): [True: 1.35k, False: 0]
  ------------------
  205|  1.35k|      b2nd_to_cbuffer(slice, buf, req * typesize);
  206|  1.35k|      b2nd_free(slice);
  207|  1.35k|    }
  208|       |
  209|       |    /* Set a slice from a payload-derived buffer (zero-padded to the full
  210|       |     * requested extent so the buffer honestly owns `buffersize` bytes). */
  211|  1.47k|    memset(buf, 0, (size_t)req * typesize);
  212|  1.47k|    memcpy(buf, payload,
  213|  1.47k|           payload_len < (size_t)req * typesize ? payload_len
  ------------------
  |  Branch (213:12): [True: 318, False: 1.15k]
  ------------------
  214|  1.47k|                                                : (size_t)req * typesize);
  215|  1.47k|    b2nd_set_slice_cbuffer(buf, diff, (int64_t)req * typesize, start, stop, arr);
  216|       |
  217|       |    /* Read the whole array back. */
  218|  1.47k|    b2nd_to_cbuffer(arr, buf, (int64_t)FUZZ_MAX_ITEMS * 8);
  ------------------
  |  |   31|  1.47k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  219|       |
  220|       |    /* Grow along axis 0 and insert at the front (bounded by payload & chunk cap). */
  221|  1.47k|    size_t max_grow = (arr->sc != NULL && arr->sc->chunksize > 0)
  ------------------
  |  Branch (221:24): [True: 1.47k, False: 0]
  |  Branch (221:43): [True: 1.47k, False: 0]
  ------------------
  222|  1.47k|                          ? (size_t)arr->sc->chunksize * 4
  223|  1.47k|                          : 4096;
  224|  1.47k|    if (max_grow > 4096) {
  ------------------
  |  Branch (224:9): [True: 895, False: 576]
  ------------------
  225|    895|      max_grow = 4096;
  226|    895|    }
  227|  1.47k|    size_t grow_len = payload_len < max_grow ? payload_len : max_grow;
  ------------------
  |  Branch (227:23): [True: 1.17k, False: 298]
  ------------------
  228|  1.47k|    if (grow_len > 0) {
  ------------------
  |  Branch (228:9): [True: 1.47k, False: 0]
  ------------------
  229|  1.47k|      b2nd_append(arr, payload, (int64_t)grow_len, 0);
  230|  1.47k|      b2nd_insert(arr, payload, (int64_t)grow_len, 0, 0);
  231|  1.47k|    }
  232|       |
  233|       |    /* Resize up (bounded by both items and chunk count). */
  234|  1.47k|    int64_t new_shape[FUZZ_MAX_DIM];
  235|  1.47k|    int64_t new_total = 1;
  236|  1.47k|    int64_t new_nchunks = 1;
  237|  7.10k|    for (d = 0; d < ndim; d++) {
  ------------------
  |  Branch (237:17): [True: 5.63k, False: 1.47k]
  ------------------
  238|  5.63k|      int64_t cand = arr->shape[d] < FUZZ_MAX_EXTENT ? arr->shape[d] + 1 : arr->shape[d];
  ------------------
  |  |   30|  5.63k|#define FUZZ_MAX_EXTENT 64     /* per-dimension bound */
  ------------------
  |  Branch (238:22): [True: 4.94k, False: 693]
  ------------------
  239|  5.63k|      int64_t cand_chunks = (cand > 0 && arr->chunkshape[d] > 0)
  ------------------
  |  Branch (239:30): [True: 5.63k, False: 0]
  |  Branch (239:42): [True: 5.63k, False: 0]
  ------------------
  240|  5.63k|                                ? (cand + arr->chunkshape[d] - 1) / arr->chunkshape[d]
  241|  5.63k|                                : 1;
  242|  5.63k|      if (cand > 0 && (new_total * cand > 2 * FUZZ_MAX_ITEMS || new_nchunks * cand_chunks > 64)) {
  ------------------
  |  |   31|  11.2k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  |  Branch (242:11): [True: 5.63k, False: 0]
  |  Branch (242:24): [True: 494, False: 5.14k]
  |  Branch (242:65): [True: 2.12k, False: 3.02k]
  ------------------
  243|  2.61k|        cand = arr->shape[d];
  244|  2.61k|        cand_chunks = (cand > 0 && arr->chunkshape[d] > 0)
  ------------------
  |  Branch (244:24): [True: 2.61k, False: 0]
  |  Branch (244:36): [True: 2.61k, False: 0]
  ------------------
  245|  2.61k|                          ? (cand + arr->chunkshape[d] - 1) / arr->chunkshape[d]
  246|  2.61k|                          : 1;
  247|  2.61k|      }
  248|  5.63k|      new_shape[d] = cand;
  249|  5.63k|      if (cand > 0) {
  ------------------
  |  Branch (249:11): [True: 5.63k, False: 0]
  ------------------
  250|  5.63k|        new_total *= cand;
  251|  5.63k|      }
  252|  5.63k|      new_nchunks *= cand_chunks;
  253|  5.63k|    }
  254|  1.47k|    if (new_total <= 2 * FUZZ_MAX_ITEMS && new_nchunks <= 64) {
  ------------------
  |  |   31|  2.94k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  |  Branch (254:9): [True: 1.39k, False: 73]
  |  Branch (254:44): [True: 953, False: 445]
  ------------------
  255|    953|      b2nd_resize(arr, new_shape, start);
  256|    953|    }
  257|       |
  258|       |    /* Structural views. */
  259|  1.47k|    b2nd_array_t *view = NULL;
  260|  1.47k|    if (b2nd_squeeze(arr, &view) >= 0 && view != NULL) {
  ------------------
  |  Branch (260:9): [True: 1.47k, False: 0]
  |  Branch (260:42): [True: 1.47k, False: 0]
  ------------------
  261|  1.47k|      b2nd_free(view);
  262|  1.47k|    }
  263|  1.47k|    bool squeeze_index[FUZZ_MAX_DIM];
  264|  7.10k|    for (d = 0; d < ndim; d++) {
  ------------------
  |  Branch (264:17): [True: 5.63k, False: 1.47k]
  ------------------
  265|  5.63k|      squeeze_index[d] = (shape[d] == 1);
  266|  5.63k|    }
  267|  1.47k|    view = NULL;
  268|  1.47k|    if (b2nd_squeeze_index(arr, &view, squeeze_index) >= 0 && view != NULL) {
  ------------------
  |  Branch (268:9): [True: 1.38k, False: 82]
  |  Branch (268:63): [True: 1.38k, False: 0]
  ------------------
  269|  1.38k|      b2nd_free(view);
  270|  1.38k|    }
  271|  1.47k|    if (ndim + 2 <= FUZZ_MAX_DIM) {
  ------------------
  |  |   29|  1.47k|#define FUZZ_MAX_DIM 16        /* B2ND_MAX_DIM */
  ------------------
  |  Branch (271:9): [True: 1.39k, False: 72]
  ------------------
  272|  1.39k|      bool axis[FUZZ_MAX_DIM] = {false};
  273|  1.39k|      axis[0] = true;
  274|  1.39k|      axis[ndim] = true;
  275|  1.39k|      view = NULL;
  276|  1.39k|      if (b2nd_expand_dims(arr, &view, axis, (uint8_t)(ndim + 2)) >= 0 &&
  ------------------
  |  Branch (276:11): [True: 1.39k, False: 0]
  ------------------
  277|  1.39k|          view != NULL) {
  ------------------
  |  Branch (277:11): [True: 1.39k, False: 0]
  ------------------
  278|  1.39k|        b2nd_free(view);
  279|  1.39k|      }
  280|  1.39k|    }
  281|       |
  282|       |    /* Serialize and parse again (round trip through the frame format). */
  283|  1.47k|    uint8_t *cframe = NULL;
  284|  1.47k|    int64_t len = 0;
  285|  1.47k|    bool needs_free = false;
  286|  1.47k|    if (b2nd_to_cframe(arr, &cframe, &len, &needs_free) >= 0 && len > 0 &&
  ------------------
  |  Branch (286:9): [True: 1.47k, False: 0]
  |  Branch (286:65): [True: 1.47k, False: 0]
  ------------------
  287|  1.47k|        cframe != NULL) {
  ------------------
  |  Branch (287:9): [True: 1.47k, False: 0]
  ------------------
  288|  1.47k|      b2nd_array_t *again = NULL;
  289|  1.47k|      if (b2nd_from_cframe(cframe, len, false, &again) >= 0 && again != NULL) {
  ------------------
  |  Branch (289:11): [True: 1.47k, False: 0]
  |  Branch (289:64): [True: 1.47k, False: 0]
  ------------------
  290|  1.47k|        b2nd_to_cbuffer(again, buf, (int64_t)FUZZ_MAX_ITEMS * 8);
  ------------------
  |  |   31|  1.47k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  291|  1.47k|        b2nd_free(again);
  292|  1.47k|      }
  293|  1.47k|      if (needs_free) {
  ------------------
  |  Branch (293:11): [True: 0, False: 1.47k]
  ------------------
  294|      0|        free(cframe);
  295|      0|      }
  296|  1.47k|    }
  297|       |
  298|  1.47k|    free(buf);
  299|  1.47k|  }
  300|       |
  301|  1.47k|  b2nd_free(arr);
  302|  1.47k|  b2nd_free_ctx(ctx);
  303|  1.47k|  blosc2_destroy();
  304|  1.47k|  return 0;
  305|  1.47k|}
fuzz_b2nd.c:tail_u8:
   38|  78.0k|static uint8_t tail_u8(tail_reader *r) {
   39|  78.0k|  if (r->size == 0) {
  ------------------
  |  Branch (39:7): [True: 0, False: 78.0k]
  ------------------
   40|      0|    return 0;
   41|      0|  }
   42|  78.0k|  r->size--;
   43|  78.0k|  return r->data[r->size];
   44|  78.0k|}
fuzz_b2nd.c:tail_dim:
   46|  39.8k|static int64_t tail_dim(tail_reader *r) {
   47|  39.8k|  return (int64_t)(tail_u8(r) % (FUZZ_MAX_EXTENT + 1));
  ------------------
  |  |   30|  39.8k|#define FUZZ_MAX_EXTENT 64     /* per-dimension bound */
  ------------------
   48|  39.8k|}

